Search in sources :

Example 11 with QueryByCriteria

use of org.apache.ojb.broker.query.QueryByCriteria in project cu-kfs by CU-CommunityApps.

the class CuVendorDaoOjb method getVendorB2BContract.

public VendorContract getVendorB2BContract(VendorDetail vendorDetail, String campus, Date currentSqlDate) {
    Criteria header = new Criteria();
    Criteria detail = new Criteria();
    Criteria campusCode = new Criteria();
    Criteria beginDate = new Criteria();
    // Criteria endDate = new Criteria();
    Criteria b2b = new Criteria();
    header.addEqualTo("VNDR_HDR_GNRTD_ID", vendorDetail.getVendorHeaderGeneratedIdentifier());
    detail.addEqualTo("VNDR_DTL_ASND_ID", vendorDetail.getVendorDetailAssignedIdentifier());
    campusCode.addEqualTo("VNDR_CMP_CD", campus);
    beginDate.addLessOrEqualThan("VNDR_CONTR_BEG_DT", currentSqlDate);
    // endDate.addGreaterOrEqualThan("VNDR_CONTR_END_DT", currentSqlDate);
    b2b.addEqualTo("VNDR_B2B_IND", "Y");
    header.addAndCriteria(detail);
    header.addAndCriteria(campusCode);
    header.addAndCriteria(beginDate);
    // header.addAndCriteria(endDate);
    header.addAndCriteria(b2b);
    VendorContract contract = (VendorContract) getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(VendorContract.class, header));
    return contract;
}
Also used : VendorContract(org.kuali.kfs.vnd.businessobject.VendorContract) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria)

Example 12 with QueryByCriteria

use of org.apache.ojb.broker.query.QueryByCriteria in project cu-kfs by CU-CommunityApps.

the class CuVendorDaoOjb method getSearchResults.

