Example usage for org.hibernate.criterion Restrictions lt

List of usage examples for org.hibernate.criterion Restrictions lt

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions lt.

Prototype

public static SimpleExpression lt(String propertyName, Object value) 

Source Link

Document

Apply a "less than" constraint to the named property

Usage

From source file:org.dspace.harvest.dao.impl.HarvestedCollectionDAOImpl.java

License:BSD License

@Override
public List<HarvestedCollection> findByLastHarvestedAndHarvestTypeAndHarvestStatusesAndHarvestTime(
        Context context, Date startTime, int minimalType, int[] statuses, int expirationStatus,
        Date expirationTime) throws SQLException {
    //      Old query: "SELECT * FROM harvested_collection WHERE
    // (last_harvested < ? or last_harvested is null) and harvest_type > ? and (harvest_status = ? or harvest_status = ? or (harvest_status=? and harvest_start_time < ?)) ORDER BY last_harvested",
    //                new java.sql.Timestamp(startTime.getTime()), 0, HarvestedCollection.STATUS_READY, HarvestedCollection.STATUS_OAI_ERROR, HarvestedCollection.STATUS_BUSY, new java.sql.Timestamp(expirationTime.getTime()));
    Criteria criteria = createCriteria(context, HarvestedCollection.class);
    LogicalExpression lastHarvestedRestriction = Restrictions.or(Restrictions.lt("lastHarvested", startTime),
            Restrictions.isNull("lastHarvested"));
    Disjunction statusRestriction = Restrictions.or();
    for (int status : statuses) {
        statusRestriction.add(Restrictions.eq("harvestStatus", status));
    }/*from   www  .  j a  v  a 2 s .c  o  m*/
    statusRestriction.add(Restrictions.and(Restrictions.eq("harvestStatus", expirationStatus),
            Restrictions.gt("harvestStartTime", expirationTime)));

    criteria.add(Restrictions.and(lastHarvestedRestriction, Restrictions.gt("harvestType", minimalType),
            statusRestriction

    ));
    criteria.addOrder(Order.asc("lastHarvested"));
    return list(criteria);

}

From source file:org.egov.egf.web.actions.masters.JQueryGridActionSupport.java

License:Open Source License

/**
 * Used to convert jqgrid search operator to hibernate restriction.
 **//*from  ww w .  j  a  va 2 s.  c o  m*/
private Criterion applyRestriction() {
    final Object convertedValue = convertValueType(searchField, searchString);

    if ("eq".equals(searchOper))
        return Restrictions.eq(searchField, convertedValue);
    else if ("ne".equals(searchOper))
        return Restrictions.ne(searchField, convertedValue);

    if (convertedValue instanceof String) {
        if ("bw".equals(searchOper))
            return Restrictions.ilike(searchField, searchString + "%");
        else if ("cn".equals(searchOper))
            return Restrictions.ilike(searchField, "%" + searchString + "%");
        else if ("ew".equals(searchOper))
            return Restrictions.ilike(searchField, "%" + searchString);
        else if ("bn".equals(searchOper))
            return Restrictions.not(Restrictions.ilike(searchField, searchString + "%"));
        else if ("en".equals(searchOper))
            return Restrictions.not(Restrictions.ilike(searchField, "%" + searchString));
        else if ("nc".equals(searchOper))
            return Restrictions.not(Restrictions.ilike(searchField, "%" + searchString + "%"));
        else if ("in".equals(searchOper))
            return Restrictions.in(searchField, searchString.split(","));
        else if ("ni".equals(searchOper))
            return Restrictions.not(Restrictions.in(searchField, searchString.split(",")));
    } else if ("lt".equals(searchOper))
        return Restrictions.lt(searchField, convertedValue);
    else if ("le".equals(searchOper))
        return Restrictions.le(searchField, convertedValue);
    else if ("gt".equals(searchOper))
        return Restrictions.gt(searchField, convertedValue);
    else if ("ge".equals(searchOper))
        return Restrictions.ge(searchField, convertedValue);
    return null;
}

From source file:org.egov.pgr.service.ComplaintEscalationService.java

License:Open Source License

