Search in sources :

Example 1 with CLIMapping

use of com.genericworkflownodes.knime.cliwrapper.CLIMapping in project GenericKnimeNodes by genericworkflownodes.

the class CLIElementHandler method startElement.

@Override
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
    if (TAG_CLIELEMENT.equals(name)) {
        // we start a new element
        m_currentElement = new CLIElement();
        String isList = attributes.getValue(ATTR_ISLIST);
        m_currentElement.setIsList((isList != null && "true".equals(isList)));
        String isRequired = attributes.getValue(ATTR_REQUIRED);
        m_currentElement.setRequired((isRequired != null && "true".equals(isRequired)));
        m_currentElement.setOptionIdentifier(attributes.getValue(ATTR_OPTION_IDENTIFIER));
    } else if (TAG_MAPPING.equals(name)) {
        CLIMapping mapping = new CLIMapping();
        String refName = attributes.getValue(ATTR_REFNAME);
        mapping.setReferenceName(refName);
        m_currentElement.getMapping().add(mapping);
    }
}
Also used : CLIElement(com.genericworkflownodes.knime.cliwrapper.CLIElement) CLIMapping(com.genericworkflownodes.knime.cliwrapper.CLIMapping)

Example 2 with CLIMapping

use of com.genericworkflownodes.knime.cliwrapper.CLIMapping in project GenericKnimeNodes by genericworkflownodes.

the class ParamHandler method transferValuesToConfig.

/**
 * Translate all parameters extracted from the ParamXML file into the given
 * INodeConfiguration.
 */
private void transferValuesToConfig() {
    // add parameters
    for (Entry<String, Parameter<?>> entry : m_extractedParameters.entrySet()) {
        m_config.addParameter(entry.getKey(), entry.getValue());
    }
    // set ports
    m_config.setInports(m_inputPorts);
    m_config.setOutports(m_outputPorts);
    // remove cli mappings of ignored parameters
    if (m_config.getCLI() != null && !m_ignoredParameters.isEmpty()) {
        Iterator<CLIElement> element_iterator = m_config.getCLI().getCLIElement().iterator();
        while (element_iterator.hasNext()) {
            CLIElement current_element = element_iterator.next();
            // check the mapping elements
            for (CLIMapping mapping : current_element.getMapping()) {
                if (m_ignoredParameters.contains(mapping.getReferenceName())) {
                    // remove this element and stop the loop
                    element_iterator.remove();
                    break;
                }
            }
        }
    }
}
Also used : CLIElement(com.genericworkflownodes.knime.cliwrapper.CLIElement) FileListParameter(com.genericworkflownodes.knime.parameter.FileListParameter) ListParameter(com.genericworkflownodes.knime.parameter.ListParameter) BoolParameter(com.genericworkflownodes.knime.parameter.BoolParameter) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) IntegerListParameter(com.genericworkflownodes.knime.parameter.IntegerListParameter) DoubleParameter(com.genericworkflownodes.knime.parameter.DoubleParameter) Parameter(com.genericworkflownodes.knime.parameter.Parameter) StringChoiceParameter(com.genericworkflownodes.knime.parameter.StringChoiceParameter) StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) DoubleListParameter(com.genericworkflownodes.knime.parameter.DoubleListParameter) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) IntegerParameter(com.genericworkflownodes.knime.parameter.IntegerParameter) CLIMapping(com.genericworkflownodes.knime.cliwrapper.CLIMapping)

Example 3 with CLIMapping

use of com.genericworkflownodes.knime.cliwrapper.CLIMapping in project GenericKnimeNodes by genericworkflownodes.

the class CTDConfigurationWriter method writeCLI.

private void writeCLI() throws IOException {
    streamPut("<cli>");
    indent();
    for (CLIElement elem : currentConfig.getCLI().getCLIElement()) {
        streamPut(String.format("<clielement optionIdentifier=\"%s\" isList=\"%s\">", elem.getOptionIdentifier(), (elem.isList() ? "true" : "false")));
        indent();
        for (CLIMapping mapping : elem.getMapping()) {
            streamPut(String.format("<mapping referenceName=\"%s\" />", mapping.getReferenceName()));
        }
        outdent();
        streamPut("</clielement>");
    }
    outdent();
    streamPut("</cli>");
}
Also used : CLIElement(com.genericworkflownodes.knime.cliwrapper.CLIElement) CLIMapping(com.genericworkflownodes.knime.cliwrapper.CLIMapping)

