NIFI-280 - changing the way properties are formatted

This commit is contained in:
danbress 2015-02-05 19:52:04 -05:00
parent c3085b8b21
commit 6e80ae7b9b
1 changed files with 30 additions and 46 deletions

View File

@ -31,6 +31,7 @@ import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.AllowableValue; import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.ConfigurableComponent; import org.apache.nifi.components.ConfigurableComponent;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.documentation.DocumentationWriter; import org.apache.nifi.documentation.DocumentationWriter;
/** /**
@ -232,10 +233,10 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
xmlStreamWriter.writeStartElement("p"); xmlStreamWriter.writeStartElement("p");
xmlStreamWriter.writeCharacters("In the list below, the names of required properties appear in "); xmlStreamWriter.writeCharacters("In the list below, the names of required properties appear in ");
writeSimpleElement(xmlStreamWriter, "strong", "bold"); writeSimpleElement(xmlStreamWriter, "strong", "bold");
xmlStreamWriter.writeCharacters(". Any" xmlStreamWriter.writeCharacters(". Any "
+ "other properties (not in bold) are considered optional. The table also " + "other properties (not in bold) are considered optional. The table also "
+ "indicates any default values, whether a property supports the "); + "indicates any default values, whether a property supports the ");
writeLink(xmlStreamWriter, "NiFi Expression Language (or simply EL)", writeLink(xmlStreamWriter, "NiFi Expression Language",
"../../html/expression-language-guide.html"); "../../html/expression-language-guide.html");
xmlStreamWriter.writeCharacters(", and whether a property is considered " xmlStreamWriter.writeCharacters(", and whether a property is considered "
+ "\"sensitive\", meaning that its value will be encrypted. Before entering a " + "\"sensitive\", meaning that its value will be encrypted. Before entering a "
@ -246,7 +247,6 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
xmlStreamWriter.writeCharacters("."); xmlStreamWriter.writeCharacters(".");
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
boolean containsSensitiveElement = false;
List<PropertyDescriptor> properties = configurableComponent.getPropertyDescriptors(); List<PropertyDescriptor> properties = configurableComponent.getPropertyDescriptors();
if (properties.size() > 0) { if (properties.size() > 0) {
@ -257,14 +257,11 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
writeSimpleElement(xmlStreamWriter, "th", "Name"); writeSimpleElement(xmlStreamWriter, "th", "Name");
writeSimpleElement(xmlStreamWriter, "th", "Default Value"); writeSimpleElement(xmlStreamWriter, "th", "Default Value");
writeSimpleElement(xmlStreamWriter, "th", "Valid Values"); writeSimpleElement(xmlStreamWriter, "th", "Valid Values");
xmlStreamWriter.writeStartElement("th"); writeSimpleElement(xmlStreamWriter, "th", "Description");
writeLink(xmlStreamWriter, "Expression Language", "../../html/expression-language-guide.html");
xmlStreamWriter.writeEndElement();
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
// write the individual properties // write the individual properties
for (PropertyDescriptor property : properties) { for (PropertyDescriptor property : properties) {
containsSensitiveElement |= property.isSensitive();
xmlStreamWriter.writeStartElement("tr"); xmlStreamWriter.writeStartElement("tr");
xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeStartElement("td");
if (property.isRequired()) { if (property.isRequired()) {
@ -272,68 +269,52 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
} else { } else {
xmlStreamWriter.writeCharacters(property.getDisplayName()); xmlStreamWriter.writeCharacters(property.getDisplayName());
} }
if (property.isSensitive()) {
writeSensitiveImg(xmlStreamWriter);
}
//writePropertyDescription(xmlStreamWriter, property.getDescription());
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
writeSimpleElement(xmlStreamWriter, "td", property.getDefaultValue()); writeSimpleElement(xmlStreamWriter, "td", property.getDefaultValue());
writeValidValues(xmlStreamWriter, property);
writeSimpleElement(xmlStreamWriter, "td", property.isExpressionLanguageSupported() ? "Yes"
: "No");
xmlStreamWriter.writeEndElement();
xmlStreamWriter.writeStartElement("tr");
xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeStartElement("td");
xmlStreamWriter.writeAttribute("colspan", "4"); writeValidValues(xmlStreamWriter, property);
xmlStreamWriter.writeAttribute("class", "description-row");
xmlStreamWriter.writeCharacters("Description:");
xmlStreamWriter.writeCharacters(property.getDescription());
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
xmlStreamWriter.writeStartElement("td");
if (property.getDescription() != null && property.getDescription().trim().length() > 0) {
xmlStreamWriter.writeCharacters(property.getDescription());
} else {
xmlStreamWriter.writeCharacters("No Description Provided.");
}
if (property.isSensitive()) {
xmlStreamWriter.writeEmptyElement("br");
writeSimpleElement(xmlStreamWriter, "strong", "Sensitive Property: true");
}
if (property.isExpressionLanguageSupported()) {
xmlStreamWriter.writeEmptyElement("br");
writeSimpleElement(xmlStreamWriter, "strong", "Supports Expression Language: true");
}
xmlStreamWriter.writeEndElement();
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
} }
// TODO support dynamic properties... // TODO support dynamic properties...
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
if (containsSensitiveElement) {
writeSensitiveImg(xmlStreamWriter);
xmlStreamWriter.writeCharacters(" indicates that a property is a sensitive property");
}
} else { } else {
writeSimpleElement(xmlStreamWriter, "p", "This component has no required or optional properties."); writeSimpleElement(xmlStreamWriter, "p", "This component has no required or optional properties.");
} }
} }
private void writePropertyDescription(XMLStreamWriter xmlStreamWriter, String description)
throws XMLStreamException {
xmlStreamWriter.writeCharacters(" ");
xmlStreamWriter.writeStartElement("img");
xmlStreamWriter.writeAttribute("src", "../../html/images/iconInfo.png");
xmlStreamWriter.writeAttribute("alt", description);
xmlStreamWriter.writeEndElement();
}
private void writeValidValueDescription(XMLStreamWriter xmlStreamWriter, String description) private void writeValidValueDescription(XMLStreamWriter xmlStreamWriter, String description)
throws XMLStreamException { throws XMLStreamException {
xmlStreamWriter.writeCharacters(" "); xmlStreamWriter.writeCharacters(" ");
xmlStreamWriter.writeStartElement("img"); xmlStreamWriter.writeStartElement("img");
xmlStreamWriter.writeAttribute("src", "../../html/images/iconInfo.png"); xmlStreamWriter.writeAttribute("src", "../../html/images/iconInfo.png");
xmlStreamWriter.writeAttribute("alt", description); xmlStreamWriter.writeAttribute("alt", description);
xmlStreamWriter.writeAttribute("title", description);
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
} }
private void writeSensitiveImg(final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
xmlStreamWriter.writeCharacters(" ");
xmlStreamWriter.writeStartElement("img");
xmlStreamWriter.writeAttribute("src", "../../html/images/iconSecure.png");
xmlStreamWriter.writeAttribute("alt", "Sensitive Property");
xmlStreamWriter.writeEndElement();
}
/** /**
* Interrogates a PropertyDescriptor to get a list of AllowableValues, if * Interrogates a PropertyDescriptor to get a list of AllowableValues, if
* there are none, nothing is written to the stream. * there are none, nothing is written to the stream.
@ -347,7 +328,6 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
*/ */
protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property) protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property)
throws XMLStreamException { throws XMLStreamException {
xmlStreamWriter.writeStartElement("td");
if (property.getAllowableValues() != null && property.getAllowableValues().size() > 0) { if (property.getAllowableValues() != null && property.getAllowableValues().size() > 0) {
xmlStreamWriter.writeStartElement("ul"); xmlStreamWriter.writeStartElement("ul");
for (AllowableValue value : property.getAllowableValues()) { for (AllowableValue value : property.getAllowableValues()) {
@ -361,8 +341,12 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
} }
xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement();
} else if (property.getControllerServiceDefinition() != null) {
Class<? extends ControllerService> controllerServiceClass = property.getControllerServiceDefinition();
writeSimpleElement(xmlStreamWriter, "strong", "Controller Service: ");
xmlStreamWriter.writeEmptyElement("br");
xmlStreamWriter.writeCharacters(controllerServiceClass.getSimpleName());
} }
xmlStreamWriter.writeEndElement();
} }
/** /**