public List<Complaint> getComplaintsEligibleForEscalation() {
    Criteria criteria = entityManager.unwrap(Session.class).createCriteria(Complaint.class, "complaint")
            .createAlias("complaint.status", "complaintStatus");

    criteria.add(Restrictions.disjunction().add(Restrictions.eq(COMPLAINT_STATUS_NAME, REOPENED.name()))
            .add(Restrictions.eq(COMPLAINT_STATUS_NAME, FORWARDED.name()))
            .add(Restrictions.eq(COMPLAINT_STATUS_NAME, PROCESSING.name()))
            .add(Restrictions.eq(COMPLAINT_STATUS_NAME, REGISTERED.name())))
            .add(Restrictions.lt("complaint.escalationDate", new Date()))
            .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);

    return criteria.list();
}

From source file:org.egov.ptis.domain.dao.property.TaxPercHibernateDAO.java

License:Open Source License

@Override
public TaxPerc getTaxPerc(Category category, PropertyUsage propertyUsage, BigDecimal amount, Date date) {
    LOGGER.info("getTaxPerc invoked");
    TaxPerc taxPerc = null;/* w w w .  j  ava 2  s  . c  om*/
    Criteria crit = getCurrentSession().createCriteria(TaxPerc.class);
    if (category != null) {
        crit.add(Restrictions.eq("category", category));
    }
    if (propertyUsage != null) {
        crit.add(Restrictions.eq("propertyUsage", propertyUsage));
    }
    if (amount != null) {
        crit.add(Restrictions.le("fromAmt", amount));
        crit.add(Restrictions.ge("toAmt", amount));
    }
    if (date != null) {
        crit.add(Restrictions.lt("fromDate", date));
        crit.add(Restrictions.gt("toDate", date));
    }
    if (crit.list().size() == 1) {
        taxPerc = (TaxPerc) crit.uniqueResult();
    }
    return taxPerc;
}

From source file:org.emonocot.persistence.dao.hibernate.ResourceDaoImpl.java

License:Open Source License

@Override
public List<Resource> listResourcesToHarvest(Integer limit, DateTime now, String fetch) {
    Criteria criteria = getSession().createCriteria(type);
    criteria.add(Restrictions.isNotNull("resourceType"));
    criteria.add(Restrictions.in("status", Arrays.asList(new BatchStatus[] { BatchStatus.COMPLETED,
            BatchStatus.FAILED, BatchStatus.ABANDONED, BatchStatus.STOPPED })));
    criteria.add(Restrictions.eq("scheduled", Boolean.TRUE));
    criteria.add(Restrictions.disjunction().add(Restrictions.lt("nextAvailableDate", now))
            .add(Restrictions.isNull("nextAvailableDate")));

    if (limit != null) {
        criteria.setMaxResults(limit);//from www .j a v  a  2 s.  c  o  m
    }
    enableProfilePreQuery(criteria, fetch);
    criteria.addOrder(Property.forName("nextAvailableDate").asc());
    List<Resource> result = (List<Resource>) criteria.list();
    for (Resource t : result) {
        enableProfilePostQuery(t, fetch);
    }
    return result;
}

From source file:org.esn.esobase.data.DBService.java

