Search in sources :

Example 11 with DatabasePortObjectSpec

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

the class DBAutoBinnerNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) specs[0];
    DataTableSpec spec = null;
    if (dbSpec != null) {
        spec = dbSpec.getDataTableSpec();
    }
    super.loadSettingsFrom(settings, new PortObjectSpec[] { spec });
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec)

Example 12 with DatabasePortObjectSpec

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

the class DBAutoBinnerNodeModel method createDatabasePortObject.

private DatabasePortObject createDatabasePortObject(final DatabasePortObjectSpec inSpec, DatabaseQueryConnectionSettings connectionSettings, final PMMLPortObject pmmlPortObject) throws InvalidSettingsException {
    final StatementManipulator statementManipulator = connectionSettings.getUtility().getStatementManipulator();
    String newQuery = createQuery(connectionSettings.getQuery(), statementManipulator, inSpec.getDataTableSpec(), pmmlPortObject);
    connectionSettings = createDBQueryConnection(inSpec, newQuery);
    DatabaseQueryConnectionSettings querySettings = new DatabaseQueryConnectionSettings(connectionSettings, newQuery);
    DatabaseReaderConnection conn = new DatabaseReaderConnection(querySettings);
    DatabasePortObjectSpec databasePortObjectSpec = null;
    try {
        databasePortObjectSpec = new DatabasePortObjectSpec(conn.getDataTableSpec(getCredentialsProvider()), connectionSettings.createConnectionModel());
    } catch (SQLException e) {
        throw new InvalidSettingsException("Failure during query generation. Error: " + e.getMessage());
    }
    DatabasePortObject databasePortObject = new DatabasePortObject(databasePortObjectSpec);
    return databasePortObject;
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DatabaseReaderConnection(org.knime.core.node.port.database.DatabaseReaderConnection) SQLException(java.sql.SQLException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) StatementManipulator(org.knime.core.node.port.database.StatementManipulator)

Example 13 with DatabasePortObjectSpec

use of org.knime.core.node.port.database.DatabasePortObjectSpec 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 14 with DatabasePortObjectSpec

use of org.knime.core.node.port.database.DatabasePortObjectSpec 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 15 with DatabasePortObjectSpec

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

the class DBNumericBinnerNodeDialog method loadSettingsFrom.

@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) specs[0];
    DataTableSpec spec = null;
    if (dbSpec != null) {
        spec = dbSpec.getDataTableSpec();
    }
    super.loadSettingsFrom(settings, new PortObjectSpec[] { spec });
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec)

Aggregations

DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)46 DataTableSpec (org.knime.core.data.DataTableSpec)36 DatabaseQueryConnectionSettings (org.knime.core.node.port.database.DatabaseQueryConnectionSettings)33 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)29 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)14 DatabasePortObject (org.knime.core.node.port.database.DatabasePortObject)13 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)12 DBReader (org.knime.core.node.port.database.reader.DBReader)12 PortObject (org.knime.core.node.port.PortObject)10 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)9 StatementManipulator (org.knime.core.node.port.database.StatementManipulator)8 SQLException (java.sql.SQLException)7 NotConfigurableException (org.knime.core.node.NotConfigurableException)5 DatabaseConnectionSettings (org.knime.core.node.port.database.DatabaseConnectionSettings)3 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)3 GridBagConstraints (java.awt.GridBagConstraints)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 DBBinnerMaps (org.knime.base.node.io.database.binning.DBBinnerMaps)2 DBAggregationFunctionProvider (org.knime.base.node.io.database.groupby.dialog.DBAggregationFunctionProvider)2