use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.
the class MissingValueColumnFilterNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
DataColumnSpecFilterConfiguration conf = createDCSFilterConfiguration();
conf.loadConfigurationInModel(settings);
SettingsModelDouble percentage = createSettingsModelNumber();
percentage.validateSettings(settings);
}
use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.
the class DBUpdateDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
DataTableSpec tableSpec = (DataTableSpec) specs[0];
// load login setting
m_loginPanel.loadSettingsFrom(settings, specs, getCredentialsProvider());
// load table name
m_tableName.setText(settings.getString(DBUpdateNodeModel.KEY_TABLE_NAME, ""));
// load SET column panel
DataColumnSpecFilterConfiguration configSet = new DataColumnSpecFilterConfiguration(DBUpdateNodeModel.KEY_SET_FILTER_COLUMN);
configSet.loadConfigurationInDialog(settings, tableSpec);
m_columnsInSetClause.loadConfiguration(configSet, tableSpec);
// load WHERE column panel
DataColumnSpecFilterConfiguration configWhere = new DataColumnSpecFilterConfiguration(DBUpdateNodeModel.KEY_WHERE_FILTER_COLUMN);
configWhere.loadConfigurationInDialog(settings, tableSpec);
m_columnsInWhereClause.loadConfiguration(configWhere, tableSpec);
// load batch size
final int batchSize = settings.getInt(DBUpdateNodeModel.KEY_BATCH_SIZE, 1);
m_batchSize.setText(Integer.toString(batchSize));
if ((specs.length > 1) && (specs[1] instanceof DatabaseConnectionPortObjectSpec)) {
m_loginPanel.setVisible(false);
} else {
m_loginPanel.setVisible(true);
}
}
use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.
the class DBUpdateNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
// validate login settings
new DatabaseConnectionSettings(settings, getCredentialsProvider());
// validate table name
final String tableName = settings.getString(KEY_TABLE_NAME);
if (tableName == null || tableName.trim().isEmpty()) {
throw new InvalidSettingsException("Configure node and enter a valid table name.");
}
// validate SET columns
final DataColumnSpecFilterConfiguration confSET = new DataColumnSpecFilterConfiguration(KEY_SET_FILTER_COLUMN);
confSET.loadConfigurationInModel(settings);
// validate WHERE columns
final DataColumnSpecFilterConfiguration confWHERE = new DataColumnSpecFilterConfiguration(KEY_WHERE_FILTER_COLUMN);
confWHERE.loadConfigurationInModel(settings);
// validate batch size
final int batchSize = settings.getInt(KEY_BATCH_SIZE);
if (batchSize <= 0) {
throw new InvalidSettingsException("Batch size must be greater than 0, is " + batchSize);
}
}
use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.
the class FeatureSelectionLoopStartNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
for (int i = 1; i < inSpecs.length; i++) {
if (!inSpecs[0].equalStructure(inSpecs[i])) {
throw new InvalidSettingsException("All input tables must have the same structure");
}
}
final DataColumnSpecFilterConfiguration filterConfig = m_settings.getStaticColumnsFilterConfiguration();
final FilterResult filterResult = filterConfig.applyTo(inSpecs[0]);
final String[] constantColumns;
// check if no feature columns are selected (e.g. before the dialog is opened the first time)
if (filterResult.getIncludes().length == 0) {
throw new InvalidSettingsException("No feature columns selected. Please specify the feature columns in the dialog.");
}
if (filterResult.getExcludes().length == 0) {
setWarningMessage("No constant columns selected. Are you sure you don't need a target column?");
}
constantColumns = filterResult.getExcludes();
for (String colName : constantColumns) {
if (!inSpecs[0].containsName(colName)) {
throw new InvalidSettingsException("The specified constant column \"" + colName + "\" is not contained in the input tables.");
}
}
if (m_iteration == 0) {
// get feature selector
try {
final AbstractColumnHandler columnHandler = new DefaultColumnHandler(Arrays.asList(constantColumns), inSpecs[0]);
final FeatureSelectionStrategy strategy = FeatureSelectionStrategies.createFeatureSelectionStrategy(m_settings.getSelectionStrategy(), m_settings.getNrFeaturesThreshold(), columnHandler.getAvailableFeatures());
m_featureSelector = new FeatureSelector(strategy, columnHandler);
// push max iterations flowvariable
m_maxIterations = m_featureSelector.getNumberOfIterations();
pushFlowVariableInt("maxIterations", m_maxIterations);
} catch (Throwable t) {
throw new InvalidSettingsException("Exception during feature selector setup", t);
}
}
// push flowvariables
pushFlowVariableInt("currentIteration", m_iteration);
pushFlowVariableString("currentFeature", m_featureSelector.getCurrentFeatureName());
final DataTableSpec outSpec = m_featureSelector.getOutSpec(inSpecs[0]);
final DataTableSpec[] outSpecs = new DataTableSpec[inSpecs.length];
Arrays.fill(outSpecs, outSpec);
return outSpecs;
}
use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.
the class DBDeleteRowsDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
DataTableSpec tableSpec = (DataTableSpec) specs[0];
// load login setting
m_loginPanel.loadSettingsFrom(settings, specs, getCredentialsProvider());
// load table name
m_tableName.setText(settings.getString(DBDeleteRowsNodeModel.KEY_TABLE_NAME, ""));
// load WHERE column panel
DataColumnSpecFilterConfiguration configWhere = new DataColumnSpecFilterConfiguration(DBDeleteRowsNodeModel.KEY_WHERE_FILTER_COLUMN);
configWhere.loadConfigurationInDialog(settings, tableSpec);
m_columnsInWhereClause.loadConfiguration(configWhere, tableSpec);
// load batch size
final int batchSize = settings.getInt(DBDeleteRowsNodeModel.KEY_BATCH_SIZE, 1);
m_batchSize.setText(Integer.toString(batchSize));
if ((specs.length > 1) && (specs[1] instanceof DatabaseConnectionPortObjectSpec)) {
m_loginPanel.setVisible(false);
} else {
m_loginPanel.setVisible(true);
}
}
Aggregations