Search in sources :

Example 11 with User

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

the class UserMaintenanceTx method load.

// .//GEN-END:_preprocessDelete_2_be
// .//GEN-BEGIN:_loadDelete_1_be
/**
 * Retrieve the domain object.
 */
private User load(UOW uow, UserMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    User domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserMeta.getName());
    // .//GEN-END:_loadDelete_1_be
    // Add custom criteria //GEN-FIRST:_loadDelete_1
    // .//GEN-LAST:_loadDelete_1
    // .//GEN-BEGIN:_loadDelete_2_be
    criteria.addCriteria(UserMeta.USER_NAME, input.getUserName());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (User) itr.next();
    // .//GEN-BEGIN:_loadDelete_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : User(org.jaffa.applications.jaffa.modules.admin.domain.User) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria)

Example 12 with User

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

the class UserMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private User createDomain(UOW uow, UserMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    User domain = new User();
    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.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.updateStatus(input.getStatus());
    } 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 {
        if (!fromPrevalidate)
            domain.updateCreatedOn(new DateTime());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        if (!fromPrevalidate && input.getHeaderDto() != null && input.getHeaderDto().getUserId() != null)
            domain.updateCreatedBy(input.getHeaderDto().getUserId());
    } 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 : User(org.jaffa.applications.jaffa.modules.admin.domain.User) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) DateTime(org.jaffa.datatypes.DateTime)

Example 13 with User

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

the class UserMaintenanceTx method load.

// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
 * Retrieve the domain object.
 */
private User load(UOW uow, UserMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    User domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(UserMeta.getName());
    // .//GEN-END:_loadUpdate_1_be
    // Add custom criteria //GEN-FIRST:_loadUpdate_1
    // .//GEN-LAST:_loadUpdate_1
    // .//GEN-BEGIN:_loadUpdate_2_be
    criteria.addCriteria(UserMeta.USER_NAME, input.getUserName());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (User) itr.next();
    // .//GEN-END:_loadUpdate_2_be
    // Add custom code //GEN-FIRST:_loadUpdate_2
    oldPassword = domain.getPassword();
    oldStatus = domain.getStatus();
    // .//GEN-BEGIN:_loadUpdate_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(UserMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : User(org.jaffa.applications.jaffa.modules.admin.domain.User) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria)

Example 14 with User

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

the class UserMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for User.
 * @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 UserMaintenanceRetrieveOutDto retrieve(UserMaintenanceRetrieveInDto 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);
        // Convert the domain objects into the outbound dto
        UserMaintenanceRetrieveOutDto 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 : 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 15 with User

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

the class UserMaintenanceTx method load.

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

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