Search in sources :

Example 66 with InvalidSettingsException

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

the class LoopStartWindowConfiguration method loadSettingsInModel.

/**
 * Load settings in model, fails if incomplete.
 *
 * @param settings To load from.
 * @throws InvalidSettingsException If invalid.
 */
void loadSettingsInModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    try {
        setWindowDefinition(WindowDefinition.valueOf(settings.getString(m_windowDefinitionKey)));
    } catch (Exception e) {
        throw new InvalidSettingsException("Invalid window definition: " + settings.getString(m_windowDefinitionKey));
    }
    try {
        setTrigger(Trigger.valueOf(settings.getString(m_triggerKey)));
    } catch (Exception e) {
        throw new InvalidSettingsException("Invalid trigger: " + settings.getString(m_triggerKey));
    }
    setEventStepSize(settings.getInt(m_evenStepSizeKey));
    setEventWindowSize(settings.getInt(m_eventWindowSizeKey));
    setTimeStepSize(settings.getString(m_timeStepSizeKey));
    setTimeWindowSize(settings.getString(m_timeWindowSizeKey));
    setTimeStepUnit(Unit.getUnit(settings.getString(m_timeStepUnitKey, null)));
    m_timeWindowUnit = Unit.getUnit(settings.getString(m_timeWindowUnitKey, null));
    setLimitWindow(settings.getBoolean(m_limitWindowKey, false));
    setUseSpecifiedStartTime(settings.getBoolean(m_useSpecifiedStartTimeKey, false));
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 67 with InvalidSettingsException

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

the class ModifyDateNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
    if (!m_hasValidatedConfiguration) {
        throw new InvalidSettingsException("Node must be configured!");
    }
    DataTableSpec in = inSpecs[0];
    ColumnRearranger r = createColumnRearranger(in);
    DataTableSpec out = r.createSpec();
    return new DataTableSpec[] { out };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 68 with InvalidSettingsException

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

the class DialogComponentDate method updateModel.

/**
 * Writes the values immediately into the model.
 *
 * @throws InvalidSettingsException if the year is not an integer
 */
protected void updateModel() throws InvalidSettingsException {
    SettingsModelCalendar model = (SettingsModelCalendar) getModel();
    if (!model.useDate()) {
        // do not update/validate if date is not used by the model
        return;
    }
    Calendar calendar = model.getCalendar();
    // taking the index is perfectly fine, since Calendar
    // represents months as zero-based indices
    // (but not day of month)
    int month = m_monthUI.getSelectedIndex();
    int day = m_dayUI.getSelectedIndex() + 1;
    // First set month and day -> unlikely that an error occurs
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, day);
    model.setCalendar(calendar);
    try {
        // check whether the year contains only numbers
        int year = Integer.parseInt(m_yearUI.getText());
        calendar.set(Calendar.YEAR, year);
        model.setCalendar(calendar);
    } catch (NumberFormatException nfe) {
        throw new InvalidSettingsException("Not a valid year: " + m_yearUI.getText() + "! " + "Please use only integer numbers", nfe);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Calendar(java.util.Calendar)

Example 69 with InvalidSettingsException

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

the class SettingsModelCalendar method loadSettingsForDialog.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    try {
        Config internals = settings.getConfig(m_key);
        loadFromInternals(internals);
    } catch (InvalidSettingsException ise) {
        // load current time
        m_value = Calendar.getInstance(DateAndTimeCell.UTC_TIMEZONE);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Config(org.knime.core.node.config.Config)

Example 70 with InvalidSettingsException

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

the class MovingAggregationNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    if (inData == null || inData.length != 1) {
        throw new InvalidSettingsException("No input table available");
    }
    final BufferedDataTable table = inData[0];
    if (table.getRowCount() == 0) {
        setWarningMessage("Empty input table found");
    } else if (!m_cumulativeComputing.getBooleanValue() && table.getRowCount() < m_winLength.getIntValue()) {
        throw new InvalidSettingsException("Window length is larger than the number of rows of the input table");
    }
    final DataTableSpec spec = table.getDataTableSpec();
    final MovingAggregationTableFactory tableFactory = createTableFactory(FileStoreFactory.createWorkflowFileStoreFactory(exec), spec);
    BufferedDataTable resultTable = tableFactory.createTable(exec, table);
    return new BufferedDataTable[] { resultTable };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) BufferedDataTable(org.knime.core.node.BufferedDataTable)

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