Search in sources :

Example 1 with SettingsModelCalendar

use of org.knime.timeseries.util.SettingsModelCalendar in project knime-core by knime.

the class DateGeneratorNodeDialog method createStartingPointModel.

/**
 * @return the calendar model for the starting point
 */
static SettingsModelCalendar createStartingPointModel() {
    Calendar c = Calendar.getInstance(DateAndTimeCell.UTC_TIMEZONE);
    c.setTimeInMillis(System.currentTimeMillis() + TimeZone.getDefault().getOffset(System.currentTimeMillis()));
    c.roll(Calendar.YEAR, false);
    return new SettingsModelCalendar("starting-point", c, true, true, false);
}
Also used : Calendar(java.util.Calendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar) DialogComponentCalendar(org.knime.timeseries.util.DialogComponentCalendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar)

Example 2 with SettingsModelCalendar

use of org.knime.timeseries.util.SettingsModelCalendar in project knime-core by knime.

the class DateShiftConfigure method createCalendarModel.

/*
     * Models...
     */
/**
 * @return settings model for the selected time
 */
public static SettingsModelCalendar createCalendarModel() {
    Calendar cal = DateAndTimeCell.getUTCCalendar();
    cal.setTimeInMillis(System.currentTimeMillis());
    SettingsModelCalendar smc = new SettingsModelCalendar(CFG_TIME, cal);
    smc.setEnabled(false);
    return smc;
}
Also used : Calendar(java.util.Calendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar)

Example 3 with SettingsModelCalendar

use of org.knime.timeseries.util.SettingsModelCalendar in project knime-core by knime.

the class DateGeneratorNodeDialog method createEndPointModel.

/**
 * @return the calendar model for the end point
 */
static SettingsModelCalendar createEndPointModel() {
    Calendar c = Calendar.getInstance(DateAndTimeCell.UTC_TIMEZONE);
    c.setTimeInMillis(System.currentTimeMillis() + TimeZone.getDefault().getOffset(System.currentTimeMillis()));
    return new SettingsModelCalendar("end-point", c, true, true, false);
}
Also used : Calendar(java.util.Calendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar) DialogComponentCalendar(org.knime.timeseries.util.DialogComponentCalendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar)

Example 4 with SettingsModelCalendar

use of org.knime.timeseries.util.SettingsModelCalendar in project knime-core by knime.

the class DateGeneratorNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_from.validateSettings(settings);
    m_to.validateSettings(settings);
    m_noOfRows.validateSettings(settings);
    // we only validate the true date if we do not use the execution time
    boolean checkFrom = true;
    try {
        SettingsModelBoolean useEx = m_useExecution.createCloneWithValidatedValue(settings);
        if (useEx.getBooleanValue()) {
            checkFrom = false;
        }
    } catch (Exception e) {
    // Do nothing, backward compatibility
    }
    if (checkFrom) {
        SettingsModelCalendar from = m_from.createCloneWithValidatedValue(settings);
        validateDates(from);
    }
    SettingsModelCalendar to = m_to.createCloneWithValidatedValue(settings);
    validateDates(to);
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IOException(java.io.IOException)

Example 5 with SettingsModelCalendar

use of org.knime.timeseries.util.SettingsModelCalendar in project knime-core by knime.

the class ExtractTimeWindowNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    // first do the basic checking
    m_columnName.validateSettings(settings);
    m_fromDate.validateSettings(settings);
    m_toDate.validateSettings(settings);
    // check whether the from date is equal or later than the to date
    Calendar from = ((SettingsModelCalendar) m_fromDate.createCloneWithValidatedValue(settings)).getCalendar();
    Calendar to = ((SettingsModelCalendar) m_toDate.createCloneWithValidatedValue(settings)).getCalendar();
    if (to.before(from)) {
        throw new InvalidSettingsException("The starting point must be before the end point!");
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Calendar(java.util.Calendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar) SettingsModelCalendar(org.knime.timeseries.util.SettingsModelCalendar)

Aggregations

SettingsModelCalendar (org.knime.timeseries.util.SettingsModelCalendar)5 Calendar (java.util.Calendar)4 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 DialogComponentCalendar (org.knime.timeseries.util.DialogComponentCalendar)2 IOException (java.io.IOException)1 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)1 SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)1