Search in sources :

Example 6 with DatabasePortObject

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

the class DBAutoBinnerNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    final DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) inSpecs[0];
    DatabaseQueryConnectionSettings connectionSettings = dbSpec.getConnectionSettings(getCredentialsProvider());
    boolean suppCase = connectionSettings.getUtility().supportsCase();
    if (!suppCase) {
        if (m_settings.getFilterConfiguration().applyTo(dbSpec.getDataTableSpec()).getIncludes().length > 1) {
            throw new InvalidSettingsException("Database does not support \"CASE\". Please choose only one column.");
        }
    }
    if (connectionSettings.getRetrieveMetadataInConfigure()) {
        PMMLPortObject pmmlPortObject = createPMMLPortObject(dbSpec, connectionSettings, new ExecutionMonitor());
        DatabasePortObject databasePortObject = createDatabasePortObject(dbSpec, connectionSettings, pmmlPortObject);
        return new PortObjectSpec[] { databasePortObject.getSpec(), pmmlPortObject.getSpec() };
    }
    return new PortObjectSpec[] { null, null };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) ExecutionMonitor(org.knime.core.node.ExecutionMonitor)

Example 7 with DatabasePortObject

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

the class DBAutoBinnerNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    exec.setMessage("Retrieving metadata from database");
    final DatabasePortObject dbObject = (DatabasePortObject) inData[0];
    final DatabasePortObjectSpec inSpec = dbObject.getSpec();
    DatabaseQueryConnectionSettings connectionSettings = inSpec.getConnectionSettings(getCredentialsProvider());
    PMMLPortObject pmmlPortObject = createPMMLPortObject(inSpec, connectionSettings, exec);
    DatabasePortObject databasePortObject = createDatabasePortObject(inSpec, connectionSettings, pmmlPortObject);
    return new PortObject[] { databasePortObject, pmmlPortObject };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject)

Example 8 with DatabasePortObject

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

the class DBApplyBinnerNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    PMMLPortObject pmmlPortObject = (PMMLPortObject) inData[0];
    DatabasePortObject databasePortObject = (DatabasePortObject) inData[1];
    DatabaseQueryConnectionSettings connectionSettings = databasePortObject.getConnectionSettings(getCredentialsProvider());
    return new PortObject[] { createDatabasePortObject(databasePortObject.getSpec(), connectionSettings, pmmlPortObject) };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject)

Example 9 with DatabasePortObject

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

the class DBNumericBinnerNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    exec.setMessage("Retrieving metadata from database");
    checkDuplicateBinNames();
    final DatabasePortObject inDatabasePortObject = (DatabasePortObject) inData[0];
    final DatabasePortObjectSpec inDatabasePortObjectSpec = inDatabasePortObject.getSpec();
    DatabaseQueryConnectionSettings connectionSettings = inDatabasePortObject.getConnectionSettings(getCredentialsProvider());
    DataTableSpec outDataTableSpec = DBAutoBinner.createNewDataTableSpec(inDatabasePortObjectSpec.getDataTableSpec(), m_columnToAppended);
    PMMLPortObject outPMMLPortObject = createPMMLPortObject(inDatabasePortObjectSpec.getDataTableSpec(), outDataTableSpec);
    DBBinnerMaps binnerMaps = DBAutoBinner.intoBinnerMaps(outPMMLPortObject, inDatabasePortObjectSpec.getDataTableSpec());
    DatabasePortObjectSpec outDatabasePortObjectSpec = createDatabasePortObjectSpec(connectionSettings, inDatabasePortObjectSpec, binnerMaps);
    return new PortObject[] { new DatabasePortObject(outDatabasePortObjectSpec), outPMMLPortObject };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DBBinnerMaps(org.knime.base.node.io.database.binning.DBBinnerMaps) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Example 10 with DatabasePortObject

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

the class DBColumnRenameNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
    final DatabasePortObject dbObject = (DatabasePortObject) inObjects[0];
    final DatabasePortObject outObject = new DatabasePortObject(createDBOutSpec(dbObject.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)

Aggregations

DatabasePortObject (org.knime.core.node.port.database.DatabasePortObject)24 PortObject (org.knime.core.node.port.PortObject)18 DatabaseQueryConnectionSettings (org.knime.core.node.port.database.DatabaseQueryConnectionSettings)17 DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)13 DBReader (org.knime.core.node.port.database.reader.DBReader)8 DataTableSpec (org.knime.core.data.DataTableSpec)7 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)6 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)5 BufferedDataTable (org.knime.core.node.BufferedDataTable)4 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)4 SQLException (java.sql.SQLException)3 StatementManipulator (org.knime.core.node.port.database.StatementManipulator)3 CredentialsProvider (org.knime.core.node.workflow.CredentialsProvider)3 DatabaseConnectionPortObject (org.knime.core.node.port.database.DatabaseConnectionPortObject)2 DatabaseConnectionSettings (org.knime.core.node.port.database.DatabaseConnectionSettings)2 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)2 IOException (java.io.IOException)1 DBBinnerMaps (org.knime.base.node.io.database.binning.DBBinnerMaps)1 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)1 DataContainer (org.knime.core.data.container.DataContainer)1