Search in sources :

Example 16 with NodeSettingsRO

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

the class NamedAggregationOperator method validateSettings.

/**
 * Validates the operator specific settings of all {@link NamedAggregationOperator}s
 * that require additional settings.
 *
 * @param settings the settings to validate
 * @param operators the operators to validate
 * @throws InvalidSettingsException if the settings of an operator are not valid
 * @since 2.7
 */
public static void validateSettings(final NodeSettingsRO settings, final List<NamedAggregationOperator> operators) throws InvalidSettingsException {
    for (NamedAggregationOperator operator : operators) {
        if (operator.hasOptionalSettings()) {
            try {
                final NodeSettingsRO operatorSettings = settings.getNodeSettings(createSettingsKey(operator));
                operator.validateSettings(operatorSettings);
            } catch (InvalidSettingsException e) {
                throw new InvalidSettingsException("Invalid operator settings for result column '" + operator.getName() + "', reason: " + e.getMessage());
            }
        }
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 17 with NodeSettingsRO

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

the class JoinedTable method load.

/**
 * Method being called when the workflow is restored and the table shall
 * recreated.
 * @param s The settings object, contains tables ids.
 * @param spec The final spec.
 * @param tblRep The table repository
 * @return The restored table.
 * @throws InvalidSettingsException If the settings can't be read.
 */
public static JoinedTable load(final NodeSettingsRO s, final DataTableSpec spec, final Map<Integer, BufferedDataTable> tblRep) throws InvalidSettingsException {
    NodeSettingsRO subSettings = s.getNodeSettings(CFG_INTERNAL_META);
    int leftID = subSettings.getInt(CFG_LEFT_TABLE_ID);
    int rightID = subSettings.getInt(CFG_RIGHT_TABLE_ID);
    BufferedDataTable leftTable = BufferedDataTable.getDataTable(tblRep, leftID);
    BufferedDataTable rightTable = BufferedDataTable.getDataTable(tblRep, rightID);
    return new JoinedTable(leftTable, rightTable, spec);
}
Also used : BufferedDataTable(org.knime.core.node.BufferedDataTable) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 18 with NodeSettingsRO

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

the class RandomForestClassificationLearnerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File file = new File(nodeInternDir, INTERNAL_TREES_FILE);
    if (file.exists()) {
        getLogger().info("Node was executed with KNIME version <2.10 - keep using old model type, re-execute node to update");
        // workflow is older than 2.10
        InputStream in = new GZIPInputStream(new FileInputStream(file));
        m_oldStyleEnsembleModel_deprecated = TreeEnsembleModel.load(in, exec);
        in.close();
    }
    file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
    if (file.exists()) {
        m_hiliteRowSample = DataContainer.readFromZip(file);
    }
    file = new File(nodeInternDir, INTERNAL_INFO_FILE);
    if (file.exists()) {
        NodeSettingsRO sets = NodeSettings.loadFromXML(new FileInputStream(file));
        m_viewMessage = sets.getString("view_warning", null);
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 19 with NodeSettingsRO

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

the class TreeEnsembleClassificationLearnerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File file = new File(nodeInternDir, INTERNAL_TREES_FILE);
    if (file.exists()) {
        getLogger().info("Node was executed with KNIME version <2.10 - keep using old model type, re-execute node to update");
        // workflow is older than 2.10
        InputStream in = new GZIPInputStream(new FileInputStream(file));
        m_oldStyleEnsembleModel_deprecated = TreeEnsembleModel.load(in, exec);
        in.close();
    }
    file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
    if (file.exists()) {
        m_hiliteRowSample = DataContainer.readFromZip(file);
    }
    file = new File(nodeInternDir, INTERNAL_INFO_FILE);
    if (file.exists()) {
        NodeSettingsRO sets = NodeSettings.loadFromXML(new FileInputStream(file));
        m_viewMessage = sets.getString("view_warning", null);
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 20 with NodeSettingsRO

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

the class CreateTempDirectoryConfiguration method loadInDialog.

void loadInDialog(final NodeSettingsRO settings) {
    m_baseName = settings.getString("baseName", "knime_tc_");
    m_variableName = settings.getString("variableName", "temp_path");
    m_deleteOnReset = settings.getBoolean("deleteOnReset", true);
    NodeSettingsRO pairs;
    try {
        pairs = settings.getNodeSettings("variable_name_pairs");
    } catch (InvalidSettingsException ise) {
        pairs = new NodeSettings("empty");
    }
    Set<String> keySet = pairs.keySet();
    List<VarNameFileNamePair> pairList = new ArrayList<VarNameFileNamePair>();
    m_pairs = new VarNameFileNamePair[keySet.size()];
    for (String key : keySet) {
        try {
            NodeSettingsRO p = pairs.getNodeSettings(key);
            String varName = p.getString("variableName");
            String fileName = p.getString("fileName");
            if (varName != null && fileName != null) {
                pairList.add(new VarNameFileNamePair(varName, fileName));
            }
        } catch (InvalidSettingsException ise) {
        // ignore
        }
    }
    m_pairs = pairList.toArray(new VarNameFileNamePair[pairList.size()]);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ArrayList(java.util.ArrayList) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Aggregations

NodeSettingsRO (org.knime.core.node.NodeSettingsRO)208 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)125 File (java.io.File)49 FileInputStream (java.io.FileInputStream)47 IOException (java.io.IOException)43 InputStream (java.io.InputStream)22 LinkedHashMap (java.util.LinkedHashMap)20 NodeSettings (org.knime.core.node.NodeSettings)20 BufferedInputStream (java.io.BufferedInputStream)19 ArrayList (java.util.ArrayList)16 GZIPInputStream (java.util.zip.GZIPInputStream)15 DataTableSpec (org.knime.core.data.DataTableSpec)14 Map (java.util.Map)11 ReferencedFile (org.knime.core.internal.ReferencedFile)11 BufferedDataTable (org.knime.core.node.BufferedDataTable)10 HashMap (java.util.HashMap)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 RowKey (org.knime.core.data.RowKey)9 DataType (org.knime.core.data.DataType)8 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)8