Search in sources :

Example 61 with NodeSettings

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

the class MVIndividualSettings method loadSettings.

/**
 * Loads settings for a column.
 * @param settings the settings
 * @param repair if true, missing factories are replaced by the do nothing factory, else an exception is thrown
 * @return if repair is false, any warning message that occurred, else null
 * @throws InvalidSettingsException when the settings are not properly structured
 *          or repair is false and a factory is missing
 */
public String loadSettings(final NodeSettingsRO settings, final boolean repair) throws InvalidSettingsException {
    String factID = settings.getString(FACTORY_ID_CFG);
    String warning = null;
    m_factory = m_handlerFactoryManager.getFactoryByID(factID);
    if (m_factory == null) {
        warning = "The factory " + factID + " is not a registered extension but is chosen in the settings.";
        if (!repair) {
            throw new InvalidSettingsException(warning);
        }
        m_factory = m_handlerFactoryManager.getDoNothingHandlerFactory();
    }
    if (settings.containsKey(SETTINGS_CFG)) {
        m_settings = new NodeSettings("");
        settings.getNodeSettings(SETTINGS_CFG).copyTo(this.m_settings);
    }
    return warning;
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 62 with NodeSettings

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

the class ReadContextPropertyNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    if (m_config == null) {
        m_config = new ReadContextPropertyConfiguration();
        m_config.loadSettingsNoFail(new NodeSettings("empty"));
        setWarningMessage("Auto-configuration: " + "extracting all available properties");
    }
    Result result = m_config.createResult();
    String message = result.getWarningMessage();
    if (message != null) {
        setWarningMessage(message);
    }
    pushFlowVariables(result);
    return new PortObjectSpec[] { FlowVariablePortObjectSpec.INSTANCE };
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) Result(org.knime.base.node.io.extractcontextprop.ReadContextPropertyConfiguration.Result)

Example 63 with NodeSettings

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

the class DBReaderNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
    final DataTableSpec lastSpec = getLastSpec();
    assert (lastSpec != null) : "Spec must not be null!";
    NodeSettings specSett = new NodeSettings("spec.xml");
    lastSpec.save(specSett);
    File specFile = new File(nodeInternDir, "spec.xml");
    specSett.saveToXML(new FileOutputStream(specFile));
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) NodeSettings(org.knime.core.node.NodeSettings) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Example 64 with NodeSettings

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

the class DBGroupByNodeModel2 method loadValidatedSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
    super.loadValidatedSettingsFrom(settings);
    m_addCountStar.loadSettingsFrom(settings);
    m_countStarColName.loadSettingsFrom(settings);
    m_groupByCols.loadSettingsFrom(settings);
    m_columnNamePolicy.loadSettingsFrom(settings);
    m_settings = new NodeSettings("copy");
    settings.copyTo(m_settings);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings)

Example 65 with NodeSettings

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

the class Statistics3NodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    NodeSettings sett = new NodeSettings("statistic.xml.gz");
    getStatTable().save(sett);
    sett.saveToXML(new FileOutputStream(new File(internDir, sett.getKey())));
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Aggregations

NodeSettings (org.knime.core.node.NodeSettings)156 File (java.io.File)58 FileOutputStream (java.io.FileOutputStream)57 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)37 GZIPOutputStream (java.util.zip.GZIPOutputStream)27 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)17 Test (org.junit.Test)16 NodeSettingsWO (org.knime.core.node.NodeSettingsWO)16 DefaultHiLiteMapper (org.knime.core.node.property.hilite.DefaultHiLiteMapper)16 IOException (java.io.IOException)14 OutputStream (java.io.OutputStream)12 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)11 BufferedOutputStream (java.io.BufferedOutputStream)9 Map (java.util.Map)8 RowKey (org.knime.core.data.RowKey)8 Config (org.knime.core.node.config.Config)8 LinkedHashMap (java.util.LinkedHashMap)7 DataTableSpec (org.knime.core.data.DataTableSpec)7 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)6 ArrayList (java.util.ArrayList)5