Search in sources :

Example 11 with UserRequest

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

the class UserRequestMaintenanceTx method delete.

/**
 * Deletes an existing instance of UserRequest.
 * @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(UserRequestMaintenanceDeleteInDto 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
    UserRequest 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 : UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 12 with UserRequest

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

the class UserRequestMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for UserRequest.
 * @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 UserRequestMaintenanceRetrieveOutDto retrieve(UserRequestMaintenanceRetrieveInDto 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
        UserRequest domain = load(uow, input);
        // Convert the domain objects into the outbound dto
        UserRequestMaintenanceRetrieveOutDto 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) UOW(org.jaffa.persistence.UOW) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 13 with UserRequest

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

the class UserRequestMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates an existing 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 UserRequestMaintenanceRetrieveOutDto update(UserRequestMaintenanceUpdateInDto 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
        UserRequest domain = load(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, false);
        uow.update(domain);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully updated the domain object. Now retrieving the object details.");
        // Build the outbound dto by performing a retrieve
        UserRequestMaintenanceRetrieveInDto retrieveInDto = new UserRequestMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setRequestId(input.getRequestId());
        UserRequestMaintenanceRetrieveOutDto 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) UOW(org.jaffa.persistence.UOW) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 14 with UserRequest

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

the class UserRequestViewerTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserRequestViewerOutDto buildDto(UOW uow, Collection results) throws UOWException {
    UserRequestViewerOutDto output = null;
    Iterator itr = results.iterator();
    if (itr.hasNext()) {
        // just return the details for the 1st record retrieved.
        UserRequest userRequest = (UserRequest) itr.next();
        output = new UserRequestViewerOutDto();
        // .//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
        output.setRequestId(userRequest.getRequestId());
        // .//GEN-END:_buildDto_RequestId_1_be
        // .//GEN-BEGIN:_buildDto_UserName_1_be
        output.setUserName(userRequest.getUserName());
        // .//GEN-END:_buildDto_UserName_1_be
        // .//GEN-BEGIN:_buildDto_FirstName_1_be
        output.setFirstName(userRequest.getFirstName());
        // .//GEN-END:_buildDto_FirstName_1_be
        // .//GEN-BEGIN:_buildDto_LastName_1_be
        output.setLastName(userRequest.getLastName());
        // .//GEN-END:_buildDto_LastName_1_be
        // .//GEN-BEGIN:_buildDto_Password_1_be
        output.setPassword(userRequest.getPassword());
        // .//GEN-END:_buildDto_Password_1_be
        // .//GEN-BEGIN:_buildDto_EMailAddress_1_be
        output.setEMailAddress(userRequest.getEMailAddress());
        // .//GEN-END:_buildDto_EMailAddress_1_be
        // .//GEN-BEGIN:_buildDto_SecurityQuestion_1_be
        output.setSecurityQuestion(userRequest.getSecurityQuestion());
        // .//GEN-END:_buildDto_SecurityQuestion_1_be
        // .//GEN-BEGIN:_buildDto_SecurityAnswer_1_be
        output.setSecurityAnswer(userRequest.getSecurityAnswer());
        // .//GEN-END:_buildDto_SecurityAnswer_1_be
        // .//GEN-BEGIN:_buildDto_Remarks_1_be
        output.setRemarks(userRequest.getRemarks());
        // .//GEN-END:_buildDto_Remarks_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        output.setCreatedOn(userRequest.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_ProcessedDatetime_1_be
        output.setProcessedDatetime(userRequest.getProcessedDatetime());
        // .//GEN-END:_buildDto_ProcessedDatetime_1_be
        // .//GEN-BEGIN:_buildDto_ProcessedUserId_1_be
        output.setProcessedUserId(userRequest.getProcessedUserId());
        // .//GEN-END:_buildDto_ProcessedUserId_1_be
        // .//GEN-BEGIN:_buildDto_Status_1_be
        output.setStatus(userRequest.getStatus());
        // .//GEN-END:_buildDto_Status_1_be
        // .//GEN-BEGIN:_buildDto_2_be
        // Add related objects, if required
        addRelatedDtos(uow, output, userRequest);
    // .//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 : UserRequestViewerOutDto(org.jaffa.applications.jaffa.modules.user.components.userrequestviewer.dto.UserRequestViewerOutDto) UserRequest(org.jaffa.applications.jaffa.modules.user.domain.UserRequest)

Example 15 with UserRequest

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

the class UserMaintenanceTx method postCreate.

// .//GEN-END:_createDomain_3_be
// .//GEN-BEGIN:_postCreate_1_be
/**
 * This method is invoked after the domain object has been created.
 */
private User postCreate(UOW uow, UserMaintenanceCreateInDto input, User domain, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    // .//GEN-END:_postCreate_1_be
    // Add custom code //GEN-FIRST:_postCreate_1
    ApplicationExceptions appExps = null;
    String[] userRole = null;
    // Build an array of roles
    userRole = new String[input.getUserRoleCount()];
    UserRoleDto[] userRoleDtos = input.getUserRole();
    for (int i = 0; i < userRoleDtos.length; i++) userRole[i] = userRoleDtos[i].getRoleName();
    Arrays.sort(userRole);
    performUserRoleValidations(userRole, domain);
    if (!fromPrevalidate) {
        // add the the roles
        for (int i = 0; i < userRole.length; i++) {
            try {
                UserRole ur = new UserRole();
                ur.updateRoleName(userRole[i]);
                ur.updateUserName(input.getUserName());
                uow.add(ur);
            } catch (ValidationException e) {
                if (appExps == null)
                    appExps = new ApplicationExceptions();
                appExps.add(e);
            }
        }
    }
    if (input.getNotifyUser().booleanValue()) {
        try {
            EmailerBean email = new EmailerBean();
            String[] to = new String[] { domain.getEMailAddress() };
            String body = "Your UserName is " + domain.getUserName() + " and your password is " + domain.getPassword() + ". Your account is currently " + domain.getStatus() + ".";
            email.sendMail(to, "Account Information", body);
        } catch (javax.mail.MessagingException e) {
            e.printStackTrace();
        }
    }
    if (input.getRequestId() != null && input.getRequestId().length() > 0) {
        try {
            UserRequest userRequest = UserRequest.findByPK(uow, new Long(input.getRequestId()));
            userRequest.setStatus("S");
            uow.update(userRequest);
        } catch (ValidationException e) {
            if (appExps == null)
                appExps = new ApplicationExceptions();
            appExps.add(e);
        }
    }
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    // .//GEN-BEGIN:_postCreate_2_be
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) EmailerBean(org.jaffa.util.EmailerBean) UserRole(org.jaffa.applications.jaffa.modules.admin.domain.UserRole) 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