use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelCalendar method loadSettingsForDialog.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
try {
Config internals = settings.getConfig(m_key);
loadFromInternals(internals);
} catch (InvalidSettingsException ise) {
// load current time
m_value = Calendar.getInstance(DateAndTimeCell.UTC_TIMEZONE);
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelCalendar method loadSettingsForModel.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
Config internals = settings.getConfig(m_key);
loadFromInternals(internals);
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelCalendar method saveSettings.
private void saveSettings(final NodeSettingsWO settings) {
Config internals = settings.addConfig(m_key);
// time (as long)
internals.addLong(KEY_TIME, m_value.getTimeInMillis());
internals.addBoolean(KEY_USE_DATE, m_useDate);
internals.addBoolean(KEY_USE_TIME, m_useTime);
internals.addBoolean(KEY_USE_MILLIS, m_useMillis);
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class VirtualParallelizedChunkPortObjectInNodeFactory method loadPortTypeList.
/**
* @param config
* @return TODO
* @throws InvalidSettingsException
*/
static PortType[] loadPortTypeList(final ConfigRO config) throws InvalidSettingsException {
Set<String> keySet = config.keySet();
PortType[] outTypes = new PortType[keySet.size()];
for (String s : keySet) {
ConfigRO portConfig = config.getConfig(s);
int index = portConfig.getInt("index");
CheckUtils.checkSetting(index >= 0 && index < outTypes.length, "Invalid port index must be in [0, %d]: %d", keySet.size() - 1, index);
Config portTypeConfig = portConfig.getConfig("type");
PortType type = PortType.load(portTypeConfig);
outTypes[index] = type;
}
int invalidIndex = Arrays.asList(outTypes).indexOf(null);
if (invalidIndex >= 0) {
throw new InvalidSettingsException("Unassigned port type at index " + invalidIndex);
}
return outTypes;
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class AttributeModel method loadModel.
/**
* @param config the <code>Config</code> object to read from
* @return the attribute model for the given <code>Config</code> object
* @throws InvalidSettingsException if the settings are invalid
*/
static AttributeModel loadModel(final Config config) throws InvalidSettingsException {
final String attrName = config.getString(ATTRIBUTE_NAME);
final String modelType = config.getString(MODEL_TYPE);
final boolean skipMissing = config.getBoolean(SKIP_MISSING_VALUES);
final int noOfMissingVals = config.getInt(NO_OF_MISSING_VALUES);
final String invalidCause = config.getString(INVALID_CAUSE);
final Config modelConfig = config.getConfig(MODEL_DATA_SECTION);
final AttributeModel model;
if (NominalAttributeModel.MODEL_TYPE.equals(modelType)) {
model = new NominalAttributeModel(attrName, noOfMissingVals, skipMissing, modelConfig);
} else if (NumericalAttributeModel.MODEL_TYPE.equals(modelType)) {
model = new NumericalAttributeModel(attrName, skipMissing, noOfMissingVals, modelConfig);
} else if (ClassAttributeModel.MODEL_TYPE.equals(modelType)) {
model = new ClassAttributeModel(attrName, noOfMissingVals, skipMissing, modelConfig);
} else if (BitVectorAttributeModel.MODEL_TYPE.equals(modelType)) {
model = new BitVectorAttributeModel(attrName, skipMissing, noOfMissingVals, modelConfig);
} else {
throw new InvalidSettingsException("Invalid model type: " + modelType);
}
model.setInvalidCause(invalidCause);
return model;
}
Aggregations