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));
}
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));
}
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));
}
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;
}
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;
}
Aggregations