Ejemplo n.º 1
0
  /**
   * @see
   *     org.kuali.kfs.pdp.dataaccess.PaymentGroupDao#getDisbursementNumbersByDisbursementType(java.lang.Integer,
   *     java.lang.String, java.lang.String)
   */
  public List<Integer> getDisbursementNumbersByDisbursementTypeAndBankCode(
      Integer pid, String disbursementType, String bankCode) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("getDisbursementNumbersByDisbursementType() started");
    }

    List<Integer> results = new ArrayList<Integer>();

    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, pid);
    criteria.addEqualTo(
        PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, bankCode);

    String[] fields =
        new String[] {PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR};

    ReportQueryByCriteria rq =
        QueryFactory.newReportQuery(PaymentGroup.class, fields, criteria, true);
    rq.addOrderBy(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR, true);

    Iterator i = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rq);
    while (i.hasNext()) {
      Object[] data = (Object[]) i.next();
      BigDecimal d = (BigDecimal) data[0];
      results.add(new Integer(d.intValue()));
    }
    return results;
  }
  /**
   * @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;
  }
  /**
   * Generate Query object for GeneralLedgerEntry search.
   *
   * @param fieldValues
   * @return
   */
  protected ReportQueryByCriteria getGeneralLedgerReportQuery(Map fieldValues) {
    Collection docTypeCodes = getDocumentType(fieldValues);
    Collection activityStatusCodes = getActivityStatusCode(fieldValues);

    Criteria criteria = OJBUtility.buildCriteriaFromMap(fieldValues, new GeneralLedgerEntry());

    // set document type code criteria
    if (!docTypeCodes.isEmpty()) {
      criteria.addIn(
          CabPropertyConstants.GeneralLedgerEntry.FINANCIAL_DOCUMENT_TYPE_CODE, docTypeCodes);
    }
    // set activity status code criteria
    if (!activityStatusCodes.isEmpty()) {
      criteria.addIn(
          CabPropertyConstants.GeneralLedgerEntry.ACTIVITY_STATUS_CODE, activityStatusCodes);
    }
    ReportQueryByCriteria query = QueryFactory.newReportQuery(GeneralLedgerEntry.class, criteria);

    List attributeList = buildAttributeList(false);

    // set the selection attributes
    String[] attributes = (String[]) attributeList.toArray(new String[attributeList.size()]);
    query.setAttributes(attributes);
    return query;
  }
Ejemplo n.º 4
0
  public void testTransactionFlush_2() throws Exception {
    String name = "testTransactionFlush_2_" + System.currentTimeMillis();
    TransactionExt tx = (TransactionExt) odmg.newTransaction();

    tx.begin();
    PersistenceBroker broker = tx.getBroker();

    ODMGZoo obj = new ODMGZoo();
    obj.setName(name);
    tx.lock(obj, Transaction.WRITE);
    tx.flush();
    // System.err.println("First flush call, insert new object");

    // PB to query
    Criteria crit = new Criteria();
    crit.addEqualTo("name", obj.getName());
    QueryByCriteria query = QueryFactory.newQuery(ODMGZoo.class, crit);
    // we flushed all objects, thus we should found object in DB/cache
    Iterator it = broker.getIteratorByQuery(query);
    assertTrue(it.hasNext());
    ODMGZoo other = (ODMGZoo) it.next();
    assertNotNull(other);
    assertEquals(obj.getZooId(), other.getZooId());
    assertEquals(obj.getName(), other.getName());
    assertFalse(it.hasNext());

    /** * Charles : Start ** */
    // Let's flush, change the name and flush again
    tx.flush();
    // System.err.println("Second flush call, nothing to do");
    obj.setName("updated_" + name);
    tx.flush();
    // System.err.println("Third flush call, update");
    OQLQuery q = odmg.newOQLQuery();
    q.create("select zoos from " + ODMGZoo.class.getName() + " where name like $1");
    q.bind("updated_" + name);

    // Redo the query - we should find the object again
    it = ((Collection) q.execute()).iterator();
    assertTrue(it.hasNext());
    other = (ODMGZoo) it.next();
    assertNotNull(other);
    assertEquals(obj.getZooId(), other.getZooId());
    assertEquals(obj.getName(), other.getName());
    assertFalse(it.hasNext());
    /** * Charles : End ** */

    // now we abort tx, so all flushed objects shouldn't be found
    // in further queries
    tx.abort();

    tx = (TransactionExt) odmg.newTransaction();
    tx.begin();
    broker = tx.getBroker();
    QueryByIdentity query2 = new QueryByIdentity(obj);
    Object result = broker.getObjectByQuery(query2);
    tx.commit();

    assertNull("We should not find objects from aborted tx", result);
  }
