Search in sources :

Example 1 with KnimeNodeDocument

use of org.knime.node2012.KnimeNodeDocument in project GenericKnimeNodes by genericworkflownodes.

the class DynamicGenericNodeFactory method createNodeDescription.

@Override
protected NodeDescription createNodeDescription() {
    try {
        INodeConfiguration cfg = getNodeConfiguration();
        KnimeNodeDocument doc = org.knime.node.v28.KnimeNodeDocument.Factory.newInstance();
        Document domDoc = (Document) doc.getDomNode();
        // Node
        KnimeNode node = doc.addNewKnimeNode();
        node.setDeprecated(m_deprecated);
        node.setName(cfg.getName());
        node.setIcon(getIconPath());
        node.setType(KnimeNode.Type.MANIPULATOR);
        node.setShortDescription(cfg.getDescription());
        FullDescription fullDescr = node.addNewFullDescription();
        // Intro
        Intro intro = fullDescr.addNewIntro();
        intro.addNewP().getDomNode().appendChild(domDoc.createTextNode(cfg.getManual()));
        // Options
        for (Parameter<?> p : cfg.getParameters()) {
            Option option = fullDescr.addNewOption();
            option.setName(p.getKey());
            option.getDomNode().appendChild(domDoc.createTextNode(p.getDescription()));
        }
        // Ports
        Ports ports = node.addNewPorts();
        int index = 0;
        for (Port p : cfg.getInputPorts()) {
            InPort ip = ports.addNewInPort();
            ip.setIndex(new BigInteger(Integer.toString(index++)));
            String mimetypes = mimetypes2String(p.getMimeTypes());
            ip.setName(p.getName() + mimetypes);
            ip.getDomNode().appendChild(domDoc.createTextNode(p.getDescription() + mimetypes));
        }
        index = 0;
        for (Port p : cfg.getOutputPorts()) {
            OutPort op = ports.addNewOutPort();
            op.setIndex(new BigInteger(Integer.toString(index++)));
            String mimetypes = mimetypes2String(p.getMimeTypes());
            op.setName(p.getName() + mimetypes);
            op.getDomNode().appendChild(domDoc.createTextNode(p.getDescription() + mimetypes));
        }
        return new NodeDescription28Proxy(doc);
    } catch (Exception e) {
        logger.error("Dynamic node description instantiation failed", e);
    }
    return null;
}
Also used : InPort(org.knime.node.v28.InPortDocument.InPort) InPort(org.knime.node.v28.InPortDocument.InPort) Port(com.genericworkflownodes.knime.port.Port) OutPort(org.knime.node.v28.OutPortDocument.OutPort) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) Ports(org.knime.node.v28.PortsDocument.Ports) Document(org.w3c.dom.Document) KnimeNodeDocument(org.knime.node.v28.KnimeNodeDocument) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) InvalidCTDFileException(com.genericworkflownodes.knime.config.reader.InvalidCTDFileException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) KnimeNode(org.knime.node.v28.KnimeNodeDocument.KnimeNode) Intro(org.knime.node.v28.IntroDocument.Intro) OutPort(org.knime.node.v28.OutPortDocument.OutPort) BigInteger(java.math.BigInteger) KnimeNodeDocument(org.knime.node.v28.KnimeNodeDocument) Option(org.knime.node.v28.OptionDocument.Option) NodeDescription28Proxy(org.knime.core.node.NodeDescription28Proxy) FullDescription(org.knime.node.v28.FullDescriptionDocument.FullDescription)

Example 2 with KnimeNodeDocument

use of org.knime.node2012.KnimeNodeDocument in project knime-core by knime.

the class MissingNodeFactory method addNodeDescription.

/**
 * {@inheritDoc}
 */
