use of com.genericworkflownodes.knime.base.data.port.IPrefixURIPortObject in project GenericKnimeNodes by genericworkflownodes.
the class DynamicGenericNodeModel method transferIncomingPorts2Config.
/**
* Transfers the incoming ports into the config, that it can be written out
* into a config file or can be transferred to the command line.
*
* @param inData
* The incoming port objects.
* @throws Exception
*/
private void transferIncomingPorts2Config(PortObject[] inData) throws Exception {
// Transfer settings from the input ports into the configuration object
for (int i = 0; i < inData.length; i++) {
// find the internal port for this PortObject
Port port = m_nodeConfig.getInputPorts().get(i);
IURIPortObject po = (IURIPortObject) inData[i];
String name = port.getName();
// find the associated parameter in the configuration
Parameter<?> p = m_nodeConfig.getParameter(name);
boolean isMultiFile = port.isMultiFile();
boolean isPrefix = port.isPrefix();
// skip optional and unconnected inport ports
if (inData[i] == null) {
((FileParameter) p).setValue(null);
continue;
}
// connected: check contents
List<URIContent> uris = po.getURIContents();
// check validity of subtypes with actual inputs
if (uris.size() > 1 && (!isMultiFile && !isPrefix)) {
throw new Exception("IURIPortObject with multiple URIs supplied at single URI port #" + i);
}
// port
if (!(p instanceof IFileParameter)) {
throw new Exception("Invalid reference from port to non-file parameter. URI port #" + i);
}
if (isPrefix) {
// we pass only the prefix to the tool
IPrefixURIPortObject puri = (IPrefixURIPortObject) inData[i];
((FileParameter) p).setValue(puri.getPrefix());
} else if (isMultiFile) {
// we need to collect all filenames and then set them as a batch
// in the config
List<String> filenames = new ArrayList<String>();
for (URIContent uric : uris) {
URI uri = uric.getURI();
filenames.add(new File(uri).getAbsolutePath());
}
((FileListParameter) p).setValue(filenames);
} else {
// just one filename
URI uri = uris.get(0).getURI();
String filename = new File(uri).getAbsolutePath();
((FileParameter) p).setValue(filename);
}
}
}
use of com.genericworkflownodes.knime.base.data.port.IPrefixURIPortObject in project GenericKnimeNodes by genericworkflownodes.
the class GenericKnimeNodeModel method transferIncomingPorts2Config.
/**
* Transfers the incoming ports into the config, that it can be written out
* into a config file or can be transferred to the command line.
*
* @param inData
* The incoming port objects.
* @throws Exception
*/
private void transferIncomingPorts2Config(PortObject[] inData) throws Exception {
// Transfer settings from the input ports into the configuration object
for (int i = 0; i < inData.length; i++) {
// find the internal port for this PortObject
Port port = m_nodeConfig.getInputPorts().get(i);
IURIPortObject po = (IURIPortObject) inData[i];
String name = port.getName();
// find the associated parameter in the configuration
Parameter<?> p = m_nodeConfig.getParameter(name);
boolean isMultiFile = port.isMultiFile();
boolean isPrefix = port.isPrefix();
// skip optional and unconnected inport ports
if (inData[i] == null) {
p.setValue(null);
continue;
}
// connected: check contents
List<URIContent> uris = po.getURIContents();
// check validity of subtypes with actual inputs
if (uris.size() > 1 && (!isMultiFile && !isPrefix)) {
throw new Exception("IURIPortObject with multiple URIs supplied at single URI port #" + i);
}
// port
if (!(p instanceof IFileParameter)) {
throw new Exception("Invalid reference from port to non-file parameter. URI port #" + i);
}
if (isPrefix) {
// we pass only the prefix to the tool
IPrefixURIPortObject puri = (IPrefixURIPortObject) inData[i];
((FileParameter) p).setValue(puri.getPrefix());
} else if (isMultiFile) {
// we need to collect all filenames and then set them as a batch
// in the config
List<String> filenames = new ArrayList<String>();
for (URIContent uric : uris) {
URI uri = uric.getURI();
filenames.add(new File(uri).getAbsolutePath());
}
((FileListParameter) p).setValue(filenames);
} else {
// just one filename
URI uri = uris.get(0).getURI();
String filename = new File(uri).getAbsolutePath();
((FileParameter) p).setValue(filename);
}
}
}
Aggregations