Search in sources :

Example 11 with Criteria

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

the class ProcurementCardDocumentDaoOjb method getDocumentByEdocNumber.

/**
 * @see edu.cornell.kfs.fp.dataaccess.ProcurementCardDocumentDao#getDocumentByEdocNumber(java.lang.String)
 */
@Override
public List<ProcurementCardDocument> getDocumentByEdocNumber(String edocNumber) {
    LOG.debug("getDocumentByCarhdHolderNameAmountDateCardHolderNetID() started");
    if (StringUtils.isBlank(edocNumber)) {
        LOG.error("Unable to validate input");
        return null;
    }
    Criteria criteria = new Criteria();
    criteria.addEqualTo("documentNumber", edocNumber);
    return (List<ProcurementCardDocument>) getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ProcurementCardDocument.class, criteria));
}
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 12 with Criteria

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

the class ProcurementCardDocumentDaoOjb method getDocumentByCarhdHolderAmountDateVendor.

public List<ProcurementCardDocument> getDocumentByCarhdHolderAmountDateVendor(String cardHolder, String amount, Date transactionDate) {
    LOG.debug("getDocumentByAmountDateVendor() started");
    if (StringUtils.isBlank(cardHolder) || StringUtils.isBlank(amount) || transactionDate == null) {
        LOG.error("Unable to validate input. Card Holder Name: " + cardHolder + ", Amount: " + amount + ", Transaction Date: " + transactionDate);
        return null;
    }
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(transactionDate);
    gc.add(Calendar.DATE, 21);
    Criteria criteria = new Criteria();
    criteria.addLike("procurementCardHolder.cardHolderName", convertCardHolderName(cardHolder));
    criteria.addEqualTo("transactionEntries.transactionTotalAmount", amount);
    criteria.addGreaterOrEqualThan("transactionEntries.transactionDate", transactionDate);
    criteria.addLessOrEqualThan("transactionEntries.transactionDate", new Timestamp(gc.getTimeInMillis()));
    return (List<ProcurementCardDocument>) getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ProcurementCardDocument.class, criteria));
}
Also used : QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) GregorianCalendar(java.util.GregorianCalendar) List(java.util.List) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) Timestamp(java.sql.Timestamp)

Example 13 with Criteria

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

the class ProcurementCardDocumentDaoOjb method getDocumentByCarhdHolderNameAmountDateCardHolderNetID.

/**
 * @see edu.cornell.kfs.fp.dataaccess.ProcurementCardDocumentDao#getDocumentByCarhdHolderNameAmountDateCardHolderNetID(java.lang.String, java.sql.Date, java.lang.String)
 */
@Override
public List<ProcurementCardDocument> getDocumentByCarhdHolderNameAmountDateCardHolderNetID(String amount, Date transactionDate, String cardHolderNetID) {
    LOG.debug("getDocumentByCarhdHolderNameAmountDateCardHolderNetID() started");
    if (StringUtils.isBlank(amount) || transactionDate == null || StringUtils.isBlank(cardHolderNetID)) {
        LOG.error("Unable to validate input. Amount: " + amount + ", Transaction Date: " + transactionDate + ", Card Holder NetID: " + cardHolderNetID + ".");
        return null;
    }
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(transactionDate);
    gc.add(Calendar.DATE, 21);
    Criteria criteria = new Criteria();
    criteria.addLike("procurementCardHolder.cardHolderAlternateName", cardHolderNetID.toUpperCase() + WILD_CARD);
    criteria.addEqualTo("transactionEntries.transactionTotalAmount", amount);
    criteria.addGreaterOrEqualThan("transactionEntries.transactionDate", transactionDate);
    criteria.addLessOrEqualThan("transactionEntries.transactionDate", new Timestamp(gc.getTimeInMillis()));
    return (List<ProcurementCardDocument>) getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ProcurementCardDocument.class, criteria));
}
Also used : QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) GregorianCalendar(java.util.GregorianCalendar) List(java.util.List) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) Timestamp(java.sql.Timestamp)

Example 14 with Criteria

use of org.apache.ojb.broker.query.Criteria 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 15 with Criteria

use of org.apache.ojb.broker.query.Criteria 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)

Aggregations

Criteria (org.apache.ojb.broker.query.Criteria)32 QueryByCriteria (org.apache.ojb.broker.query.QueryByCriteria)27 List (java.util.List)19 ArrayList (java.util.ArrayList)6 ReportQueryByCriteria (org.apache.ojb.broker.query.ReportQueryByCriteria)4 Timestamp (java.sql.Timestamp)3 GregorianCalendar (java.util.GregorianCalendar)3 Iterator (java.util.Iterator)3 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)2 Transactional (org.springframework.transaction.annotation.Transactional)2 AccountReversion (edu.cornell.kfs.coa.businessobject.AccountReversion)1 EzraProposalAward (edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward)1 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 Account (org.kuali.kfs.coa.businessobject.Account)1