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);
}
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);
}
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;
}
Aggregations