/** * @see org.kuali.kfs.module.purap.document.dataaccess.NegativePaymentRequestApprovalLimitDao#findBelowLimit(org.kuali.rice.kns.util.KualiDecimal) */ public Collection<NegativePaymentRequestApprovalLimit> findBelowLimit(KualiDecimal limit) { LOG.debug("Entering findBelowLimit(KualiDecimal)"); Criteria criteria = new Criteria(); criteria.addLessThan("negativePaymentRequestApprovalLimitAmount", limit); criteria.addAndCriteria(buildActiveCriteria()); Query query = new QueryByCriteria(NegativePaymentRequestApprovalLimit.class, criteria); LOG.debug("Leaving findBelowLimit(KualiDecimal)"); return getPersistenceBrokerTemplate().getCollectionByQuery(query); }
/** * @see org.kuali.kfs.module.ld.dataaccess.LaborLedgerBalanceDao#deleteLedgerBalancesPriorToYear(java.lang.Integer, java.lang.String) */ public void deleteLedgerBalancesPriorToYear(Integer fiscalYear, String chartOfAccountsCode) { LOG.debug("deleteLedgerBalancesPriorToYear() started"); Criteria criteria = new Criteria(); criteria.addLessThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear); criteria.addEqualTo(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); QueryByCriteria query = new QueryByCriteria(LedgerBalance.class, criteria); getPersistenceBrokerTemplate().deleteByQuery(query); }
/** * @see org.kuali.rice.krad.dao.PersistedLookupMetadataDao#deleteOldSelectedObjectIds(java.sql.Timestamp) */ public void deleteOldSelectedObjectIds(Timestamp expirationDate) { Criteria criteria = new Criteria(); criteria.addLessThan(KRADPropertyConstants.LOOKUP_DATE, expirationDate); getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(SelectedObjectIds.class, criteria)); } }
public List<LeaveBlockBo> getCalendarLeaveBlocks(String principalId, LocalDate beginDate, LocalDate endDate) { List<LeaveBlockBo> leaveBlocks = new ArrayList<LeaveBlockBo>(); Criteria root = new Criteria(); root.addEqualTo("principalId", principalId); root.addGreaterOrEqualThan("leaveDate", beginDate.toDate()); root.addLessThan("leaveDate", endDate.toDate()); List<String> typeValues = new ArrayList<String>(); typeValues.add(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_CALENDAR); typeValues.add(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR); typeValues.add(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE); root.addIn("leaveBlockType", typeValues); Query query = QueryFactory.newQuery(LeaveBlockBo.class, root); Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query); if (c != null) { leaveBlocks.addAll(c); } return leaveBlocks; }
/** * @see org.kuali.rice.krad.dao.PersistedLookupMetadataDao#deleteOldLookupResults(java.sql.Timestamp) */ public void deleteOldLookupResults(Timestamp expirationDate) { Criteria criteria = new Criteria(); criteria.addLessThan(KRADPropertyConstants.LOOKUP_DATE, expirationDate); getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(LookupResults.class, criteria)); }
public void purgeAllSessionDocuments(Timestamp expirationDate)throws DataAccessException { Criteria criteria = new Criteria(); criteria.addLessThan(KRADPropertyConstants.LAST_UPDATED_DATE, expirationDate); getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(SessionDocument.class, criteria)); //getPersistenceBrokerTemplate().clearCache(); }
/** * @see org.kuali.kfs.module.ld.dataaccess.LaborLedgerEntryDao#deleteLedgerEntriesPriorToYear(java.lang.Integer, java.lang.String) */ public void deleteLedgerEntriesPriorToYear(Integer fiscalYear, String chartOfAccountsCode) { LOG.debug("deleteLedgerEntriesPriorToYear() started"); Criteria criteria = new Criteria(); criteria.addLessThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear); criteria.addEqualTo(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); QueryByCriteria query = new QueryByCriteria(this.getEntryClass(), criteria); getPersistenceBrokerTemplate().deleteByQuery(query); }
@Override public List<LeaveCalendarDocumentHeader> getSubmissionDelinquentDocumentHeaders(String principalId, DateTime beforeDate) { Criteria crit = new Criteria(); List<LeaveCalendarDocumentHeader> lstDocumentHeaders = new ArrayList<LeaveCalendarDocumentHeader>(); crit.addEqualTo("principalId", principalId); crit.addLessThan("endDate", beforeDate.toDate()); crit.addNotEqualTo("documentStatus", HrConstants.ROUTE_STATUS.INITIATED); crit.addNotEqualTo("documentStatus", HrConstants.ROUTE_STATUS.ENROUTE); crit.addNotEqualTo("documentStatus", HrConstants.ROUTE_STATUS.FINAL); QueryByCriteria query = new QueryByCriteria(LeaveCalendarDocumentHeader.class, crit); Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query); if (c != null) { lstDocumentHeaders.addAll(c); } return lstDocumentHeaders; }
/** * Purge an entire fiscal year for a single chart. * * @param chartOfAccountsCode the chart of accounts code of account balances to purge * @param year the fiscal year of account balances to purge * @see org.kuali.kfs.gl.dataaccess.AccountBalanceDao#purgeYearByChart(java.lang.String, int) */ public void purgeYearByChart(String chartOfAccountsCode, int year) { LOG.debug("purgeYearByChart() started"); Criteria criteria = new Criteria(); criteria.addEqualTo(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); criteria.addLessThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, new Integer(year)); getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(AccountBalance.class, criteria)); // This is required because if any deleted account balances are in the cache, deleteByQuery doesn't // remove them from the cache so a future select will retrieve these deleted account balances from // the cache and return them. Clearing the cache forces OJB to go to the database again. getPersistenceBrokerTemplate().clearCache(); }
/** * Purge table by year/chart * * @param chart the chart of sufficient fund balances to purge * @param year the year of sufficient fund balances to purge */ public void purgeYearByChart(String chartOfAccountsCode, int year) { LOG.debug("purgeYearByChart() started"); Criteria criteria = new Criteria(); criteria.addEqualTo(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); criteria.addLessThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, new Integer(year)); getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(SufficientFundBalances.class, criteria)); // This is required because if any deleted account balances are in the cache, deleteByQuery doesn't // remove them from the cache so a future select will retrieve these deleted account balances from // the cache and return them. Clearing the cache forces OJB to go to the database again. getPersistenceBrokerTemplate().clearCache(); }
/** * Purge the sufficient funds balance table by year/chart * * @param chart the chart of balances to purge * @param year the university fiscal year of balances to purge */ public void purgeYearByChart(String chartOfAccountsCode, int year) { LOG.debug("purgeYearByChart() started"); Criteria criteria = new Criteria(); criteria.addEqualTo(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); criteria.addLessThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, new Integer(year)); getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(Balance.class, criteria)); // This is required because if any deleted account balances are in the cache, deleteByQuery doesn't // remove them from the cache so a future select will retrieve these deleted account balances from // the cache and return them. Clearing the cache forces OJB to go to the database again. getPersistenceBrokerTemplate().clearCache(); }
/** * Purge the table by year/chart. Clears persistence broker template at the end to ensure OJB has to to DB again * to retrieve the post-purged state of the DB. * * @see org.kuali.kfs.gl.dataaccess.CollectorDetailDao#purgeYearByChart(java.lang.String, int) */ public void purgeYearByChart(String chartOfAccountsCode, int universityFiscalYear) { LOG.debug("purgeYearByChart() started"); Criteria criteria = new Criteria(); criteria.addEqualTo(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); criteria.addLessThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, new Integer(universityFiscalYear)); getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(CollectorDetail.class, criteria)); // This is required because if any deleted items are in the cache, deleteByQuery doesn't // remove them from the cache so a future select will retrieve these deleted account balances from // the cache and return them. Clearing the cache forces OJB to go to the database again. getPersistenceBrokerTemplate().clearCache(); }
/** * Purge the entry table by chart/year * * @param chart the chart of accounts code of entries to purge * @param year the university fiscal year of entries to purge */ public void purgeYearByChart(String chartOfAccountsCode, int year) { LOG.debug("purgeYearByChart() started"); Criteria criteria = new Criteria(); criteria.addEqualTo(CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode); criteria.addLessThan(UNIVERISITY_FISCAL_YEAR, new Integer(year)); getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(Entry.class, criteria)); // This is required because if any deleted rows are in the cache, deleteByQuery doesn't // remove them from the cache so a future select will retrieve these deleted account balances from // the cache and return them. Clearing the cache forces OJB to go to the database again. getPersistenceBrokerTemplate().clearCache(); }
/** * Purges the database of all those encumbrances with the given chart and year * * @param chartOfAccountsCode the chart of accounts code purged encumbrances will have * @param year the university fiscal year purged encumbrances will have * @see org.kuali.kfs.gl.dataaccess.EncumbranceDao#purgeYearByChart(java.lang.String, int) */ public void purgeYearByChart(String chartOfAccountsCode, int year) { LOG.debug("purgeYearByChart() started"); Criteria criteria = new Criteria(); criteria.addEqualTo(KFSPropertyConstants.CHART, chartOfAccountsCode); criteria.addLessThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, new Integer(year)); getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(Encumbrance.class, criteria)); // This is required because if any deleted account balances are in the cache, deleteByQuery // doesn't // remove them from the cache so a future select will retrieve these deleted account // balances from // the cache and return them. Clearing the cache forces OJB to go to the database again. getPersistenceBrokerTemplate().clearCache(); }
public List<TimesheetDocumentHeader> getDocumentHeadersForYear(String principalId, String year) { Criteria crit = new Criteria(); List<TimesheetDocumentHeader> lstDocumentHeaders = new ArrayList<TimesheetDocumentHeader>(); crit.addEqualTo("principalId", principalId); DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy"); LocalDate currentYear = formatter.parseLocalDate(year); LocalDate nextYear = currentYear.plusYears(1); crit.addGreaterOrEqualThan("beginDate", currentYear.toDate()); crit.addLessThan("beginDate", nextYear.toDate()); QueryByCriteria query = new QueryByCriteria(TimesheetDocumentHeader.class, crit); Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query); if (c != null) { lstDocumentHeaders.addAll(c); } return lstDocumentHeaders; }
if (treatWildcardsAndOperatorsAsLiteral) throw new RuntimeException("Cannot use wildcards and operators on numeric field " + propertyName); criteria.addLessThan(propertyName, cleanNumeric(propertyValue)); } else { criteria.addEqualTo(propertyName, cleanNumeric(propertyValue));
/** * 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); } }
if (treatWildcardsAndOperatorsAsLiteral) throw new RuntimeException("Wildcards and operators are not allowed on this date field: " + propertyName); criteria.addLessThan(propertyName, parseDate( ObjectUtils.clean(propertyValue) ) ); } else { criteria.addEqualTo(propertyName, parseDate( ObjectUtils.clean(propertyValue) ) );
/** adds a single valued predicate to a Criteria. */ private void addSingleValuePredicate(SingleValuedPredicate p, Criteria parent) { final Object value = getVal(p.getValue()); final String pp = p.getPropertyPath(); if (p instanceof EqualPredicate) { parent.addEqualTo(pp, value); } else if (p instanceof EqualIgnoreCasePredicate) { parent.addEqualTo(genUpperFunc(pp), ((String) value).toUpperCase()); } else if (p instanceof GreaterThanOrEqualPredicate) { parent.addGreaterOrEqualThan(pp, value); } else if (p instanceof GreaterThanPredicate) { parent.addGreaterThan(pp, value); } else if (p instanceof LessThanOrEqualPredicate) { parent.addLessOrEqualThan(pp, value); } else if (p instanceof LessThanPredicate) { parent.addLessThan(pp, value); } else if (p instanceof LikePredicate) { //no need to convert * or ? since ojb handles the conversion/escaping parent.addLike(genUpperFunc(pp), ((String) value).toUpperCase()); } else if (p instanceof NotEqualPredicate) { parent.addNotEqualTo(pp, value); } else if (p instanceof NotEqualIgnoreCasePredicate) { parent.addNotEqualTo(genUpperFunc(pp), ((String) value).toUpperCase()); } else if (p instanceof NotLikePredicate) { parent.addNotLike(pp, value); } else { throw new UnsupportedPredicateException(p); } }
public Map<String, LeaveBlockBo> getLastCarryOverBlocks(String principalId, String leaveBlockType, LocalDate asOfDate) { Map<String, LeaveBlockBo> carryOver = new HashMap<String, LeaveBlockBo>(); Criteria root = new Criteria(); root.addEqualTo("principalId", principalId); root.addEqualTo("leaveBlockType", leaveBlockType); Criteria dateSubquery = new Criteria(); dateSubquery.addEqualToField("principalId", Criteria.PARENT_QUERY_PREFIX + "principalId"); dateSubquery.addEqualToField("leaveBlockType", Criteria.PARENT_QUERY_PREFIX + "leaveBlockType"); dateSubquery.addEqualToField("accrualCategory", Criteria.PARENT_QUERY_PREFIX + "accrualCategory"); if (asOfDate != null) { dateSubquery.addLessThan("leaveDate", asOfDate.toDate()); } ReportQueryByCriteria subQuery = QueryFactory.newReportQuery(LeaveBlockBo.class, dateSubquery); String[] attributes = new String[] { "max(leaveDate)" }; subQuery.setAttributes(attributes); root.addEqualTo("leaveDate", subQuery); Query query = QueryFactory.newQuery(LeaveBlockBo.class, root); Collection<LeaveBlockBo> c = (Collection<LeaveBlockBo>)this.getPersistenceBrokerTemplate().getCollectionByQuery(query); //Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query); for (LeaveBlockBo lb : c) { carryOver.put(lb.getAccrualCategory(), lb); } return carryOver; }