Search in sources :

Example 6 with Config

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);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Config(org.knime.core.node.config.Config)

Example 7 with Config

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);
}
Also used : Config(org.knime.core.node.config.Config)

Example 8 with Config

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);
}
Also used : Config(org.knime.core.node.config.Config)

Example 9 with Config

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;
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Config(org.knime.core.node.config.Config) ConfigRO(org.knime.core.node.config.ConfigRO) PortType(org.knime.core.node.port.PortType)

Example 10 with Config

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;
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Config(org.knime.core.node.config.Config)

Aggregations

Config (org.knime.core.node.config.Config)84 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)25 Color (java.awt.Color)10 File (java.io.File)10 FileOutputStream (java.io.FileOutputStream)8 NodeSettings (org.knime.core.node.NodeSettings)8 ArrayList (java.util.ArrayList)7 DataColumnSpec (org.knime.core.data.DataColumnSpec)7 ConfigRO (org.knime.core.node.config.ConfigRO)7 HashMap (java.util.HashMap)6 GZIPOutputStream (java.util.zip.GZIPOutputStream)6 LinkedHashMap (java.util.LinkedHashMap)5 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)5 DataTableSpec (org.knime.core.data.DataTableSpec)5 SimpleStreamableOperatorInternals (org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)5 FileInputStream (java.io.FileInputStream)4 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 GZIPInputStream (java.util.zip.GZIPInputStream)4 DataCell (org.knime.core.data.DataCell)4