Search in sources :

Example 51 with GridModelRow

use of org.jaffa.presentation.portlet.widgets.model.GridModelRow 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)

Example 52 with GridModelRow

use of org.jaffa.presentation.portlet.widgets.model.GridModelRow in project jaffa-framework by jaffa-projects.

the class UserFinderAction method do_Rows_Update_Clicked.

// .//GEN-END:_do_Rows_View_Clicked_4_be
// .//GEN-BEGIN:_do_Rows_Update_Clicked_1_be
/**
 * Invokes the updateObject() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the Update screen.
 */
public FormKey do_Rows_Update_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:_do_Rows_Update_Clicked_1_be
    // Add custom code before processing the action //GEN-FIRST:_do_Rows_Update_Clicked_1
    // .//GEN-LAST:_do_Rows_Update_Clicked_1
    // .//GEN-BEGIN:_do_Rows_Update_Clicked_2_be
    UserFinderForm myForm = (UserFinderForm) form;
    UserFinderComponent myComp = (UserFinderComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null) {
        try {
            // .//GEN-END:_do_Rows_Update_Clicked_2_be
            // Add custom code before invoking the component //GEN-FIRST:_do_Rows_Update_Clicked_2
            // .//GEN-LAST:_do_Rows_Update_Clicked_2
            // .//GEN-BEGIN:_do_Rows_Update_Clicked_3_be
            fk = myComp.updateObject((java.lang.String) selectedRow.get("userName"));
        } catch (ApplicationExceptions e) {
            if (log.isDebugEnabled())
                log.debug("Update Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (FrameworkException e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getResultsFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 53 with GridModelRow

use of org.jaffa.presentation.portlet.widgets.model.GridModelRow in project jaffa-framework by jaffa-projects.

the class UserFinderAction method do_Rows_Delete_Clicked.

// .//GEN-END:_do_Rows_Update_Clicked_4_be
// .//GEN-BEGIN:_do_Rows_Delete_Clicked_1_be
/**
 * Invokes the deleteObject() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the Delete screen.
 */
public FormKey do_Rows_Delete_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:_do_Rows_Delete_Clicked_1_be
    // Add custom code before processing the action //GEN-FIRST:_do_Rows_Delete_Clicked_1
    // .//GEN-LAST:_do_Rows_Delete_Clicked_1
    // .//GEN-BEGIN:_do_Rows_Delete_Clicked_2_be
    UserFinderForm myForm = (UserFinderForm) form;
    UserFinderComponent myComp = (UserFinderComponent) myForm.getComponent();
    try {
        // This will stop double submits
        performTokenValidation(request);
        GridModel model = (GridModel) myForm.getRowsWM();
        GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
        if (selectedRow != null) {
            // .//GEN-END:_do_Rows_Delete_Clicked_2_be
            // Add custom code before invoking the component //GEN-FIRST:_do_Rows_Delete_Clicked_2
            // .//GEN-LAST:_do_Rows_Delete_Clicked_2
            // .//GEN-BEGIN:_do_Rows_Delete_Clicked_3_be
            fk = myComp.deleteObject((java.lang.String) selectedRow.get("userName"));
        }
    } catch (ApplicationExceptions e) {
        if (log.isDebugEnabled())
            log.debug("Delete Failed");
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getResultsFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 54 with GridModelRow

use of org.jaffa.presentation.portlet.widgets.model.GridModelRow in project jaffa-framework by jaffa-projects.

the class UserLookupAction method do_Rows_Update_Clicked.

// .//GEN-END:_do_Rows_View_Clicked_4_be
// .//GEN-BEGIN:_do_Rows_Update_Clicked_1_be
/**
 * Invokes the updateObject() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the Update screen.
 */
public FormKey do_Rows_Update_Clicked(String rowNum) {
    FormKey fk = null;
    // .//GEN-END:_do_Rows_Update_Clicked_1_be
    // Add custom code before processing the action //GEN-FIRST:_do_Rows_Update_Clicked_1
    // .//GEN-LAST:_do_Rows_Update_Clicked_1
    // .//GEN-BEGIN:_do_Rows_Update_Clicked_2_be
    UserLookupForm myForm = (UserLookupForm) form;
    UserLookupComponent myComp = (UserLookupComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null) {
        try {
            // .//GEN-END:_do_Rows_Update_Clicked_2_be
            // Add custom code before invoking the component //GEN-FIRST:_do_Rows_Update_Clicked_2
            // .//GEN-LAST:_do_Rows_Update_Clicked_2
            // .//GEN-BEGIN:_do_Rows_Update_Clicked_3_be
            fk = myComp.updateObject((java.lang.String) selectedRow.get("userName"));
        } catch (ApplicationExceptions e) {
            if (log.isDebugEnabled())
                log.debug("Update Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (FrameworkException e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getResultsFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Example 55 with GridModelRow

use of org.jaffa.presentation.portlet.widgets.model.GridModelRow in project jaffa-framework by jaffa-projects.

the class TaskFinderAction method do_Rows_Activate_Clicked.

/**
 * Invokes the activateTask() method on the component.
 * @param rowNum The selected row on the Results screen.
 * @return The FormKey for the Update screen.
 */
public FormKey do_Rows_Activate_Clicked(String rowNum) {
    FormKey fk = null;
    TaskFinderForm myForm = (TaskFinderForm) form;
    TaskFinderComponent myComp = (TaskFinderComponent) myForm.getComponent();
    GridModel model = (GridModel) myForm.getRowsWM();
    GridModelRow selectedRow = model.getRow(Integer.parseInt(rowNum));
    if (selectedRow != null) {
        try {
            myComp.activateTask((java.lang.String) selectedRow.get("scheduledTaskId"));
            fk = myComp.displayResults();
        } catch (ApplicationExceptions e) {
            if (log.isDebugEnabled())
                log.debug("Activate Task Failed");
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, e);
        } catch (FrameworkException e) {
            log.error(null, e);
            myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general");
        }
    }
    // Direct User back to current form
    if (fk == null)
        fk = myComp.getResultsFormKey();
    return fk;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) GridModel(org.jaffa.presentation.portlet.widgets.model.GridModel) FormKey(org.jaffa.presentation.portlet.FormKey) GridModelRow(org.jaffa.presentation.portlet.widgets.model.GridModelRow)

Aggregations

GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)136 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)113 FormKey (org.jaffa.presentation.portlet.FormKey)104 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)103 FrameworkException (org.jaffa.exceptions.FrameworkException)100 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)9 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)8 Iterator (java.util.Iterator)6 SimpleWidgetModel (org.jaffa.presentation.portlet.widgets.model.SimpleWidgetModel)4 DateTime (org.jaffa.datatypes.DateTime)3 MessageViewerOutDto (org.jaffa.modules.messaging.components.messageviewer.dto.MessageViewerOutDto)3 DateTimeModel (org.jaffa.presentation.portlet.widgets.model.DateTimeModel)3 DropDownModel (org.jaffa.presentation.portlet.widgets.model.DropDownModel)3 File (java.io.File)2 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 BusinessEventLogFinderOutDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderOutDto)2 BusinessEventLogFinderOutRowDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderOutRowDto)2 HeaderElementDto (org.jaffa.modules.messaging.components.messageviewer.dto.HeaderElementDto)2 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)2