use of com.genericworkflownodes.knime.cluster.filesplitter.SplitterFactory in project GenericKnimeNodes by genericworkflownodes.
the class FileSplitterNodeDialog method loadAdditionalSettingsFrom.
@Override
public void loadAdditionalSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) throws NotConfigurableException {
String factoryId;
SettingsModelString facId = FileSplitterNodeModel.createFactoryIDSettingsModel();
try {
facId.loadSettingsFrom(settings);
factoryId = facId.getStringValue();
} catch (InvalidSettingsException e) {
factoryId = null;
}
URIPortObjectSpec spec = (URIPortObjectSpec) specs[0];
String ext = spec.getFileExtensions().get(0);
String mimetype = MIMETypeHelper.getMIMEtypeByExtension(ext);
List<SplitterFactory> factories = SplitterFactoryManager.getInstance().getFactories(mimetype);
List<String> facs = new ArrayList<String>();
if (factories.size() == 0) {
facs = Collections.singletonList(NO_FACTORY);
}
for (SplitterFactory f : factories) {
facs.add(f.getID());
}
m_factories.replaceListItems(facs, factoryId != null ? factoryId : facs.get(0));
}
use of com.genericworkflownodes.knime.cluster.filesplitter.SplitterFactory 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() };
}
Aggregations