@Override
protected void addNodeDescription(final KnimeNodeDocument doc) {
    KnimeNode node = doc.addNewKnimeNode();
    node.setIcon("./missing.png");
    node.setType(KnimeNode.Type.UNKNOWN);
    node.setName("MISSING " + m_nodeInfo.getNodeNameNotNull());
    String shortDescription = "Placeholder node for missing \"" + m_nodeInfo.getNodeNameNotNull() + "\".";
    node.setShortDescription(shortDescription);
    FullDescription fullDesc = node.addNewFullDescription();
    Intro intro = fullDesc.addNewIntro();
    P p = intro.addNewP();
    p.newCursor().setTextValue(shortDescription);
    p = intro.addNewP();
    p.newCursor().setTextValue(m_nodeInfo.getErrorMessageWhenNodeIsMissing());
    Ports ports = node.addNewPorts();
    for (int i = 0; i < m_inTypes.length; i++) {
        InPort inPort = ports.addNewInPort();
        inPort.setIndex(i);
        inPort.setName("Port " + i);
        inPort.newCursor().setTextValue("Port guessed from the workflow connection table.");
    }
    for (int i = 0; i < m_outTypes.length; i++) {
        OutPort outPort = ports.addNewOutPort();
        outPort.setIndex(i);
        outPort.setName("Port " + i);
        outPort.newCursor().setTextValue("Port guessed from the workflow connection table.");
    }
}
Also used : KnimeNode(org.knime.node2012.KnimeNodeDocument.KnimeNode) P(org.knime.node2012.PDocument.P) InPort(org.knime.node2012.InPortDocument.InPort) Intro(org.knime.node2012.IntroDocument.Intro) OutPort(org.knime.node2012.OutPortDocument.OutPort) Ports(org.knime.node2012.PortsDocument.Ports) FullDescription(org.knime.node2012.FullDescriptionDocument.FullDescription)

Example 3 with KnimeNodeDocument

use of org.knime.node2012.KnimeNodeDocument in project knime-core by knime.

the class DynamicNodeFactory method createNodeDescription.

/**
 * {@inheritDoc}
 *
 * In case of dynamic nodes the procedure is roughly as follows:
 * <ol>
 * <li>Create a KnimeNodeDocument in the desired version (preferably the latest)
 * <li>Populate the document</li>
 * <li>Use one of the node description proxies (e.g. {@link NodeDescription28Proxy}) in order to return the
 * {@link NodeDescription}</li>
 * </ol>
 */
@SuppressWarnings("deprecation")
@Override
protected NodeDescription createNodeDescription() {
    KnimeNodeDocument doc = KnimeNodeDocument.Factory.newInstance();
    addNodeDescription(doc);
    return new NodeDescription27Proxy(doc);
}
Also used : KnimeNodeDocument(org.knime.node2012.KnimeNodeDocument)

Aggregations

INodeConfiguration (com.genericworkflownodes.knime.config.INodeConfiguration)1 InvalidCTDFileException (com.genericworkflownodes.knime.config.reader.InvalidCTDFileException)1 Port (com.genericworkflownodes.knime.port.Port)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NodeDescription28Proxy (org.knime.core.node.NodeDescription28Proxy)1 FullDescription (org.knime.node.v28.FullDescriptionDocument.FullDescription)1 InPort (org.knime.node.v28.InPortDocument.InPort)1 Intro (org.knime.node.v28.IntroDocument.Intro)1 KnimeNodeDocument (org.knime.node.v28.KnimeNodeDocument)1 KnimeNode (org.knime.node.v28.KnimeNodeDocument.KnimeNode)1 Option (org.knime.node.v28.OptionDocument.Option)1 OutPort (org.knime.node.v28.OutPortDocument.OutPort)1 Ports (org.knime.node.v28.PortsDocument.Ports)1 FullDescription (org.knime.node2012.FullDescriptionDocument.FullDescription)1 InPort (org.knime.node2012.InPortDocument.InPort)1 Intro (org.knime.node2012.IntroDocument.Intro)1 KnimeNodeDocument (org.knime.node2012.KnimeNodeDocument)1