List of usage examples for org.hibernate.criterion Restrictions ge
public static SimpleExpression ge(String propertyName, Object value)
From source file:database.News.java
License:Open Source License
/** * Gets the news companies good rep ge polarity. * * @param polarity the polarity/*from w ww . java 2 s . c o m*/ * @return the news companies good rep ge polarity */ public static List<News> getNewsCompaniesGoodRepGePolarity(double polarity) { Criterion polarity_cr = Restrictions.ge("detail.total_polarity", polarity); //Criterion objectivity_cr = Restrictions.ge("detail.total_objectivity", 0.95); Criterion disj_cr = getNewsOfCompaniesWithGoodReputation(); return getResultsWithTwoCriterions(polarity_cr, disj_cr); }
From source file:db.helpers.FestivalHelper.java
private List<Festival> truncateFestivals(Criteria c) { c.add(Restrictions.ge("dateEnd", new Date())); return c.list(); }
From source file:db.helpers.FestivalHelper.java
public List<Festival> getFestivals(String name, String location, String artist, Date dateFrom, Date dateTo) { List<Festival> festivals = new ArrayList<>(); session = HibernateUtil.getSessionFactory().getCurrentSession(); org.hibernate.Transaction tx = session.beginTransaction(); try {/*from w w w . ja v a 2 s . c o m*/ Criteria c = session.createCriteria(Festival.class); if (name != null && !("".equals(name))) { c.add(Restrictions.ilike("name", name, MatchMode.ANYWHERE)); } if (location != null && !("".equals(location))) { c.add(Restrictions.ilike("location", location, MatchMode.ANYWHERE)); } if (dateFrom != null) { c.add(Restrictions.ge("dateStart", dateFrom)); } if (dateTo != null) { c.add(Restrictions.le("dateEnd", dateTo)); } if (artist != null && !("".equals(artist))) { c.createAlias("performances", "performance"); c.add(Restrictions.ilike("performance.artist", artist, MatchMode.ANYWHERE)); } festivals = c.list(); tx.commit(); } catch (HibernateException ex) { tx.rollback(); } return festivals; }
From source file:db.helpers.FestivalHelper.java
public List<Festival> getDaysEvents(Date date) { List<Festival> festivals = new ArrayList<>(); session = HibernateUtil.getSessionFactory().getCurrentSession(); org.hibernate.Transaction tx = session.beginTransaction(); try {//w ww. ja v a 2 s . c o m Criteria c = session.createCriteria(Festival.class); c.add(Restrictions.le("dateStart", date)); c.add(Restrictions.ge("dateEnd", date)); festivals = c.list(); tx.commit(); } catch (HibernateException ex) { tx.rollback(); } return festivals; }
From source file:de.appsolve.padelcampus.admin.controller.events.AdminEventsController.java
@RequestMapping(method = GET, value = "/{status}") public ModelAndView showEvents(HttpServletRequest request, Pageable pageable, @RequestParam(required = false, name = "search") String search, @PathVariable("status") String status) { Set<Criterion> criterions = new HashSet<>(); LocalDate today = new LocalDate(Constants.DEFAULT_TIMEZONE); if (status.equals("current")) { criterions.add(Restrictions.ge("endDate", today)); } else {//w w w.jav a2 s .c o m criterions.add(Restrictions.lt("endDate", today)); } Page<Event> page; if (!StringUtils.isEmpty(search)) { page = eventDAO.findAllByFuzzySearch(search, criterions, "participants", "participants.players"); } else { page = eventDAO.findAllFetchWithParticipantsAndPlayers(pageable, criterions); } ModelAndView mav = new ModelAndView(getModuleName() + "/events"); mav.addObject("Page", page); mav.addObject("Models", page.getContent()); mav.addObject("moduleName", getModuleName()); mav.addObject("status", status); return mav; }
From source file:de.arago.rike.svg.SVG.java
License:Open Source License
@Override protected boolean checkViewData(IDataWrapper data) { if (!SecurityHelper.isLoggedIn(data.getUser())) return false; if (data.getSessionAttribute("taskListFilter") == null) { data.setSessionAttribute("taskListFilter", new TaskListFilter() { @Override//w w w . j a v a 2 s . com public void setDefaultOptions() { super.setDefaultOptions(); DataHelperRike<Milestone> helper = new DataHelperRike<Milestone>(Milestone.class); List<Milestone> list = helper.list(helper .filter().addOrder(Order.asc("dueDate")).add(Restrictions .and(Restrictions.isNotNull("dueDate"), Restrictions.ge("dueDate", new Date()))) .setMaxResults(1)); if (list.size() > 0) { setIsActive(true); setMilestone("milestone_" + list.get(0).getId().toString()); } } }); } Long nextUpdate = (Long) data.getSessionAttribute("nextUpdate"); if (nextUpdate == null || nextUpdate < System.currentTimeMillis() || data.getSessionAttribute("lastActivity") == null) { data.setSessionAttribute("nextUpdate", System.currentTimeMillis() + Long.parseLong(GlobalConfig.get(CHECK_PERIOD_SECONDS)) * 1000); data.setSessionAttribute("lastActivity", lastChange()); } if (data.getSessionAttribute("portletTitle") == null) { String milestone = ((TaskListFilter) data.getSessionAttribute("taskListFilter")).getMilestone(); data.setSessionAttribute("portletTitle", new PortletTitleWithMilestone(milestone, "Dependencies")); } return true; }
From source file:de.escidoc.core.common.business.filter.CqlFilter.java
License:Open Source License
/** * Evaluate a CQL relation.//from w w w .j av a2 s .com * * @param relation * CQL relation * @param propertyName * left side of the statement * @param value * right side of the statement * @param useLike * use LIKE instead of = in case of an equality relation * @return Hibernate query reflecting the given CQL query * @throws InvalidSearchQueryException * thrown if the given search query could not be translated into a SQL query */ protected Criterion evaluate(final CQLRelation relation, final String propertyName, final Object value, final boolean useLike) throws InvalidSearchQueryException { final Criterion result; final String rel = relation.getBase(); if (value == null || value.toString().length() == 0) { result = Restrictions.isNull(propertyName); } else { if ("<".equals(rel)) { result = Restrictions.lt(propertyName, value); } else if ("<=".equals(rel)) { result = Restrictions.le(propertyName, value); } else if ("=".equals(rel)) { result = useLike ? Restrictions.like(propertyName, value) : Restrictions.eq(propertyName, value); } else if (">=".equals(rel)) { result = Restrictions.ge(propertyName, value); } else if (">".equals(rel)) { result = Restrictions.gt(propertyName, value); } else if ("<>".equals(rel)) { result = Restrictions.ne(propertyName, value); } else { throw new InvalidSearchQueryException(rel + ": relation not implemented"); } } return result; }
From source file:de.forsthaus.backend.dao.impl.MyCalendarEventDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from www. j av a2 s. com public List<MyCalendarEvent> getCalendarEventsFromToDate(Date beginDate, Date endDate, long usrId) { DetachedCriteria criteria = DetachedCriteria.forClass(MyCalendarEvent.class); criteria.add(Restrictions.ge("beginDate", beginDate)); criteria.add(Restrictions.le("endDate", endDate)); criteria.add(Restrictions.eq("secUser.id", usrId)); criteria.setFetchMode("secUser", FetchMode.JOIN); return getHibernateTemplate().findByCriteria(criteria); }
From source file:de.iteratec.iteraplan.businesslogic.reports.query.node.AbstractLeafNode.java
License:Open Source License
/** * Returns the {@link Criterion} for the specified {@code effectivePropertyName} and {@code comparator}. * //www .j a v a 2 s.c om * @param effectivePropertyName the property name path * @param comparator the comparator describing the compare operation * @param attrType string representation of the property's attribute type as in {@link BBAttribute#getTypeOfAttribute(String)} * @return the newly created {@link Criterion} for the specified {@code comparator} or {@code null} if the * comparator is not supported */ protected Criterion getCriterionForComparator(String effectivePropertyName, Comparator comparator, String attrType) { Criterion criterion = null; switch (comparator) { case EQ: criterion = Restrictions.eq(effectivePropertyName, getProcessedPattern()); break; case GEQ: criterion = Restrictions.ge(effectivePropertyName, getProcessedPattern()); break; case LEQ: criterion = Restrictions.le(effectivePropertyName, getProcessedPattern()); break; case GT: criterion = Restrictions.gt(effectivePropertyName, getProcessedPattern()); break; case LT: criterion = Restrictions.lt(effectivePropertyName, getProcessedPattern()); break; case LIKE: criterion = new IteraplanLikeExpression(effectivePropertyName, getProcessedPattern().toString(), true); break; case NOT_LIKE: criterion = Restrictions.not( new IteraplanLikeExpression(effectivePropertyName, getProcessedPattern().toString(), true)); break; case IS: // see Type#getSpecialPropertyHQLStrings criterion = "null".equals(getPattern()) ? Restrictions.isNull(effectivePropertyName) : Restrictions.isNotNull(effectivePropertyName); break; case ANY_ASSIGNMENT: criterion = getAnyAssignmentCriterion(effectivePropertyName, attrType); break; case NO_ASSIGNMENT: criterion = getNoAssignmentCriterion(effectivePropertyName, attrType); break; case NEQ: criterion = Restrictions.ne(effectivePropertyName, getProcessedPattern()); break; default: break; } return criterion; }