Search in sources :

Example 1 with Parameter

use of com.genericworkflownodes.knime.parameter.Parameter 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 2 with Parameter

use of com.genericworkflownodes.knime.parameter.Parameter in project GenericKnimeNodes by genericworkflownodes.

the class CLICommandGenerator method handleListParameter.

private void handleListParameter(final List<List<? extends CommandLineElement>> extractedParameterValues, final ListParameter listParameter) {
    final int nValues = listParameter.getStrings().size();
    final String key = ((Parameter<?>) listParameter).getKey();
    final List<CommandLineElement> tmpList = new LinkedList<CommandLineElement>();
    // there's only one element in the list
    if (nValues > 1) {
        int sequence = 0;
        for (final String value : listParameter.getStrings()) {
            final CommandLineElement commandLineElement;
            if (listParameter instanceof IFileParameter) {
                commandLineElement = new CommandLineFile(new FileParameter(key, value));
            } else {
                commandLineElement = new CommandLineParameter(new StringParameter(key, value));
            }
            commandLineElement.setSequenceNumber(sequence++);
            tmpList.add(commandLineElement);
        }
    } else {
        // only one value in the list, no need to use sequence numbers
        final String value = listParameter.getStrings().get(0);
        if (listParameter instanceof IFileParameter) {
            tmpList.add(new CommandLineFile(new FileParameter(key, value)));
        } else {
            tmpList.add(new CommandLineParameter(new StringParameter(key, value)));
        }
    }
    extractedParameterValues.add(tmpList);
}
Also used : IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) CommandLineParameter(com.genericworkflownodes.knime.commandline.impl.CommandLineParameter) CommandLineFile(com.genericworkflownodes.knime.commandline.impl.CommandLineFile) ListParameter(com.genericworkflownodes.knime.parameter.ListParameter) BoolParameter(com.genericworkflownodes.knime.parameter.BoolParameter) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) CommandLineParameter(com.genericworkflownodes.knime.commandline.impl.CommandLineParameter) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) Parameter(com.genericworkflownodes.knime.parameter.Parameter) IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter) LinkedList(java.util.LinkedList)

Aggregations

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