Ejemplo n.º 5
0
  /** @see org.kuali.rice.krad.dao.DocumentHeaderDao#getByDocumentHeaderId(java.lang.String) */
  public DocumentHeader getByDocumentHeaderId(String id) {
    Criteria criteria = new Criteria();
    criteria.addEqualTo(KRADPropertyConstants.DOCUMENT_NUMBER, id);

    return (DocumentHeader)
        getPersistenceBrokerTemplate()
            .getObjectByQuery(QueryFactory.newQuery(getDocumentHeaderBaseClass(), criteria));
  }
Ejemplo n.º 6
0
  @Override
  public PositionBaseBo getPosition(String hrPositionId) {
    Criteria crit = new Criteria();
    crit.addEqualTo("hrPositionId", hrPositionId);

    Query query = QueryFactory.newQuery(PositionBaseBo.class, crit);
    return (PositionBaseBo) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
  }
  @Override
  public ClassificationBo getClassificationById(String pmClassificationId) {
    Criteria crit = new Criteria();
    crit.addEqualTo("pmPositionClassId", pmClassificationId);

    Query query = QueryFactory.newQuery(ClassificationBo.class, crit);
    return (ClassificationBo) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
  }
Ejemplo n.º 8
0
  /**
   * @see
   *     org.kuali.kfs.gl.dataaccess.LedgerEntryBalancingDao#findCountGreaterOrEqualThan(java.lang.Integer)
   */
  public Integer findCountGreaterOrEqualThan(Integer year) {
    Criteria criteria = new Criteria();
    criteria.addGreaterOrEqualThan(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, year);

    ReportQueryByCriteria query = QueryFactory.newReportQuery(Entry.class, criteria);

    return getPersistenceBrokerTemplate().getCount(query);
  }
Ejemplo n.º 9
0
  /** @see org.kuali.kfs.pdp.dataaccess.PendingTransactionDao#clearExtractedTransactions() */
  public void clearExtractedTransactions() {
    LOG.debug("clearExtractedTransactions() started");

    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PROCESS_IND, true);

    QueryByCriteria qbc = QueryFactory.newQuery(GlPendingTransaction.class, criteria);
    getPersistenceBrokerTemplate().deleteByQuery(qbc);
    getPersistenceBrokerTemplate().clearCache();
  }
Ejemplo n.º 10
0
  /** @see org.kuali.kfs.pdp.dataaccess.PendingTransactionDao#getUnextractedTransactions() */
  public Iterator<GlPendingTransaction> getUnextractedTransactions() {
    LOG.debug("save() started");

    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PROCESS_IND, false);

    Criteria criteria2 = new Criteria();
    criteria2.addIsNull(PdpPropertyConstants.PROCESS_IND);

    criteria.addOrCriteria(criteria2);
    return getPersistenceBrokerTemplate()
        .getIteratorByQuery(new QueryByCriteria(GlPendingTransaction.class, criteria));
  }
