Search in sources :

Example 1 with DefaultHiLiteMapper

use of org.knime.core.node.property.hilite.DefaultHiLiteMapper in project knime-core by knime.

the class CrosstabNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
    if (m_settings.getEnableHiliting()) {
        final NodeSettings config = new NodeSettings("hilite_mapping");
        final DefaultHiLiteMapper mapper = (DefaultHiLiteMapper) m_hilite.getMapper();
        if (mapper != null) {
            mapper.save(config);
        }
        config.saveToXML(new FileOutputStream(new File(nodeInternDir, INTERNALS_FILE_NAME)));
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) FileOutputStream(java.io.FileOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) File(java.io.File)

Example 2 with DefaultHiLiteMapper

use of org.knime.core.node.property.hilite.DefaultHiLiteMapper in project knime-core by knime.

the class CrosstabNodeModel method createGroupByTable.

/**
 * Create group-by table.
 * @param exec execution context
 * @param table input table to group
 * @param groupByCols column selected for group-by operation
 * @return table with group and aggregation columns
 * @throws CanceledExecutionException if the group-by table generation was
 *         canceled externally
 */
private final GroupByTable createGroupByTable(final ExecutionContext exec, final BufferedDataTable table, final List<String> groupByCols) throws CanceledExecutionException {
    final int maxUniqueVals = Integer.MAX_VALUE;
    final boolean enableHilite = m_settings.getEnableHiliting();
    final boolean retainOrder = false;
    final ColumnNamePolicy colNamePolicy = ColumnNamePolicy.AGGREGATION_METHOD_COLUMN_NAME;
    final GlobalSettings globalSettings = GlobalSettings.builder().setFileStoreFactory(FileStoreFactory.createWorkflowFileStoreFactory(exec)).setGroupColNames(groupByCols).setMaxUniqueValues(maxUniqueVals).setValueDelimiter(GlobalSettings.STANDARD_DELIMITER).setDataTableSpec(table.getDataTableSpec()).setNoOfRows(table.size()).setAggregationContext(AggregationContext.ROW_AGGREGATION).build();
    ColumnAggregator collAggregator = null;
    if (null != m_settings.getWeightColumn()) {
        final String weightColumn = m_settings.getWeightColumn();
        // the column aggregator for the weighting column
        final boolean inclMissing = false;
        final DataColumnSpec originalColSpec = table.getDataTableSpec().getColumnSpec(weightColumn);
        final OperatorColumnSettings opColSettings = new OperatorColumnSettings(inclMissing, originalColSpec);
        collAggregator = new ColumnAggregator(originalColSpec, new NonNegativeSumOperator(globalSettings, opColSettings), inclMissing);
    } else {
        // use any column, does not matter as long as it exists and
        // include missing is true;
        final boolean inclMissing = true;
        final DataColumnSpec originalColSpec = table.getDataTableSpec().getColumnSpec(groupByCols.get(0));
        final OperatorColumnSettings opColSettings = new OperatorColumnSettings(inclMissing, originalColSpec);
        collAggregator = new ColumnAggregator(originalColSpec, new CountOperator(globalSettings, opColSettings), inclMissing);
    }
    final GroupByTable resultTable = new BigGroupByTable(exec, table, groupByCols, new ColumnAggregator[] { collAggregator }, globalSettings, enableHilite, colNamePolicy, retainOrder);
    if (enableHilite) {
        setHiliteMapping(new DefaultHiLiteMapper(resultTable.getHiliteMapping()));
    }
    // check for skipped columns
    final String warningMsg = resultTable.getSkippedGroupsMessage(3, 3);
    if (warningMsg != null) {
        setWarningMessage(warningMsg);
    }
    return resultTable;
}
Also used : OperatorColumnSettings(org.knime.base.data.aggregation.OperatorColumnSettings) GlobalSettings(org.knime.base.data.aggregation.GlobalSettings) ColumnNamePolicy(org.knime.base.node.preproc.groupby.ColumnNamePolicy) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) BigGroupByTable(org.knime.base.node.preproc.groupby.BigGroupByTable) GroupByTable(org.knime.base.node.preproc.groupby.GroupByTable) BigGroupByTable(org.knime.base.node.preproc.groupby.BigGroupByTable) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) CountOperator(org.knime.base.data.aggregation.general.CountOperator)

