mirror of https://github.com/apache/nifi.git
NIFI-3799 Add Input Requirement Info to Docs
Added input requirement info for processor documentation This closes #1756. Signed-off-by: James Wing <jvwing@gmail.com>
This commit is contained in:
parent
08b66b5b6a
commit
fb7d6d1150
|
@ -18,6 +18,7 @@ package org.apache.nifi.documentation.html;
|
|||
|
||||
import org.apache.nifi.annotation.behavior.DynamicProperties;
|
||||
import org.apache.nifi.annotation.behavior.DynamicProperty;
|
||||
import org.apache.nifi.annotation.behavior.InputRequirement;
|
||||
import org.apache.nifi.annotation.behavior.Restricted;
|
||||
import org.apache.nifi.annotation.behavior.Stateful;
|
||||
import org.apache.nifi.annotation.documentation.CapabilityDescription;
|
||||
|
@ -146,6 +147,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
writeAdditionalBodyInfo(configurableComponent, xmlStreamWriter);
|
||||
writeStatefulInfo(configurableComponent, xmlStreamWriter);
|
||||
writeRestrictedInfo(configurableComponent, xmlStreamWriter);
|
||||
writeInputRequirementInfo(configurableComponent, xmlStreamWriter);
|
||||
writeSeeAlso(configurableComponent, xmlStreamWriter);
|
||||
xmlStreamWriter.writeEndElement();
|
||||
}
|
||||
|
@ -167,6 +169,37 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
xmlStreamWriter.writeEndElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add in the documentation information regarding the component whether it accepts an
|
||||
* incoming relationship or not.
|
||||
*
|
||||
* @param configurableComponent the component to describe
|
||||
* @param xmlStreamWriter the stream writer to use
|
||||
* @throws XMLStreamException thrown if there was a problem writing the XML
|
||||
*/
|
||||
private void writeInputRequirementInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter)
|
||||
throws XMLStreamException {
|
||||
final InputRequirement inputRequirement = configurableComponent.getClass().getAnnotation(InputRequirement.class);
|
||||
|
||||
if(inputRequirement != null) {
|
||||
writeSimpleElement(xmlStreamWriter, "h3", "Input requirement: ");
|
||||
switch (inputRequirement.value()) {
|
||||
case INPUT_FORBIDDEN:
|
||||
xmlStreamWriter.writeCharacters("This component does not allow an incoming relationship.");
|
||||
break;
|
||||
case INPUT_ALLOWED:
|
||||
xmlStreamWriter.writeCharacters("This component allows an incoming relationship.");
|
||||
break;
|
||||
case INPUT_REQUIRED:
|
||||
xmlStreamWriter.writeCharacters("This component requires an incoming relationship.");
|
||||
break;
|
||||
default:
|
||||
xmlStreamWriter.writeCharacters("This component does not have input requirement.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the description of the Stateful annotation if provided in this component.
|
||||
*
|
||||
|
|
|
@ -18,11 +18,13 @@ package org.apache.nifi.documentation.example;
|
|||
|
||||
import org.apache.nifi.annotation.behavior.DynamicProperty;
|
||||
import org.apache.nifi.annotation.behavior.DynamicRelationship;
|
||||
import org.apache.nifi.annotation.behavior.InputRequirement;
|
||||
import org.apache.nifi.annotation.behavior.ReadsAttribute;
|
||||
import org.apache.nifi.annotation.behavior.Restricted;
|
||||
import org.apache.nifi.annotation.behavior.Stateful;
|
||||
import org.apache.nifi.annotation.behavior.WritesAttribute;
|
||||
import org.apache.nifi.annotation.behavior.WritesAttributes;
|
||||
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
|
||||
import org.apache.nifi.annotation.documentation.CapabilityDescription;
|
||||
import org.apache.nifi.annotation.documentation.SeeAlso;
|
||||
import org.apache.nifi.annotation.documentation.Tags;
|
||||
|
@ -56,6 +58,7 @@ import java.util.Set;
|
|||
@DynamicRelationship(name = "name from dynamic property", description = "all files that match the properties XPath")
|
||||
@Stateful(scopes = {Scope.CLUSTER, Scope.LOCAL}, description = "state management description")
|
||||
@Restricted("processor restriction description")
|
||||
@InputRequirement(Requirement.INPUT_FORBIDDEN)
|
||||
public class FullyDocumentedProcessor extends AbstractProcessor {
|
||||
|
||||
public static final PropertyDescriptor DIRECTORY = new PropertyDescriptor.Builder().name("Input Directory")
|
||||
|
|
|
@ -81,6 +81,9 @@ public class ProcessorDocumentationWriterTest {
|
|||
assertNotContains(results, "No tags provided.");
|
||||
assertNotContains(results, "Additional Details...");
|
||||
|
||||
// input requirement
|
||||
assertContains(results, "This component does not allow an incoming relationship.");
|
||||
|
||||
// verify the right OnRemoved and OnShutdown methods were called
|
||||
Assert.assertEquals(0, processor.getOnRemovedArgs());
|
||||
Assert.assertEquals(0, processor.getOnRemovedNoArgs());
|
||||
|
@ -122,6 +125,9 @@ public class ProcessorDocumentationWriterTest {
|
|||
|
||||
// state management
|
||||
assertContains(results, "This component is not restricted.");
|
||||
|
||||
// input requirement
|
||||
assertNotContains(results, "Input requirement:");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue