Search in sources :

Example 61 with NodeSettingsWO

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

the class FixedWidthColProperty method saveToConfiguration.

/**
 * @param cfg the settings object where we save our properties
 */
public void saveToConfiguration(final NodeSettingsWO cfg) {
    if (cfg == null) {
        throw new NullPointerException("Can't save column property into null config.");
    }
    cfg.addInt(CFGKEY_COLWIDTH, m_width);
    cfg.addBoolean(CFGKEY_INCLUDE, m_include);
    cfg.addString(CFGKEY_MISSVALPAT, m_missingValuePattern);
    cfg.addString(CFGKEY_FORMAT, m_formatParameter);
    // add the stuff from the ColumnSpec
    cfg.addString(CFGKEY_COLNAME, m_colSpec.getName());
    cfg.addDataType(CFGKEY_COLTYPE, m_colSpec.getType());
    Set<DataCell> posValues = m_colSpec.getDomain().getValues();
    if ((posValues != null) && (posValues.size() > 0)) {
        NodeSettingsWO pVCfg = cfg.addNodeSettings(CFGKEY_POSVALUES);
        int count = 0;
        for (DataCell cell : posValues) {
            pVCfg.addDataCell(CFGKEY_POSSVAL + count, cell);
            count++;
        }
    }
    if ((m_colSpec.getDomain().getLowerBound() != null) || (m_colSpec.getDomain().getUpperBound() != null)) {
        cfg.addDataCell(CFGKEY_LOWERBOUND, m_colSpec.getDomain().getLowerBound());
        cfg.addDataCell(CFGKEY_UPPERBOUND, m_colSpec.getDomain().getUpperBound());
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DataCell(org.knime.core.data.DataCell)

Example 62 with NodeSettingsWO

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

the class Statistics3Table method save.

/**
 * Saves this object to the given settings object.
 *
 * @param sett this object is saved to
 */
public void save(final NodeSettingsWO sett) {
    m_spec.save(sett.addConfig("spec"));
    sett.addDataCellArray("minimumCells", m_minCells);
    sett.addDataCellArray("maximumCells", m_maxCells);
    sett.addDataCellArray("minimumNonInf", m_minNonInfValues);
    sett.addDataCellArray("maximumNonInf", m_maxNonInfValues);
    sett.addDoubleArray("mean", m_meanValues);
    sett.addDoubleArray("variance", m_varianceValues);
    sett.addDoubleArray("median", m_median);
    sett.addIntArray("missings", m_missingValueCnt);
    sett.addIntArray("nans", m_nanValueCnt);
    sett.addIntArray("posInfs", m_posInfinityValueCnt);
    sett.addIntArray("negInfs", m_negInfinityValueCnt);
    sett.addDoubleArray("sums", m_sum);
    sett.addDoubleArray("skewness", m_skewness);
    sett.addDoubleArray("kurtosis", m_kurtosis);
    sett.addInt("row_count", m_rowCount);
    for (int c = 0; c < m_nominalValues.size(); c++) {
        if (m_nominalValues.get(c) != null) {
            NodeSettingsWO subSett = sett.addNodeSettings(m_spec.getColumnSpec(c).getName());
            for (Map.Entry<DataCell, Integer> e : m_nominalValues.get(c).entrySet()) {
                NodeSettingsWO nomSett = subSett.addNodeSettings(e.getKey().toString());
                nomSett.addDataCell("key", e.getKey());
                nomSett.addInt("value", e.getValue());
            }
        }
    }
}
Also used : MutableInteger(org.knime.core.util.MutableInteger) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DataCell(org.knime.core.data.DataCell) BlobWrapperDataCell(org.knime.core.data.container.BlobWrapperDataCell) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 63 with NodeSettingsWO

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

the class PatternAggregator method saveAggregators.

/**
 * @param settings the settings object to write to
 * @param key the unique settings key
 * @param aggregators the {@link PatternAggregator} objects to save
 */
public static void saveAggregators(final NodeSettingsWO settings, final String key, final Collection<PatternAggregator> aggregators) {
    if (key == null || key.isEmpty()) {
        throw new IllegalArgumentException("key must not be empty");
    }
    if (settings == null) {
        throw new NullPointerException("settings must not be null");
    }
    if (aggregators == null) {
        return;
    }
    final NodeSettingsWO root = settings.addNodeSettings(key);
    int idx = 0;
    for (PatternAggregator aggr : aggregators) {
        final NodeSettingsWO cfg = root.addNodeSettings("f_" + idx++);
        cfg.addString(CNFG_INPUT_PATTERN, aggr.getInputPattern());
        cfg.addBoolean(CNFG_IS_REGEX, aggr.m_isRegex);
        cfg.addBoolean(CNFG_INCL_MISSING_VALS, aggr.inclMissingCells());
        AggregationMethodDecorator.saveMethod(cfg, aggr.getMethodTemplate());
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 64 with NodeSettingsWO

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

the class CorrelationOperator method saveSettingsTo.

@Override
public void saveSettingsTo(final NodeSettingsWO settings) {
    NodeSettingsWO colSettings = settings.addNodeSettings(COLUMN_SETTINGS);
    super.saveSettingsTo(colSettings);
    NodeSettingsWO corrSettings = settings.addNodeSettings(CORRELATION_SETTINGS);
    m_settings.saveSettingsTo(corrSettings);
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 65 with NodeSettingsWO

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

the class ColumnAggregator method saveColumnAggregators.

/**
 * @param settings the settings object to write to
 * @param key the unique settings key or <code>null</code> if the default should be used
 * @param aggregators the {@link ColumnAggregator} objects to save
 * @since 2.11
 */
public static void saveColumnAggregators(final NodeSettingsWO settings, final String key, final List<ColumnAggregator> aggregators) {
    if (settings == null) {
        throw new NullPointerException("settings must not be null");
    }
    if (aggregators == null) {
        throw new NullPointerException("aggregators must not be null");
    }
    final String[] colNames = new String[aggregators.size()];
    final String[] aggrMethods = new String[aggregators.size()];
    final boolean[] inclMissingVals = new boolean[aggregators.size()];
    final DataType[] types = new DataType[aggregators.size()];
    final Config cnfg;
    if (key == null || key.isEmpty()) {
        cnfg = settings.addConfig(CNFG_AGGR_COL_SECTION);
    } else {
        cnfg = settings.addConfig(key);
    }
    final NodeSettingsWO operatorSettings = settings.addNodeSettings(CNFG_OPERATOR_SETTINGS);
    final Map<String, MutableInteger> idMap = new HashMap<>();
    for (int i = 0, length = aggregators.size(); i < length; i++) {
        final ColumnAggregator colAggr = aggregators.get(i);
        colNames[i] = colAggr.getOriginalColName();
        final AggregationMethod method = colAggr.getMethodTemplate();
        aggrMethods[i] = colAggr.getId();
        types[i] = colAggr.getOriginalDataType();
        inclMissingVals[i] = colAggr.inclMissingCells();
        if (colAggr.hasOptionalSettings()) {
            try {
                final NodeSettingsWO operatorSetting = operatorSettings.addNodeSettings(createSettingsKey(idMap, colAggr));
                method.saveSettingsTo(operatorSetting);
            } catch (Exception e) {
                LOGGER.error("Exception while saving settings for aggreation operator '" + colAggr.getId() + "', reason: " + e.getMessage());
            }
        }
    }
    cnfg.addStringArray(CNFG_COL_NAMES, colNames);
    cnfg.addDataTypeArray(CNFG_COL_TYPES, types);
    cnfg.addStringArray(CNFG_AGGR_METHODS, aggrMethods);
    cnfg.addBooleanArray(CNFG_INCL_MISSING_VALS, inclMissingVals);
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) HashMap(java.util.HashMap) Config(org.knime.core.node.config.Config) MutableInteger(org.knime.core.util.MutableInteger) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DataType(org.knime.core.data.DataType)

Aggregations

NodeSettingsWO (org.knime.core.node.NodeSettingsWO)111 NodeSettings (org.knime.core.node.NodeSettings)16 Map (java.util.Map)11 File (java.io.File)9 FileOutputStream (java.io.FileOutputStream)9 LinkedHashMap (java.util.LinkedHashMap)9 HashMap (java.util.HashMap)8 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)8 RowKey (org.knime.core.data.RowKey)6 DataCell (org.knime.core.data.DataCell)5 BufferedOutputStream (java.io.BufferedOutputStream)4 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)4 HashSet (java.util.HashSet)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)3 DataRow (org.knime.core.data.DataRow)3 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)3 AbstractQuickFormConfiguration (org.knime.core.quickform.AbstractQuickFormConfiguration)3 AbstractQuickFormValueInConfiguration (org.knime.core.quickform.AbstractQuickFormValueInConfiguration)3 QuickFormInputNode (org.knime.core.quickform.in.QuickFormInputNode)3 MutableInteger (org.knime.core.util.MutableInteger)3