Search in sources :

Example 26 with QueryByCriteria

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

the class CuFormatPaymentDaoOjb method markPaymentsForFormat.

public Iterator markPaymentsForFormat(List customerIds, Timestamp paydateTs, String paymentTypes, String paymentDistribution) {
    LOG.debug("markPaymentsForFormat() started");
    Criteria criteria = new Criteria();
    if (customerIds.size() > 0) {
        criteria.addIn(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BATCH + "." + PdpPropertyConstants.BatchConstants.CUSTOMER_ID, customerIds);
    }
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.OPEN);
    if (PdpConstants.PaymentTypes.DISBURSEMENTS_WITH_SPECIAL_HANDLING.equals(paymentTypes)) {
        // special handling only
        criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_SPECIAL_HANDLING, Boolean.TRUE);
    } else if (PdpConstants.PaymentTypes.DISBURSEMENTS_NO_SPECIAL_HANDLING.equals(paymentTypes)) {
        // no special handling only
        criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_SPECIAL_HANDLING, Boolean.FALSE);
    } else if (PdpConstants.PaymentTypes.DISBURSEMENTS_WITH_ATTACHMENTS.equals(paymentTypes)) {
        // attachments only
        criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_ATTACHMENT, Boolean.TRUE);
    } else if (PdpConstants.PaymentTypes.DISBURSEMENTS_NO_ATTACHMENTS.equals(paymentTypes)) {
        // no attachments only
        criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_ATTACHMENT, Boolean.FALSE);
    }
    if (PdpConstants.PaymentTypes.PROCESS_IMMEDIATE.equals(paymentTypes)) {
        criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PROCESS_IMMEDIATE, Boolean.TRUE);
    } else {
        // (Payment date <= usePaydate OR immediate = TRUE)
        Criteria criteria1 = new Criteria();
        criteria1.addEqualTo(PdpPropertyConstants.PaymentGroup.PROCESS_IMMEDIATE, Boolean.TRUE);
        Criteria criteria2 = new Criteria();
        criteria2.addLessOrEqualThan(PdpPropertyConstants.PaymentGroup.PAYMENT_DATE, paydateTs);
        criteria1.addOrCriteria(criteria2);
        criteria.addAndCriteria(criteria1);
    }
    if (CUPdpConstants.PaymentDistributions.PROCESS_ACH_ONLY.equals(paymentDistribution)) {
        criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    } else if (CUPdpConstants.PaymentDistributions.PROCESS_CHECK_ONLY.equals(paymentDistribution)) {
        Criteria criteria3 = new Criteria();
        criteria3.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.CHECK);
        Criteria criteria4 = new Criteria();
        criteria4.addIsNull(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE);
        criteria3.addOrCriteria(criteria4);
        criteria.addAndCriteria(criteria3);
    }
    Iterator groupIterator = getPersistenceBrokerTemplate().getIteratorByQuery(new QueryByCriteria(PaymentGroup.class, criteria));
    return groupIterator;
}
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)

Example 27 with QueryByCriteria

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

the class CuFiscalYearMakerDaoOjb method deleteNewYearRows.

/**
 * Deletes the new year records for the given fiscal year maker. If the object has an extension it first deletes the data
 * in the extension table.
 *
 * @see org.kuali.kfs.sys.batch.dataaccess.impl.FiscalYearMakersDaoOjb#deleteNewYearRows(java.lang.Integer,
 *      org.kuali.kfs.sys.batch.dataaccess.FiscalYearMaker)
 */
@Override
public void deleteNewYearRows(Integer baseYear, FiscalYearMaker objectFiscalYearMaker) {
    // Check if an extension exists and delete extension records first
    if (persistenceStructureService.hasReference(objectFiscalYearMaker.getBusinessObjectClass(), KFSPropertyConstants.EXTENSION)) {
        Map<String, DataObjectRelationship> relationships = persistenceStructureService.getRelationshipMetadata(objectFiscalYearMaker.getBusinessObjectClass(), KFSPropertyConstants.EXTENSION);
        Class extensionClass = relationships.get(KFSPropertyConstants.EXTENSION).getRelatedClass();
        LOG.info(String.format("\ndeleting %s for %d", extensionClass.getName(), baseYear + 1));
        QueryByCriteria queryExtension = new QueryByCriteria(extensionClass, objectFiscalYearMaker.createDeleteCriteria(baseYear));
        getPersistenceBrokerTemplate().deleteByQuery(queryExtension);
        getPersistenceBrokerTemplate().clearCache();
    }
    // Delete the main objects now
    if (LOG.isInfoEnabled()) {
        LOG.info(String.format("\ndeleting %s for target year(s)", objectFiscalYearMaker.getBusinessObjectClass().getName()));
    }
    QueryByCriteria queryID = new QueryByCriteria(objectFiscalYearMaker.getBusinessObjectClass(), objectFiscalYearMaker.createDeleteCriteria(baseYear));
    getPersistenceBrokerTemplate().deleteByQuery(queryID);
    getPersistenceBrokerTemplate().clearCache();
}
Also used : DataObjectRelationship(org.kuali.kfs.krad.bo.DataObjectRelationship) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria)

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