Search in sources :

Example 6 with UserTimeEntry

use of org.jaffa.applications.test.modules.time.domain.UserTimeEntry in project jaffa-framework by jaffa-projects.

the class UserTimeEntryFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserTimeEntryFinderOutDto buildDto(UOW uow, Collection results, UserTimeEntryFinderInDto input) throws UOWException {
    UserTimeEntryFinderOutDto output = new UserTimeEntryFinderOutDto();
    int maxRecords = input.getMaxRecords() != null ? input.getMaxRecords().intValue() : 0;
    int counter = 0;
    for (Iterator i = results.iterator(); i.hasNext(); ) {
        if (++counter > maxRecords && maxRecords > 0) {
            output.setMoreRecordsExist(Boolean.TRUE);
            break;
        }
        UserTimeEntryFinderOutRowDto row = new UserTimeEntryFinderOutRowDto();
        UserTimeEntry userTimeEntry = (UserTimeEntry) i.next();
        // .//GEN-END:_buildDto_1_be
        // Add custom code before all the setters //GEN-FIRST:_buildDto_1
        // .//GEN-LAST:_buildDto_1
        // .//GEN-BEGIN:_buildDto_UserName_1_be
        row.setUserName(userTimeEntry.getUserName());
        // .//GEN-END:_buildDto_UserName_1_be
        // .//GEN-BEGIN:_buildDto_ProjectCode_1_be
        row.setProjectCode(userTimeEntry.getProjectCode());
        // .//GEN-END:_buildDto_ProjectCode_1_be
        // .//GEN-BEGIN:_buildDto_Activity_1_be
        row.setActivity(userTimeEntry.getActivity());
        // .//GEN-END:_buildDto_Activity_1_be
        // .//GEN-BEGIN:_buildDto_Task_1_be
        row.setTask(userTimeEntry.getTask());
        // .//GEN-END:_buildDto_Task_1_be
        // .//GEN-BEGIN:_buildDto_PeriodStart_1_be
        row.setPeriodStart(userTimeEntry.getPeriodStart());
        // .//GEN-END:_buildDto_PeriodStart_1_be
        // .//GEN-BEGIN:_buildDto_PeriodEnd_1_be
        row.setPeriodEnd(userTimeEntry.getPeriodEnd());
        // .//GEN-END:_buildDto_PeriodEnd_1_be
        // Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
        // .//GEN-LAST:_buildDto_2
        // .//GEN-BEGIN:_buildDto_3_be
        output.addRows(row);
    }
    return output;
}
Also used : UserTimeEntryFinderOutDto(org.jaffa.applications.test.modules.time.components.usertimeentryfinder.dto.UserTimeEntryFinderOutDto) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) UserTimeEntryFinderOutRowDto(org.jaffa.applications.test.modules.time.components.usertimeentryfinder.dto.UserTimeEntryFinderOutRowDto)

Example 7 with UserTimeEntry

use of org.jaffa.applications.test.modules.time.domain.UserTimeEntry in project jaffa-framework by jaffa-projects.

the class UserTimeEntryLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserTimeEntryLookupOutDto buildDto(UOW uow, Collection results, UserTimeEntryLookupInDto input) throws UOWException {
    UserTimeEntryLookupOutDto output = new UserTimeEntryLookupOutDto();
    int maxRecords = input.getMaxRecords() != null ? input.getMaxRecords().intValue() : 0;
    int counter = 0;
    for (Iterator i = results.iterator(); i.hasNext(); ) {
        if (++counter > maxRecords && maxRecords > 0) {
            output.setMoreRecordsExist(Boolean.TRUE);
            break;
        }
        UserTimeEntryLookupOutRowDto row = new UserTimeEntryLookupOutRowDto();
        UserTimeEntry userTimeEntry = (UserTimeEntry) i.next();
        // .//GEN-END:_buildDto_1_be
        // Add custom code before all the setters //GEN-FIRST:_buildDto_1
        // .//GEN-LAST:_buildDto_1
        // .//GEN-BEGIN:_buildDto_UserName_1_be
        row.setUserName(userTimeEntry.getUserName());
        // .//GEN-END:_buildDto_UserName_1_be
        // .//GEN-BEGIN:_buildDto_ProjectCode_1_be
        row.setProjectCode(userTimeEntry.getProjectCode());
        // .//GEN-END:_buildDto_ProjectCode_1_be
        // .//GEN-BEGIN:_buildDto_Activity_1_be
        row.setActivity(userTimeEntry.getActivity());
        // .//GEN-END:_buildDto_Activity_1_be
        // .//GEN-BEGIN:_buildDto_Task_1_be
        row.setTask(userTimeEntry.getTask());
        // .//GEN-END:_buildDto_Task_1_be
        // .//GEN-BEGIN:_buildDto_PeriodStart_1_be
        row.setPeriodStart(userTimeEntry.getPeriodStart());
        // .//GEN-END:_buildDto_PeriodStart_1_be
        // .//GEN-BEGIN:_buildDto_PeriodEnd_1_be
        row.setPeriodEnd(userTimeEntry.getPeriodEnd());
        // .//GEN-END:_buildDto_PeriodEnd_1_be
        // Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
        // .//GEN-LAST:_buildDto_2
        // .//GEN-BEGIN:_buildDto_3_be
        output.addRows(row);
    }
    return output;
}
Also used : UserTimeEntryLookupOutRowDto(org.jaffa.applications.test.modules.time.components.usertimeentrylookup.dto.UserTimeEntryLookupOutRowDto) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) UserTimeEntryLookupOutDto(org.jaffa.applications.test.modules.time.components.usertimeentrylookup.dto.UserTimeEntryLookupOutDto)