Ejemplo n.º 11
0
  /** @see org.kuali.kfs.pdp.dataaccess.PaymentGroupDao#getAchPaymentsNeedingAdviceNotification() */
  public List<PaymentGroup> getAchPaymentsNeedingAdviceNotification() {
    LOG.debug("getAchPaymentsNeedingAdviceNotification() started");

    Criteria criteria = new Criteria();
    criteria.addEqualTo(
        PdpPropertyConstants.PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.EXTRACTED);
    criteria.addEqualTo(
        PdpPropertyConstants.DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    criteria.addIsNull(PdpPropertyConstants.ADVICE_EMAIL_SENT_DATE);

    return (List<PaymentGroup>)
        getPersistenceBrokerTemplate()
            .getCollectionByQuery(new QueryByCriteria(PaymentGroup.class, criteria));
  }
Ejemplo n.º 12
0
  /**
   * @see
   *     org.kuali.kfs.pdp.dataaccess.PaymentFileLoadDao#isDuplicateBatch(org.kuali.kfs.pdp.businessobject.CustomerProfile,
   *     java.lang.Integer, java.math.BigDecimal, java.sql.Timestamp)
   */
  public boolean isDuplicateBatch(
      CustomerProfile customer, Integer count, BigDecimal totalAmount, Timestamp now) {
    LOG.debug("isDuplicateBatch() starting");

    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.CUSTOMER_ID, customer.getId());
    criteria.addEqualTo(PdpPropertyConstants.CUSTOMER_FILE_CREATE_TIMESTAMP, now);
    criteria.addEqualTo(PdpPropertyConstants.PAYMENT_COUNT, count);
    criteria.addEqualTo(PdpPropertyConstants.PAYMENT_TOTAL_AMOUNT, totalAmount);

    return getPersistenceBrokerTemplate()
            .getObjectByQuery(new QueryByCriteria(Batch.class, criteria))
        != null;
  }
Ejemplo n.º 13
0
  /**
   * Purge the entry table by chart/year
   *
   * @param chart the chart of accounts code of entries to purge
   * @param year the university fiscal year of entries to purge
   */
  public void purgeYearByChart(String chartOfAccountsCode, int year) {
    LOG.debug("purgeYearByChart() started");

    Criteria criteria = new Criteria();
    criteria.addEqualTo(CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode);
    criteria.addLessThan(UNIVERISITY_FISCAL_YEAR, new Integer(year));

    getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(Entry.class, criteria));

    // This is required because if any deleted rows are in the cache, deleteByQuery doesn't
    // remove them from the cache so a future select will retrieve these deleted account balances
    // from
    // the cache and return them. Clearing the cache forces OJB to go to the database again.
    getPersistenceBrokerTemplate().clearCache();
  }
  /**
   * @see org.kuali.kfs.coa.dataaccess.ObjectCodeDao#getYearList(java.lang.String, java.lang.String)
   */
  public List getYearList(String chartOfAccountsCode, String financialObjectCode) {

    List returnList = new ArrayList();
    Criteria criteria = new Criteria();
    criteria.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
    criteria.addEqualTo("financialObjectCode", financialObjectCode);
    Collection years =
        getPersistenceBrokerTemplate()
            .getCollectionByQuery(QueryFactory.newQuery(ObjectCode.class, criteria));
    for (Iterator iter = years.iterator(); iter.hasNext(); ) {
      ObjectCode o = (ObjectCode) iter.next();
      if (o != null) {
        returnList.add(o.getUniversityFiscalYear());
      }
    }
    return returnList;
  }
Ejemplo n.º 15
0
  /**
   * Retrieves accounting lines associate with a given document header ID using OJB.
   *
   * @param classname
   * @param id
   * @return
   */
  public ArrayList findByDocumentHeaderId(Class clazz, String documentHeaderId)
      throws DataAccessException {
    Criteria criteria = new Criteria();
    criteria.addEqualTo("FDOC_NBR", documentHeaderId);
    if (MetadataManager.getInstance()
            .getRepository()
            .getDescriptorFor(clazz)
            .getFieldDescriptorByName("financialDocumentLineTypeCode")
        != null) {
      if (SourceAccountingLine.class.isAssignableFrom(clazz)) {
        criteria.addEqualTo("FDOC_LN_TYP_CD", KFSConstants.SOURCE_ACCT_LINE_TYPE_CODE);
      } else if (TargetAccountingLine.class.isAssignableFrom(clazz)) {
        criteria.addEqualTo("FDOC_LN_TYP_CD", KFSConstants.TARGET_ACCT_LINE_TYPE_CODE);
      }
    }

    QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
    Collection lines = findCollection(query);

    return new ArrayList(lines);
  }
