Search in sources :

Example 96 with Criteria

use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.

the class UserViewerTx method read.

// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_read_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 UserViewerOutDto read(UserViewerInDto 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();
        // Build the Criteria Object
        Criteria criteria = buildCriteria(input, uow);
        // .//GEN-END:_read_1_be
        // Add custom code before the query //GEN-FIRST:_read_1
        // .//GEN-LAST:_read_1
        // .//GEN-BEGIN:_read_2_be
        // Execute The Query
        Collection results = uow.query(criteria);
        // .//GEN-END:_read_2_be
        // Add custom code after the query //GEN-FIRST:_read_2
        // .//GEN-LAST:_read_2
        // .//GEN-BEGIN:_read_3_be
        // Convert the domain objects into the outbound dto
        UserViewerOutDto output = buildDto(uow, results);
        // Print Debug Information for the output
        if (log.isDebugEnabled()) {
            log.debug("Output: " + (output != null ? output.toString() : null));
        }
        return output;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : UserViewerOutDto(org.jaffa.applications.jaffa.modules.admin.components.userviewer.dto.UserViewerOutDto) Criteria(org.jaffa.persistence.Criteria) UOW(org.jaffa.persistence.UOW)

Example 97 with Criteria

use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.

the class UserViewerTx method buildCriteria.

// .//GEN-END:_read_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(UserViewerInDto input, UOW uow) {
    Criteria criteria = new Criteria();
    criteria.setTable(UserMeta.getName());
    // .//GEN-END:_buildCriteria_1_be
    // Add custom criteria //GEN-FIRST:_buildCriteria_1
    // .//GEN-LAST:_buildCriteria_1
    // .//GEN-BEGIN:_buildCriteria_2_be
    criteria.addCriteria(UserMeta.USER_NAME, input.getUserName());
    // .//GEN-BEGIN:_buildCriteria_3_be
    return criteria;
}
Also used : Criteria(org.jaffa.persistence.Criteria)

Example 98 with Criteria

use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.

the class UserViewerTx method addRelatedDtos.

// .//GEN-END:_buildDto_3_be
// .//GEN-BEGIN:_addRelatedDtos_1_be
private void addRelatedDtos(UOW uow, UserViewerOutDto output, User user) throws UOWException {
    // .//GEN-BEGIN:_addRelatedDtos_UserRole_1_be
    if (user.getUserName() != null) {
        Criteria criteria = new Criteria();
        criteria.setTable(UserRoleMeta.getName());
        criteria.addCriteria(UserRoleMeta.USER_NAME, user.getUserName());
        criteria.addOrderBy("UserName", Criteria.ORDER_BY_ASC);
        criteria.addOrderBy("RoleName", Criteria.ORDER_BY_ASC);
        // .//GEN-END:_addRelatedDtos_UserRole_1_be
        // Add custom code to set the criteria before the query //GEN-FIRST:_addRelatedDtos_UserRole_1
        // .//GEN-LAST:_addRelatedDtos_UserRole_1
        // .//GEN-BEGIN:_addRelatedDtos_UserRole_2_be
        Iterator itr = uow.query(criteria).iterator();
        while (itr.hasNext()) {
            UserRole userRole = (UserRole) itr.next();
            UserRoleDto dto = new UserRoleDto();
            // .//GEN-END:_addRelatedDtos_UserRole_2_be
            // Add custom code before all the setters //GEN-FIRST:_addRelatedDtos_UserRole_2
            // .//GEN-LAST:_addRelatedDtos_UserRole_2
            // .//GEN-BEGIN:_addRelatedDtos_UserRole_UserName_1_be
            dto.setUserName(userRole.getUserName());
            // .//GEN-END:_addRelatedDtos_UserRole_UserName_1_be
            // .//GEN-BEGIN:_addRelatedDtos_UserRole_RoleName_1_be
            dto.setRoleName(userRole.getRoleName());
            // .//GEN-END:_addRelatedDtos_UserRole_RoleName_1_be
            // Add custom code to pass values to the dto //GEN-FIRST:_addRelatedDtos_UserRole_3
            // .//GEN-LAST:_addRelatedDtos_UserRole_3
            // .//GEN-BEGIN:_addRelatedDtos_UserRole_3_be
            output.addUserRole(dto);
        }
    }
// .//GEN-END:_addRelatedDtos_UserRole_3_be
// .//GEN-BEGIN:_addRelatedDtos_2_be
}
Also used : UserRoleDto(org.jaffa.applications.jaffa.modules.admin.components.userviewer.dto.UserRoleDto) UserRole(org.jaffa.applications.jaffa.modules.admin.domain.UserRole) Criteria(org.jaffa.persistence.Criteria)

Example 99 with Criteria

use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.

the class UserRequestFinderTx method buildCriteria.

// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(UserRequestFinderInDto input, UOW uow) {
    Criteria criteria = new Criteria();
    criteria.setTable(UserRequestMeta.getName());
    // .//GEN-END:_buildCriteria_1_be
    // Add custom criteria //GEN-FIRST:_buildCriteria_1
    // .//GEN-LAST:_buildCriteria_1
    // .//GEN-BEGIN:_buildCriteria_2_be
    FinderTx.addCriteria(input.getRequestId(), UserRequestMeta.REQUEST_ID, criteria);
    FinderTx.addCriteria(input.getUserName(), UserRequestMeta.USER_NAME, criteria);
    FinderTx.addCriteria(input.getFirstName(), UserRequestMeta.FIRST_NAME, criteria);
    FinderTx.addCriteria(input.getLastName(), UserRequestMeta.LAST_NAME, criteria);
    FinderTx.addCriteria(input.getPassword(), UserRequestMeta.PASSWORD, criteria);
    FinderTx.addCriteria(input.getEMailAddress(), UserRequestMeta.E_MAIL_ADDRESS, criteria);
    FinderTx.addCriteria(input.getSecurityQuestion(), UserRequestMeta.SECURITY_QUESTION, criteria);
    FinderTx.addCriteria(input.getSecurityAnswer(), UserRequestMeta.SECURITY_ANSWER, criteria);
    FinderTx.addCriteria(input.getRemarks(), UserRequestMeta.REMARKS, criteria);
    FinderTx.addCriteria(input.getCreatedOn(), UserRequestMeta.CREATED_ON, criteria);
    FinderTx.addCriteria(input.getProcessedDatetime(), UserRequestMeta.PROCESSED_DATETIME, criteria);
    FinderTx.addCriteria(input.getProcessedUserId(), UserRequestMeta.PROCESSED_USER_ID, criteria);
    FinderTx.addCriteria(input.getStatus(), UserRequestMeta.STATUS, criteria);
    // append an orderBy clause to the criteria
    OrderByField[] orderByFields = input.getOrderByFields();
    if (orderByFields != null) {
        for (int i = 0; i < orderByFields.length; i++) {
            OrderByField orderByField = orderByFields[i];
            int sort = Criteria.ORDER_BY_ASC;
            if (orderByField.getSortAscending() != null && !orderByField.getSortAscending().booleanValue())
                sort = Criteria.ORDER_BY_DESC;
            criteria.addOrderBy(orderByField.getFieldName(), sort);
        }
    }
    // .//GEN-BEGIN:_buildCriteria_3_be
    return criteria;
}
Also used : OrderByField(org.jaffa.components.finder.OrderByField) AtomicCriteria(org.jaffa.persistence.AtomicCriteria) Criteria(org.jaffa.persistence.Criteria)

Example 100 with Criteria

use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.

the class UserRequestLookupTx method find.

// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_find_1_be
/**
 * Searches for UserRequest objects.
 * @param input The criteria based on which the search will be performed.
 * @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
 * @throws FrameworkException Indicates some system error
 * @return The search results.
 */
public UserRequestLookupOutDto find(UserRequestLookupInDto 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();
        // Build the Criteria Object
        Criteria criteria = buildCriteria(input, uow);
        // .//GEN-END:_find_1_be
        // Add custom code before the query //GEN-FIRST:_find_1
        // .//GEN-LAST:_find_1
        // .//GEN-BEGIN:_find_2_be
        // Execute The Query
        Collection results = uow.query(criteria);
        // .//GEN-END:_find_2_be
        // Add custom code after the query //GEN-FIRST:_find_2
        // .//GEN-LAST:_find_2
        // .//GEN-BEGIN:_find_3_be
        // Convert the domain objects into the outbound dto
        UserRequestLookupOutDto output = buildDto(uow, results, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled()) {
            log.debug("Output: " + (output != null ? output.toString() : null));
        }
        return output;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : UserRequestLookupOutDto(org.jaffa.applications.jaffa.modules.user.components.userrequestlookup.dto.UserRequestLookupOutDto) AtomicCriteria(org.jaffa.persistence.AtomicCriteria) Criteria(org.jaffa.persistence.Criteria) UOW(org.jaffa.persistence.UOW)

Aggregations

Criteria (org.jaffa.persistence.Criteria)300 UOW (org.jaffa.persistence.UOW)136 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)124 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)66 Iterator (java.util.Iterator)53 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)39 TransactionCriteria (org.jaffa.transaction.apis.data.TransactionCriteria)32 TransactionFieldCriteria (org.jaffa.transaction.apis.data.TransactionFieldCriteria)32 OrderByField (org.jaffa.components.finder.OrderByField)28 Map (java.util.Map)23 ArrayList (java.util.ArrayList)17 DateTime (org.jaffa.datatypes.DateTime)16 FrameworkException (org.jaffa.exceptions.FrameworkException)14 ApplicationException (org.jaffa.exceptions.ApplicationException)13 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)13 Transaction (org.jaffa.transaction.domain.Transaction)13 Collection (java.util.Collection)12 LinkedHashMap (java.util.LinkedHashMap)11 IPersistent (org.jaffa.persistence.IPersistent)11 HashMap (java.util.HashMap)9