List of usage examples for org.hibernate.criterion Restrictions gt
public static SimpleExpression gt(String propertyName, Object value)
From source file:org.openmrs.api.db.hibernate.HibernateConceptDAO.java
License:Mozilla Public License
/** * @see org.openmrs.api.db.ConceptDAO#getNextConcept(org.openmrs.Concept) */// w w w . ja v a 2s . co m @SuppressWarnings("unchecked") public Concept getNextConcept(Concept c) { Integer i = c.getConceptId(); List<Concept> concepts = sessionFactory.getCurrentSession().createCriteria(Concept.class) .add(Restrictions.gt("conceptId", i)).addOrder(Order.asc("conceptId")).setMaxResults(1).list(); if (concepts.size() < 1) { return null; } return concepts.get(0); }
From source file:org.openmrs.api.db.hibernate.HibernatePatientSetDAO.java
License:Mozilla Public License
@SuppressWarnings("unchecked") public Map<Integer, List<DrugOrder>> getCurrentDrugOrders(Cohort patients, List<Concept> drugConcepts) throws DAOException { Map<Integer, List<DrugOrder>> ret = new HashMap<Integer, List<DrugOrder>>(); Date now = new Date(); Criteria criteria = sessionFactory.getCurrentSession().createCriteria(DrugOrder.class); criteria.setFetchMode("patient", FetchMode.JOIN); criteria.setCacheMode(CacheMode.IGNORE); // this "where clause" is only necessary if patients were passed in if (patients != null) { criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); }// w w w .j a va 2s. c o m //criteria.add(Restrictions.in("encounter.patient.personId", ids)); //criteria.createCriteria("encounter").add(Restrictions.in("patient.personId", ids)); if (drugConcepts != null) { criteria.add(Restrictions.in("concept", drugConcepts)); } criteria.add(Restrictions.eq("voided", false)); criteria.add(Restrictions.le("dateActivated", now)); criteria.add(Restrictions.and( Restrictions.or(Restrictions.isNull("autoExpireDate"), Restrictions.gt("autoExpireDate", now)), Restrictions.or(Restrictions.isNull("dateStopped"), Restrictions.gt("dateStopped", now)))); criteria.addOrder(org.hibernate.criterion.Order.asc("dateActivated")); log.debug("criteria: " + criteria); List<DrugOrder> temp = criteria.list(); for (DrugOrder regimen : temp) { Integer ptId = regimen.getPatient().getPatientId(); List<DrugOrder> list = ret.get(ptId); if (list == null) { list = new ArrayList<DrugOrder>(); ret.put(ptId, list); } list.add(regimen); } return ret; }
From source file:org.openmrs.api.db.hibernate.HibernateVisitDAO.java
License:Mozilla Public License
/** * @see org.openmrs.api.db.VisitDAO#getVisits(java.util.Collection, java.util.Collection, * java.util.Collection, java.util.Collection, java.util.Date, java.util.Date, * java.util.Date, java.util.Date, java.util.Map, boolean, boolean) *///from ww w . ja va2 s . com @SuppressWarnings("unchecked") @Override @Transactional(readOnly = true) public List<Visit> getVisits(Collection<VisitType> visitTypes, Collection<Patient> patients, Collection<Location> locations, Collection<Concept> indications, Date minStartDatetime, Date maxStartDatetime, Date minEndDatetime, Date maxEndDatetime, final Map<VisitAttributeType, String> serializedAttributeValues, boolean includeInactive, boolean includeVoided) throws DAOException { Criteria criteria = getCurrentSession().createCriteria(Visit.class); if (visitTypes != null) { criteria.add(Restrictions.in("visitType", visitTypes)); } if (patients != null) { criteria.add(Restrictions.in("patient", patients)); } if (locations != null) { criteria.add(Restrictions.in("location", locations)); } if (indications != null) { criteria.add(Restrictions.in("indication", indications)); } if (minStartDatetime != null) { criteria.add(Restrictions.ge("startDatetime", minStartDatetime)); } if (maxStartDatetime != null) { criteria.add(Restrictions.le("startDatetime", maxStartDatetime)); } // active visits have null end date, so it doesn't make sense to search against it if include inactive is set to false if (!includeInactive) { // the user only asked for currently active visits, so stop time needs to be null or after right now criteria.add(Restrictions.or(Restrictions.isNull("stopDatetime"), Restrictions.gt("stopDatetime", new Date()))); } else { if (minEndDatetime != null) { criteria.add(Restrictions.or(Restrictions.isNull("stopDatetime"), Restrictions.ge("stopDatetime", minEndDatetime))); } if (maxEndDatetime != null) { criteria.add(Restrictions.le("stopDatetime", maxEndDatetime)); } } if (!includeVoided) { criteria.add(Restrictions.eq("voided", false)); } criteria.addOrder(Order.desc("startDatetime")); criteria.addOrder(Order.desc("visitId")); List<Visit> visits = criteria.list(); if (serializedAttributeValues != null) { CollectionUtils.filter(visits, new AttributeMatcherPredicate<Visit, VisitAttributeType>(serializedAttributeValues)); } return visits; }
From source file:org.openmrs.api.db.hibernate.HibernateVisitDAO.java
License:Mozilla Public License
/** * @see org.openmrs.api.db.VisitDAO#getNextVisit(Visit, Collection, Date) *//* www. ja v a2 s . co m*/ @Override public Visit getNextVisit(Visit previousVisit, Collection<VisitType> visitTypes, Date maximumStartDate) { Criteria criteria = getCurrentSession().createCriteria(Visit.class); criteria.add(Restrictions.eq("voided", false)) .add(Restrictions.gt("visitId", (previousVisit != null) ? previousVisit.getVisitId() : 0)) .addOrder(Order.asc("visitId")).add(Restrictions.isNull("stopDatetime")).setMaxResults(1); if (maximumStartDate != null) { criteria.add(Restrictions.le("startDatetime", maximumStartDate)); } if (CollectionUtils.isNotEmpty(visitTypes)) { criteria.add(Restrictions.in("visitType", visitTypes)); } return (Visit) criteria.uniqueResult(); }
From source file:org.openmrs.logic.db.hibernate.HibernateLogicEncounterDAO.java
License:Open Source License
/** * Convenience method to get the list of hibernate queries for this expression * // w w w .j a v a 2 s. c o m * @param logicExpression * @param indexDate * @param criteria Criteria object so that certain expressions can add aliases, etc * @return Criterion to be added to the Criteria */ public Criterion getCriterion(LogicExpression logicExpression, Date indexDate, Criteria criteria) { Operator operator = logicExpression.getOperator(); Object rightOperand = logicExpression.getRightOperand(); Object leftOperand = null; if (logicExpression instanceof LogicExpressionBinary) { leftOperand = ((LogicExpressionBinary) logicExpression).getLeftOperand(); } List<Criterion> criterion = new ArrayList<Criterion>(); //if the leftOperand is a String and does not match any components, //see if it is a concept name and restrict accordingly //a null operator implies a concept restriction if (leftOperand instanceof LogicExpression) { // no restrictions if there is no operator // TODO restrict on provider != null for encounterProvider token? } String token = logicExpression.getRootToken(); if (operator == null) { // no restrictions if there is no operator // TODO restrict on provider != null for encounterProvider token? } else if (operator == Operator.BEFORE || operator == Operator.LT) { if (ENCOUNTER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandDate) { criterion.add(Restrictions.lt("encounterDatetime", rightOperand)); } else { throw new LogicException("'before' is not a valid operator on " + token + " and " + rightOperand); } } else if (operator == Operator.AFTER || operator == Operator.GT) { if (ENCOUNTER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandDate) { criterion.add(Restrictions.gt("encounterDatetime", rightOperand)); } else { throw new LogicException("'after' is not a valid operator on " + token + " and " + rightOperand); } } else if (operator == Operator.AND || operator == Operator.OR) { if (ENCOUNTER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandDate) { Criterion leftCriteria = null; Criterion rightCriteria = null; if (leftOperand instanceof LogicExpression) { leftCriteria = this.getCriterion((LogicExpression) leftOperand, indexDate, criteria); } if (rightOperand instanceof LogicExpression) { rightCriteria = this.getCriterion((LogicExpression) rightOperand, indexDate, criteria); } if (leftCriteria != null && rightCriteria != null) { if (operator == Operator.AND) { criterion.add(Restrictions.and(leftCriteria, rightCriteria)); } if (operator == Operator.OR) { criterion.add(Restrictions.or(leftCriteria, rightCriteria)); } } } else { throw new LogicException("'and/or' are not valid operators on " + token + " and " + rightOperand); } } else if (operator == Operator.NOT) { Criterion rightCriteria = null; if (rightOperand instanceof LogicExpression) { rightCriteria = this.getCriterion((LogicExpression) rightOperand, indexDate, criteria); } if (rightCriteria != null) { criterion.add(Restrictions.not(rightCriteria)); } } else if (operator == Operator.CONTAINS) { if (ENCOUNTER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandText) { criteria.createAlias("encounterType", "encounterType"); criterion.add(Expression.eq("encounterType.name", ((OperandText) rightOperand).asString())); } else if (LOCATION_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandText) { criteria.createAlias("location", "location"); criterion.add(Restrictions.eq("location.name", ((OperandText) rightOperand).asString())); } else if (PROVIDER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandNumeric) { criteria.createAlias("provider", "provider"); criterion.add(Restrictions.eq("provider.personId", ((OperandNumeric) rightOperand).asInteger())); } else { throw new LogicException("'contains' is not a valid operator on " + token + " and " + rightOperand); } } else if (operator == Operator.IN) { if (ENCOUNTER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandCollection) { criteria.createAlias("encounterType", "encounterType"); criterion.add( Expression.in("encounterType.name", ((OperandCollection) rightOperand).asCollection())); } else if (LOCATION_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandCollection) { criteria.createAlias("location", "location"); criterion.add(Restrictions.in("location.name", ((OperandCollection) rightOperand).asCollection())); } else if (PROVIDER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandCollection) { criteria.createAlias("provider", "provider"); criterion.add( Restrictions.in("provider.systemId", ((OperandCollection) rightOperand).asCollection())); } else { throw new LogicException("'in' is not a valid operator on " + token + " and " + rightOperand); } } else if (operator == Operator.EQUALS) { if (ENCOUNTER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandDate) { criterion.add(Restrictions.eq("encounterDatetime", rightOperand)); } else if (ENCOUNTER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandText) { criteria.createAlias("encounterType", "encounterType"); criterion.add(Restrictions.eq("encounterType.name", ((OperandText) rightOperand).asString())); } else if (LOCATION_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandText) { criteria.createAlias("location", "location"); criterion.add(Restrictions.eq("location.name", ((OperandText) rightOperand).asString())); } else if (PROVIDER_KEY.equalsIgnoreCase(token) && rightOperand instanceof OperandText) { criteria.createAlias("provider", "provider"); criterion.add(Restrictions.eq("provider.systemId", ((OperandText) rightOperand).asString())); } else { throw new LogicException("'equals' is not a valid operator on " + token + " and " + rightOperand); } } else if (operator == Operator.LTE) { if (rightOperand instanceof OperandDate) criterion.add(Restrictions.le("encounterDatetime", rightOperand)); else throw new LogicException( "'less than or equals' is not a valid operator on " + token + " and " + rightOperand); } else if (operator == Operator.GTE) { if (rightOperand instanceof OperandDate) criterion.add(Restrictions.ge("encounterDatetime", rightOperand)); else throw new LogicException( "'greater than or equals' is not a valid operator on " + token + " and " + rightOperand); } else if (operator == Operator.LT) { if (rightOperand instanceof OperandDate) criterion.add(Restrictions.lt("encounterDatetime", rightOperand)); else throw new LogicException( "'less than' is not a valid operator on " + token + " and " + rightOperand); } else if (operator == Operator.GT) { if (rightOperand instanceof OperandDate) criterion.add(Restrictions.gt("encounterDatetime", rightOperand)); else throw new LogicException( "'greater than' is not a valid operator on " + token + " and " + rightOperand); } else if (operator == Operator.EXISTS) { // EXISTS can be handled on the higher level (above // LogicService, even) by coercing the Result into a Boolean for // each patient } else if (operator == Operator.ASOF && rightOperand instanceof Date) { indexDate = (Date) rightOperand; criterion.add(Restrictions.le("encounterDatetime", indexDate)); } else if (operator == Operator.WITHIN) { if (rightOperand instanceof Duration) { Duration duration = (Duration) rightOperand; Calendar within = Calendar.getInstance(); within.setTime(indexDate); if (duration.getUnits() == Duration.Units.YEARS) { within.add(Calendar.YEAR, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.MONTHS) { within.add(Calendar.MONTH, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.WEEKS) { within.add(Calendar.WEEK_OF_YEAR, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.DAYS) { within.add(Calendar.DAY_OF_YEAR, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.HOURS) { within.add(Calendar.HOUR_OF_DAY, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.MINUTES) { within.add(Calendar.MINUTE, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.SECONDS) { within.add(Calendar.SECOND, duration.getDuration().intValue()); } if (indexDate.compareTo(within.getTime()) > 0) { criterion.add(Restrictions.between("encounterDatetime", within.getTime(), indexDate)); } else { criterion.add(Restrictions.between("encounterDatetime", indexDate, within.getTime())); } } else { throw new LogicException("'within' is not a valid operator on " + token + " and " + rightOperand); } } Criterion c = null; for (Criterion crit : criterion) { if (c == null) { c = crit; } else { c = Restrictions.and(c, crit); } } return c; }
From source file:org.openmrs.logic.db.hibernate.HibernateLogicObsDAO.java
License:Open Source License
public Criterion getCriterion(LogicExpression logicExpression, Date indexDate, Criteria criteria) { Operator operator = logicExpression.getOperator(); Operand rightOperand = logicExpression.getRightOperand(); Operand leftOperand = null;/*from ww w . ja va 2 s.c o m*/ if (logicExpression instanceof LogicExpressionBinary) { leftOperand = ((LogicExpressionBinary) logicExpression).getLeftOperand(); } List<Criterion> criterion = new ArrayList<Criterion>(); //the root token can be a concept name for the obs datasource String rootToken = logicExpression.getRootToken(); Concept concept = getConceptForToken(rootToken); if (concept != null) { criterion.add(Restrictions.eq("concept", concept)); } else { if (rootToken != null && (rootToken.equalsIgnoreCase(COMPONENT_ENCOUNTER_ID) || rootToken.equalsIgnoreCase(COMPONENT_OBS_DATETIME))) { //this is a component not a concept so it is fine } else { throw new LogicException("Concept: " + rootToken + " does not exist"); } } if (operator == Operator.BEFORE) { criterion.add(Restrictions.lt("obsDatetime", rightOperand)); } else if (operator == Operator.AFTER) { criterion.add(Restrictions.gt("obsDatetime", rightOperand)); } else if (operator == Operator.AND || operator == Operator.OR) { Criterion leftCriteria = null; Criterion rightCriteria = null; if (leftOperand instanceof LogicExpression) { leftCriteria = this.getCriterion((LogicExpression) leftOperand, indexDate, criteria); } if (rightOperand instanceof LogicExpression) { rightCriteria = this.getCriterion((LogicExpression) rightOperand, indexDate, criteria); } if (leftCriteria != null && rightCriteria != null) { if (operator == Operator.AND) { criterion.add(Restrictions.and(leftCriteria, rightCriteria)); } if (operator == Operator.OR) { criterion.add(Restrictions.or(leftCriteria, rightCriteria)); } } } else if (operator == Operator.NOT) { Criterion rightCriteria = null; if (rightOperand instanceof LogicExpression) { rightCriteria = this.getCriterion((LogicExpression) rightOperand, indexDate, criteria); } if (rightCriteria != null) { criterion.add(Restrictions.not(rightCriteria)); } } else if (operator == Operator.CONTAINS) { // used with PROBLEM ADDED concept, to retrieve the "ANSWERED // BY" concept, stashed inside the concept's valueCoded member // variable. for example: // new LogicCriteria("PROBLEM ADDED").contains("HIV INFECTED"); if (rightOperand instanceof OperandNumeric) { concept = Context.getConceptService().getConcept(((OperandNumeric) rightOperand).asInteger()); criterion.add(Restrictions.eq("valueCoded", concept)); } else if (rightOperand instanceof OperandText) { concept = Context.getConceptService().getConcept((String) ((OperandText) rightOperand).asString()); criterion.add(Restrictions.eq("valueCoded", concept)); } else if (rightOperand instanceof OperandConcept) { criterion.add(Restrictions.eq("valueCoded", ((OperandConcept) rightOperand).asConcept())); } else log.error("Invalid operand value for CONTAINS operation"); } else if (operator == Operator.IN) { log.error("Invalid operand value for IN operation"); } else if (operator == Operator.EQUALS) { if (rightOperand instanceof OperandNumeric) { if (rootToken.equalsIgnoreCase(COMPONENT_ENCOUNTER_ID)) { EncounterService encounterService = Context.getEncounterService(); Encounter encounter = encounterService .getEncounter(((OperandNumeric) rightOperand).asInteger()); criterion.add(Restrictions.eq("encounter", encounter)); } else criterion.add(Restrictions.eq("valueNumeric", ((OperandNumeric) rightOperand).asDouble())); } else if (rightOperand instanceof OperandText) criterion.add(Restrictions.eq("valueText", ((OperandText) rightOperand).asString())); else if (rightOperand instanceof OperandDate) if (leftOperand instanceof OperandText && ((OperandText) leftOperand).asString().equals(COMPONENT_OBS_DATETIME)) { criterion.add(Restrictions.eq(COMPONENT_OBS_DATETIME, rightOperand)); } else { criterion.add(Restrictions.eq("valueDatetime", rightOperand)); } else if (rightOperand instanceof OperandConcept) criterion.add(Restrictions.eq("valueCoded", ((OperandConcept) rightOperand).asConcept())); else log.error("Invalid operand value for EQUALS operation"); } else if (operator == Operator.LTE) { if (rightOperand instanceof OperandNumeric) criterion.add(Restrictions.le("valueNumeric", ((OperandNumeric) rightOperand).asDouble())); else if (rightOperand instanceof OperandDate) if (leftOperand instanceof OperandText && ((OperandText) leftOperand).asString().equals(COMPONENT_OBS_DATETIME)) { criterion.add(Restrictions.le(COMPONENT_OBS_DATETIME, rightOperand)); } else { criterion.add(Restrictions.le("valueDatetime", rightOperand)); } else log.error("Invalid operand value for LESS THAN EQUAL operation"); } else if (operator == Operator.GTE) { if (rightOperand instanceof OperandNumeric) criterion.add(Restrictions.ge("valueNumeric", ((OperandNumeric) rightOperand).asDouble())); else if (rightOperand instanceof OperandDate) if (leftOperand instanceof OperandText && ((OperandText) leftOperand).asString().equals(COMPONENT_OBS_DATETIME)) { criterion.add(Restrictions.ge(COMPONENT_OBS_DATETIME, rightOperand)); } else { criterion.add(Restrictions.ge("valueDatetime", rightOperand)); } else log.error("Invalid operand value for GREATER THAN EQUAL operation"); } else if (operator == Operator.LT) { if (rightOperand instanceof OperandNumeric) criterion.add(Restrictions.lt("valueNumeric", ((OperandNumeric) rightOperand).asDouble())); else if (rightOperand instanceof OperandDate) if (leftOperand instanceof OperandText && ((OperandText) leftOperand).asString().equals(COMPONENT_OBS_DATETIME)) { criterion.add(Restrictions.lt(COMPONENT_OBS_DATETIME, rightOperand)); } else { criterion.add(Restrictions.lt("valueDatetime", rightOperand)); } else log.error("Invalid operand value for LESS THAN operation"); } else if (operator == Operator.GT) { if (rightOperand instanceof OperandNumeric) criterion.add(Restrictions.gt("valueNumeric", ((OperandNumeric) rightOperand).asDouble())); else if (rightOperand instanceof OperandDate) if (leftOperand instanceof OperandText && ((OperandText) leftOperand).asString().equals(COMPONENT_OBS_DATETIME)) { criterion.add(Restrictions.gt(COMPONENT_OBS_DATETIME, rightOperand)); } else { criterion.add(Restrictions.gt("valueDatetime", rightOperand)); } else log.error("Invalid operand value for GREATER THAN operation"); } else if (operator == Operator.EXISTS) { // EXISTS can be handled on the higher level (above // LogicService, even) by coercing the Result into a Boolean for // each patient } else if (operator == Operator.ASOF && rightOperand instanceof OperandDate) { indexDate = (Date) rightOperand; criterion.add(Restrictions.le("obsDatetime", indexDate)); } else if (operator == Operator.WITHIN && rightOperand instanceof Duration) { Duration duration = (Duration) rightOperand; Calendar within = Calendar.getInstance(); within.setTime(indexDate); if (duration.getUnits() == Duration.Units.YEARS) { within.add(Calendar.YEAR, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.MONTHS) { within.add(Calendar.MONTH, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.WEEKS) { within.add(Calendar.WEEK_OF_YEAR, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.DAYS) { within.add(Calendar.DAY_OF_YEAR, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.HOURS) { within.add(Calendar.HOUR_OF_DAY, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.MINUTES) { within.add(Calendar.MINUTE, duration.getDuration().intValue()); } else if (duration.getUnits() == Duration.Units.SECONDS) { within.add(Calendar.SECOND, duration.getDuration().intValue()); } if (indexDate.compareTo(within.getTime()) > 0) { criterion.add(Restrictions.between("obsDatetime", within.getTime(), indexDate)); } else { criterion.add(Restrictions.between("obsDatetime", indexDate, within.getTime())); } } Criterion c = null; for (Criterion crit : criterion) { if (c == null) { c = crit; } else { c = Restrictions.and(c, crit); } } return c; }
From source file:org.openmrs.logic.util.LogicExpressionToCriterion.java
License:Open Source License
public List<Criterion> evaluateAfter(String leftItem, Operand leftOperand, Operand rightOperand, Operator operator, Date indexDate, List<Criterion> c, Criteria criteria) throws LogicException { if (!rightOperand.supports(ComparisonOperator.AFTER)) throw new LogicException("'after' is not a valid operator on " + leftItem + " and " + rightOperand); nullSafeCriterionAdd(c, Restrictions.gt(mapHelper(leftItem), rightOperand)); return c;//www . j ava 2s. c o m }
From source file:org.openmrs.logic.util.LogicExpressionToCriterion.java
License:Open Source License
public List<Criterion> evaluateOr(String leftItem, Operand leftOperand, Operand rightOperand, Operator operator, Date indexDate, List<Criterion> c, Criteria criteria) throws LogicException { Criterion leftCriteria = null;// ww w . j ava 2s .co m Criterion rightCriteria = null; if (leftOperand instanceof LogicExpression) { leftCriteria = this.getCriterion((LogicExpression) leftOperand, indexDate, criteria); } if (rightOperand instanceof LogicExpression) { rightCriteria = this.getCriterion((LogicExpression) rightOperand, indexDate, criteria); } if (leftCriteria != null && rightCriteria != null) { nullSafeCriterionAdd(c, Restrictions.gt(mapHelper(leftItem), rightOperand)); } return c; }
From source file:org.openmrs.logic.util.LogicExpressionToCriterion.java
License:Open Source License
public List<Criterion> evaluateGT(String leftItem, Operand leftOperand, Operand rightOperand, Operator operator, Date indexDate, List<Criterion> c, Criteria criteria) throws LogicException { if (!rightOperand.supports(ComparisonOperator.GT)) throw new LogicException("'gt' is not a valid operator on " + leftItem + " and " + rightOperand); if (rightOperand instanceof OperandNumeric) nullSafeCriterionAdd(c,//from w w w.j a v a 2 s . c om Restrictions.gt(mapHelper(leftItem), ((OperandNumeric) rightOperand).asDouble())); else if (rightOperand instanceof OperandDate) nullSafeCriterionAdd(c, Restrictions.gt(mapHelper(leftItem), rightOperand)); return c; }
From source file:org.openmrs.module.accounting.api.db.AccountingDAO.java
License:Open Source License
public List<FiscalYear> getListFutureYear(Date startDate) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(FiscalYear.class); criteria.add(Restrictions.eq("status", GeneralStatus.OPEN)) // .add(Restrictions.ne("status", GeneralStatus.DELETED)) .add(Restrictions.gt("startDate", startDate)); criteria.addOrder(Order.desc("endDate")); return criteria.list(); }