@Override public List<TimeBlockBo> getIntersectingTimeBlocks(String principalId, Interval interval) { Criteria rootCriteria = new Criteria(); rootCriteria.addEqualTo("principalId", principalId); Criteria orCriteria = new Criteria(); Criteria beginCriteria = new Criteria(); Criteria endCriteria = new Criteria(); Timestamp intervalStart = new Timestamp(interval.getStartMillis()); Timestamp intervalEnd = new Timestamp(interval.getEndMillis()); beginCriteria.addBetween("beginTimestamp", intervalStart, intervalEnd); endCriteria.addBetween("endTimestamp", intervalStart, intervalEnd); orCriteria.addOrCriteria(beginCriteria); orCriteria.addOrCriteria(endCriteria); rootCriteria.addAndCriteria(orCriteria); Query query = QueryFactory.newQuery(TimeBlockBo.class, rootCriteria); List<TimeBlockBo> timeBlocks = (List<TimeBlockBo>) this.getPersistenceBrokerTemplate().getCollectionByQuery(query); return timeBlocks == null || timeBlocks.isEmpty() ? new ArrayList<TimeBlockBo>() : timeBlocks; }
protected void clearBothYearsBCPosition(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaId = new Criteria(); criteriaId.addBetween(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, BaseYear, RequestYear); QueryByCriteria queryId = new QueryByCriteria(BudgetConstructionPosition.class, criteriaId); getPersistenceBrokerTemplate().deleteByQuery(queryId); getPersistenceBrokerTemplate().clearCache(); }
protected void clearBothYearsHeaders(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaId = new Criteria(); criteriaId.addBetween(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, BaseYear, RequestYear); QueryByCriteria queryId = new QueryByCriteria(BudgetConstructionHeader.class, criteriaId); getPersistenceBrokerTemplate().deleteByQuery(queryId); getPersistenceBrokerTemplate().clearCache(); }
protected void clearBothYearsPendingApptFunding(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaId = new Criteria(); criteriaId.addBetween(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, BaseYear, RequestYear); QueryByCriteria queryId = new QueryByCriteria(PendingBudgetConstructionAppointmentFunding.class, criteriaId); getPersistenceBrokerTemplate().deleteByQuery(queryId); getPersistenceBrokerTemplate().clearCache(); }
throw new IllegalArgumentException("Improper syntax of BETWEEN operator in " + propertyName); criteria.addBetween(propertyName, cleanNumeric( rangeValues[0] ), cleanNumeric( rangeValues[1] )); } else if (propertyValue.startsWith(SearchOperator.GREATER_THAN_EQUAL.op())) { if (treatWildcardsAndOperatorsAsLiteral)
protected void clearBothYearsBudgetConstructionAppointmentFundingReason(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaId = new Criteria(); criteriaId.addBetween(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, BaseYear, RequestYear); QueryByCriteria queryId = new QueryByCriteria(BudgetConstructionAppointmentFundingReason.class, criteriaId); getPersistenceBrokerTemplate().deleteByQuery(queryId); getPersistenceBrokerTemplate().clearCache(); }
protected void clearBothYearsBCSF(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaId = new Criteria(); criteriaId.addBetween(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, BaseYear, RequestYear); QueryByCriteria queryId = new QueryByCriteria(BudgetConstructionCalculatedSalaryFoundationTracker.class, criteriaId); getPersistenceBrokerTemplate().deleteByQuery(queryId); getPersistenceBrokerTemplate().clearCache(); }
/** * Adds to the criteria object based on query characters given */ private void addStringRangeCriteria(String propertyName, String propertyValue, Criteria criteria) { try { if (StringUtils.contains(propertyValue, SearchOperator.BETWEEN.op())) { String[] rangeValues = StringUtils.split(propertyValue, SearchOperator.BETWEEN.op()); if (rangeValues.length < 2) throw new IllegalArgumentException("Improper syntax of BETWEEN operator in " + propertyName); criteria.addBetween(propertyName, rangeValues[0], rangeValues[1]); } else if (propertyValue.startsWith(SearchOperator.GREATER_THAN_EQUAL.op())) { criteria.addGreaterOrEqualThan(propertyName, ObjectUtils.clean(propertyValue)); } else if (propertyValue.startsWith(SearchOperator.LESS_THAN_EQUAL.op())) { criteria.addLessOrEqualThan(propertyName, ObjectUtils.clean(propertyValue)); } else if (propertyValue.startsWith(SearchOperator.GREATER_THAN.op())) { criteria.addGreaterThan(propertyName, ObjectUtils.clean(propertyValue)); } else if (propertyValue.startsWith(SearchOperator.LESS_THAN.op())) { criteria.addLessThan(propertyName, ObjectUtils.clean(propertyValue)); } else { criteria.addEqualTo(propertyName, ObjectUtils.clean(propertyValue)); } } catch (IllegalArgumentException ex) { GlobalVariables.getMessageMap().putError("lookupCriteria[" + propertyName + "]", RiceKeyConstants.ERROR_BETWEEN_SYNTAX, propertyName); } }
@Override public List<SystemScheduledTimeOff> getSystemScheduledTimeOffForPayPeriod( String leavePlan, LocalDate startDate, LocalDate endDate) { Criteria root = new Criteria(); root.addEqualTo("leavePlan", leavePlan); root.addBetween("accruedDate", startDate.toDate(), endDate.toDate()); return (List<SystemScheduledTimeOff>)this.getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(SystemScheduledTimeOff.class, root)); }
throw new IllegalArgumentException("Improper syntax of BETWEEN operator in " + propertyName); criteria.addBetween(propertyName, parseDate( ObjectUtils.clean(rangeValues[0] ) ), parseDate( ObjectUtils.clean(rangeValues[1] ) ) ); } else if (propertyValue.startsWith(SearchOperator.GREATER_THAN_EQUAL.op())) { if (treatWildcardsAndOperatorsAsLiteral)
@Override public ClockLogBo getLastClockLog(String principalId, String jobNumber, String workArea, String task, CalendarEntryBo calendarEntry) { Criteria criteria = new Criteria(); criteria.addEqualTo("principalId", principalId); criteria.addEqualTo("jobNumber", jobNumber); criteria.addEqualTo("workArea", workArea); criteria.addEqualTo("task", task); Criteria clockTimeJoinCriteria = new Criteria(); clockTimeJoinCriteria.addEqualToField("principalId", Criteria.PARENT_QUERY_PREFIX + "principalId"); clockTimeJoinCriteria.addEqualToField("jobNumber", Criteria.PARENT_QUERY_PREFIX + "jobNumber"); clockTimeJoinCriteria.addEqualToField("workArea", Criteria.PARENT_QUERY_PREFIX + "workArea"); clockTimeJoinCriteria.addEqualToField("task", Criteria.PARENT_QUERY_PREFIX + "task"); clockTimeJoinCriteria.addBetween("clockTimestamp", calendarEntry.getBeginPeriodDate(), calendarEntry.getEndPeriodDate()); ReportQueryByCriteria clockTimeSubQuery = QueryFactory.newReportQuery(ClockLogBo.class, clockTimeJoinCriteria); clockTimeSubQuery.setAttributes(new String[]{"max(clockTimestamp)"}); criteria.addEqualTo("clockTimestamp", clockTimeSubQuery); Criteria timestampJoinCriteria = new Criteria(); timestampJoinCriteria.addEqualToField("principalId", Criteria.PARENT_QUERY_PREFIX + "principalId"); timestampJoinCriteria.addEqualToField("jobNumber", Criteria.PARENT_QUERY_PREFIX + "jobNumber"); timestampJoinCriteria.addEqualToField("workArea", Criteria.PARENT_QUERY_PREFIX + "workArea"); timestampJoinCriteria.addEqualToField("task", Criteria.PARENT_QUERY_PREFIX + "task"); timestampJoinCriteria.addBetween("clockTimestamp", calendarEntry.getBeginPeriodDate(), calendarEntry.getEndPeriodDate()); ReportQueryByCriteria timestampSubQuery = QueryFactory.newReportQuery(ClockLogBo.class, timestampJoinCriteria); timestampSubQuery.setAttributes(new String[]{"max(timestamp)"}); criteria.addEqualTo("timestamp", timestampSubQuery); return (ClockLogBo) this.getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(ClockLogBo.class, criteria)); }