Ejemplo n.º 16
0
  /**
   * Given a process id and a disbursement type, finds a distinct list of bank codes used by payment
   * groups within that payment process
   *
   * @param pid payment process to query payment groups of
   * @param disbursementType the type of disbursements to query
   * @return a sorted List of bank codes
   */
  public List<String> getDistinctBankCodesForProcessAndType(Integer pid, String disbursementType) {
    List<String> results = new ArrayList<String>();

    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, pid);
    criteria.addEqualTo(
        PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);

    String[] fields = new String[] {PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE};

    ReportQueryByCriteria rq =
        QueryFactory.newReportQuery(PaymentGroup.class, fields, criteria, true);
    rq.addOrderBy(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, true);

    Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rq);
    while (iter.hasNext()) {
      final Object[] row = (Object[]) iter.next();
      final String bankCode = (String) row[0];

      results.add(bankCode);
    }

    return results;
  }
Ejemplo n.º 17
0
  public void testTransactionFlush() throws Exception {
    String name = "testTransactionFlush_" + System.currentTimeMillis();
    TransactionExt tx = (TransactionExt) odmg.newTransaction();

    tx.begin();
    PersistenceBroker broker = tx.getBroker();
    ODMGZoo obj = new ODMGZoo();
    tx.lock(obj, Transaction.WRITE);
    obj.setName(name);

    tx.flush();

    Criteria crit = new Criteria();
    crit.addEqualTo("name", obj.getName());
    QueryByCriteria query = QueryFactory.newQuery(ODMGZoo.class, crit);
    // we flushed all objects, thus we should find object in DB/cache
    Iterator it = broker.getIteratorByQuery(query);
    assertTrue(it.hasNext());
    ODMGZoo other = (ODMGZoo) it.next();
    assertNotNull(other);
    assertEquals(obj.getZooId(), other.getZooId());
    assertEquals(obj.getName(), other.getName());
    assertFalse(it.hasNext());
    // now we abort tx, so all flushed objects shouldn't be found
    // in further queries
    tx.abort();

    tx = (TransactionExt) odmg.newTransaction();
    tx.begin();
    broker = tx.getBroker();
    QueryByIdentity query2 = new QueryByIdentity(obj);
    Object result = broker.getObjectByQuery(query2);
    tx.commit();

    assertNull("We should not find objects from aborted tx", result);
  }
Ejemplo n.º 18
0
  /**
   * @see org.kuali.kfs.gl.dataaccess.LedgerEntryBalancingDao#findEntryByGroup(java.lang.Integer,
   *     java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
   */
  public Object[] findEntryByGroup(
      Integer universityFiscalYear,
      String chartOfAccountsCode,
      String financialObjectCode,
      String financialBalanceTypeCode,
      String universityFiscalPeriodCode,
      String transactionDebitCreditCode) {
    Criteria criteria = new Criteria();
    criteria.addEqualTo(KFSConstants.UNIVERSITY_FISCAL_YEAR_PROPERTY_NAME, universityFiscalYear);
    criteria.addEqualTo(KFSConstants.CHART_OF_ACCOUNTS_CODE_PROPERTY_NAME, chartOfAccountsCode);
    criteria.addEqualTo(KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME, financialObjectCode);
    criteria.addEqualTo(
        KFSConstants.FINANCIAL_BALANCE_TYPE_CODE_PROPERTY_NAME, financialBalanceTypeCode);
    criteria.addEqualTo(
        KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME, universityFiscalPeriodCode);
    criteria.addEqualTo(KFSConstants.TRANSACTION_DEBIT_CREDIT_CODE, transactionDebitCreditCode);

    ReportQueryByCriteria reportQuery = QueryFactory.newReportQuery(Entry.class, criteria);
    reportQuery.setAttributes(
        new String[] {"count(*)", "sum(" + KFSConstants.TRANSACTION_LEDGER_ENTRY_AMOUNT + ")"});
    reportQuery.addGroupBy(
        new String[] {
          KFSConstants.UNIVERSITY_FISCAL_YEAR_PROPERTY_NAME,
          KFSConstants.CHART_OF_ACCOUNTS_CODE_PROPERTY_NAME,
          KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME,
          KFSConstants.FINANCIAL_BALANCE_TYPE_CODE_PROPERTY_NAME,
          KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME,
          KFSConstants.TRANSACTION_DEBIT_CREDIT_CODE
        });

    Iterator<Object[]> iterator =
        getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(reportQuery);
    Object[] returnResult = TransactionalServiceUtils.retrieveFirstAndExhaustIterator(iterator);

    if (ObjectUtils.isNull(returnResult)) {
      // Do nothing, we'll return null. Data wasn't found.
    } else if (returnResult[0] instanceof BigDecimal) {
      returnResult[0] = ((BigDecimal) returnResult[0]).intValue();
    } else {
      returnResult[0] = ((Long) returnResult[0]).intValue();
    }

    return returnResult;
  }
