Search in sources :

Example 1 with CommandLineParameter

use of com.genericworkflownodes.knime.commandline.impl.CommandLineParameter in project GenericKnimeNodes by genericworkflownodes.

the class CLICommandGenerator method handleNonListParameter.

private void handleNonListParameter(final List<List<? extends CommandLineElement>> extractedParameterValues, final Parameter<?> p) {
    final List<CommandLineElement> l = new ArrayList<CommandLineElement>();
    final CommandLineElement commandLineElement;
    if (p instanceof FileParameter) {
        commandLineElement = new CommandLineFile((FileParameter) p);
    } else {
        commandLineElement = new CommandLineParameter(p);
    }
    l.add(commandLineElement);
    extractedParameterValues.add(l);
}
Also used : CommandLineParameter(com.genericworkflownodes.knime.commandline.impl.CommandLineParameter) ArrayList(java.util.ArrayList) CommandLineFile(com.genericworkflownodes.knime.commandline.impl.CommandLineFile) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter)

Example 2 with CommandLineParameter

use of com.genericworkflownodes.knime.commandline.impl.CommandLineParameter 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)

Example 3 with CommandLineParameter

use of com.genericworkflownodes.knime.commandline.impl.CommandLineParameter 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

CommandLineElement (com.genericworkflownodes.knime.commandline.CommandLineElement)3 CommandLineParameter (com.genericworkflownodes.knime.commandline.impl.CommandLineParameter)3 FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)3 CommandLineFile (com.genericworkflownodes.knime.commandline.impl.CommandLineFile)2 CommandLineFixedString (com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString)2 IFileParameter (com.genericworkflownodes.knime.parameter.IFileParameter)2 ListParameter (com.genericworkflownodes.knime.parameter.ListParameter)2 ArrayList (java.util.ArrayList)2 CLIMapping (com.genericworkflownodes.knime.cliwrapper.CLIMapping)1 BoolParameter (com.genericworkflownodes.knime.parameter.BoolParameter)1 FileListParameter (com.genericworkflownodes.knime.parameter.FileListParameter)1 Parameter (com.genericworkflownodes.knime.parameter.Parameter)1 StringParameter (com.genericworkflownodes.knime.parameter.StringParameter)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1