Search in sources :

Example 71 with InvalidSettingsException

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

the class MovingAggregationNodeModel method configure.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
    if (inSpecs == null || inSpecs.length != 1) {
        throw new InvalidSettingsException("No input table specification available");
    }
    final DataTableSpec inputSpec = inSpecs[0];
    m_columnAggregators2Use.clear();
    final ArrayList<ColumnAggregator> invalidColAggrs = new ArrayList<>(1);
    m_columnAggregators2Use.addAll(GroupByNodeModel.getAggregators(inputSpec, Collections.EMPTY_LIST, m_columnAggregators, m_patternAggregators, m_dataTypeAggregators, invalidColAggrs));
    if (m_columnAggregators2Use.isEmpty()) {
        setWarningMessage("No aggregation column defined");
    }
    if (!invalidColAggrs.isEmpty()) {
        setWarningMessage(invalidColAggrs.size() + " invalid aggregation column(s) found.");
    }
    LOGGER.debug(m_columnAggregators2Use);
    final MovingAggregationTableFactory tableFactory = createTableFactory(FileStoreFactory.createNotInWorkflowFileStoreFactory(), inputSpec);
    return new DataTableSpec[] { tableFactory.createResultSpec() };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ArrayList(java.util.ArrayList)

Example 72 with InvalidSettingsException

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

the class TimeFieldExtractorNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
    DataTableSpec inSpec = inSpecs[0];
    // contains timestamp?
    if (!inSpec.containsCompatibleType(DateAndTimeValue.class)) {
        throw new InvalidSettingsException("No timestamp found in input table!");
    }
    // currently selected column still there?
    String selectedColName = m_selectedColumn.getStringValue();
    if (selectedColName != null && !selectedColName.isEmpty()) {
        if (!inSpec.containsName(selectedColName)) {
            throw new InvalidSettingsException("Column " + selectedColName + " not found in input spec!");
        }
    } else {
        // no value set: auto-configure -> choose first timeseries
        for (DataColumnSpec colSpec : inSpec) {
            if (colSpec.getType().isCompatible(DateAndTimeValue.class)) {
                String colName = colSpec.getName();
                m_selectedColumn.setStringValue(colName);
                setWarningMessage("Auto-configure: selected " + colName);
                break;
            }
        }
    }
    // create outputspec
    ColumnRearranger colRearranger = createColumnRearranger(inSpec).getColumnRearranger();
    return new DataTableSpec[] { colRearranger.createSpec() };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DateAndTimeValue(org.knime.core.data.date.DateAndTimeValue) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 73 with InvalidSettingsException

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

the class TimePresetNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
    // does input spec contain a date and time col?
    DataTableSpec inSpec = inSpecs[0];
    if (!inSpec.containsCompatibleType(DateAndTimeValue.class)) {
        throw new InvalidSettingsException("Input table must contain at least one time column!");
    }
    String selectedColName = m_selectedCol.getStringValue();
    if (selectedColName != null && !selectedColName.isEmpty()) {
        // already set -> search for column name in input table
        if (!inSpec.containsName(selectedColName)) {
            throw new InvalidSettingsException("Column " + selectedColName + " not found in input table!");
        } else {
            // check if it is of correct type
            DataColumnSpec colSpec = inSpec.getColumnSpec(selectedColName);
            if (!colSpec.getType().isCompatible(DateAndTimeValue.class)) {
                throw new InvalidSettingsException("Selected column (" + selectedColName + ") must contain date or time!");
            }
        }
    } else {
        // not yet set -> auto-configure: choose first time column
        for (DataColumnSpec colSpec : inSpec) {
            if (colSpec.getType().isCompatible(DateAndTimeValue.class)) {
                String colName = colSpec.getName();
                m_selectedCol.setStringValue(colName);
                setWarningMessage("Auto-configure: selected " + colName);
                // take the first compatible column
                break;
            }
        }
    }
    // values in time column are "enriched"
    return inSpecs;
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DateAndTimeValue(org.knime.core.data.date.DateAndTimeValue) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 74 with InvalidSettingsException

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

the class TimeMissingValueHandlingColSetting method loadSubConfigs.

/**
 * Get ColSetting objects in a map, mapping name to ColSetting.
 */
private static Map<String, TimeMissingValueHandlingColSetting> loadSubConfigs(final NodeSettingsRO settings) throws InvalidSettingsException {
    LinkedHashMap<String, TimeMissingValueHandlingColSetting> result = new LinkedHashMap<String, TimeMissingValueHandlingColSetting>();
    for (String key : settings.keySet()) {
        NodeSettingsRO subConfig = settings.getNodeSettings(key);
        TimeMissingValueHandlingColSetting local = new TimeMissingValueHandlingColSetting();
        try {
            local.loadSettings(subConfig);
        } catch (InvalidSettingsException ise) {
            throw new InvalidSettingsException("Unable to load sub config for key '" + key + "'", ise);
        }
        result.put(key, local);
    }
    return result;
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) LinkedHashMap(java.util.LinkedHashMap)

Example 75 with InvalidSettingsException

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

the class VirtualParallelizedChunkPortObjectInNodeFactory method loadPortTypeList.

/**
 * @param config
 * @return TODO
 * @throws InvalidSettingsException
 */
static PortType[] loadPortTypeList(final ConfigRO config) throws InvalidSettingsException {
    Set<String> keySet = config.keySet();
    PortType[] outTypes = new PortType[keySet.size()];
    for (String s : keySet) {
        ConfigRO portConfig = config.getConfig(s);
        int index = portConfig.getInt("index");
        CheckUtils.checkSetting(index >= 0 && index < outTypes.length, "Invalid port index must be in [0, %d]: %d", keySet.size() - 1, index);
        Config portTypeConfig = portConfig.getConfig("type");
        PortType type = PortType.load(portTypeConfig);
        outTypes[index] = type;
    }
    int invalidIndex = Arrays.asList(outTypes).indexOf(null);
    if (invalidIndex >= 0) {
        throw new InvalidSettingsException("Unassigned port type at index " + invalidIndex);
    }
    return outTypes;
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Config(org.knime.core.node.config.Config) ConfigRO(org.knime.core.node.config.ConfigRO) PortType(org.knime.core.node.port.PortType)

Aggregations

InvalidSettingsException (org.knime.core.node.InvalidSettingsException)818 DataTableSpec (org.knime.core.data.DataTableSpec)278 DataColumnSpec (org.knime.core.data.DataColumnSpec)211 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)153 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)121 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)113 IOException (java.io.IOException)109 DataCell (org.knime.core.data.DataCell)99 ArrayList (java.util.ArrayList)96 DataType (org.knime.core.data.DataType)89 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)82 File (java.io.File)72 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)69 DataRow (org.knime.core.data.DataRow)66 DoubleValue (org.knime.core.data.DoubleValue)58 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)48 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)47 FileInputStream (java.io.FileInputStream)43 LinkedHashMap (java.util.LinkedHashMap)42 NotConfigurableException (org.knime.core.node.NotConfigurableException)41