@Transactional
public BeanItemContainer<Npc> getNpcs(BeanItemContainer<Npc> container, TRANSLATE_STATUS translateStatus,
        SysAccount translator, boolean noTranslations) {
    container.removeAllItems();/*w  ww  .  ja  va 2 s  .  c o m*/
    Session session = (Session) em.getDelegate();
    Criteria crit = session.createCriteria(Npc.class);
    crit.setFetchMode("location", FetchMode.JOIN);
    if (translateStatus != null && translator != null) {
        Query q = em.createNativeQuery(
                "select npc_id from (select t.npc_id from translatedtext tt join topic t on tt.npctopic_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join topic t on tt.playertopic_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join greeting t on tt.greeting_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join subtitle t on tt.subtitle_id=t.id where tt.status=:translateStatus and tt.author_id=:authorId) as rr group by npc_id");
        q.setParameter("authorId", translator.getId());
        q.setParameter("translateStatus", translateStatus.name());
        List<BigInteger> resultList = q.getResultList();
        List<Long> longResultList = new ArrayList();
        for (BigInteger id : resultList) {
            longResultList.add(id.longValue());
        }
        if (longResultList.isEmpty()) {
            longResultList.add(0L);
        }
        crit.add(Restrictions.in("id", longResultList));
    } else if (translateStatus != null) {
        Query q = em.createNativeQuery(
                "select npc_id from (select t.npc_id from translatedtext tt join topic t on tt.npctopic_id=t.id where tt.status=:translateStatus\n"
                        + "union all select t.npc_id from translatedtext tt join topic t on tt.playertopic_id=t.id where tt.status=:translateStatus\n"
                        + "union all select t.npc_id from translatedtext tt join greeting t on tt.greeting_id=t.id where tt.status=:translateStatus\n"
                        + "union all select t.npc_id from translatedtext tt join subtitle t on tt.subtitle_id=t.id where tt.status=:translateStatus) as rr group by npc_id");
        q.setParameter("translateStatus", translateStatus.name());
        List<BigInteger> resultList = q.getResultList();
        List<Long> longResultList = new ArrayList();
        for (BigInteger id : resultList) {
            longResultList.add(id.longValue());
        }
        if (longResultList.isEmpty()) {
            longResultList.add(0L);
        }
        crit.add(Restrictions.in("id", longResultList));
    } else if (translator != null) {
        Query q = em.createNativeQuery(
                "select npc_id from (select t.npc_id from translatedtext tt join topic t on tt.npctopic_id=t.id where tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join topic t on tt.playertopic_id=t.id where tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join greeting t on tt.greeting_id=t.id where tt.author_id=:authorId\n"
                        + "union all select t.npc_id from translatedtext tt join subtitle t on tt.subtitle_id=t.id where tt.author_id=:authorId) as rr group by npc_id");
        q.setParameter("authorId", translator.getId());
        List<BigInteger> resultList = q.getResultList();
        List<Long> longResultList = new ArrayList();
        for (BigInteger id : resultList) {
            longResultList.add(id.longValue());
        }
        if (longResultList.isEmpty()) {
            longResultList.add(0L);
        }
        crit.add(Restrictions.in("id", longResultList));
    }
    if (noTranslations) {
        crit.add(Restrictions.lt("progress", BigDecimal.ONE));
    }
    crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    List<Npc> list = crit.list();
    container.addAll(list);
    return container;
}

From source file:org.eulerframework.web.core.base.dao.impl.hibernate5.BaseDao.java

License:Apache License

protected Criterion generateRestriction(String property, String value, QueryMode queryMode) {
    Field field;//from www .  jav a2  s . c o m
    try {
        String fieldName = property;
        if (property.indexOf('.') > 0) {
            fieldName = property.substring(0, property.indexOf('.'));
        }
        field = this.entityClass.getDeclaredField(fieldName);
    } catch (NoSuchFieldException e) {
        throw new IllegalArgumentException("Property '" + property + "' not exist");
    }

    if (BaseEmbeddable.class.isAssignableFrom(field.getType())) {
        try {
            field = field.getType().getDeclaredField(property.substring(property.indexOf('.') + 1));
        } catch (NoSuchFieldException e) {
            throw new IllegalArgumentException("Property '" + property + "' not exist");
        }
    }

    switch (queryMode) {
    case ANYWHERE:
        return RestrictionsX.like(property, value, MatchMode.ANYWHERE);
    case START:
        return RestrictionsX.like(property, value, MatchMode.START);
    case END:
        return RestrictionsX.like(property, value, MatchMode.END);
    case EXACT:
        return RestrictionsX.like(property, value, MatchMode.EXACT);
    case GE:
        return Restrictions.ge(property, JavaObjectUtils.analyzeStringValueToObject(value, field.getType()));
    case GT:
        return Restrictions.gt(property, JavaObjectUtils.analyzeStringValueToObject(value, field.getType()));
    case LE:
        return Restrictions.le(property, JavaObjectUtils.analyzeStringValueToObject(value, field.getType()));
    case LT:
        return Restrictions.lt(property, JavaObjectUtils.analyzeStringValueToObject(value, field.getType()));
    case IN:
        return Restrictions.in(property, this.analyzeInterval(value, field.getType()));
    case NOTIN:
        return Restrictions.not(RestrictionsX.in(property, this.analyzeInterval(value, field.getType())));
    case IS:
        return Restrictions.eq(property, JavaObjectUtils.analyzeStringValueToObject(value, field.getType()));
    case NOT:
        return Restrictions.ne(property, JavaObjectUtils.analyzeStringValueToObject(value, field.getType()));
    case BETWEEN:
        Object[] array1 = this.analyzeInterval(value, field.getType());
        return Restrictions.between(property, array1[0], array1[1]);
    case OUTSIDE:
        Object[] array2 = this.analyzeInterval(value, field.getType());
        return Restrictions.not(Restrictions.between(property, array2[0], array2[1]));
    default:
        throw new IllegalArgumentException("Unknown query mode: " + queryMode);
    }
}

