Search in sources :

Example 1 with UserRequest

use of org.jaffa.applications.jaffa.modules.user.domain.UserRequest in project jaffa-framework by jaffa-projects.

the class UserRequestFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserRequestFinderOutDto buildDto(UOW uow, Collection results, UserRequestFinderInDto input) throws UOWException {
    UserRequestFinderOutDto output = new UserRequestFinderOutDto();
    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;
        }
        UserRequestFinderOutRowDto row = new UserRequestFinderOutRowDto();
        UserRequest userRequest = (UserRequest) 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_RequestId_1_be
        row.setRequestId(userRequest.getRequestId());
        // .//GEN-END:_buildDto_RequestId_1_be
        // .//GEN-BEGIN:_buildDto_UserName_1_be
        row.setUserName(userRequest.getUserName());
        // .//GEN-END:_buildDto_UserName_1_be
        // .//GEN-BEGIN:_buildDto_FirstName_1_be
        row.setFirstName(userRequest.getFirstName());
        // .//GEN-END:_buildDto_FirstName_1_be
        // .//GEN-BEGIN:_buildDto_LastName_1_be
        row.setLastName(userRequest.getLastName());
        // .//GEN-END:_buildDto_LastName_1_be
        // .//GEN-BEGIN:_buildDto_Password_1_be
        row.setPassword(userRequest.getPassword());
        // .//GEN-END:_buildDto_Password_1_be
        // .//GEN-BEGIN:_buildDto_EMailAddress_1_be
        row.setEMailAddress(userRequest.getEMailAddress());
        // .//GEN-END:_buildDto_EMailAddress_1_be
        // .//GEN-BEGIN:_buildDto_SecurityQuestion_1_be
        row.setSecurityQuestion(userRequest.getSecurityQuestion());
        // .//GEN-END:_buildDto_SecurityQuestion_1_be
        // .//GEN-BEGIN:_buildDto_SecurityAnswer_1_be
        row.setSecurityAnswer(userRequest.getSecurityAnswer());
        // .//GEN-END:_buildDto_SecurityAnswer_1_be
        // .//GEN-BEGIN:_buildDto_Remarks_1_be
        row.setRemarks(userRequest.getRemarks());
        // .//GEN-END:_buildDto_Remarks_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(userRequest.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_ProcessedDatetime_1_be
        row.setProcessedDatetime(userRequest.getProcessedDatetime());
        // .//GEN-END:_buildDto_ProcessedDatetime_1_be
        // .//GEN-BEGIN:_buildDto_ProcessedUserId_1_be
        row.setProcessedUserId(userRequest.getProcessedUserId());
        // .//GEN-END:_buildDto_ProcessedUserId_1_be
        // .//GEN-BEGIN:_buildDto_Status_1_be
        row.setStatus(userRequest.getStatus());
        // .//GEN-END:_buildDto_Status_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 : UserRequestFinderOutDto(org.jaffa.applications.jaffa.modules.user.components.userrequestfinder.dto.UserRequestFinderOutDto) UserRequestFinderOutRowDto(org.jaffa.applications.jaffa.modules.user.components.userrequestfinder.dto.UserRequestFinderOutRowDto) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 2 with UserRequest

use of org.jaffa.applications.jaffa.modules.user.domain.UserRequest in project jaffa-framework by jaffa-projects.

the class UserRequestMaintenanceTx method load.

// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
 * Retrieve the domain object.
 */
private UserRequest load(UOW uow, UserRequestMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    UserRequest domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserRequestMeta.getName());
    // .//GEN-END:_loadRetrieve_1_be
    // Add custom criteria //GEN-FIRST:_loadRetrieve_1
    // .//GEN-LAST:_loadRetrieve_1
    // .//GEN-BEGIN:_loadRetrieve_2_be
    criteria.addCriteria(UserRequestMeta.REQUEST_ID, input.getRequestId());
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (UserRequest) itr.next();
    // .//GEN-BEGIN:_loadRetrieve_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserRequestMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 3 with UserRequest

