/** * This method will build out criteria in the key-value paradigm (attribute-value). * * @param negativeFieldValues * @return */ private Criteria buildNegativeCriteria(Map<String, ?> negativeFieldValues) { Criteria criteria = new Criteria(); for (Iterator i = negativeFieldValues.entrySet().iterator(); i.hasNext();) { Map.Entry<String, Object> e = (Map.Entry<String, Object>) i.next(); String key = e.getKey(); Object value = e.getValue(); if (value instanceof Collection) { criteria.addNotIn(key, (Collection) value); } else { criteria.addNotEqualTo(key, value); } } return criteria; }
@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; }
@Override public List<LeaveCalendarDocumentHeader> getApprovalDelinquentDocumentHeaders(String principalId) { Criteria crit = new Criteria(); List<LeaveCalendarDocumentHeader> lstDocumentHeaders = new ArrayList<LeaveCalendarDocumentHeader>(); crit.addEqualTo("principalId", principalId); crit.addNotEqualTo("documentStatus", HrConstants.ROUTE_STATUS.INITIATED); 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; }
public int getCountByChartOrgAndLockboxNumber(String processingChartCode, String processingOrgCode, String lockboxNumber) { Criteria criteria = new Criteria(); criteria.addEqualTo("lockboxNumber", lockboxNumber); criteria.addNotEqualTo("processingChartOfAccountCode", processingChartCode); criteria.addNotEqualTo("processingOrganizationCode", processingOrgCode); return getPersistenceBrokerTemplate().getCount(QueryFactory.newQuery(SystemInformation.class, criteria)); }
/** * @see org.kuali.kfs.module.ld.dataaccess.LaborLedgerPendingEntryDao#hasPendingLaborLedgerEntry(java.util.Map, java.lang.Object) */ public Collection<LaborLedgerPendingEntry> hasPendingLaborLedgerEntry(Map fieldValues, Object businessObject) { LOG.debug("hasPendingLaborLedgerEntry() started"); Criteria criteria = new Criteria(); for (Iterator iter = fieldValues.keySet().iterator(); iter.hasNext();) { String element = (String) iter.next(); if (element.equals("documentNumber")) { criteria.addNotEqualTo(element, fieldValues.get(element)); } else { criteria.addEqualTo(element, fieldValues.get(element)); } } QueryByCriteria qbc = QueryFactory.newQuery(getEntryClass(), criteria); return getPersistenceBrokerTemplate().getCollectionByQuery(qbc); }
/** * This method creates Criteria that exclude the fund balance object type from the result. * @return Criteria */ protected Criteria buildCriteriaToExcludeFundBalance() { SystemOptions option = optionsService.getCurrentYearOptions(); String fundBalanceObjectTypeCode = option.getFinObjectTypeFundBalanceCd(); Criteria criteria = new Criteria(); criteria.addNotEqualTo(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE, fundBalanceObjectTypeCode); return criteria; }
public List<PaymentRequestDocument> getPaymentRequestInReceivingStatus() { Criteria criteria = new Criteria(); criteria.addNotEqualTo("holdIndicator", "Y"); criteria.addNotEqualTo("paymentRequestedCancelIndicator", "Y"); criteria.addEqualTo("statusCode", PurapConstants.PaymentRequestStatuses.AWAITING_RECEIVING_REVIEW); Query query = new QueryByCriteria(PaymentRequestDocument.class, criteria); Iterator<PaymentRequestDocument> documents = (Iterator<PaymentRequestDocument>) getPersistenceBrokerTemplate().getIteratorByQuery(query); ArrayList<String> documentHeaderIds = new ArrayList<String>(); while (documents.hasNext()) { PaymentRequestDocument document = (PaymentRequestDocument) documents.next(); documentHeaderIds.add(document.getDocumentNumber()); } if (documentHeaderIds.size() > 0) { try { return SpringContext.getBean(DocumentService.class).getDocumentsByListOfDocumentHeaderIds(PaymentRequestDocument.class, documentHeaderIds); } catch (WorkflowException e) { throw new InfrastructureException("unable to retrieve paymentRequestDocuments", e); } } else { return null; } } }
public List<String> getLockingDocumentNumbers(Collection capitalAssetNumbers, Collection documentTypeNames, String documentNumber) { // build the query criteria Criteria criteria = new Criteria(); criteria.addIn(CabPropertyConstants.CapitalAssetLock.CAPITAL_ASSET_NUMBER,capitalAssetNumbers); if (documentTypeNames != null && !documentTypeNames.isEmpty()) { criteria.addIn(CabPropertyConstants.CapitalAssetLock.DOCUMENT_TYPE_NAME, documentTypeNames); } // if a docHeaderId is specified, then it will be excluded from the // locking representation test. if (StringUtils.isNotBlank(documentNumber)) { criteria.addNotEqualTo(KNSPropertyConstants.DOCUMENT_NUMBER, documentNumber); } // attempt to retrieve a document based off this criteria Collection<AssetLock> assetLocks = getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(AssetLock.class, criteria)); List<String> documentNumbers = new ArrayList(); if (!assetLocks.isEmpty()) { for (AssetLock assetLock : assetLocks) { documentNumbers.add( assetLock.getDocumentNumber()); } } return documentNumbers; }
/** * this method makes sure all accounting periods inn the target fiscal year are open * * @param request fiscal year (or other fiscal period) which is the TARGET of the load */ protected void openAllAccountingPeriods(Integer requestYear) { Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, requestYear); criteriaID.addNotEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_PERIOD_STATUS_CODE, "Y"); QueryByCriteria queryID = new QueryByCriteria(AccountingPeriod.class, criteriaID); Iterator<AccountingPeriod> unopenPeriods = getPersistenceBrokerTemplate().getIteratorByQuery(queryID); int periodsOpened = 0; while (unopenPeriods.hasNext()) { AccountingPeriod periodToOpen = unopenPeriods.next(); periodToOpen.setActive(true); getPersistenceBrokerTemplate().store(periodToOpen); periodsOpened = periodsOpened + 1; } LOG.warn(String.format("\n\naccounting periods for %d changed to open status: %d", requestYear, new Integer(periodsOpened))); }
/** * @see org.kuali.kfs.module.purap.document.dataaccess.PurchaseOrderDao#getAutoCloseRecurringPurchaseOrders(java.util.List) */ public List<AutoClosePurchaseOrderView> getAutoCloseRecurringPurchaseOrders(List<String> excludedVendorChoiceCodes) { LOG.debug("getAutoCloseRecurringPurchaseOrders() started."); Criteria criteria = new Criteria(); criteria.addNotNull(PurapPropertyConstants.RECURRING_PAYMENT_TYPE_CODE); criteria.addEqualTo(PurapPropertyConstants.PURCHASE_ORDER_STATUS_CODE, PurapConstants.PurchaseOrderStatuses.OPEN); for (String excludeCode : excludedVendorChoiceCodes) { criteria.addNotEqualTo(PurapPropertyConstants.VENDOR_CHOICE_CODE, excludeCode); } QueryByCriteria qbc = new QueryByCriteria(AutoClosePurchaseOrderView.class, criteria); LOG.debug("getAutoCloseRecurringPurchaseOrders() Query criteria is " + criteria.toString()); List<AutoClosePurchaseOrderView> l = (List<AutoClosePurchaseOrderView>) getPersistenceBrokerTemplate().getCollectionByQuery(qbc); LOG.debug("getAutoCloseRecurringPurchaseOrders() ended."); return l; }
/** * This method builds the query to fetch the pending budget construction general ledger rows to be loaded * * @param fiscalYear: the year to be loaded * @return query for fetching pending budget construction GL rows */ protected QueryByCriteria queryForPendingBudgetConstructionGeneralLedger(Integer fiscalYear) { // we only select rows which have non-zero budget amounts // on this object, proxy=true, so we can do a regular query for a business object instead of a report query Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear); criteriaID.addNotEqualTo(KFSPropertyConstants.ACCOUNT_LINE_ANNUAL_BALANCE_AMOUNT, new KualiInteger(0)); QueryByCriteria queryID = new QueryByCriteria(PendingBudgetConstructionGeneralLedger.class, criteriaID); return queryID; }
/** * add the status code into the given criteria. The status code can be categorized into approved and all. * * @param criteria the given criteria * @param isApproved the flag that indictates if only approved status code can be added into the given searach criteria */ protected void addStatusCode(Criteria criteria, boolean isOnlyApproved) { // add criteria for the approved pending entries if (isOnlyApproved) { criteria.addIn("documentHeader.financialDocumentStatusCode", this.buildApprovalCodeList()); criteria.addNotEqualTo(KFSPropertyConstants.FINANCIAL_DOCUMENT_APPROVED_CODE, KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.PROCESSED); } else { Criteria subCriteria1 = new Criteria(); subCriteria1.addNotEqualTo(KFSPropertyConstants.FINANCIAL_DOCUMENT_APPROVED_CODE, KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.PROCESSED); Criteria subCriteria2 = new Criteria(); subCriteria2.addIsNull(KFSPropertyConstants.FINANCIAL_DOCUMENT_APPROVED_CODE); subCriteria1.addOrCriteria(subCriteria2); criteria.addAndCriteria(subCriteria1); } }
/** * @see org.kuali.kfs.module.ec.dataaccess.EffortCertificationReportDefinitionDao#getOverlappingReportDefinitions(org.kuali.kfs.module.ec.businessobject.EffortCertificationReportDefinition) */ public List<EffortCertificationReportDefinition> getAllOtherActiveByType(EffortCertificationReportDefinition effortCertificationReportDefinition) { Criteria criteria = new Criteria(); criteria.addEqualTo(EffortPropertyConstants.EFFORT_CERTIFICATION_REPORT_TYPE_CODE, effortCertificationReportDefinition.getEffortCertificationReportTypeCode()); criteria.addEqualTo(KFSPropertyConstants.ACTIVE, true); Criteria subCriteria = new Criteria(); Criteria subCriteriaReportNumber = new Criteria(); subCriteria.addNotEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, effortCertificationReportDefinition.getUniversityFiscalYear()); subCriteriaReportNumber.addNotEqualTo(EffortPropertyConstants.EFFORT_CERTIFICATION_REPORT_NUMBER, effortCertificationReportDefinition.getEffortCertificationReportNumber()); subCriteria.addOrCriteria(subCriteriaReportNumber); criteria.addAndCriteria(subCriteria); Collection col = getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(EffortCertificationReportDefinition.class, criteria)); Iterator i = col.iterator(); List<EffortCertificationReportDefinition> overlappingReportDefinitions = new ArrayList(); while (i.hasNext()) { EffortCertificationReportDefinition temp = (EffortCertificationReportDefinition) i.next(); overlappingReportDefinitions.add(temp); } return overlappingReportDefinitions; }
public Set<String> getPortletWindowIds(org.apache.jetspeed.om.portlet.PortletDefinition portletdefinition) { Set<String> windowsId = new TreeSet<String>(); String appName = portletdefinition.getApplication().getName(); String portletName = portletdefinition.getPortletName(); Criteria c = new Criteria(); c.addEqualTo(DTYPE, DISCRIMINATOR_USER); c.addEqualTo(APPLICATION_NAME, appName); c.addEqualTo(PORTLET_NAME, portletName); c.addNotEqualTo(ENTITY_ID, EMPTY_VALUE); ReportQueryByCriteria query = QueryFactory.newReportQuery(DatabasePreference.class, c); query.setAttributes(new String[] {ENTITY_ID, "id" }); Iterator<Object[]> ObjectwindowsId = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(query); while (ObjectwindowsId.hasNext()) { windowsId.add((String) ObjectwindowsId.next()[0]); } return windowsId; }
/** * @see org.kuali.kfs.module.purap.document.dataaccess.PurchaseOrderDao#getAllOpenPurchaseOrders(java.util.List) */ public List<AutoClosePurchaseOrderView> getAllOpenPurchaseOrders(List<String> excludedVendorChoiceCodes) { LOG.debug("getAllOpenPurchaseOrders() started"); Criteria criteria = new Criteria(); criteria.addIsNull(PurapPropertyConstants.RECURRING_PAYMENT_TYPE_CODE); criteria.addEqualTo(PurapPropertyConstants.PURCHASE_ORDER_STATUS_CODE, PurapConstants.PurchaseOrderStatuses.OPEN); criteria.addEqualTo(PurapPropertyConstants.TOTAL_ENCUMBRANCE, new KualiDecimal(0)); criteria.addEqualTo(PurapPropertyConstants.PURCHASE_ORDER_CURRENT_INDICATOR, true); for (String excludeCode : excludedVendorChoiceCodes) { criteria.addNotEqualTo(PurapPropertyConstants.VENDOR_CHOICE_CODE, excludeCode); } QueryByCriteria qbc = new QueryByCriteria(AutoClosePurchaseOrderView.class, criteria); LOG.debug("getAllOpenPurchaseOrders() Query criteria is " + criteria.toString()); List<AutoClosePurchaseOrderView> l = (List<AutoClosePurchaseOrderView>) getPersistenceBrokerTemplate().getCollectionByQuery(qbc); LOG.debug("getAllOpenPurchaseOrders() ended."); return l; }
/** * @see org.kuali.rice.krad.dao.MaintenanceDocumentDao#getLockingDocumentNumber(java.lang.String, java.lang.String) */ public String getLockingDocumentNumber(String lockingRepresentation, String documentNumber) { String lockingDocNumber = ""; // build the query criteria Criteria criteria = new Criteria(); criteria.addEqualTo("lockingRepresentation", lockingRepresentation); // if a docHeaderId is specified, then it will be excluded from the // locking representation test. if (StringUtils.isNotBlank(documentNumber)) { criteria.addNotEqualTo(KRADPropertyConstants.DOCUMENT_NUMBER, documentNumber); } // attempt to retrieve a document based off this criteria MaintenanceLock maintenanceLock = (MaintenanceLock) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(MaintenanceLock.class, criteria)); // if a document was found, then there's already one out there pending, and // we consider it 'locked' and we return the docnumber. if (maintenanceLock != null) { lockingDocNumber = maintenanceLock.getDocumentNumber(); } return lockingDocNumber; }
public Set<String> getUserNames(org.apache.jetspeed.om.portlet.PortletDefinition portletdefinition, String windowId) { Set<String> userNames = new TreeSet<String>(); String appName = portletdefinition.getApplication().getName(); String portletName = portletdefinition.getPortletName(); Criteria c = new Criteria(); c.addEqualTo(DTYPE, DISCRIMINATOR_USER); c.addEqualTo(APPLICATION_NAME, appName); c.addEqualTo(PORTLET_NAME, portletName); c.addEqualTo(ENTITY_ID, windowId); c.addNotEqualTo(USER_NAME, EMPTY_VALUE); ReportQueryByCriteria query = QueryFactory.newReportQuery(DatabasePreference.class, c); query.setAttributes(new String[] {USER_NAME, "id" }); query.setDistinct(true); Iterator<Object[]> userObjects = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(query); while (userObjects.hasNext()) { userNames.add((String) userObjects.next()[0]); } return userNames; }
/** * @see org.kuali.kfs.module.cg.dataaccess.AwardDao#getAwardsToClose(org.kuali.kfs.module.cg.businessobject.Close) */ public Collection<Award> getAwardsToClose(ProposalAwardCloseDocument close) { Criteria criteria = new Criteria(); criteria.addIsNull("awardClosingDate"); criteria.addLessOrEqualThan("awardEntryDate", close.getCloseOnOrBeforeDate()); criteria.addNotEqualTo("awardStatusCode", "U"); return (Collection<Award>) getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(Award.class, criteria)); }
/** * Checks to see if the TransactionArchiveSecurity exists in TransactionArchive with the given condition * @param documentTypeNames * @param transactionArchiveSecurity * @return */ protected boolean existsTransactionArchiveSecurityWithDocNames(String kemid, List<String> documentTypeNames, TransactionArchiveSecurity transactionArchiveSecurity, Date currentDate) { Criteria crit = new Criteria(); crit.addEqualTo(EndowPropertyConstants.TRANSACTION_ARCHIVE_POSTED_DATE, currentDate); crit.addNotEqualTo(EndowPropertyConstants.TRANSACTION_ARCHIVE_KEM_ID, kemid); if (documentTypeNames != null && !documentTypeNames.isEmpty()) { crit.addIn(EndowPropertyConstants.TRANSACTION_ARCHIVE_TYPE_CODE, documentTypeNames); } crit.addEqualTo(EndowPropertyConstants.TRANSACTION_ARCHIVE_DOCUMENT_NUMBER, transactionArchiveSecurity.getDocumentNumber()); crit.addEqualTo(EndowPropertyConstants.TRANSACTION_ARCHIVE_LINE_NUMBER, transactionArchiveSecurity.getLineNumber()); crit.addEqualTo(EndowPropertyConstants.TRANSACTION_ARCHIVE_LINE_TYPE_CODE, transactionArchiveSecurity.getLineTypeCode()); return getPersistenceBrokerTemplate().getCount(QueryFactory.newQuery(TransactionArchive.class, crit)) > 0 ? true : false; }
/** * @see org.kuali.kfs.module.endow.dataaccess.IncomeDistributionForPooledFundDao#getKemidPayoutInstructionForECT(java.lang.String) */ public List<KemidPayoutInstruction> getKemidPayoutInstructionForECT(String kemid, Date currentDate) { Criteria crit = new Criteria(); Criteria crit2 = new Criteria(); Criteria crit21 = new Criteria(); crit.addEqualTo(EndowPropertyConstants.KEMID_PAY_INC_KEMID, kemid); crit.addNotEqualTo(EndowPropertyConstants.KEMID_PAY_INC_TO_KEMID, kemid); crit.addLessOrEqualThan(EndowPropertyConstants.KEMID_PAY_INC_START_DATE, currentDate); crit2.addGreaterThan(EndowPropertyConstants.KEMID_PAY_INC_END_DATE, currentDate); crit21.addIsNull(EndowPropertyConstants.KEMID_PAY_INC_END_DATE); crit2.addOrCriteria(crit21); crit.addAndCriteria(crit2); return (List<KemidPayoutInstruction>) getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(KemidPayoutInstruction.class, crit)); }