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