public List<BusinessObject> getSearchResults(Map<String, String> fieldValues) {
    List results = new ArrayList();
    Map<String, VendorDetail> nonDupResults = new HashMap<String, VendorDetail>();
    RemovalAwareCollection rac = new RemovalAwareCollection();
    Criteria header = new Criteria();
    Criteria detail = new Criteria();
    Criteria taxNum = new Criteria();
    Criteria name = new Criteria();
    Criteria alias = new Criteria();
    Criteria active = new Criteria();
    Criteria type = new Criteria();
    Criteria state = new Criteria();
    Criteria commodityCode = new Criteria();
    Criteria supplierDiversity = new Criteria();
    Criteria vendorOwnershipCode = new Criteria();
    Criteria vendorSupplierDiversityExpirationDate = new Criteria();
    String headerVal = fieldValues.get(VendorPropertyConstants.VENDOR_HEADER_GENERATED_ID);
    String detailVal = fieldValues.get(VendorPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID);
    String taxNumVal = fieldValues.get(VendorPropertyConstants.VENDOR_TAX_NUMBER);
    String activeVal = fieldValues.get(ACTIVE_INDICATOR);
    String nameVal = fieldValues.get(VendorPropertyConstants.VENDOR_NAME);
    String typeVal = fieldValues.get(VendorPropertyConstants.VENDOR_TYPE_CODE);
    String stateVal = fieldValues.get(VendorPropertyConstants.VENDOR_ADDRESS + "." + VendorPropertyConstants.VENDOR_ADDRESS_STATE);
    String supplierDiversityVal = fieldValues.get(VendorPropertyConstants.VENDOR_HEADER_PREFIX + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITY_CODE);
    String vendorOwnershipCodeVal = fieldValues.get(VendorPropertyConstants.VENDOR_OWNERSHIP_CODE);
    String commodityCodeVal = fieldValues.get(VendorPropertyConstants.VENDOR_COMMODITIES_CODE_PURCHASING_COMMODITY_CODE);
    String vendorSupplierDiversityExpirationDateVal = fieldValues.get(VendorPropertyConstants.VENDOR_HEADER_PREFIX + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION);
    // KFSPTS-1891
    String defaultPaymentMethod = fieldValues.get("extension.defaultB2BPaymentMethodCode");
    if (StringUtils.isNotBlank(headerVal)) {
        // 
        header.addEqualTo("vendorHeaderGeneratedIdentifier", headerVal);
    }
    if (StringUtils.isNotBlank(detailVal)) {
        detail.addEqualTo("vendorDetailAssignedIdentifier", detailVal);
        header.addAndCriteria(detail);
    }
    if (StringUtils.isNotBlank(taxNumVal)) {
        // THIS IS ENCRYPTED IN THE DB, COMES OFF HDR TABLE
        taxNum.addEqualTo("vendorHeader.vendorTaxNumber", taxNumVal);
        header.addAndCriteria(taxNum);
    }
    if (StringUtils.isNotBlank(activeVal)) {
        // VNDR_DTL
        active.addEqualTo(ACTIVE_INDICATOR, activeVal);
        header.addAndCriteria(active);
    }
    if (StringUtils.isNotBlank(nameVal) && nameVal.contains("*")) {
        String upperVendorName = getDbPlatform().getUpperCaseFunction() + "( vendorName )";
        String upperNameVal = nameVal.toUpperCase();
        name.addLike(upperVendorName, upperNameVal);
        alias.addLike(getDbPlatform().getUpperCaseFunction() + "( " + VendorPropertyConstants.VENDOR_ALIAS_NAME_FULL_PATH + " )", upperNameVal);
        alias.addEqualTo(VendorPropertyConstants.VENDOR_ALIAS_ACTIVE, "Y");
        Criteria t = new Criteria();
        t.addOrCriteria(name);
        t.addOrCriteria(alias);
        header.addAndCriteria(t);
    }
    if (StringUtils.isNotBlank(nameVal) && !nameVal.contains("*")) {
        name.addEqualTo(VendorPropertyConstants.VENDOR_NAME, nameVal);
        alias.addEqualTo(VendorPropertyConstants.VENDOR_ALIAS_NAME_FULL_PATH, nameVal);
        alias.addEqualTo(VendorPropertyConstants.VENDOR_ALIAS_ACTIVE, "Y");
        Criteria t = new Criteria();
        t.addOrCriteria(name);
        t.addOrCriteria(alias);
        header.addAndCriteria(t);
    }
    if (StringUtils.isNotBlank(typeVal)) {
        // VNDR_HDR
        type.addEqualTo(VendorPropertyConstants.VENDOR_TYPE_CODE, typeVal);
        header.addAndCriteria(type);
    }
    if (StringUtils.isNotBlank(stateVal)) {
        // THIS COMES OUT OF PUR_VND_ADDR_T
        state.addEqualTo(VendorPropertyConstants.VENDOR_ADDRESS_STATE_CODE, stateVal);
        header.addAndCriteria(state);
    }
    if (StringUtils.isNotBlank(commodityCodeVal)) {
        // THIS COMES OUT OF PUR_VNDR_COMM_T
        commodityCode.addEqualTo(VendorPropertyConstants.VENDOR_COMMODITIES_CODE_PURCHASING_COMMODITY_CODE, commodityCodeVal);
        header.addAndCriteria(commodityCode);
    }
    if (StringUtils.isNotBlank(supplierDiversityVal)) {
        // THIS COMES OUT OF PUR_VNDR_SUPP_DVRST_T
        supplierDiversity.addEqualTo(CUVendorPropertyConstants.VENDOR_HEADER_SUPPLIER_DIVERSITY_CODE, supplierDiversityVal);
        header.addAndCriteria(supplierDiversity);
    }
    if (StringUtils.isNotBlank(vendorOwnershipCodeVal)) {
        // VNDR_HDR
        vendorOwnershipCode.addEqualTo(VendorPropertyConstants.VENDOR_OWNERSHIP_CODE, vendorOwnershipCodeVal);
        header.addAndCriteria(vendorOwnershipCode);
    }
    if (StringUtils.isNotBlank(vendorSupplierDiversityExpirationDateVal)) {
        try {
            Date date = new java.sql.Date(new SimpleDateFormat("MM/dd/yyyy").parse(vendorSupplierDiversityExpirationDateVal).getTime());
            vendorSupplierDiversityExpirationDate.addGreaterOrEqualThan(VendorPropertyConstants.VENDOR_HEADER_PREFIX + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, date);
            header.addAndCriteria(vendorSupplierDiversityExpirationDate);
        } catch (ParseException e) {
            LOG.error("unable to parse date");
        }
    }
    // KFSPTS-1891
    if (StringUtils.isNotBlank(defaultPaymentMethod)) {
        // 
        header.addEqualTo("extension.defaultB2BPaymentMethodCode", defaultPaymentMethod);
    }
    Long val = new Long(getPersistenceBrokerTemplate().getCount(QueryFactory.newQuery(VendorDetail.class, header)));
    Integer searchResultsLimit = LookupUtils.getSearchResultsLimit(VendorDetail.class);
    if (val.intValue() > searchResultsLimit.intValue()) {
        LookupUtils.applySearchResultsLimit(VendorDetail.class, header, getDbPlatform());
    }
    QueryByCriteria qbc = new QueryByCriteria(VendorDetail.class, header);
    rac = (RemovalAwareCollection) getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
    Criteria children = new Criteria();
    Iterator it = rac.iterator();
    while (it.hasNext()) {
        VendorDetail vd = (VendorDetail) it.next();
        String key = vd.getVendorNumber();
        if (!nonDupResults.containsKey(key)) {
            Criteria c = new Criteria();
            c.addEqualTo("vendorHeaderGeneratedIdentifier", vd.getVendorHeaderGeneratedIdentifier());
            children.addOrCriteria(c);
            nonDupResults.put(key, vd);
            results.add(vd);
        }
    }
    // THE CHILDREN OF ANY MATCHING VENDOR DETAIL OBJECT MUST BE FOUND AND ADDED TO THE RESULTS LIST
    if (nonDupResults.size() > 0) {
        qbc = new QueryByCriteria(VendorDetail.class, children);
        rac = (RemovalAwareCollection) getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
        it = rac.iterator();
        while (it.hasNext()) {
            VendorDetail vd = (VendorDetail) it.next();
            String key = vd.getVendorNumber();
            if (!nonDupResults.containsKey(key)) {
                nonDupResults.put(key, vd);
                results.add(vd);
            }
        }
    }
    CollectionIncomplete resultsTruncated = new CollectionIncomplete((Collection) results, new Long(results.size()));
    if (val.intValue() > searchResultsLimit.intValue()) {
        resultsTruncated.setActualSizeIfTruncated(new Long(-1));
    }
    return resultsTruncated;
}
Also used : CollectionIncomplete(org.kuali.kfs.krad.lookup.CollectionIncomplete) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) Date(java.sql.Date) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) RemovalAwareCollection(org.apache.ojb.broker.util.collections.RemovalAwareCollection)

