Search in sources :

Example 1 with SizeHandlerPortObject

use of org.knime.core.node.port.viewproperty.SizeHandlerPortObject in project knime-core by knime.

the class SizeManager2NodeModel method execute.

/**
 * Is invoked during the node's execution to make the size settings.
 *
 * @param data the input data array
 * @param exec the execution monitor
 * @return the same input data table whereby the DataTableSpec contains
 *         additional size infos
 * @throws CanceledExecutionException if user canceled execution
 *
 * @see NodeModel#execute(BufferedDataTable[],ExecutionContext)
 */
@Override
protected PortObject[] execute(final PortObject[] data, final ExecutionContext exec) throws CanceledExecutionException {
    final DataTableSpec inSpec = (DataTableSpec) data[INPORT].getSpec();
    final String columnName = m_column.getStringValue();
    final DataColumnSpec cspec = inSpec.getColumnSpec(columnName);
    SizeHandler sizeHandler = createSizeHandler(cspec);
    final DataTableSpec newSpec = appendSizeHandler(inSpec, columnName, sizeHandler);
    BufferedDataTable changedSpecTable = exec.createSpecReplacerTable((BufferedDataTable) data[INPORT], newSpec);
    DataTableSpec modelSpec = new DataTableSpec(newSpec.getColumnSpec(m_column.getStringValue()));
    SizeHandlerPortObject viewPort = new SizeHandlerPortObject(modelSpec, sizeHandler.toString() + " based on column \"" + m_column.getStringValue() + "\"");
    return new PortObject[] { changedSpecTable, viewPort };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) SizeHandler(org.knime.core.data.property.SizeHandler) BufferedDataTable(org.knime.core.node.BufferedDataTable) SizeHandlerPortObject(org.knime.core.node.port.viewproperty.SizeHandlerPortObject) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SizeHandlerPortObject(org.knime.core.node.port.viewproperty.SizeHandlerPortObject) PortObject(org.knime.core.node.port.PortObject)

Aggregations

DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 SizeHandler (org.knime.core.data.property.SizeHandler)1 BufferedDataTable (org.knime.core.node.BufferedDataTable)1 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)1 PortObject (org.knime.core.node.port.PortObject)1 SizeHandlerPortObject (org.knime.core.node.port.viewproperty.SizeHandlerPortObject)1