List of usage examples for org.hibernate.criterion Restrictions between
public static Criterion between(String propertyName, Object low, Object high)
From source file:org.codehaus.groovy.grails.orm.hibernate.query.AbstractHibernateQuery.java
License:Apache License
@Override public Query between(String property, Object start, Object end) { addToCriteria(Restrictions.between(calculatePropertyName(property), start, end)); return this; }
From source file:org.codehaus.groovy.grails.orm.hibernate.query.HibernateQuery.java
License:Apache License
@Override public Query between(String property, Object start, Object end) { criteria.add(Restrictions.between(property, start, end)); return this; }
From source file:org.egov.council.service.CouncilAgendaService.java
License:Open Source License
public Criteria buildSearchCriteria(CouncilAgenda councilAgenda) { final Criteria criteria = getCurrentSession().createCriteria(CouncilAgenda.class, "councilAgenda") .createAlias("councilAgenda.status", "status"); if (null != councilAgenda.getStatus()) criteria.add(Restrictions.eq("status", councilAgenda.getStatus().getCode())); if (null != councilAgenda.getCommitteeType()) criteria.add(Restrictions.eq("committeeType", councilAgenda.getCommitteeType())); if (councilAgenda.getFromDate() != null && councilAgenda.getToDate() != null) { criteria.add(Restrictions.between("councilAgenda.createdDate", councilAgenda.getFromDate(), DateUtils.addDays(councilAgenda.getToDate(), 1))); }//from w ww.j a v a 2 s. c o m if (null != councilAgenda.getAgendaNumber()) criteria.add(Restrictions.ilike("councilAgenda.agendaNumber", councilAgenda.getAgendaNumber(), MatchMode.ANYWHERE)); return criteria; }
From source file:org.egov.council.service.CouncilMeetingService.java
License:Open Source License
public Criteria buildSearchCriteria(CouncilMeeting councilMeeting) { final Criteria criteria = getCurrentSession().createCriteria(CouncilMeeting.class, "councilMeeting") .createAlias("councilMeeting.status", "status"); if (councilMeeting.getCommitteeType() != null) criteria.add(Restrictions.eq("committeeType", councilMeeting.getCommitteeType())); if (councilMeeting.getMeetingNumber() != null) criteria.add(Restrictions.eq("meetingNumber", councilMeeting.getMeetingNumber())); if (councilMeeting.getFromDate() != null && councilMeeting.getToDate() != null) { criteria.add(Restrictions.between("meetingDate", councilMeeting.getFromDate(), DateUtils.addDays(councilMeeting.getToDate(), 1))); }//from www . j av a 2 s . c om if (councilMeeting.getMeetingType() != null) criteria.add(Restrictions.eq("meetingType", councilMeeting.getMeetingType())); return criteria; }
From source file:org.egov.council.service.CouncilPreambleService.java
License:Open Source License
public Criteria buildSearchCriteria(CouncilPreamble councilPreamble) { final Criteria criteria = getCurrentSession().createCriteria(CouncilPreamble.class, "councilPreamble") .createAlias("councilPreamble.status", "status"); if (councilPreamble.getDepartment() != null) criteria.add(Restrictions.eq("councilPreamble.department", councilPreamble.getDepartment())); if (councilPreamble.getFromDate() != null && councilPreamble.getToDate() != null) { criteria.add(Restrictions.between("councilPreamble.createdDate", councilPreamble.getFromDate(), DateUtils.addDays(councilPreamble.getToDate(), 1))); }// w w w.j av a 2s . com if (councilPreamble.getPreambleNumber() != null) criteria.add(Restrictions.ilike("councilPreamble.preambleNumber", councilPreamble.getPreambleNumber(), MatchMode.ANYWHERE)); if (councilPreamble.getWards() != null && !councilPreamble.getWards().isEmpty()) { ArrayList<Long> boundaryid = new ArrayList<>(); for (Boundary bndry : councilPreamble.getWards()) { boundaryid.add(bndry.getId()); } if (!boundaryid.isEmpty()) criteria.createAlias("councilPreamble.wards", "wards").add(Restrictions.in("wards.id", boundaryid)); } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria; }
From source file:org.egov.egf.web.actions.report.FundFlowManualEntryReportAction.java
License:Open Source License
@SuppressWarnings("unchecked") public void getResultList() { // manualEntryReportList = new ArrayList<Map<String,Object>>(); if (LOGGER.isDebugEnabled()) LOGGER.debug("Inside getResultList "); Date startdt = null;//from w w w . ja v a 2 s . c o m Date enddt = null; grandTotal = BigDecimal.ZERO; try { startdt = Constants.DDMMYYYYFORMAT2.parse(reportSearch.getStartDate()); enddt = Constants.DDMMYYYYFORMAT2.parse(reportSearch.getEndDate()); } catch (final ParseException e) { LOGGER.error("Error in parsing Date "); } final Criteria critQuery = persistenceService.getSession().createCriteria(FundFlowBean.class) .add(Restrictions.between("reportDate", startdt, enddt)) .add(Restrictions.ne("currentReceipt", BigDecimal.ZERO)) .add(Restrictions.eq("bankAccountId", BigDecimal.valueOf(reportSearch.getBankAccount().getId()))) .addOrder(Order.asc("reportDate")); entryReportList.addAll(critQuery.list()); if (LOGGER.isDebugEnabled()) LOGGER.debug("No of Fund flow Manual entry during the period " + reportSearch.getStartDate() + "to " + reportSearch.getEndDate() + "is " + entryReportList.size()); for (final FundFlowBean entry : entryReportList) { manualEntry = new FundFlowBean(); // manulEntryMap.put("slNo", ++index); manualEntry.setReportDate(entry.getReportDate()); manualEntry.setCurrentReceipt(entry.getCurrentReceipt()); grandTotal = grandTotal.add(entry.getCurrentReceipt()); manualEntryReportList.add(manualEntry); // } } getSession().put("entryResultReportList", entryReportList); getSession().put("headingStr", heading); getSession().put("total", grandTotal); getSession().put("manualEntryReportList", manualEntryReportList); if (LOGGER.isInfoEnabled()) LOGGER.info("manualEntryReportList+" + manualEntryReportList.size()); }
From source file:org.egov.eventnotification.repository.EventRepositoryImpl.java
License:Open Source License
@Override public List<Event> searchEvent(EventSearch eventSearch) { Date startDate = null;//from w w w . ja v a 2 s .c om Date endDate = null; if (isNotBlank(eventSearch.getEventDateType()) && eventSearch.getEventDateType().equalsIgnoreCase("upcoming")) { startDate = startOfToday().plusDays(7).toDate(); endDate = endOfGivenDate(new DateTime(startDate)).plusDays(6).toDate(); } else if (isNotBlank(eventSearch.getEventDateType()) && eventSearch.getEventDateType().equalsIgnoreCase("ongoing")) { startDate = startOfToday().toDate(); endDate = endOfGivenDate(new DateTime(startDate)).plusDays(6).toDate(); } Criteria criteria = entityManager.unwrap(Session.class).createCriteria(Event.class, "evnt"); criteria.createAlias("evnt.eventType", "eventType"); if (isNotBlank(eventSearch.getEventType())) criteria.add(Restrictions.ilike("eventType.name", eventSearch.getEventType(), MatchMode.ANYWHERE)); if (isNotBlank(eventSearch.getName())) criteria.add(Restrictions.ilike(NAME, eventSearch.getName(), MatchMode.ANYWHERE)); if (isNotBlank(eventSearch.getEventHost())) criteria.add( Restrictions.ilike("evnt.address.eventHost", eventSearch.getEventHost(), MatchMode.ANYWHERE)); if (startDate != null && endDate != null) criteria.add(Restrictions.between("evnt.startDate", startDate, endDate)); criteria.add(Restrictions.eq("evnt.status", ACTIVE.toUpperCase())); criteria.addOrder(Order.desc("evnt.id")); return criteria.list(); }
From source file:org.egov.infstr.services.PersistenceService.java
License:Open Source License
public void addFilterCriteriaForObject(final Map<String, List> params, final Criteria c, final String... orderbyFields) { for (final Map.Entry<String, List> entry : params.entrySet()) if (entry.getKey().contains("date") || entry.getKey().contains("Date")) c.add(Restrictions.between(entry.getKey(), entry.getValue().get(0), entry.getValue().get(1))); else//from w ww . j a v a 2 s . c o m c.add(Restrictions.eq(entry.getKey(), entry.getValue().get(0))); for (final String orderBy : orderbyFields) c.addOrder(Order.asc(orderBy).ignoreCase()); }
From source file:org.egov.mrs.application.reports.service.MarriageRegistrationReportsService.java
License:Open Source License
@ReadOnly @SuppressWarnings("unchecked") public List<MarriageRegistration> getAgewiseDetails(final MarriageRegistration registration, final String regunit, final String age, final int year, final String applicant) throws ParseException { final Criteria criteria = getCurrentSession().createCriteria(MarriageRegistration.class, MARRIAGE_REGISTRATION);/* w w w . jav a2s . c o m*/ final String[] values = age.split("-"); final SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD); final Date fromDate = formatter.parse(year + "/" + 1 + "/" + 1); final Date toDate = formatter.parse(year + "/" + 12 + "/" + 31); if (HUSBAND.equals(applicant)) { criteria.createAlias(MARRIAGE_REGISTRATION_DOT_HUSBAND, HUSBAND).add(Restrictions.between( "husband.ageInYearsAsOnMarriage", Integer.valueOf(values[0]), Integer.valueOf(values[1]))); buildAgeWiseSearchCriteria(registration, regunit, criteria, fromDate, toDate); } else { criteria.createAlias(MARRIAGE_REGISTRATION_DOT_WIFE, WIFE).add(Restrictions.between( "wife.ageInYearsAsOnMarriage", Integer.valueOf(values[0]), Integer.valueOf(values[1]))); buildAgeWiseSearchCriteria(registration, regunit, criteria, fromDate, toDate); } criteria.createAlias(MARRIAGE_REGISTRATION_STATUS, STATUS) .add(Restrictions.in(STATUS_DOT_CODE, MarriageRegistration.RegistrationStatus.REGISTERED.name())); return criteria.list(); }
From source file:org.egov.mrs.application.reports.service.MarriageRegistrationReportsService.java
License:Open Source License
@ReadOnly @SuppressWarnings("unchecked") public List<MarriageRegistration> searchRegistrationBydate(final MarriageRegistration registration) { final Criteria criteria = getCurrentSession().createCriteria(MarriageRegistration.class, MARRIAGE_REGISTRATION);// w ww . j a va 2 s . c o m if (null != registration.getMarriageRegistrationUnit() && registration.getMarriageRegistrationUnit().getId() != null) criteria.add(Restrictions.eq(MARRIAGE_REGISTRATION_UNIT_DOT_ID, registration.getMarriageRegistrationUnit().getId())); if (null != registration.getZone() && registration.getZone().getId() != null) criteria.add(Restrictions.eq(ZONE_ID, registration.getZone().getId())); if (null != registration.getStatus() && registration.getStatus().getCode() != null) criteria.createAlias(MARRIAGE_REGISTRATION_STATUS, STATUS) .add(Restrictions.eq(STATUS_DOT_CODE, registration.getStatus().getCode())); if (registration.getFromDate() != null) criteria.add(Restrictions.ge(MARRIAGE_REGISTRATION_APPLICATION_DATE, resetFromDateTimeStamp(registration.getFromDate()))); if (registration.getToDate() != null) criteria.add(Restrictions.le(MARRIAGE_REGISTRATION_APPLICATION_DATE, resetToDateTimeStamp(registration.getToDate()))); criteria.addOrder(Order.desc(MARRIAGE_REGISTRATION_APPLICATION_DATE)); if (registration.getFromDate() != null) { final Calendar cal = Calendar.getInstance(); final Date todate = cal.getTime(); criteria.add(Restrictions.between(MARRIAGE_REGISTRATION_APPLICATION_DATE, registration.getFromDate(), todate != null ? todate : new Date())); } if (registration.getToDate() == null) { final Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2009); final Date fromdate = cal.getTime(); criteria.add(Restrictions.between(MARRIAGE_REGISTRATION_APPLICATION_DATE, fromdate, registration.getToDate() != null ? org.apache.commons.lang3.time.DateUtils.addDays(registration.getToDate(), 1) : new Date())); } return criteria.list(); }