Search in sources :

Example 6 with User

use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.

the class RequestPasswordComponent method sendEmail.

public void sendEmail() {
    Criteria criteria = new Criteria();
    criteria.setTable(UserMeta.getName());
    if (this.getUserName() != null)
        criteria.addCriteria(UserMeta.USER_NAME, this.getUserName());
    if (this.getEmail() != null)
        criteria.addCriteria(UserMeta.E_MAIL_ADDRESS, this.getEmail());
    if (!this.getSecurityQuestion().equalsIgnoreCase("None"))
        criteria.addCriteria(UserMeta.SECURITY_QUESTION, this.getSecurityQuestion());
    if (this.getSecurityAnswer() != null)
        criteria.addCriteria(UserMeta.SECURITY_ANSWER, this.getSecurityAnswer());
    criteria.addCriteria(UserMeta.STATUS, "A");
    try {
        UOW uow = new UOW();
        if (!uow.query(criteria).isEmpty()) {
            StringBuffer body = new StringBuffer();
            if (uow.query(criteria).size() > 1) {
                body.append("You have " + uow.query(criteria).size() + " Active Accounts");
                int counter = 1;
                for (Iterator itr = uow.query(criteria).iterator(); itr.hasNext(); ) {
                    User ur = (User) itr.next();
                    body.append(", Account " + counter++ + ", User Name is " + ur.getUserName() + ", Security Question is '" + MessageHelper.replaceTokens("[label.Jaffa.User.UserRequest.SecurityQuestion." + ur.getSecurityQuestion() + "]") + "'");
                }
            } else {
                User ur = (User) uow.query(criteria).iterator().next();
                if (this.getUserName() != null) {
                    body.append("You have the following Active Account  ");
                    body.append(", User Name is " + ur.getUserName() + ", Password is " + ur.getPassword() + ".");
                } else if (this.getSecurityQuestion() != null && new Long(this.getSecurityQuestion()).equals(ur.getSecurityQuestion()) && (this.getSecurityAnswer().equals(ur.getSecurityAnswer()))) {
                    body.append("You have the following Active Account  ");
                    body.append(", User Name is " + ur.getUserName() + ", Password is " + ur.getPassword() + ".");
                } else {
                    body.append("You have the following Active Account");
                    body.append(", User Name is " + ur.getUserName() + ", Security Question is '" + MessageHelper.replaceTokens("[label.Jaffa.User.UserRequest.SecurityQuestion." + ur.getSecurityQuestion() + "]") + "'.");
                }
            }
            EmailerBean email = new EmailerBean();
            String[] to = new String[] { this.getEmail() };
            try {
                email.sendMail(to, "Account Information", body.toString());
            } catch (MessagingException e) {
                e.printStackTrace();
            }
        }
    } catch (UOWException e) {
        e.printStackTrace();
    }
}
Also used : User(org.jaffa.applications.jaffa.modules.admin.domain.User) UOWException(org.jaffa.persistence.exceptions.UOWException) MessagingException(javax.mail.MessagingException) EmailerBean(org.jaffa.util.EmailerBean) Criteria(org.jaffa.persistence.Criteria) UOW(org.jaffa.persistence.UOW)

Example 7 with User

use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.

the class UserFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserFinderOutDto buildDto(UOW uow, Collection results, UserFinderInDto input) throws UOWException {
    UserFinderOutDto output = new UserFinderOutDto();
    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;
        }
        UserFinderOutRowDto row = new UserFinderOutRowDto();
        User user = (User) 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(user.getUserName());
        // .//GEN-END:_buildDto_UserName_1_be
        // .//GEN-BEGIN:_buildDto_FirstName_1_be
        row.setFirstName(user.getFirstName());
        // .//GEN-END:_buildDto_FirstName_1_be
        // .//GEN-BEGIN:_buildDto_LastName_1_be
        row.setLastName(user.getLastName());
        // .//GEN-END:_buildDto_LastName_1_be
        // .//GEN-BEGIN:_buildDto_Status_1_be
        row.setStatus(user.getStatus());
        // .//GEN-END:_buildDto_Status_1_be
        // .//GEN-BEGIN:_buildDto_StatusDescription_1_be
        row.setStatusDescription(user.getStatus());
        // .//GEN-END:_buildDto_StatusDescription_1_be
        // .//GEN-BEGIN:_buildDto_EMailAddress_1_be
        row.setEMailAddress(user.getEMailAddress());
        // .//GEN-END:_buildDto_EMailAddress_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(user.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(user.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastUpdatedOn_1_be
        row.setLastUpdatedOn(user.getLastUpdatedOn());
        // .//GEN-END:_buildDto_LastUpdatedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastUpdatedBy_1_be
        row.setLastUpdatedBy(user.getLastUpdatedBy());
        // .//GEN-END:_buildDto_LastUpdatedBy_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 : User(org.jaffa.applications.jaffa.modules.admin.domain.User) UserFinderOutRowDto(org.jaffa.applications.jaffa.modules.admin.components.userfinder.dto.UserFinderOutRowDto) UserFinderOutDto(org.jaffa.applications.jaffa.modules.admin.components.userfinder.dto.UserFinderOutDto)

