Search in sources :

Example 31 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class EqualSizeSamplingConfiguration method loadConfigurationInDialog.

void loadConfigurationInDialog(final NodeSettingsRO settings, final DataTableSpec spec) throws NotConfigurableException {
    String defClassColumn = null;
    for (DataColumnSpec c : spec) {
        if (c.getType().isCompatible(NominalValue.class)) {
            defClassColumn = c.getName();
        }
    }
    if (defClassColumn == null) {
        throw new NotConfigurableException("No nominal attribute column in input");
    }
    m_classColumn = settings.getString("classColumn", defClassColumn);
    String seedS = settings.getString("seed", null);
    if (seedS == null) {
        m_seed = null;
    } else {
        try {
            m_seed = Long.parseLong(seedS);
        } catch (NumberFormatException nfe) {
            m_seed = null;
        }
    }
    String sMethod = settings.getString("samplingMethod", SamplingMethod.Exact.name());
    try {
        m_samplingMethod = SamplingMethod.valueOf(sMethod);
    } catch (Exception e) {
        m_samplingMethod = SamplingMethod.Exact;
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataColumnSpec(org.knime.core.data.DataColumnSpec) NotConfigurableException(org.knime.core.node.NotConfigurableException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 32 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class DataColumnSpecFilterNodeDialogPane method loadSettingsFrom.

/**
 * Calls the update method of the underlying filter panel.
 * @param settings the node settings to read from
 * @param specs the input specs
 * @throws NotConfigurableException if no columns are available for
 *             filtering
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    final DataTableSpec spec = specs[0];
    if (spec == null || spec.getNumColumns() == 0) {
        throw new NotConfigurableException("No columns available for " + "selection.");
    }
    DataColumnSpecFilterConfiguration config = DataColumnSpecFilterNodeModel.createDCSFilterConfiguration();
    config.loadConfigurationInDialog(settings, specs[0]);
    m_filterPanel.loadConfiguration(config, specs[0]);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)

Example 33 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class EqualSizeSamplingNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
    if (m_configuration == null) {
        EqualSizeSamplingConfiguration c = new EqualSizeSamplingConfiguration();
        try {
            c.loadConfigurationInDialog(new NodeSettings("empty"), inSpecs[0]);
        } catch (NotConfigurableException e) {
            throw new InvalidSettingsException("Can't auto-guess settings: " + "No nominal column in input");
        }
        m_configuration = c;
        setWarningMessage("Auto-guessing \"" + c.getClassColumn() + "\" as selected nominal class column");
    }
    String classColumn = m_configuration.getClassColumn();
    DataColumnSpec col = inSpecs[0].getColumnSpec(classColumn);
    if (col == null) {
        throw new InvalidSettingsException("No column \"" + classColumn + "\" in input data");
    }
    if (!col.getType().isCompatible(NominalValue.class)) {
        throw new InvalidSettingsException("Class column \"" + classColumn + "\" is not a nominal attribute");
    }
    return new DataTableSpec[] { inSpecs[0] };
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) NodeSettings(org.knime.core.node.NodeSettings) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NominalValue(org.knime.core.data.NominalValue)

Example 34 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class CorrelationFilterNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    m_model = (PMCCPortObjectAndSpec) specs[0];
    DataTableSpec spec = getTableSpec(specs);
    if (m_model == null || spec == null) {
        throw new NotConfigurableException("No input available");
    }
    // check if all columns in the model are also present in the spec
    HashSet<String> allColsInModel = new HashSet<>(Arrays.asList(m_model.getColNames()));
    double d = settings.getDouble(CorrelationFilterNodeModel.CFG_THRESHOLD, 1.0);
    m_textField.setValue(d);
    DefaultListModel m = (DefaultListModel) m_list.getModel();
    m.removeAllElements();
    int totalCount = 0;
    for (DataColumnSpec s : spec) {
        if (s.getType().isCompatible(NominalValue.class) || s.getType().isCompatible(DoubleValue.class)) {
            if (allColsInModel.remove(s.getName())) {
                totalCount++;
                m.addElement(s);
            }
        }
    }
    if (!allColsInModel.isEmpty()) {
        throw new NotConfigurableException("Some columns in the model are " + "not contained in the input table or incompatible: " + allColsInModel.iterator().next());
    }
    m_lastCommittedValue = -1.0;
    if (m_model.hasData()) {
        m_errorLabel.setText(" ");
        m_calcButton.setEnabled(true);
    } else {
        m_errorLabel.setText("No correlation in input available");
        m_calcButton.setEnabled(false);
    }
    setLabels(-1, totalCount);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) DoubleValue(org.knime.core.data.DoubleValue) NominalValue(org.knime.core.data.NominalValue) DefaultListModel(javax.swing.DefaultListModel) HashSet(java.util.HashSet)

Example 35 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class DBPivotNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    if (specs == null || specs.length < 1 || specs[0] == null) {
        throw new NotConfigurableException("No input connection found.");
    }
    final DatabasePortObjectSpec dbspec = (DatabasePortObjectSpec) specs[0];
    final DataTableSpec spec = dbspec.getDataTableSpec();
    try {
        final DatabaseQueryConnectionSettings connectionSettings = dbspec.getConnectionSettings(null);
        m_columnNamePolicy.loadSettingsFrom(settings);
        final String dbIdentifier = connectionSettings.getDatabaseIdentifier();
        m_aggregationPanel.loadSettingsFrom(settings, dbIdentifier, spec);
        final DBAggregationFunctionProvider functionProvider = new DBAggregationFunctionProvider(connectionSettings.getUtility());
        m_descriptionTab.removeAll();
        final GridBagConstraints c = new GridBagConstraints();
        c.anchor = GridBagConstraints.CENTER;
        c.fill = GridBagConstraints.BOTH;
        c.weightx = 1;
        c.weighty = 1;
        m_descriptionTab.add(functionProvider.getDescriptionPane(), c);
    } catch (final InvalidSettingsException e) {
        throw new NotConfigurableException(e.getMessage());
    }
    m_groupCol.loadSettingsFrom(settings, new DataTableSpec[] { spec });
    m_pivotCol.loadSettingsFrom(settings, new DataTableSpec[] { spec });
    columnsChanged();
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) GridBagConstraints(java.awt.GridBagConstraints) DBAggregationFunctionProvider(org.knime.base.node.io.database.groupby.dialog.DBAggregationFunctionProvider) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Aggregations

NotConfigurableException (org.knime.core.node.NotConfigurableException)79 DataColumnSpec (org.knime.core.data.DataColumnSpec)35 DataTableSpec (org.knime.core.data.DataTableSpec)35 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)31 DataColumnSpecFilterConfiguration (org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)8 HashSet (java.util.HashSet)6 ArrayList (java.util.ArrayList)5 DataType (org.knime.core.data.DataType)5 NominalValue (org.knime.core.data.NominalValue)5 DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)5 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)4 Container (java.awt.Container)3 Frame (java.awt.Frame)3 GridBagConstraints (java.awt.GridBagConstraints)3 ActionListener (java.awt.event.ActionListener)3 ItemListener (java.awt.event.ItemListener)3 AbstractButton (javax.swing.AbstractButton)3 DefaultListModel (javax.swing.DefaultListModel)3 LinkedHashMap (java.util.LinkedHashMap)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2