Example 13 with QueryByCriteria

use of org.apache.ojb.broker.query.QueryByCriteria in project cu-kfs by CU-CommunityApps.

the class AccountReversionDaoOjb method getAccountReversionsByBudgetReversionAcount.

/**
 * @see edu.cornell.kfs.coa.dataaccess.AccountReversionDao#getAccountReversionsByBudgetReversionAcount(java.lang.String, java.lang.String)
 */
@Override
public List<AccountReversion> getAccountReversionsByBudgetReversionAcount(String budgetReversionChartOfAccountsCode, String budgetReversionAccountNumber) {
    LOG.debug("getAccountReversionsByBudgetReversionAcount() started");
    Criteria criteria = new Criteria();
    criteria.addEqualTo(CUKFSPropertyConstants.ACCT_REVERSION_BUDGET_REVERSION_CHART_OF_ACCT_CODE, budgetReversionChartOfAccountsCode);
    criteria.addEqualTo(CUKFSPropertyConstants.ACCT_REVERSION_BUDGET_REVERSION_ACCT_NUMBER, budgetReversionAccountNumber);
    criteria.addEqualTo(CUKFSPropertyConstants.ACCT_REVERSION_ACTIVE, true);
    QueryByCriteria q = QueryFactory.newQuery(AccountReversion.class, criteria);
    return (List) getPersistenceBrokerTemplate().getCollectionByQuery(q);
}
Also used : QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) List(java.util.List) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria)

Example 14 with QueryByCriteria

use of org.apache.ojb.broker.query.QueryByCriteria in project cu-kfs by CU-CommunityApps.

