Search in sources :

Example 11 with DatabaseUtility

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

the class ParameterizedDBQueryPanel method loadSettingsFrom.

void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs, final Collection<FlowVariable> flowVariables) {
    try {
        m_appendInputColsModel.loadSettingsFrom(settings);
        m_includeEmptyResultsModel.loadSettingsFrom(settings);
        m_retainAllColumnsModel.loadSettingsFrom(settings);
        m_failIfExceptionModel.loadSettingsFrom(settings);
        m_editor.setText(settings.getString(ParameterizedDBQueryNodeModel.CFG_SQL_STATEMENT, ParameterizedDBQueryNodeModel.getDefaultSQLStatement()));
    } catch (InvalidSettingsException ex) {
        m_appendInputColsModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_APPEND_INPUT_COL);
        m_includeEmptyResultsModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_INCLUDE_EMPTY_RESULTS);
        m_retainAllColumnsModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_RETAIN_ALL_COLUMNS);
        m_failIfExceptionModel.setBooleanValue(ParameterizedDBQueryNodeModel.DEF_FAIL_IF_EXCEPTION);
    }
    updateKnimeColumns((DataTableSpec) specs[0]);
    updateDBColumns(((DatabasePortObjectSpec) specs[1]).getDataTableSpec());
    updateFlowVariables(flowVariables.toArray(new FlowVariable[flowVariables.size()]));
    if (specs[1] != null && specs[1] instanceof DatabasePortObjectSpec) {
        final DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) specs[1];
        final DatabaseUtility dbUtility = DatabaseUtility.getUtility(dbSpec.getDatabaseIdentifier());
        m_statementManipulator = dbUtility.getStatementManipulator();
    }
}
Also used : DatabaseUtility(org.knime.core.node.port.database.DatabaseUtility) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Aggregations

DatabaseUtility (org.knime.core.node.port.database.DatabaseUtility)11 DBAggregationFunctionProvider (org.knime.base.node.io.database.groupby.dialog.DBAggregationFunctionProvider)6 DBAggregationFunction (org.knime.core.node.port.database.aggregation.DBAggregationFunction)6 ArrayList (java.util.ArrayList)5 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)5 DataType (org.knime.core.data.DataType)4 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)4 SQLException (java.sql.SQLException)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)3 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)3 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)3 DataTableSpec (org.knime.core.data.DataTableSpec)2 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)2 DatabaseQueryConnectionSettings (org.knime.core.node.port.database.DatabaseQueryConnectionSettings)2 File (java.io.File)1 IOException (java.io.IOException)1 ExceptionUtils (org.apache.commons.lang.exception.ExceptionUtils)1 DBColumnAggregationFunctionRow (org.knime.base.node.io.database.groupby.dialog.column.DBColumnAggregationFunctionRow)1 ColumnNamePolicy (org.knime.base.node.preproc.groupby.ColumnNamePolicy)1 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)1