From source file:org.faster.orm.criteria.GenericCriteria.java

License:Open Source License

public DetachedCriteria buildCriteria() {
    beforeBuildCriteria();//from  w w  w . j a v  a 2  s  .  co  m
    DetachedCriteria dc = DetachedCriteria.forClass(persistClass);
    List<Field> queryFields = QueryHelper.getQueryFields(this.getClass());
    Set<String> aliases = new HashSet<String>(); // ??
    for (Field f : queryFields) {
        try {
            Object obj = f.get(this);
            boolean ignoreNull = QueryHelper.isIgnoreNull(f);
            if (obj == null) {
                if (ignoreNull) {
                    continue;
                }
            }

            String fieldName = QueryHelper.getFieldName(f);
            if (fieldName.contains(".")) {
                String[] subFieldNames = fieldName.split("\\.");
                String fieldPath = subFieldNames[0];
                String alias = subFieldNames[0];
                if (!aliases.contains(alias)) {
                    dc.createAlias(fieldPath, alias);
                    aliases.add(alias);
                }

                // ?alias
                for (int i = 1; i < subFieldNames.length - 1; i++) {
                    fieldPath += "." + subFieldNames[i];
                    alias += "_" + subFieldNames[i];
                    if (!aliases.contains(alias)) {
                        dc.createAlias(fieldPath, alias);
                        aliases.add(alias);
                    }
                }

                if (subFieldNames.length > 2) {
                    fieldName = alias + "." + subFieldNames[subFieldNames.length - 1];
                }
            }

            if (obj == null && !ignoreNull) {
                dc.add(Restrictions.isNull(fieldName));
                continue;
            }

            String stringValue = String.valueOf(obj);
            boolean ignoreEmptyOrZero = QueryHelper.isIgnoreEmptyOrZero(f);
            if (ignoreEmptyOrZero && isBlank(stringValue)) {
                continue;
            }

            if (stringValue.startsWith(NULL)) {
                dc.add(Restrictions.isNull(fieldName));
                continue;
            }

            if (stringValue.startsWith(NOT_NULL)) {
                dc.add(Restrictions.isNotNull(fieldName));
                continue;
            }

            String delimiter = QueryHelper.getDelimiter(f);
            DataType dt = QueryHelper.getDataType(f);
            MatchMode mm = QueryHelper.getMatchMode(f);

            switch (dt) {
            case STRING:
                switch (mm) {
                case EQ:
                    dc.add(Restrictions.eq(fieldName, stringValue));
                    continue;
                case LIKE:
                    dc.add(Restrictions.like(fieldName, stringValue,
                            org.hibernate.criterion.MatchMode.ANYWHERE));
                    continue;
                case LIKE_START:
                    dc.add(Restrictions.like(fieldName, stringValue, org.hibernate.criterion.MatchMode.START));
                    continue;
                case LIKE_END:
                    dc.add(Restrictions.like(fieldName, stringValue, org.hibernate.criterion.MatchMode.END));
                    continue;
                case ILIKE:
                    dc.add(Restrictions.ilike(fieldName, stringValue,
                            org.hibernate.criterion.MatchMode.ANYWHERE));
                    continue;
                case ILIKE_START:
                    dc.add(Restrictions.ilike(fieldName, stringValue, org.hibernate.criterion.MatchMode.START));
                    continue;
                case ILIKE_END:
                    dc.add(Restrictions.ilike(fieldName, stringValue, org.hibernate.criterion.MatchMode.END));
                    continue;
                case IN:
                    CriteriaRender.renderFieldByStringFilterValues(dc, fieldName, stringValue, delimiter);
                    continue;
                default:
                    throw new IllegalArgumentException("Invalid MatchMode for String: " + mm);
                }
            case INTEGER:
                if (ignoreEmptyOrZero && stringValue.equals("0")) {
                    continue;
                }

                Integer intValue = 0;
                if (mm != MatchMode.IN) {
                    try {
                        intValue = Integer.valueOf(stringValue);
                    } catch (Exception e) {
                        throw new IllegalArgumentException(
                                stringValue + " is not valid int value and can't use MatchMode: " + mm);
                    }
                }

                switch (mm) {
                case EQ:
                    dc.add(Restrictions.eq(fieldName, intValue));
                    continue;
                case NE:
                    dc.add(Restrictions.ne(fieldName, intValue));
                    continue;
                case IN:
                    CriteriaRender.renderFieldByIntegerFilterValues(dc, fieldName, stringValue, delimiter);
                    continue;
                case GT:
                    dc.add(Restrictions.gt(fieldName, intValue));
                    continue;
                case GE:
                    dc.add(Restrictions.ge(fieldName, intValue));
                    continue;
                case LT:
                    dc.add(Restrictions.lt(fieldName, intValue));
                    continue;
                case LE:
                    dc.add(Restrictions.le(fieldName, intValue));
                    continue;
                default:
                    throw new IllegalArgumentException("Invalid MatchMode for Long: " + mm);
                }
            case LONG:
                if (ignoreEmptyOrZero && stringValue.equals("0")) {
                    continue;
                }

                Long longValue = 0L;
                if (mm != MatchMode.IN) {
                    try {
                        longValue = Long.valueOf(stringValue);
                    } catch (Exception e) {
                        throw new IllegalArgumentException(
                                stringValue + " is not valid long value and can't use MatchMode: " + mm);
                    }
                }

                switch (mm) {
                case EQ:
                    dc.add(Restrictions.eq(fieldName, longValue));
                    continue;
                case NE:
                    dc.add(Restrictions.ne(fieldName, longValue));
                    continue;
                case IN:
                    CriteriaRender.renderFieldByLongFilterValues(dc, fieldName, stringValue, delimiter);
                    continue;
                case GT:
                    dc.add(Restrictions.gt(fieldName, longValue));
                    continue;
                case GE:
                    dc.add(Restrictions.ge(fieldName, longValue));
                    continue;
                case LT:
                    dc.add(Restrictions.lt(fieldName, longValue));
                    continue;
                case LE:
                    dc.add(Restrictions.le(fieldName, longValue));
                    continue;
                default:
                    throw new IllegalArgumentException("Invalid MatchMode for Long: " + mm);
                }
            case DATE:
                // TODO ??????
                Date date = DateTimes.parseStringToDate(stringValue);
                switch (mm) {
                case EQ:
                    dc.add(Restrictions.eq(fieldName, date));
                    continue;
                case NE:
                    dc.add(Restrictions.ne(fieldName, date));
                    continue;
                case GT:
                    dc.add(Restrictions.gt(fieldName, date));
                    continue;
                case GE:
                    dc.add(Restrictions.ge(fieldName, date));
                    continue;
                case LT:
                    dc.add(Restrictions.lt(fieldName, date));
                    continue;
                case LE:
                    dc.add(Restrictions.le(fieldName, date));
                    continue;
                default:
                    throw new IllegalArgumentException("Invalid MatchMode for Date: " + mm);
                }
            case BOOLEAN:
                Boolean bool = BooleanUtils.toBooleanObject(stringValue);
                switch (mm) {
                case EQ:
                    dc.add(Restrictions.eq(fieldName, bool));
                    continue;
                case NE:
                    dc.add(Restrictions.ne(fieldName, bool));
                    continue;
                default:
                    throw new IllegalArgumentException("Invalid MatchMode for Boolean: " + mm);
                }
            case LatLong:
                LatLngBound b = new LatLngBound(stringValue);
                if (b.isValid()) {
                    String minLatitude = b.getMinLatitude() == null ? "0.0" : b.getMinLatitude().toString();
                    String maxLatitude = b.getMaxLatitude() == null ? "0.0" : b.getMaxLatitude().toString();
                    String minLongitude = b.getMinLongitude() == null ? "0.0" : b.getMinLongitude().toString();
                    String maxLongitude = b.getMaxLongitude() == null ? "0.0" : b.getMaxLongitude().toString();
                    if ("area".equalsIgnoreCase(fieldName)) {
                        dc.add(Restrictions.between("latitude", minLatitude, maxLatitude));
                        dc.add(Restrictions.between("longitude", minLongitude, maxLongitude));
                    } else {
                        if (fieldName.contains(".")) {
                            String alias = fieldName.replace(".", "_");
                            if (!aliases.contains(alias)) {
                                dc.createAlias(fieldName, alias);
                                aliases.add(alias);
                            }
                            fieldName = alias;
                        } else {
                            if (!aliases.contains(fieldName)) {
                                dc.createAlias(fieldName, fieldName);
                                aliases.add(fieldName);
                            }
                        }
                        dc.add(Restrictions.between(fieldName + ".latitude", minLatitude, maxLatitude));
                        dc.add(Restrictions.between(fieldName + ".longitude", minLongitude, maxLongitude));
                    }
                }
                continue;
            default:
                throw new IllegalArgumentException("Unsupported DataType: " + dt);
            }
        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
    }

    renderCriteria(dc);

    if (isNotBlank(sort)) {
        String[] fields = sort.split("-");
        if (fields.length < 2 || "desc".equalsIgnoreCase(fields[1])) {
            dc.addOrder(Order.desc(fields[0]));
        } else {
            dc.addOrder(Order.asc(fields[0]));
        }
    }

    return dc;
}

From source file:org.fireflow.engine.modules.persistence.hibernate.ActivityInstancePersisterHibernateImpl.java

License:Open Source License

public int countAliveActivityInstance(final String processInstanceId, final String nodeId) {
    Object result = this.getHibernateTemplate().execute(new HibernateCallback() {

        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Criteria criteria = session.createCriteria(ActivityInstanceImpl.class);
            criteria.add(Restrictions.eq("processInstanceId", processInstanceId))
                    .add(Restrictions.eq("nodeId", nodeId))
                    .add(Restrictions.lt("state", ActivityInstanceState.DELIMITER))
                    .setProjection(Projections.rowCount());

            return criteria.uniqueResult();
        }//from w  w  w.  j a  v a  2  s . c  o m

    });

    if (result instanceof Integer) {
        return (Integer) result;
    } else if (result instanceof Long) {
        return ((Long) result).intValue();
    }
    return 0;
}