the class AchBundlerAdviceDaoObj method getAchPaymentDetailsNeedingAdviceNotificationByDisbursementNumber.

// KFSPTS--1460
/**
 * Returns all PaymentDetail records needing ACH advice email notifications for a given disbursement number
 *
 * NOTE:
 * This method was made transactional per fix described in KULRICE-6914 for the iterator no longer
 * containing the data and iter.hasNext() causing a run time exception.
 *
 * @return an iterator of PaymentDetail records matching the given criteria
 */
@Transactional
public List<PaymentDetail> getAchPaymentDetailsNeedingAdviceNotificationByDisbursementNumber(Integer disbursementNumber) {
    LOG.debug("getAchPaymentDetailsNeedingAdviceNotificationByDisbursementNumber() started");
    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    criteria.addEqualTo(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.EXTRACTED);
    criteria.addEqualTo(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR, disbursementNumber);
    criteria.addIsNull(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.ADVICE_EMAIL_SENT_DATE);
    QueryByCriteria paymentDetailsQuery = QueryFactory.newQuery(PaymentDetail.class, criteria);
    List paymentDetailByDisbursementNumberList = (List) getPersistenceBrokerTemplate().getCollectionByQuery(paymentDetailsQuery);
    DynamicCollectionComparator.sort(paymentDetailByDisbursementNumberList, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_FINANCIAL_DOCUMENT_TYPE_CODE, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_CUST_PAYMENT_DOC_NBR);
    return paymentDetailByDisbursementNumberList;
}
Also used : QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) List(java.util.List) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with QueryByCriteria

use of org.apache.ojb.broker.query.QueryByCriteria in project cu-kfs by CU-CommunityApps.

the class AchBundlerAdviceDaoObj method getDistinctDisbursementNumbersForAchPaymentsNeedingAdviceNotification.

// KFSPTS-1460
/**
 * Returns distinct disbursement numbers for ACH payments needing advice email notifications.
 *
 * NOTE:
 * This method was made transactional per fix described in KULRICE-6914 for the iterator no longer
 * containing the data and iter.hasNext() causing a run time exception.
 *
 * @return an iterator of Disbursement Numbers matching the given criteria
 */
@Transactional
public HashSet<Integer> getDistinctDisbursementNumbersForAchPaymentsNeedingAdviceNotification() {
    LOG.debug("getDistinctDisbursementNumbersForAchPaymentsNeedingAdviceNotification() started");
    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.EXTRACTED);
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    criteria.addIsNull(PdpPropertyConstants.ADVICE_EMAIL_SENT_DATE);
    QueryByCriteria disbursementNumbersQuery = QueryFactory.newQuery(PaymentGroup.class, criteria);
    Iterator iter = getPersistenceBrokerTemplate().getIteratorByQuery(disbursementNumbersQuery);
    // used to pair down to distinct disbursement numbers
    HashSet<Integer> results = new HashSet<Integer>();
    while (iter.hasNext()) {
        PaymentGroup pg = (PaymentGroup) iter.next();
        results.add(new Integer(pg.getDisbursementNbr().toString()));
    }
    return results;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Iterator(java.util.Iterator) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) HashSet(java.util.HashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

QueryByCriteria (org.apache.ojb.broker.query.QueryByCriteria)27 Criteria (org.apache.ojb.broker.query.Criteria)25 List (java.util.List)17 ArrayList (java.util.ArrayList)5 Timestamp (java.sql.Timestamp)3 GregorianCalendar (java.util.GregorianCalendar)3 Iterator (java.util.Iterator)3 ReportQueryByCriteria (org.apache.ojb.broker.query.ReportQueryByCriteria)3 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)2 Transactional (org.springframework.transaction.annotation.Transactional)2 CuAutoClosePurchaseOrderView (edu.cornell.kfs.module.purap.businessobject.CuAutoClosePurchaseOrderView)1 Date (java.sql.Date)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 RemovalAwareCollection (org.apache.ojb.broker.util.collections.RemovalAwareCollection)1 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)1 Attachment (org.kuali.kfs.krad.bo.Attachment)1 DataObjectRelationship (org.kuali.kfs.krad.bo.DataObjectRelationship)1