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)));
}
}
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;
}
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)));
}
}
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() };
}
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"))));
}
}
Aggregations