Package org.crank.crud.criteria

Examples of org.crank.crud.criteria.OrderBy


public class CriteriaUtilsTest extends TestCase
{
    public void testOrderBy () {
        /* Create a list of OrderBy objects. */
        List<OrderBy> list = new ArrayList<OrderBy>();
        list.add(new OrderBy("foobar", OrderDirection.ASC));
        list.add(new OrderBy("baz", OrderDirection.DESC));
        /* Make this OrderBy one that is case insensitive. */
        OrderBy bacon = new OrderBy("bacon", OrderDirection.DESC);
        list.add(bacon);
        bacon.setCaseSensitive(false);
        /* Convert the list into an array. */
        OrderBy[] ob = list.toArray(new OrderBy[list.size()]);
        /* Invoke the utility class that constructs the Order By. */
        String orderByClause = CriteriaUtils.constructOrderBy(ob);
        assertEquals(" ORDER BY o.foobar ASC, o.baz DESC, UPPER( o.bacon ) DESC", orderByClause);
View Full Code Here


   * @param pref
   * @return
   */
  @SuppressWarnings("unchecked")
  private List<S> getList(String pref) {
    OrderBy orderBy = new OrderBy(propertyName, OrderDirection.ASC);
        /* Clear the comparison group b/c we are about to recreate it */
        dataSource.group().clear();
       
        /* Add the criteria */
        if (group.size() > 0) {
View Full Code Here

   * @param pref
   * @return
   */
  @SuppressWarnings("unchecked")
  private List<S> getListExact(String pref) {
    OrderBy orderBy = new OrderBy(propertyName, OrderDirection.ASC);
   
        /* Clear the comparison group b/c we are about to recreate it */
        dataSource.group().clear();
       
        /* Add the criteria */
 
View Full Code Here

      final int startPosition, final int maxResult) {

    if (orderBy != null) {
      List<OrderBy> list = new ArrayList<OrderBy>();
      for (String order : orderBy) {
        list.add(new OrderBy(order, OrderDirection.ASC));
      }
      return doFind(clazz, list.toArray(new OrderBy[orderBy.length]),
          criteria, fetches, startPosition, maxResult);

    } else {
View Full Code Here

    if (null != orderBys && orderBys.length > 0) {
      query.append(" ORDER BY ");

      for (int index = 0; index < orderBys.length; index++) {

                OrderBy cob = orderBys[index];
                if (cob == null) {
                    throw new IllegalStateException();
                }
                if (!cob.isCaseSensitive()){
                    query.append("UPPER( " );
                }
        if (!cob.isAlias()) {
          query.append("o." + cob.getName());
        } else {
          query.append(cob.getName());
        }
        query.append(" ");
                if (!cob.isCaseSensitive()){
                    query.append(") ");
                }
        query.append(cob.getDirection().toString());
        if (index + 1 < orderBys.length) {
          query.append(", ");
        }
      }
    }
View Full Code Here

      final int startPosition, final int maxResult) {

    if (orderBy != null) {
      List<OrderBy> list = new ArrayList<OrderBy>();
      for (String order : orderBy) {
        list.add(new OrderBy(order, OrderDirection.ASC));
      }
      return doFind(clazz, list.toArray(new OrderBy[orderBy.length]),
          criteria, fetches, startPosition, maxResult);

    } else {
View Full Code Here

TOP

Related Classes of org.crank.crud.criteria.OrderBy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.