Search in sources :

Example 6 with SettingsModelFilterString

use of org.knime.core.node.defaultnodesettings.SettingsModelFilterString in project knime-core by knime.

the class CAIMDiscretizationNodeModel method createModelSpec.

/**
 * Creates a table spec including the columns used. In order to specify
 * included names and types a data table spec is created that contains the
 * included columns.
 *
 * @param cols the names of the columns to include.
 * @param inSpec the input spec the specified columns are taken from and
 *            included into the result.
 * @return a table spec containing the columns with the specified names
 * @throws InvalidSettingsException if a name is specified that is not
 *             included in the input spec.
 */
private DataTableSpec createModelSpec(final SettingsModelFilterString cols, final DataTableSpec inSpec) throws InvalidSettingsException {
    DataColumnSpec[] colSpecs = new DataColumnSpec[cols.getIncludeList().size()];
    int c = 0;
    for (String colName : cols.getIncludeList()) {
        int colIdx = inSpec.findColumnIndex(colName);
        if (colIdx < 0) {
            throw new InvalidSettingsException("Specified column name (" + colName + ") not in input table.");
        }
        colSpecs[c] = inSpec.getColumnSpec(colIdx);
        c++;
    }
    return new DataTableSpec(colSpecs);
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 7 with SettingsModelFilterString

use of org.knime.core.node.defaultnodesettings.SettingsModelFilterString in project knime-core by knime.

the class PMCCNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    // FIX bug 5040: potential problem with clone settings method when in-/exclude list contain same elements
    SettingsModelFilterString clone = createNewSettingsObject();
    clone.loadSettingsFrom(settings);
    if (clone.getIncludeList().isEmpty()) {
        throw new InvalidSettingsException("No column selected");
    }
    m_maxPossValueCountModel.validateSettings(settings);
}
Also used : SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Aggregations

InvalidSettingsException (org.knime.core.node.InvalidSettingsException)7 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)7 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)4 DataColumnSpec (org.knime.core.data.DataColumnSpec)2 DataTableSpec (org.knime.core.data.DataTableSpec)2 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1 ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)1 PatternAggregator (org.knime.base.data.aggregation.dialogutil.pattern.PatternAggregator)1 DataTypeAggregator (org.knime.base.data.aggregation.dialogutil.type.DataTypeAggregator)1