From source file:org.fireflow.engine.modules.persistence.hibernate.PersisterUtils.java

License:Open Source License

public static org.hibernate.criterion.Criterion fireCriterion2HibernateCriterion(
        org.fireflow.client.query.Criterion fireCriterion) {
    String operation = fireCriterion.getOperation().trim();

    if (Criterion.OPERATION_EQ.equals(operation)) {
        return Restrictions.eq(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0]);
    } else if (Criterion.OPERATION_NE.equals(operation)) {
        return Restrictions.ne(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0]);
    } else if (Criterion.OPERATION_LIKE.equals(operation)) {
        return Restrictions.like(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0]);
    } else if (Criterion.OPERATION_GT.equals(operation)) {
        return Restrictions.gt(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0]);
    } else if (Criterion.OPERATION_LT.equals(operation)) {
        return Restrictions.lt(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0]);
    } else if (Criterion.OPERATION_GE.equals(operation)) {
        return Restrictions.ge(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0]);
    } else if (Criterion.OPERATION_LE.equals(operation)) {
        return Restrictions.le(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0]);
    } else if (operation.equals(Criterion.OPERATION_IS_NULL)) {
        return Restrictions.isNull(fireCriterion.getEntityProperty().getPropertyName());
    } else if (operation.equals(Criterion.OPERATION_IS_NOT_NULL)) {
        return Restrictions.isNotNull(fireCriterion.getEntityProperty().getPropertyName());
    } else if (operation.equals(Criterion.OPERATION_IN)) {
        return Restrictions.in(fireCriterion.getEntityProperty().getPropertyName(), fireCriterion.getValues());
    } else if (Criterion.OPERATION_BETWEEN.equals(operation)) {
        return Restrictions.between(fireCriterion.getEntityProperty().getPropertyName(),
                fireCriterion.getValues()[0], fireCriterion.getValues()[1]);
    } else if (Criterion.OPERATION_AND.equals(operation)) {
        org.fireflow.client.query.Criterion left = (org.fireflow.client.query.Criterion) fireCriterion
                .getValues()[0];// w w  w .  j  a va 2  s  .  c om
        org.fireflow.client.query.Criterion right = (org.fireflow.client.query.Criterion) fireCriterion
                .getValues()[1];
        org.hibernate.criterion.Criterion hLeft = fireCriterion2HibernateCriterion(left);
        org.hibernate.criterion.Criterion hRight = fireCriterion2HibernateCriterion(right);
        return Restrictions.and(hLeft, hRight);

    } else if (Criterion.OPERATION_OR.equals(operation)) {
        org.fireflow.client.query.Criterion left = (org.fireflow.client.query.Criterion) fireCriterion
                .getValues()[0];
        org.fireflow.client.query.Criterion right = (org.fireflow.client.query.Criterion) fireCriterion
                .getValues()[1];
        org.hibernate.criterion.Criterion hLeft = fireCriterion2HibernateCriterion(left);
        org.hibernate.criterion.Criterion hRight = fireCriterion2HibernateCriterion(right);
        return Restrictions.or(hLeft, hRight);

    }
    return null;
}