Search in sources :

Example 46 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class DBReaderConnectionNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    try {
        // DatabaseQueryConnectionSettings conn = m_load.getQueryConnection();
        if (m_conn == null) {
            throw new InvalidSettingsException("No database connection available.");
        }
        final DatabaseQueryConnectionSettings conn = new DatabaseQueryConnectionSettings(m_conn, parseQuery(m_conn.getQuery()));
        if (!conn.getRetrieveMetadataInConfigure()) {
            return new PortObjectSpec[1];
        }
        DBReader load = conn.getUtility().getReader(conn);
        DataTableSpec spec = load.getDataTableSpec(getCredentialsProvider());
        if (spec == null) {
            throw new InvalidSettingsException("No database connection available.");
        }
        DatabasePortObjectSpec dbSpec = new DatabasePortObjectSpec(spec, conn.createConnectionModel());
        return new PortObjectSpec[] { dbSpec };
    } catch (InvalidSettingsException ise) {
        throw ise;
    } catch (Throwable t) {
        throw new InvalidSettingsException(t);
    }
}
Also used : DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DataTableSpec(org.knime.core.data.DataTableSpec) DBReader(org.knime.core.node.port.database.reader.DBReader) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec)

Example 47 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class DBRowFilterNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    DatabasePortObjectSpec spec = (DatabasePortObjectSpec) inSpecs[0];
    final String columnName = m_column.getStringValue();
    if (columnName == null) {
        throw new InvalidSettingsException("No filter column selected.");
    }
    if (!spec.getDataTableSpec().containsName(columnName)) {
        throw new InvalidSettingsException("Can't filter according to " + "selected column \"" + columnName + "\".");
    }
    DatabaseQueryConnectionSettings conn = spec.getConnectionSettings(getCredentialsProvider());
    String newQuery = createQuery(conn.getQuery(), conn.getUtility().getStatementManipulator());
    conn = createDBQueryConnection(spec, newQuery);
    return new PortObjectSpec[] { new DatabasePortObjectSpec(spec.getDataTableSpec(), conn.createConnectionModel()) };
}
Also used : DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 48 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class WritePNGNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    String outPath = m_fileOutSettings.getStringValue();
    boolean overwriteOK = m_overwriteOKBoolean.getBooleanValue();
    if (outPath == null || outPath.length() == 0) {
        throw new InvalidSettingsException("No output path specified");
    }
    File f = new File(outPath);
    if (f.isDirectory()) {
        throw new InvalidSettingsException("Can't write to \"" + outPath + "\": it is a directory");
    }
    if (f.isFile() && !overwriteOK) {
        throw new InvalidSettingsException("Can't write to \"" + outPath + "\": file exists (configure overwrite in dialog)");
    }
    File directory = f.getParentFile();
    if (directory == null || !directory.isDirectory()) {
        throw new InvalidSettingsException("Can't write to \"" + outPath + "\": parent directory does not exist");
    }
    ImagePortObjectSpec imageInObject = (ImagePortObjectSpec) inSpecs[0];
    DataType dataType = imageInObject.getDataType();
    if (!dataType.isCompatible(PNGImageValue.class)) {
        throw new InvalidSettingsException("Unsupported image type, " + "expecting PNG input, got " + dataType);
    }
    return new PortObjectSpec[0];
}
Also used : ImagePortObjectSpec(org.knime.core.node.port.image.ImagePortObjectSpec) PNGImageValue(org.knime.core.data.image.png.PNGImageValue) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ImagePortObjectSpec(org.knime.core.node.port.image.ImagePortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) DataType(org.knime.core.data.DataType) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) File(java.io.File)

Example 49 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project GenericKnimeNodes by genericworkflownodes.

the class GenericKnimeNodeModel method createOutSpec.

protected PortObjectSpec[] createOutSpec() {
    int nOut = m_fileEndingsOutPorts.length;
    PortObjectSpec[] out_spec = new PortObjectSpec[nOut];
    // set selected MIMEURIPortObjectSpecs at output ports
    for (int i = 0; i < nOut; i++) {
        // selected output MIMEType
        int selectedMIMETypeIndex = getOutputTypeIndex(i);
        // TODO: check
        String mt = m_fileEndingsOutPorts[i][selectedMIMETypeIndex];
        if (!mt.toLowerCase().equals("inactive")) {
            out_spec[i] = new URIPortObjectSpec(mt);
        } else {
            out_spec[i] = InactiveBranchPortObjectSpec.INSTANCE;
        }
    }
    return out_spec;
}
Also used : URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec)

Example 50 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project GenericKnimeNodes by genericworkflownodes.

the class FileMergerNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    // check not null
    checkNotNullSpecs(inSpecs);
    // check equal MIMEType
    checkEqualMIMETypes(inSpecs);
    // create output spec
    URIPortObjectSpec outSpec = new URIPortObjectSpec(((URIPortObjectSpec) inSpecs[0]).getFileExtensions());
    return new PortObjectSpec[] { outSpec };
}
Also used : URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) URIPortObjectSpec(org.knime.core.data.uri.URIPortObjectSpec)

Aggregations

PortObjectSpec (org.knime.core.node.port.PortObjectSpec)139 DataTableSpec (org.knime.core.data.DataTableSpec)93 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)86 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)35 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)30 DataColumnSpec (org.knime.core.data.DataColumnSpec)29 FlowVariablePortObjectSpec (org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec)25 IOException (java.io.IOException)24 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)24 InactiveBranchPortObjectSpec (org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec)24 PortObject (org.knime.core.node.port.PortObject)19 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)16 InactiveBranchPortObject (org.knime.core.node.port.inactive.InactiveBranchPortObject)16 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)14 FileStorePortObject (org.knime.core.data.filestore.FileStorePortObject)13 File (java.io.File)12 ArrayList (java.util.ArrayList)12 DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)12 DatabaseQueryConnectionSettings (org.knime.core.node.port.database.DatabaseQueryConnectionSettings)12 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)12