use of org.knime.core.data.uri.URIPortObjectSpec in project GenericKnimeNodes by genericworkflownodes.
the class FileSplitterNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
String factoryID = m_factoryID.getStringValue();
URIPortObjectSpec spec = (URIPortObjectSpec) inSpecs[0];
// If no factory has been selected in the dialog, we take the first one that matches
if (factoryID == null) {
String ext = spec.getFileExtensions().get(0);
String mime = MIMETypeHelper.getMIMEtypeByExtension(ext);
Iterator<SplitterFactory> factories = SplitterFactoryManager.getInstance().getFactories(mime).iterator();
if (!factories.hasNext()) {
throw new InvalidSettingsException("No suitable splitter found for mimetype " + mime + ".");
}
SplitterFactory fac = factories.next();
factoryID = fac.getID();
m_factoryID.setStringValue(factoryID);
setWarningMessage("No splitter selected. Choosing " + factoryID + ".");
}
return new PortObjectSpec[] { createSpec() };
}
use of org.knime.core.data.uri.URIPortObjectSpec in project GenericKnimeNodes by genericworkflownodes.
the class FileSplitterNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
// check not null
checkNotNullSpecs(inSpecs);
// create output spec
URIPortObjectSpec outSpec = new URIPortObjectSpec(((URIPortObjectSpec) inSpecs[0]).getFileExtensions());
PortObjectSpec[] specs = new PortObjectSpec[getOutgoing().length];
for (int i = 0; i < specs.length; i++) {
specs[i] = outSpec;
}
return specs;
}
use of org.knime.core.data.uri.URIPortObjectSpec in project GenericKnimeNodes by genericworkflownodes.
the class ListMimeFileImporterNodeModel method configure.
@Override
protected PortObjectSpec[] configure(PortObjectSpec[] inSpecs) throws InvalidSettingsException {
/*
* Upon inserting the node into a workflow, it gets configured, so at
* least something fundamental like the file name should be checked
*/
String[] filenames = m_filenames.getStringArrayValue();
if (filenames == null || filenames.length == 0) {
throw new InvalidSettingsException("No Files selected.");
}
URIPortObjectSpec uri_spec = null;
if (m_file_extension.isActive()) {
uri_spec = new URIPortObjectSpec(m_file_extension.getStringValue());
} else {
uri_spec = new URIPortObjectSpec(MIMETypeHelper.getMIMEtypeExtension(m_filenames.getStringArrayValue()[0]));
}
return new PortObjectSpec[] { uri_spec };
}
Aggregations