Ejemplo n.º 19
0
  @Override
  public PositionBaseBo getPosition(String positionNumber, LocalDate effectiveDate) {
    Criteria root = new Criteria();

    root.addEqualTo("positionNumber", positionNumber);
    root.addEqualTo(
        "effectiveDate",
        OjbSubQueryUtil.getEffectiveDateSubQuery(
            PositionBaseBo.class, effectiveDate, PositionBaseBo.BUSINESS_KEYS, false));
    root.addEqualTo(
        "timestamp",
        OjbSubQueryUtil.getTimestampSubQuery(
            PositionBaseBo.class, PositionBaseBo.BUSINESS_KEYS, false));

    Criteria activeFilter = new Criteria(); // Inner Join For Activity
    activeFilter.addEqualTo("active", true);
    root.addAndCriteria(activeFilter);

    Query query = QueryFactory.newQuery(PositionBaseBo.class, root);
    return (PositionBaseBo) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  private void injectSubQueries(
      Criteria root, Class<? extends HrBusinessObjectContract> hrBOClass, Map formProps) {
    // create the effective date filter criteria
    Criteria effectiveDateFilter = new Criteria();
    LocalDate fromEffdt =
        TKUtils.formatDateString(TKUtils.getFromDateString((String) formProps.get(EFFECTIVE_DATE)));
    LocalDate toEffdt =
        TKUtils.formatDateString(TKUtils.getToDateString((String) formProps.get(EFFECTIVE_DATE)));
    if (fromEffdt != null) {
      effectiveDateFilter.addGreaterOrEqualThan(EFFECTIVE_DATE, fromEffdt.toDate());
    }
    if (toEffdt != null) {
      effectiveDateFilter.addLessOrEqualThan(EFFECTIVE_DATE, toEffdt.toDate());
    }
    if (fromEffdt == null && toEffdt == null) {
      effectiveDateFilter.addLessOrEqualThan(EFFECTIVE_DATE, LocalDate.now().toDate());
    }

    List<String> businessKeys = new ArrayList<String>();
    try {
      businessKeys =
          (List<String>) hrBOClass.getDeclaredField(BUSINESS_KEYS_VAR_NAME).get(hrBOClass);
    } catch (NoSuchFieldException e) {
      LOG.warn(hrBOClass.getName() + DOES_NOT_CONTAIN_BUSINESS_KEYS_MESSAGE);
    } catch (IllegalAccessException e) {
      LOG.warn(hrBOClass.getName() + DOES_NOT_CONTAIN_BUSINESS_KEYS_MESSAGE);
    }

    // inject the subqueries
    root.addEqualTo(
        EFFECTIVE_DATE,
        OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(
            hrBOClass, effectiveDateFilter, businessKeys, false));
    root.addEqualTo(
        TIMESTAMP, OjbSubQueryUtil.getTimestampSubQuery(hrBOClass, businessKeys, false));
  }
Ejemplo n.º 21
0
 public Collection findOwners(String lastName) throws DataAccessException {
   Criteria criteria = new Criteria();
   criteria.addLike("lastName", lastName + "%");
   Query query = new QueryByCriteria(Owner.class, criteria);
   return getPersistenceBrokerTemplate().getCollectionByQuery(query);
 }
 /** @see org.kuali.rice.krad.dao.MaintenanceDocumentDao#deleteLocks(java.lang.String) */
 public void deleteLocks(String documentNumber) {
   Criteria criteria = new Criteria();
   criteria.addEqualTo("documentNumber", documentNumber);
   QueryByCriteria query = new QueryByCriteria(MaintenanceLock.class, criteria);
   getPersistenceBrokerTemplate().deleteByQuery(query);
 }
Ejemplo n.º 23
0
  /**
   * Find the maximum transactionLedgerEntrySequenceNumber in the entry table for a specific
   * transaction. This is used to make sure that rows added have a unique primary key.
   *
   * @param t the transaction to check
   * @return the max sequence number
   */
  public int getMaxSequenceNumber(Transaction t) {
    LOG.debug("getSequenceNumber() ");

    Criteria crit = new Criteria();
    crit.addEqualTo(UNIVERISITY_FISCAL_YEAR, t.getUniversityFiscalYear());
    crit.addEqualTo(CHART_OF_ACCOUNTS_CODE, t.getChartOfAccountsCode());
    crit.addEqualTo(ACCOUNT_NUMBER, t.getAccountNumber());
    crit.addEqualTo(SUB_ACCOUNT_NUMBER, t.getSubAccountNumber());
    crit.addEqualTo(FINANCIAL_OBJECT_CODE, t.getFinancialObjectCode());
    crit.addEqualTo(FINANCIAL_SUB_OBJECT_CODE, t.getFinancialSubObjectCode());
    crit.addEqualTo(FINANCIAL_BALANCE_TYPE_CODE, t.getFinancialBalanceTypeCode());
    crit.addEqualTo(FINANCIAL_OBJECT_TYPE_CODE, t.getFinancialObjectTypeCode());
    crit.addEqualTo(UNIVERISTY_FISCAL_PERIOD_CODE, t.getUniversityFiscalPeriodCode());
    crit.addEqualTo(FINANCIAL_DOCUMENT_TYPE_CODE, t.getFinancialDocumentTypeCode());
    crit.addEqualTo(FINANCIAL_SYSTEM_ORIGINATION_CODE, t.getFinancialSystemOriginationCode());
    crit.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, t.getDocumentNumber());

    ReportQueryByCriteria q = QueryFactory.newReportQuery(Entry.class, crit);
    q.setAttributes(new String[] {"max(transactionLedgerEntrySequenceNumber)"});

    Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(q);
    // would this work better? max = (BigDecimal)
    // getPersistenceBrokerTemplate().getObjectByQuery(q);
    BigDecimal max = null;
    while (iter.hasNext()) {
      Object[] data = (Object[]) iter.next();
      max = (BigDecimal) data[0]; // Don't know why OJB returns a BigDecimal, but it does
    }
    if (max == null) {
      return 0;
    } else {
      return max.intValue();
    }
  }
