Search in sources :

Example 31 with ModelContentRO

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

the class URIPortObject method load.

/**
 * {@inheritDoc}
 */
@Override
protected void load(final ModelContentRO model, final PortObjectSpec spec, final ExecutionMonitor exec) throws InvalidSettingsException, CanceledExecutionException {
    List<URIContent> list = new ArrayList<URIContent>();
    for (String key : model.keySet()) {
        if (key.startsWith("child-")) {
            ModelContentRO child = model.getModelContent(key);
            list.add(URIContent.load(child));
        }
    }
    m_uriContents = Collections.unmodifiableList(list);
    m_uriPortObjectSpec = (URIPortObjectSpec) spec;
}
Also used : ModelContentRO(org.knime.core.node.ModelContentRO) ArrayList(java.util.ArrayList)

Example 32 with ModelContentRO

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

the class NumericOutliersModel method loadModel.

/**
 * Loads the information provided by the model content into the model.
 *
 * @param model the model content to be loaded
 * @throws InvalidSettingsException if the outliers defined by the model content differs from the outliers defining
 *             the intervals
 */
@SuppressWarnings("unchecked")
private void loadModel(final ModelContentRO model) throws InvalidSettingsException {
    final Enumeration<ModelContentRO> rowContents = model.children();
    while (rowContents.hasMoreElements()) {
        // acess the current group
        final ModelContentRO rowContent = rowContents.nextElement();
        // load the group key
        final GroupKey key = new GroupKey(rowContent.getModelContent("key").getDataCellArray(CFG_GROUP_KEY));
        // load all intervals for the current group key
        ModelContentRO intervalCols = rowContent.getModelContent(CFG_INTERVAL_COLUMNS);
        final Enumeration<ModelContentRO> intervalContents = intervalCols.children();
        while (intervalContents.hasMoreElements()) {
            final ModelContentRO intervalContent = intervalContents.nextElement();
            addEntry(key, intervalContent.getString("outlier"), intervalContent.getDoubleArray(CFG_INTERVAL));
        }
    }
}
Also used : ModelContentRO(org.knime.core.node.ModelContentRO) GroupKey(org.knime.base.node.preproc.groupby.GroupKey)

Aggregations

ModelContentRO (org.knime.core.node.ModelContentRO)32 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)19 IOException (java.io.IOException)16 File (java.io.File)15 FileInputStream (java.io.FileInputStream)14 BufferedInputStream (java.io.BufferedInputStream)12 GZIPInputStream (java.util.zip.GZIPInputStream)11 DataTableSpec (org.knime.core.data.DataTableSpec)6 DecisionTree (org.knime.base.node.mine.decisiontree2.model.DecisionTree)5 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)5 ArrayList (java.util.ArrayList)3 ZipEntry (java.util.zip.ZipEntry)3 DefaultDataArray (org.knime.base.node.util.DefaultDataArray)3 ZipInputStream (java.util.zip.ZipInputStream)2 GroupKey (org.knime.base.node.preproc.groupby.GroupKey)2 ContainerTable (org.knime.core.data.container.ContainerTable)2 NonClosableInputStream (org.knime.core.data.util.NonClosableInputStream)2 ObjectInputStream (java.io.ObjectInputStream)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1