Search in sources :

Example 1 with UserTimeEntry

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

the class UserTimeEntryViewerTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserTimeEntryViewerOutDto buildDto(UOW uow, Collection results) throws UOWException {
    UserTimeEntryViewerOutDto output = null;
    Iterator itr = results.iterator();
    if (itr.hasNext()) {
        // just return the details for the 1st record retrieved.
        UserTimeEntry userTimeEntry = (UserTimeEntry) itr.next();
        output = new UserTimeEntryViewerOutDto();
        // .//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
        output.setUserName(userTimeEntry.getUserName());
        // .//GEN-END:_buildDto_UserName_1_be
        // .//GEN-BEGIN:_buildDto_ProjectCode_1_be
        output.setProjectCode(userTimeEntry.getProjectCode());
        // .//GEN-END:_buildDto_ProjectCode_1_be
        // .//GEN-BEGIN:_buildDto_Activity_1_be
        output.setActivity(userTimeEntry.getActivity());
        // .//GEN-END:_buildDto_Activity_1_be
        // .//GEN-BEGIN:_buildDto_Task_1_be
        output.setTask(userTimeEntry.getTask());
        // .//GEN-END:_buildDto_Task_1_be
        // .//GEN-BEGIN:_buildDto_PeriodStart_1_be
        output.setPeriodStart(userTimeEntry.getPeriodStart());
        // .//GEN-END:_buildDto_PeriodStart_1_be
        // .//GEN-BEGIN:_buildDto_PeriodEnd_1_be
        output.setPeriodEnd(userTimeEntry.getPeriodEnd());
        // .//GEN-END:_buildDto_PeriodEnd_1_be
        // .//GEN-BEGIN:_buildDto_2_be
        // Add related objects, if required
        addRelatedDtos(uow, output, userTimeEntry);
    // .//GEN-END:_buildDto_2_be
    // Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
    // .//GEN-LAST:_buildDto_2
    // .//GEN-BEGIN:_buildDto_3_be
    }
    return output;
}
Also used : UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry) UserTimeEntryViewerOutDto(org.jaffa.applications.test.modules.time.components.usertimeentryviewer.dto.UserTimeEntryViewerOutDto)

Example 2 with UserTimeEntry

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

the class UserTimeEntryMaintenanceTx method create.

// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
 * Persists a new 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 UserTimeEntryMaintenanceRetrieveOutDto create(UserTimeEntryMaintenanceCreateInDto 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);
        // Do not allow a Duplicate record
        duplicateCheck(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Create the domain object
        UserTimeEntry domain = createDomain(uow, input, false);
        uow.add(domain);
        // Perform post create processing
        postCreate(uow, input, domain, false);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully created the domain object. Now retrieving the object details.");
        // Build the outbound dto by performing a retrieve
        UserTimeEntryMaintenanceRetrieveInDto retrieveInDto = new UserTimeEntryMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setUserName(input.getUserName());
        retrieveInDto.setProjectCode(input.getProjectCode());
        retrieveInDto.setTask(input.getTask());
        retrieveInDto.setPeriodStart(input.getPeriodStart());
        retrieveInDto.setPeriodEnd(input.getPeriodEnd());
        UserTimeEntryMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
        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)

Example 3 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:_preprocessDelete_2_be
// .//GEN-BEGIN:_loadDelete_1_be
/**
 * Retrieve the domain object.
 */
private UserTimeEntry load(UOW uow, UserTimeEntryMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    UserTimeEntry domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserTimeEntryMeta.getName());
    // .//GEN-END:_loadDelete_1_be
    // Add custom criteria //GEN-FIRST:_loadDelete_1
    // .//GEN-LAST:_loadDelete_1
    // .//GEN-BEGIN:_loadDelete_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());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (UserTimeEntry) itr.next();
    // .//GEN-BEGIN:_loadDelete_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 4 with UserTimeEntry

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

the class UserTimeEntryMaintenanceTx method delete.

/**
 * Deletes an existing instance of UserTimeEntry.
 * @param input The key values for the domain object to be deleted.
 * @param uow The delete will be performed using the input UOW.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 */
public void delete(UserTimeEntryMaintenanceDeleteInDto input, UOW uow) throws FrameworkException, ApplicationExceptions {
    // Print Debug Information for the input
    if (log.isDebugEnabled())
        log.debug("Input: " + (input != null ? input.toString() : null));
    // Preprocess the input
    preprocess(uow, input);
    // Retrieve the object
    UserTimeEntry domain = load(uow, input);
    // Delete the domain object
    deleteDomain(uow, input, domain);
    // Print Debug Information for the output
    if (log.isDebugEnabled())
        log.debug("The domain object has been marked for deletion. It will be deleted when the UOW is committed");
}
Also used : UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry)

Example 5 with UserTimeEntry

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

the class UserTimeEntryMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for UserTimeEntry.
 * @param input The criteria based on which an object will be retrieved.
 * @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details. A null indicates, the object was not found.
 */
public UserTimeEntryMaintenanceRetrieveOutDto retrieve(UserTimeEntryMaintenanceRetrieveInDto 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);
        // Convert the domain objects into the outbound dto
        UserTimeEntryMaintenanceRetrieveOutDto output = buildRetrieveOutDto(uow, input, domain);
        // 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