Example 3 with DefaultHiLiteMapper

use of org.knime.core.node.property.hilite.DefaultHiLiteMapper in project knime-core by knime.

the class SetOperatorNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
    if (m_enableHilite.getBooleanValue()) {
        final NodeSettings config0 = new NodeSettings("hilite_mapping");
        final DefaultHiLiteMapper mapper0 = (DefaultHiLiteMapper) m_trans0.getMapper();
        if (mapper0 != null) {
            mapper0.save(config0);
        }
        config0.saveToXML(new FileOutputStream(new File(nodeInternDir, HILITE_MAPPING0)));
        final NodeSettings config1 = new NodeSettings("hilite_mapping");
        final DefaultHiLiteMapper mapper1 = (DefaultHiLiteMapper) m_trans1.getMapper();
        if (mapper1 != null) {
            mapper1.save(config1);
        }
        config1.saveToXML(new FileOutputStream(new File(nodeInternDir, HILITE_MAPPING1)));
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) FileOutputStream(java.io.FileOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) File(java.io.File)

Example 4 with DefaultHiLiteMapper

use of org.knime.core.node.property.hilite.DefaultHiLiteMapper in project knime-core by knime.

the class SetOperatorNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    if (inData.length < 2) {
        throw new IllegalArgumentException("Two input tables expected");
    }
    final SetOperation op = SetOperation.getOperation4Name(m_setOp.getStringValue());
    final SetOperationTable table = new SetOperationTable(exec, m_col1.useRowID(), m_col1.getColumnName(), inData[0], m_col2.useRowID(), m_col2.getColumnName(), inData[1], op, m_enableHilite.getBooleanValue(), m_skipMissing.getBooleanValue());
    if (m_enableHilite.getBooleanValue()) {
        m_trans0.setMapper(new DefaultHiLiteMapper(table.getHiliteMapping0()));
        m_trans1.setMapper(new DefaultHiLiteMapper(table.getHiliteMapping1()));
    }
    return new BufferedDataTable[] { table.getBufferedTable() };
}
Also used : BufferedDataTable(org.knime.core.node.BufferedDataTable) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper)

Example 5 with DefaultHiLiteMapper

use of org.knime.core.node.property.hilite.DefaultHiLiteMapper in project knime-core by knime.

the class UngroupNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    if (m_enableHilite.getBooleanValue()) {
        final NodeSettings config = new NodeSettings("hilite_mapping");
        final DefaultHiLiteMapper mapper = (DefaultHiLiteMapper) m_trans.getMapper();
        if (mapper != null) {
            // the mapper is null if the node produces an empty data table
            mapper.save(config);
        }
        config.saveToXML(new GZIPOutputStream(new FileOutputStream(new File(nodeInternDir, "hilite_mapping.xml.gz"))));
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) FileOutputStream(java.io.FileOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) File(java.io.File)

Aggregations

DefaultHiLiteMapper (org.knime.core.node.property.hilite.DefaultHiLiteMapper)35 File (java.io.File)16 FileOutputStream (java.io.FileOutputStream)16 NodeSettings (org.knime.core.node.NodeSettings)16 Set (java.util.Set)12 RowKey (org.knime.core.data.RowKey)12 BufferedDataTable (org.knime.core.node.BufferedDataTable)12 GZIPOutputStream (java.util.zip.GZIPOutputStream)9 DataRow (org.knime.core.data.DataRow)8 DataTableSpec (org.knime.core.data.DataTableSpec)8 DataCell (org.knime.core.data.DataCell)7 DefaultRow (org.knime.core.data.def.DefaultRow)7 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)7 HashMap (java.util.HashMap)6 LinkedHashSet (java.util.LinkedHashSet)6 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)6 LinkedHashMap (java.util.LinkedHashMap)5 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 DataColumnSpec (org.knime.core.data.DataColumnSpec)4