Ejemplo n.º 24
0
  @Override
  @SuppressWarnings("unchecked")
  public List<PositionBaseBo> getPositions(
      String positionNum,
      String description,
      LocalDate fromEffdt,
      LocalDate toEffdt,
      String active,
      String showHistory) {
    List<PositionBaseBo> results = new ArrayList<PositionBaseBo>();

    Criteria root = new Criteria();

    if (StringUtils.isNotBlank(positionNum)) {
      root.addLike("positionNumber", positionNum);
    }

    if (StringUtils.isNotBlank(description)) {
      root.addLike("UPPER(description)", description.toUpperCase()); // KPME-2695
    }

    Criteria effectiveDateFilter = new Criteria();
    if (fromEffdt != null) {
      effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate());
    }
    if (toEffdt != null) {
      effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate());
    }
    if (fromEffdt == null && toEffdt == null) {
      effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate());
    }
    root.addAndCriteria(effectiveDateFilter);

    if (StringUtils.isNotBlank(active)) {
      Criteria activeFilter = new Criteria();
      if (StringUtils.equals(active, "Y")) {
        activeFilter.addEqualTo("active", true);
      } else if (StringUtils.equals(active, "N")) {
        activeFilter.addEqualTo("active", false);
      }
      root.addAndCriteria(activeFilter);
    }

    if (StringUtils.equals(showHistory, "N")) {
      root.addEqualTo(
          "effectiveDate",
          OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(
              PositionBaseBo.class, effectiveDateFilter, PositionBaseBo.BUSINESS_KEYS, false));
      root.addEqualTo(
          "timestamp",
          OjbSubQueryUtil.getTimestampSubQuery(
              PositionBaseBo.class, PositionBaseBo.BUSINESS_KEYS, false));
    }

    Query query = QueryFactory.newQuery(PositionBaseBo.class, root);
    results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));

    return results;
  }