Example usage for com.liferay.portal.kernel.dao.orm RestrictionsFactoryUtil ge

List of usage examples for com.liferay.portal.kernel.dao.orm RestrictionsFactoryUtil ge

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm RestrictionsFactoryUtil ge.

Prototype

public static Criterion ge(String propertyName, Object value) 

Source Link

Usage

From source file:com.rivetlogic.event.service.impl.EventLocalServiceImpl.java

License:Open Source License

private DynamicQuery getUpcomingEventsDynamicQuery(boolean useOrder, long userId) {
    Date currentDate = new Date();
    Criterion criterion = RestrictionsFactoryUtil.ge(EVENT_DATE_COLUMN, currentDate);
    criterion = RestrictionsFactoryUtil.and(criterion, getOwnerOrPublicEventsCriterion(userId));
    return getEventsDynamicQuery(criterion, useOrder);
}

From source file:com.vietnamobile.service.impl.OnlinetestEntryLocalServiceImpl.java

License:Open Source License

private DynamicQuery buildDynamicQuery(String title, String userName, Date fromDate, Date toDate,
        Class<?> clazz, boolean andSearch) {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(clazz, getClassLoader());
    Junction junction = null;//  ww w .jav a 2 s .  c o  m
    if (andSearch) {
        junction = RestrictionsFactoryUtil.conjunction();
    } else {
        junction = RestrictionsFactoryUtil.disjunction();
    }

    if (Validator.isNotNull(userName)) {
        Property property = PropertyFactoryUtil.forName("userName");
        String value = (new StringBuilder("%")).append(userName).append("%").toString();
        junction.add(property.like(value));

    }
    if (Validator.isNotNull(title)) {
        Property property = PropertyFactoryUtil.forName("title");
        String value = (new StringBuilder("%")).append(title).append("%").toString();
        junction.add(property.like(value));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.ge("createDate", fromDate));
    }
    if (Validator.isNotNull(toDate) && Validator.isNull(fromDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.le("createDate", toDate));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNotNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.between("createDate", fromDate, toDate));
    }

    return dynamicQuery.add(junction);
}

From source file:com.vietnamobile.service.impl.OnlinetestResultEntryLocalServiceImpl.java

License:Open Source License

private DynamicQuery buildDynamicQuery(long userId, long onlinetestEntryId, String userName, double score,
        Date fromDate, Date toDate, String examType, Class<?> clazz, boolean andSearch) {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(clazz, getClassLoader());
    Junction junction = null;//from ww w. j ava  2  s  . c  om
    if (andSearch) {
        junction = RestrictionsFactoryUtil.conjunction();
    } else {
        junction = RestrictionsFactoryUtil.disjunction();
    }

    if (userId > 0) {
        Property property = PropertyFactoryUtil.forName("userId");
        junction.add(property.eq(Long.valueOf(userId)));
    }
    if (onlinetestEntryId > 0) {
        Property property = PropertyFactoryUtil.forName("onlineTestEntryId");
        junction.add(property.eq(Long.valueOf(onlinetestEntryId)));
    }
    if (Validator.isNotNull(userName)) {
        Property property = PropertyFactoryUtil.forName("userName");
        String value = (new StringBuilder("%")).append(userName).append("%").toString();
        junction.add(property.like(value));

    }
    if (Validator.isNotNull(examType)) {
        Property property = PropertyFactoryUtil.forName("examType");
        String value = (new StringBuilder("")).append(examType).toString();
        junction.add(property.eq(value));
    }
    if (score > 0) {
        Property property = PropertyFactoryUtil.forName("score");
        junction.add(property.eq(score));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.ge("createDate", fromDate));
    }
    if (Validator.isNotNull(toDate) && Validator.isNull(fromDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.le("createDate", toDate));
    }
    if (Validator.isNotNull(fromDate) && Validator.isNotNull(toDate)) {
        dynamicQuery.add(RestrictionsFactoryUtil.between("createDate", fromDate, toDate));
    }

    return dynamicQuery.add(junction);
}

