Search in sources :

Example 1 with ReadsAttribute

use of org.apache.nifi.annotation.behavior.ReadsAttribute in project nifi by apache.

the class HtmlProcessorDocumentationWriter method handleReadsAttributes.

/**
 * Writes out just the attributes that are being read in a table form.
 *
 * @param xmlStreamWriter the xml stream writer to use
 * @param processor the processor to describe
 * @throws XMLStreamException xse
 */
private void handleReadsAttributes(XMLStreamWriter xmlStreamWriter, final Processor processor) throws XMLStreamException {
    List<ReadsAttribute> attributesRead = getReadsAttributes(processor);
    writeSimpleElement(xmlStreamWriter, "h3", "Reads Attributes: ");
    if (attributesRead.size() > 0) {
        xmlStreamWriter.writeStartElement("table");
        xmlStreamWriter.writeAttribute("id", "reads-attributes");
        xmlStreamWriter.writeStartElement("tr");
        writeSimpleElement(xmlStreamWriter, "th", "Name");
        writeSimpleElement(xmlStreamWriter, "th", "Description");
        xmlStreamWriter.writeEndElement();
        for (ReadsAttribute attribute : attributesRead) {
            xmlStreamWriter.writeStartElement("tr");
            writeSimpleElement(xmlStreamWriter, "td", defaultIfBlank(attribute.attribute(), "Not Specified"));
            // TODO allow for HTML characters here.
            writeSimpleElement(xmlStreamWriter, "td", defaultIfBlank(attribute.description(), "Not Specified"));
            xmlStreamWriter.writeEndElement();
        }
        xmlStreamWriter.writeEndElement();
    } else {
        xmlStreamWriter.writeCharacters("None specified.");
    }
}
Also used : ReadsAttribute(org.apache.nifi.annotation.behavior.ReadsAttribute)

Example 2 with ReadsAttribute

use of org.apache.nifi.annotation.behavior.ReadsAttribute in project nifi by apache.

the class HtmlProcessorDocumentationWriter method getReadsAttributes.

/**
 * Collects the attributes that a processor is reading from.
 *
 * @param processor the processor to describe
 * @return the list of attributes that processor is reading
 */
private List<ReadsAttribute> getReadsAttributes(Processor processor) {
    List<ReadsAttribute> attributes = new ArrayList<>();
    ReadsAttributes readsAttributes = processor.getClass().getAnnotation(ReadsAttributes.class);
    if (readsAttributes != null) {
        attributes.addAll(Arrays.asList(readsAttributes.value()));
    }
    ReadsAttribute readsAttribute = processor.getClass().getAnnotation(ReadsAttribute.class);
    if (readsAttribute != null) {
        attributes.add(readsAttribute);
    }
    return attributes;
}
Also used : ReadsAttribute(org.apache.nifi.annotation.behavior.ReadsAttribute) ArrayList(java.util.ArrayList) ReadsAttributes(org.apache.nifi.annotation.behavior.ReadsAttributes)

Aggregations

ReadsAttribute (org.apache.nifi.annotation.behavior.ReadsAttribute)2 ArrayList (java.util.ArrayList)1 ReadsAttributes (org.apache.nifi.annotation.behavior.ReadsAttributes)1