Search in sources :

Example 1 with TaskMaintenanceDto

use of org.jaffa.modules.scheduler.components.taskmaintenance.dto.TaskMaintenanceDto in project jaffa-framework by jaffa-projects.

the class TaskMaintenanceTx method buildRetrieveOutDto.

private TaskMaintenanceOutDto buildRetrieveOutDto(ScheduledTask task) throws ApplicationExceptions, FrameworkException {
    TaskMaintenanceOutDto output = new TaskMaintenanceOutDto();
    output.setTaskMaintenanceDto(new TaskMaintenanceDto(task));
    output.setBusinessEventLog(buildBusinessEventLogDto(task));
    return output;
}
Also used : TaskMaintenanceDto(org.jaffa.modules.scheduler.components.taskmaintenance.dto.TaskMaintenanceDto) TaskMaintenanceOutDto(org.jaffa.modules.scheduler.components.taskmaintenance.dto.TaskMaintenanceOutDto)

Example 2 with TaskMaintenanceDto

use of org.jaffa.modules.scheduler.components.taskmaintenance.dto.TaskMaintenanceDto in project jaffa-framework by jaffa-projects.

the class TaskMaintenanceForm method doValidate0.

/**
 * This method should be invoked to ensure a valid state of the FormBean. It will validate the data in the models and set the corresponding properties.
 * Errors will be raised in the FormBean, if any validation fails.
 * @param request The request stream
 * @return A true indicates validations went through successfully.
 */
public boolean doValidate0(HttpServletRequest request) {
    TaskMaintenanceDto taskMaintenanceDto = ((TaskMaintenanceComponent) getComponent()).getTaskMaintenanceDto();
    String value;
    value = getScheduledTaskIdWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    taskMaintenanceDto.setScheduledTaskId(value);
    value = getTaskTypeWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    taskMaintenanceDto.setTaskType(value);
    value = getDescriptionWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    taskMaintenanceDto.setDescription(value);
    value = getRunAsWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    taskMaintenanceDto.setRunAs(value);
    taskMaintenanceDto.setStartOn(getStartOnWM().getDateTimeValue());
    taskMaintenanceDto.setEndOn(getEndOnWM().getDateTimeValue());
    value = getMisfireRecoveryWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    taskMaintenanceDto.setMisfireRecovery(value != null ? ScheduledTask.MisfireRecovery.valueOf(value) : null);
    taskMaintenanceDto.setCreatedOn(getCreatedOnWM().getDateTimeValue());
    value = getCreatedByWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    taskMaintenanceDto.setCreatedBy(value);
    taskMaintenanceDto.setLastChangedOn(getLastChangedOnWM().getDateTimeValue());
    value = getLastChangedByWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    taskMaintenanceDto.setLastChangedBy(value);
    value = getRecurrenceWM().getStringValue();
    if (value != null && value.length() == 0)
        value = null;
    if (value == null) {
        taskMaintenanceDto.setRecurrence(null);
    } else if (RecurrenceEnum.OFTEN.toString().equals(value)) {
        value = getOftenHoursWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        Integer hours = value != null ? new Integer(value) : null;
        value = getOftenMinutesWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        Integer minutes = value != null ? new Integer(value) : null;
        value = getOftenSecondsWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        Integer seconds = value != null ? new Integer(value) : null;
        taskMaintenanceDto.setRecurrence(new Recurrence.Often(hours, minutes, seconds));
    } else if (RecurrenceEnum.DAILY.toString().equals(value)) {
        taskMaintenanceDto.setRecurrence(new Recurrence.Daily(getDailyWeekDaysOnlyWM().getBooleanValue()));
    } else if (RecurrenceEnum.WEEKLY.toString().equals(value)) {
        value = getWeeklyFrequencyWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        Recurrence.WeekFrequency frequency = value != null ? Recurrence.WeekFrequency.valueOf(value) : null;
        value = getWeeklyDayWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        Recurrence.WeekDay day = value != null ? Recurrence.WeekDay.valueOf(value) : null;
        taskMaintenanceDto.setRecurrence(new Recurrence.Weekly(frequency, day));
    } else if (RecurrenceEnum.MONTHLY.toString().equals(value)) {
        Integer day = null;
        Recurrence.WeekFrequency weekFrequency = null;
        Recurrence.WeekDay weekDay = null;
        value = getMonthlyTypeWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        if (value == null || value.equals(MonthlyType.DAY.toString())) {
            value = getMonthlyDayWM().getStringValue();
            if (value != null && value.length() == 0)
                value = null;
            day = value != null ? new Integer(value) : null;
        } else {
            value = getMonthlyWeekFrequencyWM().getStringValue();
            if (value != null && value.length() == 0)
                value = null;
            weekFrequency = value != null ? Recurrence.WeekFrequency.valueOf(value) : null;
            value = getMonthlyWeekDayWM().getStringValue();
            if (value != null && value.length() == 0)
                value = null;
            weekDay = value != null ? Recurrence.WeekDay.valueOf(value) : null;
        }
        // Build the list of selected months
        Collection<Recurrence.Month> months = new TreeSet<Recurrence.Month>();
        for (Iterator itr = getMonthlyMonthsWM().getRows().iterator(); itr.hasNext(); ) {
            GridModelRow row = (GridModelRow) itr.next();
            for (int i = 0; i < MONTHS_GRID_COLUMNS; i++) {
                Boolean selected = ((SimpleWidgetModel) row.get("selected" + i)).getBooleanValue();
                if (selected != null && selected) {
                    Recurrence.Month month = (Recurrence.Month) row.get("value" + i);
                    months.add(month);
                }
            }
        }
        taskMaintenanceDto.setRecurrence(new Recurrence.Monthly(day, weekFrequency, weekDay, months.toArray(new Recurrence.Month[months.size()])));
    } else if (RecurrenceEnum.YEARLY.toString().equals(value)) {
        value = getYearlyFrequencyWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        Integer frequency = value != null ? new Integer(value) : null;
        value = getYearlyOnWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        Recurrence.Month on = value != null ? Recurrence.Month.valueOf(value) : null;
        taskMaintenanceDto.setRecurrence(new Recurrence.Yearly(frequency, on));
    } else if (RecurrenceEnum.CUSTOM.toString().equals(value)) {
        value = getCustomPatternWM().getStringValue();
        if (value != null && value.length() == 0)
            value = null;
        taskMaintenanceDto.setRecurrence(new Recurrence.Custom(value));
    } else
        taskMaintenanceDto.setRecurrence(null);
    return true;
}
Also used : TaskMaintenanceDto(org.jaffa.modules.scheduler.components.taskmaintenance.dto.TaskMaintenanceDto) Recurrence(org.jaffa.modules.scheduler.services.Recurrence) SimpleWidgetModel(org.jaffa.presentation.portlet.widgets.model.SimpleWidgetModel) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Aggregations

TaskMaintenanceDto (org.jaffa.modules.scheduler.components.taskmaintenance.dto.TaskMaintenanceDto)2 Iterator (java.util.Iterator)1 TreeSet (java.util.TreeSet)1 TaskMaintenanceOutDto (org.jaffa.modules.scheduler.components.taskmaintenance.dto.TaskMaintenanceOutDto)1 Recurrence (org.jaffa.modules.scheduler.services.Recurrence)1 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)1 SimpleWidgetModel (org.jaffa.presentation.portlet.widgets.model.SimpleWidgetModel)1