Search in sources :

Example 11 with URIPortObjectSpec

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() };
}
Also used : SplitterFactory(com.genericworkflownodes.knime.cluster.filesplitter.SplitterFactory) URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 12 with URIPortObjectSpec

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;
}
Also used : URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec)

Example 13 with URIPortObjectSpec

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 };
}
Also used : URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) SettingsModelOptionalString(org.knime.core.node.defaultnodesettings.SettingsModelOptionalString)

Aggregations

URIPortObjectSpec (org.knime.core.data.uri.URIPortObjectSpec)13 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)6 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)6 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)4 SplitterFactory (com.genericworkflownodes.knime.cluster.filesplitter.SplitterFactory)2 IFileParameter (com.genericworkflownodes.knime.parameter.IFileParameter)2 ArrayList (java.util.ArrayList)2 InactiveBranchPortObjectSpec (org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec)2 IDemangler (com.genericworkflownodes.knime.mime.demangler.IDemangler)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 SettingsModelOptionalString (org.knime.core.node.defaultnodesettings.SettingsModelOptionalString)1