Search in sources :

Example 6 with AggregationOperator

use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.

the class AggregationSettingsDialog method onHelp.

/**
 * @param method
 * @since 2.12
 */
protected void onHelp(final AggregationFunction method) {
    final String help;
    if (method instanceof AggregationOperator) {
        final AggregationOperator op = (AggregationOperator) method;
        help = op.getDetailedDescription();
    } else {
        help = method.getDescription();
    }
    final HelpDialog helpDialog = new HelpDialog(this, help);
    Point location = this.getLocation();
    Dimension size = this.getSize();
    helpDialog.setLocation((int) (location.getX() + size.getWidth() + 10), location.y);
    // helpDialog.setLocationRelativeTo(this);
    helpDialog.setVisible(true);
}
Also used : AggregationOperator(org.knime.base.data.aggregation.AggregationOperator) Point(java.awt.Point) Dimension(java.awt.Dimension)

Example 7 with AggregationOperator

use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.

the class SettingsModelAggregationMethod method loadSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    try {
        final NodeSettingsRO subSettings = settings.getNodeSettings(m_configName);
        final String methodId = subSettings.getString(CFG_METHOD_ID);
        final AggregationOperator method = (AggregationOperator) AggregationMethods.getMethod4Id(methodId);
        final boolean includeMissing = subSettings.getBoolean(CFG_INCL_MISSING, method.inclMissingCells());
        // update the missing value option in the method based on the settings
        method.getOperatorColumnSettings().setInclMissing(includeMissing);
        if (method.hasOptionalSettings()) {
            final NodeSettingsRO methodSettings = subSettings.getNodeSettings(CFG_METHOD_SETTINGS);
            method.loadValidatedSettings(methodSettings);
        }
        // no default value, throw an exception instead
        setValues(method, subSettings.getString(CFG_VALUE_SEPARATOR), subSettings.getInt(CFG_MAX_UNIQUE_VALUES));
    } catch (final IllegalArgumentException iae) {
        throw new InvalidSettingsException(iae.getMessage());
    }
}
Also used : AggregationOperator(org.knime.base.data.aggregation.AggregationOperator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 8 with AggregationOperator

use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.

the class SettingsModelAggregationMethod method createClone.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected SettingsModelAggregationMethod createClone() {
    AggregationOperator operator = (AggregationOperator) m_method;
    final AggregationMethod clone;
    if (!operator.hasOptionalSettings()) {
        clone = operator;
    } else {
        clone = operator.createInstance(operator.getGlobalSettings(), operator.getOperatorColumnSettings());
    }
    return new SettingsModelAggregationMethod(m_configName, m_inputPortIndex, m_valueDelimiter, m_maxUniqueValues, clone);
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) AggregationOperator(org.knime.base.data.aggregation.AggregationOperator)

Example 9 with AggregationOperator

use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.

the class SettingsModelAggregationMethod method loadSettingsForDialog.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    try {
        DataTableSpec spec;
        if (m_inputPortIndex < 0 || specs == null || specs.length < m_inputPortIndex || specs[m_inputPortIndex] == null) {
            // we do not have a data table spec available this might be the reason if
            // the dialog component is used in a node that does not aggregate an input
            // data table
            spec = new DataTableSpec();
        } else {
            spec = (DataTableSpec) specs[m_inputPortIndex];
        }
        final NodeSettingsRO subSettings = settings.getNodeSettings(m_configName);
        final String methodId = subSettings.getString(CFG_METHOD_ID);
        final AggregationOperator method = (AggregationOperator) AggregationMethods.getMethod4Id(methodId);
        final boolean includeMissing = subSettings.getBoolean(CFG_INCL_MISSING, method.inclMissingCells());
        // update the missing value option in the method based on the settings
        method.getOperatorColumnSettings().setInclMissing(includeMissing);
        if (method.hasOptionalSettings()) {
            final NodeSettingsRO methodSettings = subSettings.getNodeSettings(CFG_METHOD_SETTINGS);
            method.loadSettingsFrom(methodSettings, spec);
        }
        // no default value, throw an exception instead
        setValues(method, subSettings.getString(CFG_VALUE_SEPARATOR), subSettings.getInt(CFG_MAX_UNIQUE_VALUES));
    } catch (final Exception iae) {
        throw new NotConfigurableException(iae.getMessage());
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) AggregationOperator(org.knime.base.data.aggregation.AggregationOperator) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NotConfigurableException(org.knime.core.node.NotConfigurableException)

Example 10 with AggregationOperator

use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.

the class DialogComponentAggregationMethod method updateModel.

/**
 * Transfers the current value from the component into the model.
 * @throws InvalidSettingsException
 */
private void updateModel() throws InvalidSettingsException {
    // we transfer the value from the field into the model
    final SettingsModelAggregationMethod model = getMethodModel();
    model.removeChangeListener(this);
    final AggregationOperator method = (AggregationOperator) getSelectedAggregationMethod();
    // copy the include missing information from the select box into the method instance prior passing the method
    // to the model
    method.getOperatorColumnSettings().setInclMissing(getIncludeMissing());
    model.setValues(method, getValueDelimiter(), getMaxUniqueValues());
    model.prependChangeListener(this);
}
Also used : AggregationOperator(org.knime.base.data.aggregation.AggregationOperator)

Aggregations

AggregationOperator (org.knime.base.data.aggregation.AggregationOperator)13 DataCell (org.knime.core.data.DataCell)7 DataRow (org.knime.core.data.DataRow)6 DefaultRow (org.knime.core.data.def.DefaultRow)6 LinkedList (java.util.LinkedList)3 ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)2 NamedAggregationOperator (org.knime.base.data.aggregation.NamedAggregationOperator)2 RowKey (org.knime.core.data.RowKey)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)2 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 AggregationMethod (org.knime.base.data.aggregation.AggregationMethod)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)1 NotConfigurableException (org.knime.core.node.NotConfigurableException)1 Pair (org.knime.core.util.Pair)1