use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class BinByDictionaryConfiguration method loadSettingsDialog.
/**
* Load settings in dialog.
* @param settings To load from.
* @param ins Input specs for initialization.
* @throws NotConfigurableException if no appropriate columns in input.
*/
void loadSettingsDialog(final NodeSettingsRO settings, final DataTableSpec[] ins) throws NotConfigurableException {
String valueColPort0 = null;
String lowerBoundColPort1 = null;
String upperBoundColPort1 = null;
String labelColumnPort1 = null;
// find default values in the table, try be smart and favor
// date columns over int over double over ... etc.
@SuppressWarnings("unchecked") Class<? extends DataValue>[] typeCandidates = new Class[] { DateAndTimeValue.class, IntValue.class, DoubleValue.class, LongValue.class, BoundedValue.class, DataValue.class };
for (Class<? extends DataValue> valueClass : typeCandidates) {
for (DataColumnSpec c : ins[0]) {
if (c.getType().isCompatible(valueClass)) {
valueColPort0 = c.getName();
break;
}
}
if (valueColPort0 == null) {
// no such type in input, continue with next one
continue;
}
for (int i = ins[1].getNumColumns(); --i >= 0; ) {
DataColumnSpec c = ins[1].getColumnSpec(i);
if (c.getType().isCompatible(valueClass)) {
if (upperBoundColPort1 == null) {
upperBoundColPort1 = c.getName();
} else if (lowerBoundColPort1 == null) {
lowerBoundColPort1 = c.getName();
break;
}
}
}
if (upperBoundColPort1 != null) {
// and accept these columns as default
break;
}
}
if (valueColPort0 == null) {
throw new NotConfigurableException("No value column in first input");
}
if (upperBoundColPort1 == null) {
throw new NotConfigurableException("No reasonable column in second input");
}
m_valueColumnPort0 = settings.getString("valueColumnPort0", valueColPort0);
m_lowerBoundColumnPort1 = settings.getString("lowerBoundColumnPort1", lowerBoundColPort1);
m_lowerBoundInclusive = settings.getBoolean("lowerBoundInclusive", false);
m_upperBoundColumnPort1 = settings.getString("upperBoundColumnPort1", upperBoundColPort1);
m_upperBoundInclusive = settings.getBoolean("upperBoundInclusive", true);
for (DataColumnSpec c : ins[1]) {
if (labelColumnPort1 == null) {
labelColumnPort1 = c.getName();
} else if (c.getType().isCompatible(NominalValue.class)) {
labelColumnPort1 = c.getName();
}
}
m_labelColumnPort1 = settings.getString("labelColumnPort1", labelColumnPort1);
if (!ins[0].containsName(m_valueColumnPort0)) {
m_valueColumnPort0 = valueColPort0;
}
if (!ins[1].containsName(m_upperBoundColumnPort1)) {
m_upperBoundColumnPort1 = upperBoundColPort1;
m_lowerBoundColumnPort1 = lowerBoundColPort1;
}
if (!ins[1].containsName(m_labelColumnPort1)) {
m_labelColumnPort1 = labelColumnPort1;
}
m_failIfNoRuleMatches = settings.getBoolean("failIfNoRuleMatches", false);
m_useBinarySearch = settings.getBoolean("useBinarySearch", false);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class MissingValueHandlerNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
MVSettings mvSettings = createEmptySettings();
m_specs = specs;
DataTableSpec spec = (DataTableSpec) specs[0];
StringBuffer warning = new StringBuffer();
if (spec.getNumColumns() == 0) {
throw new NotConfigurableException("There are no columns for missing value replacement available.");
}
m_searchableListModifier = m_searchableListPanel.update(spec);
try {
mvSettings.loadSettings(settings, true);
} catch (Exception e) {
if (warning.length() > 0) {
warning.append("\n");
}
warning.append("The settings are malformed and had to be reset");
mvSettings = new MVSettings(spec);
}
m_warnings.setText(warning.toString());
m_types = new LinkedHashMap<DataType, MissingValueHandlerFactorySelectionPanel>();
for (int i = 0; i < spec.getNumColumns(); i++) {
m_types.put(spec.getColumnSpec(i).getType(), null);
}
m_individualsPanel.removeAll();
for (MVColumnSettings colSetting : mvSettings.getColumnSettings()) {
ColumnHandlingFactorySelectionPanel p = new ColumnHandlingFactorySelectionPanel(colSetting, specs, 0, getHandlerFactoryManager());
addToIndividualPanel(p);
}
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
m_typeSettingsPanel.removeAll();
for (DataType type : m_types.keySet()) {
gbc.gridx = 0;
gbc.ipadx = 10;
JLabel l = new JLabel(type.toPrettyString());
m_typeSettingsPanel.add(l, gbc);
gbc.gridx = 1;
gbc.ipadx = 0;
MVIndividualSettings s = mvSettings.getSettingsForDataType(type);
// but check anyways and fall back to do nothing factory
if (s == null) {
s = new MVIndividualSettings(getHandlerFactoryManager());
}
MissingValueHandlerFactorySelectionPanel p = new MissingValueHandlerFactorySelectionPanel(type, s, getHandlerFactoryManager(), specs);
p.setBorder(BorderFactory.createBevelBorder(1));
p.addPropertyChangeListener(new FactoryChangedListener());
m_typeSettingsPanel.add(p, gbc);
m_types.put(type, p);
gbc.gridy++;
}
m_scrollPane.setPreferredSize(new Dimension(m_defaultsPanel.getPreferredSize().width + 20, 500));
updatePMMLLabelColor();
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class RenameNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
DataTableSpec spec = specs[0];
if (spec.getNumColumns() == 0) {
throw new NotConfigurableException("No columns at input.");
}
m_orgTableSpec = specs[0];
m_columnToSettings.clear();
m_errornousColNames.clear();
m_individualsPanel.removeAll();
m_searchableListModifier = m_searchableListPanel.update(spec);
NodeSettingsRO subSettings;
try {
// this node settings object must contain only entry of type
// NodeSetting
subSettings = settings.getNodeSettings(RenameNodeModel.CFG_SUB_CONFIG);
} catch (InvalidSettingsException ise) {
subSettings = null;
}
if (subSettings != null) {
// process settings for individual column
for (String id : subSettings) {
NodeSettingsRO idSettings;
String nameForSettings;
try {
// idSettigs address the settings for one particular column
idSettings = subSettings.getNodeSettings(id);
// the name of the column - must match
nameForSettings = idSettings.getString(RenameColumnSetting.CFG_OLD_COLNAME);
} catch (InvalidSettingsException is) {
continue;
}
final DataColumnSpec orgSpec = m_orgTableSpec.getColumnSpec(nameForSettings);
final RenameColumnSetting renameColumnSetting = orgSpec == null ? new RenameColumnSetting(nameForSettings) : new RenameColumnSetting(orgSpec);
renameColumnSetting.loadSettingsFrom(idSettings);
if (orgSpec == null) {
DataColumnSpec invalidSpec = createInvalidSpec(nameForSettings);
m_searchableListModifier.addAdditionalColumn(invalidSpec);
m_columnToSettings.put(invalidSpec, renameColumnSetting);
} else {
m_columnToSettings.put(orgSpec, renameColumnSetting);
}
}
}
// add for each setting a panel in the individual panel
for (Map.Entry<DataColumnSpec, RenameColumnSetting> entries : m_columnToSettings.entrySet()) {
addToIndividualPanel(new RenameColumnPanel(entries.getValue(), entries.getKey(), m_hideColumnType));
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class GroupByNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
assert (specs.length == 1);
final DataTableSpec spec = (DataTableSpec) specs[0];
try {
m_maxUniqueValues.loadSettingsFrom(settings);
m_enableHilite.loadSettingsFrom(settings);
m_columnNamePolicy.loadSettingsFrom(settings);
} catch (final InvalidSettingsException e) {
throw new NotConfigurableException(e.getMessage());
}
try {
// this option was introduced in Knime 2.0
m_aggrColPanel.loadSettingsFrom(settings, spec);
} catch (final InvalidSettingsException e) {
final List<ColumnAggregator> columnMethods = GroupByNodeModel.compGetColumnMethods(spec, m_groupByCols.getIncludeList(), settings);
m_aggrColPanel.initialize(spec, columnMethods);
}
try {
m_patternAggrPanel.loadSettingsFrom(settings, spec);
m_dataTypeAggrPanel.loadSettingsFrom(settings, spec);
} catch (InvalidSettingsException e) {
// introduced in 2.11
}
try {
// this option was introduced in Knime 2.0.3+
m_retainOrder.loadSettingsFrom(settings);
} catch (final InvalidSettingsException e) {
m_retainOrder.setBooleanValue(false);
}
try {
// this option was introduced in Knime 2.1.2+
m_inMemory.loadSettingsFrom(settings);
} catch (final InvalidSettingsException e) {
m_inMemory.setBooleanValue(false);
}
// this option was introduced in Knime 2.4+
try {
m_valueDelimiter.loadSettingsFrom(settings);
} catch (final InvalidSettingsException e) {
m_valueDelimiter.setStringValue(GlobalSettings.STANDARD_DELIMITER);
}
m_groupCol.loadSettingsFrom(settings, new DataTableSpec[] { spec });
columnsChanged();
try {
m_version.loadSettingsFrom(settings);
} catch (final InvalidSettingsException e) {
throw new NotConfigurableException(e.getMessage());
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class DomainNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
DataTableSpec spec = specs[0];
if (spec.getNumColumns() == 0) {
throw new NotConfigurableException("No data at input.");
}
DataColumnSpecFilterConfiguration possConfig = DomainNodeModel.createDCSFilterConfigurationPossVals();
DataColumnSpecFilterConfiguration minMaxConfig = DomainNodeModel.createDCSFilterConfigurationMinMax();
possConfig.loadConfigurationInDialog(settings, spec);
minMaxConfig.loadConfigurationInDialog(settings, spec);
m_filterPanelPossValues.loadConfiguration(possConfig, spec);
m_filterPanelMinMax.loadConfiguration(minMaxConfig, spec);
int maxPossValues = settings.getInt(DomainNodeModel.CFG_MAX_POSS_VALUES, DataContainer.MAX_POSSIBLE_VALUES);
if ((maxPossValues >= 0) != m_maxValuesChecker.isSelected()) {
m_maxValuesChecker.doClick();
}
m_maxValuesSpinner.setValue(maxPossValues >= 0 ? maxPossValues : DataContainer.MAX_POSSIBLE_VALUES);
boolean possValRetainUnselected = settings.getBoolean(DomainNodeModel.CFG_POSSVAL_RETAIN_UNSELECTED, true);
boolean minMaxRetainUnselected = settings.getBoolean(DomainNodeModel.CFG_MIN_MAX_RETAIN_UNSELECTED, true);
if (possValRetainUnselected) {
m_possValUnselectedRetainButton.doClick();
} else {
m_possValUnselectedDropButton.doClick();
}
if (minMaxRetainUnselected) {
m_minMaxUnselectedRetainButton.doClick();
} else {
m_minMaxUnselectedDropButton.doClick();
}
}
Aggregations