use of org.jaffa.applications.jaffa.modules.user.domain.UserRequest in project jaffa-framework by jaffa-projects.

the class UserRequestMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private UserRequest createDomain(UOW uow, UserRequestMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    UserRequest domain = new UserRequest();
    ApplicationExceptions appExps = null;
    // Add custom code //GEN-FIRST:_createDomain_1
    try {
        if (input.getPassword1() != null)
            domain.updatePassword(input.getPassword1());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateRequestId(input.getRequestId());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateUserName(input.getUserName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFirstName(input.getFirstName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateLastName(input.getLastName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateEMailAddress(input.getEMailAddress());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateSecurityQuestion(input.getSecurityQuestion());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateSecurityAnswer(input.getSecurityAnswer());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateRemarks(input.getRemarks());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateCreatedOn(input.getCreatedOn());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateProcessedDatetime(input.getProcessedDatetime());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateProcessedUserId(input.getProcessedUserId());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateStatus(input.getStatus());
    } 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) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 4 with UserRequest

use of org.jaffa.applications.jaffa.modules.user.domain.UserRequest in project jaffa-framework by jaffa-projects.

the class UserRequestMaintenanceTx method prevalidateCreate.

// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_prevalidateCreate_1_be
/**
 * This method is used to perform prevalidations before creating a new instance of UserRequest.
 * @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 UserRequestMaintenancePrevalidateOutDto prevalidateCreate(UserRequestMaintenanceCreateInDto 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
        UserRequest domain = createDomain(uow, input, true);
        // Perform post create processing
        postCreate(uow, input, domain, true);
        // Build the outbound dto
        UserRequestMaintenancePrevalidateOutDto 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) UOW(org.jaffa.persistence.UOW) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 5 with UserRequest

use of org.jaffa.applications.jaffa.modules.user.domain.UserRequest in project jaffa-framework by jaffa-projects.

the class UserRequestMaintenanceTx method load.

// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
 * Retrieve the domain object.
 */
private UserRequest load(UOW uow, UserRequestMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UserRequest domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserRequestMeta.getName());
    // .//GEN-END:_loadUpdate_1_be
    // Add custom criteria //GEN-FIRST:_loadUpdate_1
    // .//GEN-LAST:_loadUpdate_1
    // .//GEN-BEGIN:_loadUpdate_2_be
    criteria.addCriteria(UserRequestMeta.REQUEST_ID, input.getRequestId());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (UserRequest) itr.next();
    // .//GEN-BEGIN:_loadUpdate_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserRequestMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Aggregations

UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)16 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)10 UOW (org.jaffa.persistence.UOW)6 ApplicationException (org.jaffa.exceptions.ApplicationException)5 FrameworkException (org.jaffa.exceptions.FrameworkException)5 Criteria (org.jaffa.persistence.Criteria)5 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 ValidationException (org.jaffa.datatypes.ValidationException)2 EmailerBean (org.jaffa.util.EmailerBean)2 Iterator (java.util.Iterator)1 MessagingException (javax.mail.MessagingException)1 UserRole (org.jaffa.applications.jaffa.modules.admin.domain.UserRole)1 UserRequestFinderOutDto (org.jaffa.applications.jaffa.modules.user.components.userrequestfinder.dto.UserRequestFinderOutDto)1 UserRequestFinderOutRowDto (org.jaffa.applications.jaffa.modules.user.components.userrequestfinder.dto.UserRequestFinderOutRowDto)1 UserRequestLookupOutDto (org.jaffa.applications.jaffa.modules.user.components.userrequestlookup.dto.UserRequestLookupOutDto)1 UserRequestLookupOutRowDto (org.jaffa.applications.jaffa.modules.user.components.userrequestlookup.dto.UserRequestLookupOutRowDto)1 UserRequestViewerOutDto (org.jaffa.applications.jaffa.modules.user.components.userrequestviewer.dto.UserRequestViewerOutDto)1