Search in sources :

Example 1 with CommandLineElement

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

use of com.genericworkflownodes.knime.commandline.CommandLineElement in project GenericKnimeNodes by genericworkflownodes.

the class DockerCommandGenerator method handleFileParameter.

/**
 * Process a file parameter by specifying the docker mount point and
 * altering the file paths to fit the internal docker path
 *
 * @param hostFile string to file on host system
 * @param dockerCommands a list of specific docker commands
 * @param hostDockerMap a map of host paths to docker paths that have already been mapped
 * @return List of extracted commands
 * @throws IOException
 */
private List<? extends CommandLineElement> handleFileParameter(String hostFile, List<CommandLineElement> dockerCommands, Map<String, String> hostDockerMap) throws IOException {
    String dockerMount;
    File fileParam = new File(hostFile);
    String hostPath = toUnixPath(fileParam.getParentFile().getCanonicalPath());
    if (hostDockerMap.containsKey(hostPath)) {
        dockerMount = hostDockerMap.get(hostPath);
    } else {
        dockerMount = DOCKER_INTERNAL_MOUNT + dockerCommands.size() + DOCKER_DIR_SEP;
        hostDockerMap.put(hostPath, dockerMount);
        dockerCommands.add(new CommandLineFixedString(DOCKER_MOUNT_COMMAND));
        dockerCommands.add(new CommandLineFixedString(hostPath + ":" + dockerMount));
    }
    List<CommandLineElement> l = new ArrayList<CommandLineElement>();
    l.add(new CommandLineFixedString(dockerMount + fileParam.getName()));
    return l;
}
Also used : ArrayList(java.util.ArrayList) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) File(java.io.File)

Example 3 with CommandLineElement

use of com.genericworkflownodes.knime.commandline.CommandLineElement in project GenericKnimeNodes by genericworkflownodes.

the class BALLCommandGenerator method generateCommands.

@Override
public List<CommandLineElement> generateCommands(INodeConfiguration nodeConfiguration, IPluginConfiguration pluginConfiguration, File workingDirectory) throws Exception {
    File paramFile = writePARFile(nodeConfiguration, workingDirectory);
    List<CommandLineElement> commands = new ArrayList<CommandLineElement>();
    commands.add(new CommandLineFixedString(PAR_SWITCH));
    commands.add(new CommandLineCTDFile(paramFile));
    return commands;
}
Also used : CommandLineCTDFile(com.genericworkflownodes.knime.commandline.impl.CommandLineCTDFile) ArrayList(java.util.ArrayList) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) CommandLineCTDFile(com.genericworkflownodes.knime.commandline.impl.CommandLineCTDFile) File(java.io.File)

Example 4 with CommandLineElement

use of com.genericworkflownodes.knime.commandline.CommandLineElement in project GenericKnimeNodes by genericworkflownodes.

the class OpenMSCommandGenerator method generateCommands.

@Override
public List<CommandLineElement> generateCommands(INodeConfiguration nodeConfiguration, IPluginConfiguration pluginConfiguration, File workingDirectory) throws Exception {
    File iniFile = createINIFile(nodeConfiguration, workingDirectory);
    List<CommandLineElement> commands = new ArrayList<CommandLineElement>();
    commands.add(new CommandLineFixedString(INI_SWITCH));
    commands.add(new CommandLineCTDFile(iniFile));
    return commands;
}
Also used : CommandLineCTDFile(com.genericworkflownodes.knime.commandline.impl.CommandLineCTDFile) ArrayList(java.util.ArrayList) CommandLineFixedString(com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) CommandLineCTDFile(com.genericworkflownodes.knime.commandline.impl.CommandLineCTDFile) File(java.io.File)

Example 5 with CommandLineElement

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

CommandLineElement (com.genericworkflownodes.knime.commandline.CommandLineElement)7 CommandLineFixedString (com.genericworkflownodes.knime.commandline.impl.CommandLineFixedString)6 ArrayList (java.util.ArrayList)6 CommandLineParameter (com.genericworkflownodes.knime.commandline.impl.CommandLineParameter)3 FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)3 File (java.io.File)3 CommandLineCTDFile (com.genericworkflownodes.knime.commandline.impl.CommandLineCTDFile)2 CommandLineFile (com.genericworkflownodes.knime.commandline.impl.CommandLineFile)2 IFileParameter (com.genericworkflownodes.knime.parameter.IFileParameter)2 ListParameter (com.genericworkflownodes.knime.parameter.ListParameter)2 List (java.util.List)2 CLIElement (com.genericworkflownodes.knime.cliwrapper.CLIElement)1 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 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1