Example 8 with UserTimeEntry

use of org.jaffa.applications.test.modules.time.domain.UserTimeEntry in project jaffa-framework by jaffa-projects.

the class UserTimeEntryMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private UserTimeEntry createDomain(UOW uow, UserTimeEntryMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    UserTimeEntry domain = new UserTimeEntry();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateUserName(input.getUserName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateProjectCode(input.getProjectCode());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateActivity(input.getActivity());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateTask(input.getTask());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePeriodStart(input.getPeriodStart());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePeriodEnd(input.getPeriodEnd());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    // .//GEN-BEGIN:_createDomain_3_be
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry)

Example 9 with UserTimeEntry

use of org.jaffa.applications.test.modules.time.domain.UserTimeEntry in project jaffa-framework by jaffa-projects.

the class UserTimeEntryMaintenanceTx method load.

// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
 * Retrieve the domain object.
 */
private UserTimeEntry load(UOW uow, UserTimeEntryMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    UserTimeEntry domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserTimeEntryMeta.getName());
    // .//GEN-END:_loadRetrieve_1_be
    // Add custom criteria //GEN-FIRST:_loadRetrieve_1
    // .//GEN-LAST:_loadRetrieve_1
    // .//GEN-BEGIN:_loadRetrieve_2_be
    criteria.addCriteria(UserTimeEntryMeta.USER_NAME, input.getUserName());
    criteria.addCriteria(UserTimeEntryMeta.PROJECT_CODE, input.getProjectCode());
    criteria.addCriteria(UserTimeEntryMeta.TASK, input.getTask());
    criteria.addCriteria(UserTimeEntryMeta.PERIOD_START, input.getPeriodStart());
    criteria.addCriteria(UserTimeEntryMeta.PERIOD_END, input.getPeriodEnd());
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (UserTimeEntry) itr.next();
    // .//GEN-BEGIN:_loadRetrieve_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserTimeEntryMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) Criteria(org.jaffa.persistence.Criteria)

Example 10 with UserTimeEntry

use of org.jaffa.applications.test.modules.time.domain.UserTimeEntry in project jaffa-framework by jaffa-projects.

the class UserTimeEntryMaintenanceTx method prevalidateUpdate.

// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
 * This method is used to perform prevalidations before updating an existing instance of UserTimeEntry.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public UserTimeEntryMaintenancePrevalidateOutDto prevalidateUpdate(UserTimeEntryMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        UserTimeEntry domain = load(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, true);
        // Build the outbound dto
        UserTimeEntryMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + (output != null ? output.toString() : null));
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) UOW(org.jaffa.persistence.UOW)

Aggregations

UserTimeEntry (org.jaffa.applications.test.modules.time.domain.UserTimeEntry)13 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)9 ApplicationException (org.jaffa.exceptions.ApplicationException)5 FrameworkException (org.jaffa.exceptions.FrameworkException)5 UOW (org.jaffa.persistence.UOW)5 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 Criteria (org.jaffa.persistence.Criteria)3 UserTimeEntryFinderOutDto (org.jaffa.applications.test.modules.time.components.usertimeentryfinder.dto.UserTimeEntryFinderOutDto)1 UserTimeEntryFinderOutRowDto (org.jaffa.applications.test.modules.time.components.usertimeentryfinder.dto.UserTimeEntryFinderOutRowDto)1 UserTimeEntryLookupOutDto (org.jaffa.applications.test.modules.time.components.usertimeentrylookup.dto.UserTimeEntryLookupOutDto)1 UserTimeEntryLookupOutRowDto (org.jaffa.applications.test.modules.time.components.usertimeentrylookup.dto.UserTimeEntryLookupOutRowDto)1 UserTimeEntryViewerOutDto (org.jaffa.applications.test.modules.time.components.usertimeentryviewer.dto.UserTimeEntryViewerOutDto)1 ValidationException (org.jaffa.datatypes.ValidationException)1