From source file:it.smc.calendar.sync.calendar.util.CalendarUtil.java

License:Open Source License

public static List<CalendarBooking> getCalendarBookings(PermissionChecker permissionChecker, Calendar calendar,
        Date startDate, Date endDate) throws PortalException, SystemException {

    ClassLoader classLoader = ClassLoaderPool.getClassLoader("calendar-portlet");

    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(CalendarBooking.class, classLoader);

    dynamicQuery.add(RestrictionsFactoryUtil.eq("calendarId", calendar.getCalendarId()));

    Integer[] status = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_PENDING,
            9 /* CalendarBookingWorkflowConstants.STATUS_MAYBE */ };
    dynamicQuery.add(RestrictionsFactoryUtil.in("status", status));

    if (startDate != null) {
        dynamicQuery.add(RestrictionsFactoryUtil.ge("startTime", new Long(startDate.getTime())));
    }/* ww w. j av a  2  s  .  c  o  m*/

    if (endDate != null) {
        dynamicQuery.add(RestrictionsFactoryUtil.le("endTime", new Long(endDate.getTime())));
    }

    List<CalendarBooking> allCalendarBookings = CalendarBookingLocalServiceUtil.dynamicQuery(dynamicQuery);

    return filterCalendarBookings(allCalendarBookings, permissionChecker, ActionKeys.VIEW);
}

From source file:ru.inrecolan.statistics.service.impl.StatisticsLocalServiceImpl.java

License:Open Source License

 @SuppressWarnings("unchecked")
public List<Statistics> search(
      Date startDate, //from   w ww  .  j a  v  a2s  .c  om
       Date endDate,
       String url,
       boolean isAndOperator) {
      
    List<Statistics> audits = null;
   try {
      DynamicQuery auditQuery = DynamicQueryFactoryUtil.forClass(Statistics.class);
      Criterion sumCriterion = null;
      Criterion startDateCrit = RestrictionsFactoryUtil.ge("actionDate", startDate);
      Criterion endDateCrit = RestrictionsFactoryUtil.le("actionDate", endDate);               
      Criterion urlCrit = RestrictionsFactoryUtil.eq("url", url);
         
      if(isAndOperator) {
         if (isYearValid(startDate)) {
            if(sumCriterion == null) {
               sumCriterion = startDateCrit;
            }
         }
         if (isYearValid(endDate)) {
            if(sumCriterion == null) {
               sumCriterion = endDateCrit;
            } else {
               sumCriterion = RestrictionsFactoryUtil.and(sumCriterion, endDateCrit);
            };
         }
         if (url != null && !(url.equals(StringPool.BLANK))) {
            if(sumCriterion == null) {
               sumCriterion = urlCrit;
            } else {               
               sumCriterion = RestrictionsFactoryUtil.and(sumCriterion, urlCrit);
            }
         }      
      } else {
         if (isYearValid(startDate)) {
            if(sumCriterion == null) {
               sumCriterion = startDateCrit;
            }
         }
         if (isYearValid(endDate)) {
            if(sumCriterion == null) {
               sumCriterion = endDateCrit;
            } else {
               sumCriterion = RestrictionsFactoryUtil.or(sumCriterion, endDateCrit);
            };
         }
         if (url != null && !(url.equals(StringPool.BLANK))) {
            if(sumCriterion == null) {
               sumCriterion = urlCrit;
            } else {               
               sumCriterion = RestrictionsFactoryUtil.or(sumCriterion, urlCrit);
            }
         }               
      }
      if(sumCriterion != null) {
         auditQuery.add(sumCriterion);
      }
      audits = (List<Statistics>) StatisticsLocalServiceUtil
            .dynamicQuery(auditQuery);
   } catch (SystemException e) {
      _log.error("   ??     URL: " + e.getMessage());
   }
   return audits;
}