Search in sources :

Example 96 with PortObject

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

the class DBColumnFilterNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    DatabasePortObject dbObj = (DatabasePortObject) inData[0];
    DatabaseQueryConnectionSettings conn = dbObj.getConnectionSettings(getCredentialsProvider());
    ColumnRearranger colre = new ColumnRearranger(dbObj.getSpec().getDataTableSpec());
    colre.keepOnly(m_filter.getIncludeList().toArray(new String[0]));
    final DataTableSpec resultSpec = colre.createSpec();
    final String newQuery = createQuery(conn, resultSpec);
    conn = createDBQueryConnection(dbObj.getSpec(), newQuery);
    DatabasePortObjectSpec outSpec = new DatabasePortObjectSpec(resultSpec, conn.createConnectionModel());
    DatabasePortObject outObj = new DatabasePortObject(outSpec);
    return new PortObject[] { outObj };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DataTableSpec(org.knime.core.data.DataTableSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Example 97 with PortObject

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

the class TableRowToImageNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
    BufferedDataTable inTable = (BufferedDataTable) inObjects[0];
    // check for empty table
    if (inTable.size() == 0) {
        throw new IllegalArgumentException("Input table is empty.");
    }
    // warn if more than one row
    if (inTable.size() > 1) {
        setWarningMessage("Input data table has more than one rows! " + "Using first row only.");
    }
    String column = m_imageColSettingsModel.getStringValue();
    DataTableSpec inSpec = inTable.getDataTableSpec();
    int columnIndex = inSpec.findColumnIndex(column);
    if (columnIndex < 0) {
        columnIndex = findImageColumnIndex(inSpec);
    }
    ImagePortObjectSpec imagePortObjectSpec = new ImagePortObjectSpec(inSpec.getColumnSpec(columnIndex).getType());
    final RowIterator it = inTable.iterator();
    while (it.hasNext()) {
        DataRow row = it.next();
        DataCell cell = row.getCell(columnIndex);
        if (!cell.isMissing()) {
            ImageContent ic = ((ImageValue) cell).getImageContent();
            return new PortObject[] { new ImagePortObject(ic, imagePortObjectSpec) };
        } else {
            setWarningMessage("Found missing image cell, skipping it...");
        }
    }
    throw new IllegalArgumentException("Input table contains only missing cells.");
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ImagePortObjectSpec(org.knime.core.node.port.image.ImagePortObjectSpec) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) ImagePortObject(org.knime.core.node.port.image.ImagePortObject) DataRow(org.knime.core.data.DataRow) ImageContent(org.knime.core.data.image.ImageContent) RowIterator(org.knime.core.data.RowIterator) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataCell(org.knime.core.data.DataCell) ImageValue(org.knime.core.data.image.ImageValue) PortObject(org.knime.core.node.port.PortObject) ImagePortObject(org.knime.core.node.port.image.ImagePortObject)

Example 98 with PortObject

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

the class DBJoinerNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    exec.setMessage("Retrieving metadata from database");
    DatabasePortObject dbObjectLeft = (DatabasePortObject) inData[0];
    DatabasePortObject dbObjectRight = (DatabasePortObject) inData[1];
    DatabasePortObject outObject = new DatabasePortObject(createDbOutSpec(dbObjectLeft.getSpec(), dbObjectRight.getSpec()));
    return new PortObject[] { outObject };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Example 99 with PortObject

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

the class DBReaderConnectionNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    // DatabaseQueryConnectionSettings conn = m_load.getQueryConnection();
    DatabaseQueryConnectionSettings conn = new DatabaseQueryConnectionSettings(m_conn, parseQuery(m_conn.getQuery()));
    DBReader load = conn.getUtility().getReader(conn);
    DataTableSpec spec = load.getDataTableSpec(getCredentialsProvider());
    DatabasePortObject dbObj = new DatabasePortObject(new DatabasePortObjectSpec(spec, conn.createConnectionModel()));
    return new PortObject[] { dbObj };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DataTableSpec(org.knime.core.data.DataTableSpec) DBReader(org.knime.core.node.port.database.reader.DBReader) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Example 100 with PortObject

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

the class DBRowFilterNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    DatabasePortObject dbObj = (DatabasePortObject) inData[0];
    DatabaseQueryConnectionSettings conn = dbObj.getConnectionSettings(getCredentialsProvider());
    String newQuery = createQuery(conn.getQuery(), conn.getUtility().getStatementManipulator());
    conn = createDBQueryConnection(dbObj.getSpec(), newQuery);
    DatabasePortObject outObj = new DatabasePortObject(new DatabasePortObjectSpec(dbObj.getSpec().getDataTableSpec(), conn.createConnectionModel()));
    return new PortObject[] { outObj };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Aggregations

PortObject (org.knime.core.node.port.PortObject)173 BufferedDataTable (org.knime.core.node.BufferedDataTable)97 DataTableSpec (org.knime.core.data.DataTableSpec)68 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)59 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)39 InactiveBranchPortObject (org.knime.core.node.port.inactive.InactiveBranchPortObject)37 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)35 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)34 IOException (java.io.IOException)33 DataRow (org.knime.core.data.DataRow)25 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)24 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)23 DataCell (org.knime.core.data.DataCell)20 FileStorePortObject (org.knime.core.data.filestore.FileStorePortObject)19 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)19 DatabasePortObject (org.knime.core.node.port.database.DatabasePortObject)18 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)16 ExecutionContext (org.knime.core.node.ExecutionContext)15 DataColumnSpec (org.knime.core.data.DataColumnSpec)14 InactiveBranchPortObjectSpec (org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec)13