Example 8 with User

use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.

the class UserLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private UserLookupOutDto buildDto(UOW uow, Collection results, UserLookupInDto input) throws UOWException {
    UserLookupOutDto output = new UserLookupOutDto();
    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;
        }
        UserLookupOutRowDto row = new UserLookupOutRowDto();
        User user = (User) 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(user.getUserName());
        // .//GEN-END:_buildDto_UserName_1_be
        // .//GEN-BEGIN:_buildDto_FirstName_1_be
        row.setFirstName(user.getFirstName());
        // .//GEN-END:_buildDto_FirstName_1_be
        // .//GEN-BEGIN:_buildDto_LastName_1_be
        row.setLastName(user.getLastName());
        // .//GEN-END:_buildDto_LastName_1_be
        // .//GEN-BEGIN:_buildDto_Status_1_be
        row.setStatus(user.getStatus());
        // .//GEN-END:_buildDto_Status_1_be
        // .//GEN-BEGIN:_buildDto_StatusDescription_1_be
        row.setStatusDescription(user.getStatus());
        // .//GEN-END:_buildDto_StatusDescription_1_be
        // .//GEN-BEGIN:_buildDto_EMailAddress_1_be
        row.setEMailAddress(user.getEMailAddress());
        // .//GEN-END:_buildDto_EMailAddress_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(user.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(user.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastUpdatedOn_1_be
        row.setLastUpdatedOn(user.getLastUpdatedOn());
        // .//GEN-END:_buildDto_LastUpdatedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastUpdatedBy_1_be
        row.setLastUpdatedBy(user.getLastUpdatedBy());
        // .//GEN-END:_buildDto_LastUpdatedBy_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 : User(org.jaffa.applications.jaffa.modules.admin.domain.User) UserLookupOutRowDto(org.jaffa.applications.jaffa.modules.admin.components.userlookup.dto.UserLookupOutRowDto) UserLookupOutDto(org.jaffa.applications.jaffa.modules.admin.components.userlookup.dto.UserLookupOutDto)

Example 9 with User

use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.

the class UserMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates an existing instance of User.
 * @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 UserMaintenanceRetrieveOutDto update(UserMaintenanceUpdateInDto 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
        User domain = load(uow, input);
        // Ensure the domain object has not been modified
        domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastUpdatedOn());
        // 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
        UserMaintenanceRetrieveInDto retrieveInDto = new UserMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setUserName(input.getUserName());
        UserMaintenanceRetrieveOutDto 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 : User(org.jaffa.applications.jaffa.modules.admin.domain.User) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 10 with User

use of org.jaffa.applications.jaffa.modules.admin.domain.User in project jaffa-framework by jaffa-projects.

the class UserMaintenanceTx method delete.

/**
 * Deletes an existing instance of User.
 * @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(UserMaintenanceDeleteInDto 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
    User domain = load(uow, input);
    // Ensure the domain object has not been modified
    domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastUpdatedOn());
    // 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 : User(org.jaffa.applications.jaffa.modules.admin.domain.User)

Aggregations

User (org.jaffa.applications.jaffa.modules.admin.domain.User)15 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)9 UOW (org.jaffa.persistence.UOW)6 ApplicationException (org.jaffa.exceptions.ApplicationException)5 FrameworkException (org.jaffa.exceptions.FrameworkException)5 Criteria (org.jaffa.persistence.Criteria)4 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 MessagingException (javax.mail.MessagingException)1 UserFinderOutDto (org.jaffa.applications.jaffa.modules.admin.components.userfinder.dto.UserFinderOutDto)1 UserFinderOutRowDto (org.jaffa.applications.jaffa.modules.admin.components.userfinder.dto.UserFinderOutRowDto)1 UserLookupOutDto (org.jaffa.applications.jaffa.modules.admin.components.userlookup.dto.UserLookupOutDto)1 UserLookupOutRowDto (org.jaffa.applications.jaffa.modules.admin.components.userlookup.dto.UserLookupOutRowDto)1 UserViewerOutDto (org.jaffa.applications.jaffa.modules.admin.components.userviewer.dto.UserViewerOutDto)1 DateTime (org.jaffa.datatypes.DateTime)1 ValidationException (org.jaffa.datatypes.ValidationException)1 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)1 UOWException (org.jaffa.persistence.exceptions.UOWException)1 EmailerBean (org.jaffa.util.EmailerBean)1