Search in sources :

Example 16 with OrderByField

use of org.jaffa.components.finder.OrderByField in project jaffa-framework by jaffa-projects.

the class GraphComparator method compare.

public int compare(Object o1, Object o2) {
    int i = 0;
    if (o1 != null && o2 != null) {
        for (OrderByField orderByField : orderByFields) {
            try {
                Object v1 = BeanHelper.getField(o1, orderByField.getFieldName());
                Object v2 = BeanHelper.getField(o2, orderByField.getFieldName());
                i = v1 != null ? (v2 != null ? (v1 instanceof Comparable ? ((Comparable) v1).compareTo(v2) : 0) : 1) : (v2 != null ? -1 : 0);
                if (i != 0) {
                    // For a descending-sort, multiply the output by -1
                    if (orderByField.getSortAscending() != null && !orderByField.getSortAscending())
                        i *= -1;
                    break;
                }
            } catch (Exception e) {
                if (log.isDebugEnabled())
                    log.debug("Exception in enforcing orderBy clause '" + Arrays.toString(orderByFields) + "' on " + o1 + " and " + o2, e);
            }
        }
    } else if (o1 != null) {
        i = 1;
    } else if (o2 != null) {
        i = -1;
    }
    return i;
}
Also used : OrderByField(org.jaffa.components.finder.OrderByField)

Example 17 with OrderByField

use of org.jaffa.components.finder.OrderByField in project jaffa-framework by jaffa-projects.

the class UserTimeEntryFinderTx method buildCriteria.

// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(UserTimeEntryFinderInDto input, UOW uow) {
    Criteria criteria = new Criteria();
    criteria.setTable(UserTimeEntryMeta.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.getUserName(), UserTimeEntryMeta.USER_NAME, criteria);
    FinderTx.addCriteria(input.getProjectCode(), UserTimeEntryMeta.PROJECT_CODE, criteria);
    FinderTx.addCriteria(input.getActivity(), UserTimeEntryMeta.ACTIVITY, criteria);
    FinderTx.addCriteria(input.getTask(), UserTimeEntryMeta.TASK, criteria);
    FinderTx.addCriteria(input.getPeriodStart(), UserTimeEntryMeta.PERIOD_START, criteria);
    FinderTx.addCriteria(input.getPeriodEnd(), UserTimeEntryMeta.PERIOD_END, 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 18 with OrderByField

use of org.jaffa.components.finder.OrderByField in project jaffa-framework by jaffa-projects.

the class UserTimeEntryLookupTx method buildCriteria.

// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(UserTimeEntryLookupInDto input, UOW uow) {
    Criteria criteria = new Criteria();
    criteria.setTable(UserTimeEntryMeta.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.getUserName(), UserTimeEntryMeta.USER_NAME, criteria);
    FinderTx.addCriteria(input.getProjectCode(), UserTimeEntryMeta.PROJECT_CODE, criteria);
    FinderTx.addCriteria(input.getActivity(), UserTimeEntryMeta.ACTIVITY, criteria);
    FinderTx.addCriteria(input.getTask(), UserTimeEntryMeta.TASK, criteria);
    FinderTx.addCriteria(input.getPeriodStart(), UserTimeEntryMeta.PERIOD_START, criteria);
    FinderTx.addCriteria(input.getPeriodEnd(), UserTimeEntryMeta.PERIOD_END, 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 19 with OrderByField

use of org.jaffa.components.finder.OrderByField in project jaffa-framework by jaffa-projects.

the class UserFinderTx method buildCriteria.

// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(UserFinderInDto 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
    FinderTx.addCriteria(input.getUserName(), UserMeta.USER_NAME, criteria);
    FinderTx.addCriteria(input.getFirstName(), UserMeta.FIRST_NAME, criteria);
    FinderTx.addCriteria(input.getLastName(), UserMeta.LAST_NAME, criteria);
    FinderTx.addCriteria(input.getStatus(), UserMeta.STATUS, criteria);
    FinderTx.addCriteria(input.getEMailAddress(), UserMeta.E_MAIL_ADDRESS, 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 20 with OrderByField

use of org.jaffa.components.finder.OrderByField in project jaffa-framework by jaffa-projects.

the class FormTemplateLookupTx method buildCriteria.

// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(FormTemplateLookupInDto input, UOW uow) {
    Criteria criteria = new Criteria();
    criteria.setTable(FormTemplateMeta.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.getFormId(), FormTemplateMeta.FORM_ID, criteria);
    FinderTx.addCriteria(input.getTemplateData(), FormTemplateMeta.TEMPLATE_DATA, criteria);
    FinderTx.addCriteria(input.getLayoutData(), FormTemplateMeta.LAYOUT_DATA, 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)

Aggregations

OrderByField (org.jaffa.components.finder.OrderByField)31 Criteria (org.jaffa.persistence.Criteria)28 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)27 StringCriteriaField (org.jaffa.components.finder.StringCriteriaField)2 BusinessEventLogFinderInDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderInDto)2 BusinessEventLogFinderTx (org.jaffa.modules.messaging.components.businesseventlogfinder.tx.BusinessEventLogFinderTx)2 BusinessEventLogFinderOutDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderOutDto)1