List of usage examples for org.hibernate.criterion Restrictions between
public static Criterion between(String propertyName, Object low, Object high)
From source file:org.headsupdev.agile.app.milestones.MilestoneFilterPanel.java
License:Open Source License
private Criterion getDateCriterionDue() { if (startDateDue != null && endDateDue != null) { if (!startDateDue.after(endDateDue)) { return Restrictions.between("due", startDateDue, endDateDue); }/*from w w w . ja v a 2s.c o m*/ } return null; }
From source file:org.headsupdev.agile.app.milestones.MilestoneFilterPanel.java
License:Open Source License
@Override public Criterion getDateCriterionUpdated() { if (startDateUpdated != null && endDateUpdated != null && filterByDateUpdated) { if (!startDateUpdated.after(endDateUpdated)) { return Restrictions.between("updated", startDateUpdated, endDateUpdated); }//from w w w.ja v a 2s . co m } return null; }
From source file:org.headsupdev.agile.app.milestones.MilestoneFilterPanel.java
License:Open Source License
@Override public Criterion getDateCriterionCreated() { if (startDateCreated != null && endDateCreated != null && filterByDateCreated) { if (!startDateCreated.after(endDateCreated)) { return Restrictions.between("created", startDateCreated, endDateCreated); }//w w w . j ava 2s. com } return null; }
From source file:org.headsupdev.agile.app.milestones.MilestoneFilterPanel.java
License:Open Source License
@Override public Criterion getDateCriterionCompleted() { if (startDateCompleted != null && endDateCompleted != null && filterByDateCompleted) { if (!startDateCompleted.after(endDateCompleted)) { return Restrictions.between("completed", startDateCompleted, endDateCompleted); }//www .ja v a2 s .co m } return null; }
From source file:org.headsupdev.agile.storage.resource.ResourceManagerImpl.java
License:Open Source License
public List<DurationWorked> getDurationWorkedForUser(User user, Date start, Date end) { List<DurationWorked> workedList = new ArrayList<DurationWorked>(); Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession(); Criteria c = session.createCriteria(DurationWorked.class); c.add(Restrictions.eq("user", user)); c.add(Restrictions.gt("worked.time", 0)); c.add(Restrictions.between("day", start, end)); for (DurationWorked worked : (List<DurationWorked>) c.list()) { if (worked.getDay().before(start) || worked.getDay().after(end)) { continue; }/* w w w . j a va 2 s. c o m*/ workedList.add(worked); } return workedList; }
From source file:org.headsupdev.agile.web.components.issues.IssueFilterPanel.java
License:Open Source License
public Criterion getDateCriterionUpdated() { if (startDateUpdated != null && endDateUpdated != null && filterByDateUpdated) { if (!startDateUpdated.after(endDateUpdated)) { return Restrictions.between("updated", startDateUpdated, endDateUpdated); }/*from w w w. j a va2 s . co m*/ } return null; }
From source file:org.headsupdev.agile.web.components.issues.IssueFilterPanel.java
License:Open Source License
public Criterion getDateCriterionCreated() { if (startDateCreated != null && endDateCreated != null && filterByDateCreated) { if (!startDateCreated.after(endDateCreated)) { return Restrictions.between("created", startDateCreated, endDateCreated); }// w w w . j a va 2 s.c om } return null; }
From source file:org.hsqldb.hibernate.geomajas.layer.hibernate.CriteriaVisitor.java
License:Open Source License
/** {@inheritDoc} */ public Object visit(PropertyIsBetween filter, Object userData) { String propertyName = getPropertyName(filter.getExpression()); String finalName = parsePropertyName(propertyName, userData); Object lo = castLiteral(getLiteralValue(filter.getLowerBoundary()), propertyName); Object hi = castLiteral(getLiteralValue(filter.getUpperBoundary()), propertyName); return Restrictions.between(finalName, lo, hi); }
From source file:org.iternine.jeppetto.dao.hibernate.HibernateQueryModelDAO.java
License:Apache License
@Override public Condition buildCondition(String conditionField, ConditionType conditionType, Iterator argsIterator) { Condition condition = new Condition(); condition.setField(conditionField);/*from ww w.ja v a 2 s . c o m*/ switch (conditionType) { case Between: condition.setConstraint(Restrictions.between(conditionField, argsIterator.next(), argsIterator.next())); break; case Equal: condition.setConstraint(Restrictions.eq(conditionField, argsIterator.next())); break; case GreaterThan: condition.setConstraint(Restrictions.gt(conditionField, argsIterator.next())); break; case GreaterThanEqual: condition.setConstraint(Restrictions.ge(conditionField, argsIterator.next())); break; case IsNotNull: condition.setConstraint(Restrictions.isNotNull(conditionField)); break; case IsNull: condition.setConstraint(Restrictions.isNull(conditionField)); break; case LessThan: condition.setConstraint(Restrictions.lt(conditionField, argsIterator.next())); break; case LessThanEqual: condition.setConstraint(Restrictions.le(conditionField, argsIterator.next())); break; case NotEqual: condition.setConstraint(Restrictions.ne(conditionField, argsIterator.next())); break; case NotWithin: condition.setConstraint( Restrictions.not(Restrictions.in(conditionField, (Collection) argsIterator.next()))); break; case Within: condition.setConstraint(Restrictions.in(conditionField, (Collection) argsIterator.next())); break; } return condition; }
From source file:org.jspresso.framework.model.persistence.hibernate.criterion.DefaultCriteriaFactory.java
License:Open Source License
/** * Creates a criterion by processing a comparable query structure. * * @param path/*from w w w .java2s .c o m*/ * the path to the comparable property. * @param queryStructure * the comparable query structure. * @param componentDescriptor * the component descriptor * @param queryComponent * the query component * @param context * the context * @return the created criterion or null if no criterion necessary. */ protected Criterion createComparableQueryStructureRestriction(String path, ComparableQueryStructure queryStructure, IComponentDescriptor<?> componentDescriptor, IQueryComponent queryComponent, Map<String, Object> context) { Junction queryStructureRestriction = null; if (queryStructure.isRestricting()) { queryStructureRestriction = Restrictions.conjunction(); String comparator = queryStructure.getComparator(); Object infValue = queryStructure.getInfValue(); Object supValue = queryStructure.getSupValue(); Object compareValue = infValue; if (compareValue == null) { compareValue = supValue; } switch (comparator) { case ComparableQueryStructureDescriptor.EQ: queryStructureRestriction.add(Restrictions.eq(path, compareValue)); break; case ComparableQueryStructureDescriptor.GT: queryStructureRestriction.add(Restrictions.gt(path, compareValue)); break; case ComparableQueryStructureDescriptor.GE: queryStructureRestriction.add(Restrictions.ge(path, compareValue)); break; case ComparableQueryStructureDescriptor.LT: queryStructureRestriction.add(Restrictions.lt(path, compareValue)); break; case ComparableQueryStructureDescriptor.LE: queryStructureRestriction.add(Restrictions.le(path, compareValue)); break; case ComparableQueryStructureDescriptor.NU: queryStructureRestriction.add(Restrictions.isNull(path)); break; case ComparableQueryStructureDescriptor.NN: queryStructureRestriction.add(Restrictions.isNotNull(path)); break; case ComparableQueryStructureDescriptor.BE: if (infValue != null && supValue != null) { queryStructureRestriction.add(Restrictions.between(path, infValue, supValue)); } else if (infValue != null) { queryStructureRestriction.add(Restrictions.ge(path, infValue)); } else { queryStructureRestriction.add(Restrictions.le(path, supValue)); } break; default: break; } } return queryStructureRestriction; }