Example 4 with CLIMapping

use of com.genericworkflownodes.knime.cliwrapper.CLIMapping in project GenericKnimeNodes by genericworkflownodes.

the class DockerCommandGenerator method extractParamterValues.

private List<List<? extends CommandLineElement>> extractParamterValues(CLIElement cliElement, List<CommandLineElement> dockerCommands, Map<String, String> hostDockerMap) throws IOException {
    List<List<? extends CommandLineElement>> extractedParameterValues = new ArrayList<List<? extends CommandLineElement>>();
    for (CLIMapping cliMapping : cliElement.getMapping()) {
        if (nodeConfig.getParameterKeys().contains(cliMapping.getReferenceName())) {
            Parameter<?> p = nodeConfig.getParameter(cliMapping.getReferenceName());
            if (!p.isNull()) {
                if (p instanceof ListParameter) {
                    ListParameter lp = (ListParameter) p;
                    if (lp.getStrings().size() > 0) {
                        final List<CommandLineElement> tmp = new ArrayList<CommandLineElement>();
                        for (final String s : lp.getStrings()) {
                            tmp.add(new CommandLineFixedString(s));
                        }
                        extractedParameterValues.add(tmp);
                    }
                } else if (p instanceof FileParameter) {
                    extractedParameterValues.add(handleFileParameter(((FileParameter) p).getValue(), dockerCommands, hostDockerMap));
                } else if (p instanceof FileListParameter) {
                    List<String> fl = ((FileListParameter) p).getValue();
                    if (fl.size() > 0) {
                        for (String hostFile : fl) {
                            extractedParameterValues.add(handleFileParameter(hostFile, dockerCommands, hostDockerMap));
                        }
                    }
                } else {
                    List<CommandLineElement> l = new ArrayList<CommandLineElement>();
                    l.add(new CommandLineParameter(p));
                    extractedParameterValues.add(l);
                }
            }
        }
    }
    return extractedParameterValues;
}
Also used : FileListParameter(com.genericworkflownodes.knime.parameter.FileListParameter) CommandLineParameter(com.genericworkflownodes.knime.commandline.impl.CommandLineParameter) ArrayList(java.util.ArrayList) CLIMapping(com.genericworkflownodes.knime.cliwrapper.CLIMapping) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) ArrayList(java.util.ArrayList) List(java.util.List) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) FileListParameter(com.genericworkflownodes.knime.parameter.FileListParameter) ListParameter(com.genericworkflownodes.knime.parameter.ListParameter)

Aggregations

CLIMapping (com.genericworkflownodes.knime.cliwrapper.CLIMapping)4 CLIElement (com.genericworkflownodes.knime.cliwrapper.CLIElement)3 FileListParameter (com.genericworkflownodes.knime.parameter.FileListParameter)2 FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)2 ListParameter (com.genericworkflownodes.knime.parameter.ListParameter)2 CommandLineElement (com.genericworkflownodes.knime.commandline.CommandLineElement)1 CommandLineFixedString (com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString)1 CommandLineParameter (com.genericworkflownodes.knime.commandline.impl.CommandLineParameter)1 BoolParameter (com.genericworkflownodes.knime.parameter.BoolParameter)1 DoubleListParameter (com.genericworkflownodes.knime.parameter.DoubleListParameter)1 DoubleParameter (com.genericworkflownodes.knime.parameter.DoubleParameter)1 IntegerListParameter (com.genericworkflownodes.knime.parameter.IntegerListParameter)1 IntegerParameter (com.genericworkflownodes.knime.parameter.IntegerParameter)1 Parameter (com.genericworkflownodes.knime.parameter.Parameter)1 StringChoiceParameter (com.genericworkflownodes.knime.parameter.StringChoiceParameter)1 StringListParameter (com.genericworkflownodes.knime.parameter.StringListParameter)1 StringParameter (com.genericworkflownodes.knime.parameter.StringParameter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1