@Override
 public List<QueryReportRunStep> list(
     String search,
     QueryReportRunStepType type,
     QueryReportRunStepStatus status,
     String sort,
     Order order,
     int page,
     int count)
     throws DataOperationException {
   Criteria criteria = new Criteria();
   if (!StringUtils.isBlank(search)) {
     final String pattern = "%" + search.replaceAll("\\*", "%") + "%";
     criteria.like("name", pattern);
   }
   if (type != null) {
     criteria.eq("type", type);
   }
   if (status != null) {
     criteria.eq("status", status);
   }
   if (!StringUtils.isBlank(sort)) {
     criteria.orderBy(sort, order == null ? Order.ASC : order);
   }
   return super.list(criteria.offset(page * count).rows(count));
 }
Beispiel #2
0
 /**
  * Returns the value of a property descriptor, or null if an error occurs.
  *
  * @param object The object instance to invoke the property descriptor on
  * @param field The field of the class of the object that corresponds with the property
  *     descriptor.
  * @param propertyDescriptor The property descriptor to invoke on the object.
  * @return The value of a property descriptor, or null if an error occurs.
  */
 public static Object propGetSafeAuto(
     final Object object, final Field field, final PropertyDescriptor propertyDescriptor) {
   if (IntrospectionUtils.isString(field)) {
     // It's a string
     return ReflectionUtils.propGetSafe(object, propertyDescriptor);
   } else if (IntrospectionUtils.isDate(field)) {
     // It's a date
     return DateUtils.safeToLong(ReflectionUtils.propGetDateSafe(object, propertyDescriptor));
   } else if (IntrospectionUtils.isToStringable(field)) {
     // It's toStringable
     return StringUtils.safeToString(ReflectionUtils.propGetSafe(object, propertyDescriptor));
   } else if (IntrospectionUtils.isIdentifiable(field)) {
     // It's identifiable
     final Identifiable<?> identifiable =
         ((Identifiable<?>) ReflectionUtils.propGetSafe(object, propertyDescriptor));
     if (identifiable == null) {
       return null;
     }
     return StringUtils.safeToString(identifiable.getId());
   } else if (IntrospectionUtils.isInt(field)) {
     // It's an int
     return ReflectionUtils.propGetSafe(object, propertyDescriptor);
   } else if (IntrospectionUtils.isLong(field)) {
     // It's a long
     return ReflectionUtils.propGetSafe(object, propertyDescriptor);
   } else if (IntrospectionUtils.isBoolean(field)) {
     // It's a boolean
     return ReflectionUtils.propGetSafe(object, propertyDescriptor);
   } else {
     log.warning(
         "Can't handle property getting of type "
             + field.getType()
             + " for field "
             + field.getName());
     return ReflectionUtils.propGetSafe(object, propertyDescriptor);
   }
 }
 /**
  * @see com.ajah.report.query.data.QueryReportRunStepDao#searchCount(String,
  *     QueryReportRunStepType, QueryReportRunStepStatus)
  */
 @Override
 public int searchCount(
     String search, QueryReportRunStepType type, QueryReportRunStepStatus status)
     throws DataOperationException {
   Criteria criteria = new Criteria();
   if (!StringUtils.isBlank(search)) {
     criteria.like("name", "%" + search.replaceAll("\\*", "%") + "%");
   }
   if (type != null) {
     criteria.eq("type", type);
   }
   if (status != null) {
     criteria.eq("status", status);
   }
   return super.count(criteria);
 }