Search in sources :

Example 86 with NodeSettingsWO

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

the class FileNodeContainerMetaPersistor method saveNodeMessage.

protected static void saveNodeMessage(final NodeSettingsWO settings, final NodeContainer nc) {
    NodeMessage message = nc.getNodeMessage();
    if (message != null && !message.getMessageType().equals(Type.RESET)) {
        NodeSettingsWO sub = settings.addNodeSettings("nodecontainer_message");
        sub.addString("type", message.getMessageType().name());
        sub.addString("message", message.getMessage());
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 87 with NodeSettingsWO

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

the class FileSubNodeContainerPersistor method save.

/**
 * @param subnodeNC
 * @param settings
 * @param exec
 * @param nodeDirRef
 * @param saveHelper
 * @throws LockFailedException
 * @throws CanceledExecutionException
 * @throws IOException
 */
static void save(final SubNodeContainer subnodeNC, final NodeSettings settings, final ExecutionMonitor exec, final ReferencedFile nodeDirRef, final WorkflowSaveHelper saveHelper) throws IOException, CanceledExecutionException, LockFailedException {
    NativeNodeContainer virtualInNode = subnodeNC.getVirtualInNode();
    settings.addInt("virtual-in-ID", virtualInNode.getID().getIndex());
    NodeSettingsWO inportsSettings = settings.addNodeSettings("inports");
    // input of subnode is represented by output of virtual in node.
    for (int i = 1; i < virtualInNode.getNrOutPorts(); i++) {
        // start at one to skip the hidden flow var port
        NodeSettingsWO inportSetting = inportsSettings.addNodeSettings("inport_" + (i - 1));
        inportSetting.addInt("index", i - 1);
        NodeSettingsWO portTypeSettings = inportSetting.addNodeSettings("type");
        virtualInNode.getOutputType(i).save(portTypeSettings);
    }
    NativeNodeContainer virtualOutNode = subnodeNC.getVirtualOutNode();
    settings.addInt("virtual-out-ID", virtualOutNode.getID().getIndex());
    // output of subnode is represented by input of virtual in node.
    NodeSettingsWO outportsSettings = settings.addNodeSettings("outports");
    for (int i = 1; i < virtualOutNode.getNrInPorts(); i++) {
        // start at one to skip the hidden flow var port
        NodeSettingsWO inportSetting = outportsSettings.addNodeSettings("outport_" + (i - 1));
        inportSetting.addInt("index", i - 1);
        NodeSettingsWO portTypeSettings = inportSetting.addNodeSettings("type");
        virtualOutNode.getInPort(i).getPortType().save(portTypeSettings);
    }
    subnodeNC.getTemplateInformation().save(settings);
    Map<Integer, WizardNodeLayoutInfo> layoutInfoMap = subnodeNC.getLayoutInfo();
    Integer[] layoutIDs = layoutInfoMap.keySet().toArray(new Integer[0]);
    NodeSettingsWO layoutInfoSettings = settings.addNodeSettings("layoutInfos");
    for (int i = 0; i < layoutInfoMap.size(); i++) {
        NodeSettingsWO curLayoutInfoSettings = layoutInfoSettings.addNodeSettings("layoutInfo_" + (i));
        curLayoutInfoSettings.addInt("nodeID", layoutIDs[i]);
        WizardNodeLayoutInfo.saveToNodeSettings(curLayoutInfoSettings, layoutInfoMap.get(layoutIDs[i]));
    }
    settings.addString("layoutJSON", subnodeNC.getLayoutJSONString());
    WorkflowManager workflowManager = subnodeNC.getWorkflowManager();
    FileWorkflowPersistor.save(workflowManager, nodeDirRef, exec, saveHelper);
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) WizardNodeLayoutInfo(org.knime.core.node.wizard.WizardNodeLayoutInfo)

Example 88 with NodeSettingsWO

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

the class BinnerNodeModel method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
    for (String columnKey : m_columnToBins.keySet()) {
        NodeSettingsWO column = settings.addNodeSettings(columnKey);
        if (m_columnToAppended.get(columnKey) != null) {
            settings.addString(columnKey + IS_APPENDED, m_columnToAppended.get(columnKey));
        } else {
            settings.addString(columnKey + IS_APPENDED, null);
        }
        Bin[] bins = m_columnToBins.get(columnKey);
        for (int b = 0; b < bins.length; b++) {
            NodeSettingsWO bin = column.addNodeSettings(bins[b].getBinName() + "_" + b);
            bins[b].saveToSettings(bin);
        }
    }
    settings.addStringArray(NUMERIC_COLUMNS, m_columnToAppended.keySet().toArray(new String[0]));
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Bin(org.knime.base.node.preproc.pmml.binner.BinnerColumnFactory.Bin)

Example 89 with NodeSettingsWO

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

the class RenameNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    NodeSettingsWO subSettings = settings.addNodeSettings(RenameNodeModel.CFG_SUB_CONFIG);
    Map<String, RenameColumnSetting> duplicateHash = new HashMap<String, RenameColumnSetting>();
    clearBorders();
    // Bug 5299 - New rename node creates false duplicate column errors
    // in a first iteration find the names which are replaced and remove them from the duplicate check
    Set<String> oldColumnNames = new HashSet<String>();
    Collections.addAll(oldColumnNames, m_orgTableSpec.getColumnNames());
    for (RenameColumnSetting colSet : m_columnToSettings.values()) {
        final String newName = colSet.getNewColumnName();
        final String oldName = colSet.getName();
        if (newName != null) {
            // we have a replacement for the old name - so we can remove that.
            oldColumnNames.remove(oldName);
        }
    }
    int i = 0;
    for (RenameColumnSetting colSet : m_columnToSettings.values()) {
        String newName = colSet.getNewColumnName();
        final String oldName = colSet.getName();
        if (newName == null) {
            newName = oldName;
        }
        // check for empty configured names
        if (newName == null || newName.length() == 0) {
            int indexIndividualIndex = getIndexIndividualIndex(colSet);
            String warnMessage = String.format("Column name for setting with index '%d' is empty.", getIndexIndividualIndex(colSet));
            addToErrornousColNames(null, indexIndividualIndex);
            throw new InvalidSettingsException(warnMessage);
        }
        // check for duplicates with configured names
        RenameColumnSetting put = duplicateHash.put(newName, colSet);
        if (put != null) {
            int index1 = getIndexIndividualIndex(colSet);
            int index2 = getIndexIndividualIndex(put);
            String warnMessage = String.format("Duplicate column name: '%s' on index %d and %d.", newName, index1, index2);
            addToErrornousColNames(newName, index1, index2);
            throw new InvalidSettingsException(warnMessage);
        }
        // check for duplicates with column names
        if (oldColumnNames.contains(newName) && colSet.getNewColumnName() != null) {
            int index1 = getIndexIndividualIndex(colSet);
            String warnMessage = String.format("Duplicate column name: '%s' on index %d and existing column.", newName, index1);
            addToErrornousColNames(newName, index1);
            throw new InvalidSettingsException(warnMessage);
        }
        NodeSettingsWO subSub = subSettings.addNodeSettings(Integer.toString(i++));
        colSet.saveSettingsTo(subSub);
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) HashSet(java.util.HashSet)

Example 90 with NodeSettingsWO

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

the class InteractiveHiLiteCollectorNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    NodeSettings sett = new NodeSettings(KEY_ANNOTATIONS);
    RowKey[] cells = m_annotationMap.keySet().toArray(new RowKey[m_annotationMap.size()]);
    sett.addRowKeyArray("row_keys", cells);
    for (RowKey cell : cells) {
        NodeSettingsWO subSett = sett.addNodeSettings(cell.toString());
        for (Map.Entry<Integer, String> e : m_annotationMap.get(cell).entrySet()) {
            subSett.addString(e.getKey().toString(), e.getValue());
        }
    }
    File f = new File(nodeInternDir, KEY_ANNOTATIONS);
    sett.saveToXML(new FileOutputStream(f));
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) RowKey(org.knime.core.data.RowKey) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) FileOutputStream(java.io.FileOutputStream) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File)

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