protected void getCurrentBCHeaderKeys(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaId = new Criteria(); Iterator<Object[]> Results; criteriaId.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, RequestYear); String[] selectList = { KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, KFSPropertyConstants.ACCOUNT_NUMBER, KFSPropertyConstants.SUB_ACCOUNT_NUMBER }; ReportQueryByCriteria queryId = new ReportQueryByCriteria(BudgetConstructionHeader.class, selectList, criteriaId); Results = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryId); while (Results.hasNext()) { Object[] returnedRow = Results.next(); currentBCHeaderKeys.add(((String) returnedRow[0]) + ((String) returnedRow[1]) + ((String) returnedRow[2])); } }
protected Integer hashObjectSize(Class classID, Criteria criteriaID) { // this counts all rows String[] selectList = new String[] {"COUNT(*)"}; ReportQueryByCriteria queryID = new ReportQueryByCriteria(classID, selectList, criteriaID); Iterator resultRows = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); if (resultRows.hasNext()) { return(hashCapacity(((Number)((Object[]) TransactionalServiceUtils.retrieveFirstAndExhaustIterator(resultRows))[0]).intValue())); } return (new Integer(1)); }
protected void setUpPositionNormalWorkMonths(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, RequestYear); positionNormalWorkMonths = new HashMap<String, Integer>(hashObjectSize(BudgetConstructionPosition.class, criteriaID)); String[] fieldList = { KFSPropertyConstants.POSITION_NUMBER, KFSPropertyConstants.IU_NORMAL_WORK_MONTHS }; ReportQueryByCriteria queryID = new ReportQueryByCriteria(BudgetConstructionPosition.class, fieldList, criteriaID); Iterator positionRows = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); while (positionRows.hasNext()) { // apparently, numbers come back from report queries in DB-specific ways. use Number to be safe (as OJB itself does) since the results do not go through the business object Object[] positionRow = (Object[]) positionRows.next(); positionNormalWorkMonths.put((String) positionRow[0], (Integer) ((Number) positionRow[1]).intValue()); } }
protected void setUpbcHdrDocNumbers(Integer BaseYear) { Integer RequestYear = BaseYear + 1; Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, RequestYear); bcHdrDocNumbers = new HashMap<String, String>(hashObjectSize(BudgetConstructionHeader.class, criteriaID)); // now we have to get the actual data String[] headerList = { KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, KFSPropertyConstants.ACCOUNT_NUMBER, KFSPropertyConstants.SUB_ACCOUNT_NUMBER, KFSPropertyConstants.DOCUMENT_NUMBER }; ReportQueryByCriteria queryID = new ReportQueryByCriteria(BudgetConstructionHeader.class, headerList, criteriaID); Iterator headerRows = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); while (headerRows.hasNext()) { Object[] headerRow = (Object[]) headerRows.next(); String testKey = ((String) headerRow[0]) + ((String) headerRow[1]) + ((String) headerRow[2]); bcHdrDocNumbers.put(testKey, ((String) headerRow[3])); } }
public final Map<String, String> getBudgetConstructionControlFlags(Integer universityFiscalYear) { /* return the flag names and the values for all the BC flags for the fiscal year */ /* the key to the map returned will be the name of the flag * the entry will be the flag's value */ Map<String, String> controlFlags = new HashMap(); Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSConstants.UNIVERSITY_FISCAL_YEAR_PROPERTY_NAME, universityFiscalYear); String[] queryAttr = { KFSPropertyConstants.FINANCIAL_SYSTEM_FUNCTION_CONTROL_CODE, KFSPropertyConstants.FINANCIAL_SYSTEM_FUNCTION_ACTIVE_INDICATOR }; ReportQueryByCriteria queryID = new ReportQueryByCriteria(FiscalYearFunctionControl.class, queryAttr, criteriaID); Iterator Results = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); /* fill in the map */ while (Results.hasNext()) { String[] mapValues = (String[]) ((Object[]) Results.next()); controlFlags.put(mapValues[0], mapValues[1]); } ; return controlFlags; }
protected void readBCHeaderForDocNumber(Integer BaseYear) { // we have to read all the budget construction header objects so that // we can use them to assign document numbers // Integer RequestYear = BaseYear + 1; // Long documentsRead = new Long(0); Criteria criteriaId = new Criteria(); criteriaId.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, RequestYear); documentNumberFromBCHdr = new HashMap<String, String>(hashObjectSize(BudgetConstructionHeader.class, criteriaId)); String[] queryAttr = { KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, KFSPropertyConstants.ACCOUNT_NUMBER, KFSPropertyConstants.SUB_ACCOUNT_NUMBER, KFSPropertyConstants.DOCUMENT_NUMBER }; ReportQueryByCriteria queryId = new ReportQueryByCriteria(BudgetConstructionHeader.class, queryAttr, criteriaId); Iterator Results = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryId); while (Results.hasNext()) { Object[] rowReturned = (Object[]) Results.next(); String hashKey = ((String) rowReturned[0]) + ((String) rowReturned[1]) + ((String) rowReturned[2]); documentNumberFromBCHdr.put(hashKey, ((String) rowReturned[3])); documentsRead = documentsRead + 1; } LOG.info(String.format("\nBC Headers read = %d", documentsRead)); }
public Integer fiscalYearFromToday() { // we look up the fiscal year for today's date, and return it // we return 0 if nothing is found Integer currentFiscalYear = new Integer(0); Date lookUpDate = dateTimeService.getCurrentSqlDateMidnight(); Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSPropertyConstants.UNIVERSITY_DATE, lookUpDate); String[] attrb = { KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR }; ReportQueryByCriteria queryID = new ReportQueryByCriteria(UniversityDate.class, attrb, criteriaID); Iterator resultRow = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); // there will only be one row. // Oracle will not close the cursor, however, until the iterator has been exhausted if (resultRow.hasNext()) { currentFiscalYear = (Integer) ((Number) ((Object[]) TransactionalServiceUtils.retrieveFirstAndExhaustIterator(resultRow))[0]).intValue(); } LOG.debug(String.format("\nreturned from fiscalYearFromToday: %d", currentFiscalYear)); return currentFiscalYear; }
protected Integer hashObjectSize(Class classID, Criteria criteriaID, String propertyName) { // this one counts distinct values of a single field String[] selectList = buildCountDistinct(propertyName,classID); // if the field is not found, return the default if (selectList[0] == null) { return (new Integer(this.DEFAULT_QUERY_RETURN_COUNT)); } ReportQueryByCriteria queryID = new ReportQueryByCriteria(classID, selectList, criteriaID); Iterator resultRows = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); if (resultRows.hasNext()) { return(hashCapacity(((Number)((Object[]) TransactionalServiceUtils.retrieveFirstAndExhaustIterator(resultRows))[0]).intValue())); } return (new Integer(1)); }
public void getCSFCandidateDocumentKeys(Integer BaseYear) { Criteria criteriaId = new Criteria(); criteriaId.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, BaseYear); criteriaId.addEqualTo(KFSPropertyConstants.CSF_DELETE_CODE, BCConstants.ACTIVE_CSF_DELETE_CODE); String[] queryAttr = { KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, KFSPropertyConstants.ACCOUNT_NUMBER, KFSPropertyConstants.SUB_ACCOUNT_NUMBER }; ReportQueryByCriteria queryId = new ReportQueryByCriteria(CalculatedSalaryFoundationTracker.class, queryAttr, criteriaId, true); Iterator rowsReturned = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryId); // decide which keys from CSF need to create new documents // we have already created new documents for all the GL keys while (rowsReturned.hasNext()) { Object[] returnedRow = (Object[]) rowsReturned.next(); String testKey = ((String) returnedRow[0]) + ((String) returnedRow[1]) + ((String) returnedRow[2]); if (currentBCHeaderKeys.contains(testKey)) { // there is no need to create a row for this key continue; } String[] valueCSF = { (String) returnedRow[0], (String) returnedRow[1], (String) returnedRow[2] }; CSFTrackerKeys.put(testKey, valueCSF); } }
protected void readBaseYearInactiveObjects(Integer BaseYear) { Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, BaseYear); criteriaID.addEqualTo(KFSPropertyConstants.ACTIVE, false); baseYearInactiveObjects = new HashMap<String, String[]>(hashObjectSize(ObjectCode.class, criteriaID)); String[] queryAttr = { KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, KFSPropertyConstants.FINANCIAL_OBJECT_CODE }; ReportQueryByCriteria queryID = new ReportQueryByCriteria(ObjectCode.class, queryAttr, criteriaID); Iterator result = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); while (result.hasNext()) { Object[] resultRow = (Object[]) result.next(); String[] hashMapValue = new String[2]; hashMapValue[0] = (String) resultRow[0]; hashMapValue[1] = (String) resultRow[1]; String hashMapKey = hashMapValue[0] + hashMapValue[1]; baseYearInactiveObjects.put(hashMapKey, hashMapValue); } }
public boolean getBudgetConstructionControlFlag(Integer universityFiscalYear, String FlagID) { /* return true if a flag is on, false if it is not */ Boolean result; Criteria criteriaID = new Criteria(); criteriaID.addEqualTo(KFSConstants.UNIVERSITY_FISCAL_YEAR_PROPERTY_NAME, universityFiscalYear); criteriaID.addEqualTo(KFSPropertyConstants.FINANCIAL_SYSTEM_FUNCTION_CONTROL_CODE, FlagID); String[] queryAttr = { KFSPropertyConstants.FINANCIAL_SYSTEM_FUNCTION_ACTIVE_INDICATOR }; ReportQueryByCriteria queryID = new ReportQueryByCriteria(FiscalYearFunctionControl.class, queryAttr, criteriaID, true); Iterator Results = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(queryID); result = (Boolean) ((Object[]) Results.next())[0]; return result; }
/** * Retrieves a list of document numbers of the purchase order returned by the passed in criteria. * * @param criteria - list of criteria to use in the retrieve * @return Iterator of document numbers */ protected Iterator<Object[]> getDocumentNumbersUsingPurchaseOrderCriteria(Criteria criteria) { ReportQueryByCriteria rqbc = new ReportQueryByCriteria(PurchaseOrderDocument.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); return getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); }
/** * @see org.kuali.kfs.module.purap.document.dataaccess.PurchaseOrderDao#getOldestPurchaseOrderDocumentNumber(java.lang.Integer) */ public String getOldestPurchaseOrderDocumentNumber(Integer id) { Criteria criteria = new Criteria(); criteria.addEqualTo(PurapPropertyConstants.PURAP_DOC_ID, id); ReportQueryByCriteria rqbc = new ReportQueryByCriteria(PurchaseOrderDocument.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); Iterator<Object[]> iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); String oldestDocumentNumber = null; if (iter.hasNext()) { oldestDocumentNumber = (String) (iter.next())[0]; } return oldestDocumentNumber; }
/** * Retrieves a document number for a payment request by user defined criteria and sorts the values ascending if orderByAscending * parameter is true, descending otherwise. * * @param criteria - list of criteria to use in the retrieve * @param orderByAscending - boolean to sort results ascending if true, descending otherwise * @return - Iterator of document numbers */ protected Iterator<Object[]> getDocumentNumbersOfPaymentRequestByCriteria(Criteria criteria, boolean orderByAscending) { LOG.debug("getDocumentNumberOfPaymentRequestByCriteria() started"); ReportQueryByCriteria rqbc = new ReportQueryByCriteria(PaymentRequestDocument.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); if (orderByAscending) { rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); } else { rqbc.addOrderByDescending(KFSPropertyConstants.DOCUMENT_NUMBER); } return getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); }
/** * Retrieves a document number for a credit memo by user defined criteria and sorts the values ascending if orderByAscending * parameter is true, descending otherwise. * * @param criteria - list of criteria to use in the retrieve * @param orderByAscending - boolean indicating results should be sorted ascending, descending otherwise * @return - Iterator of document numbers */ protected Iterator<Object[]> getDocumentNumbersOfCreditMemoByCriteria(Criteria criteria, boolean orderByAscending) { LOG.debug("getDocumentNumberOfCreditMemoByCriteria() started"); ReportQueryByCriteria rqbc = new ReportQueryByCriteria(VendorCreditMemoDocument.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); if (orderByAscending) { rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); } else { rqbc.addOrderByDescending(KFSPropertyConstants.DOCUMENT_NUMBER); } return getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); }
protected Iterator<Object[]> getDocumentNumbersOfBulkReceivingByCriteria(Criteria criteria, boolean orderByAscending) { ReportQueryByCriteria rqbc = new ReportQueryByCriteria(BulkReceivingDocument.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); if (orderByAscending) { rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); }else { rqbc.addOrderByDescending(KFSPropertyConstants.DOCUMENT_NUMBER); } return getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); }
protected Iterator<Object[]> getDocumentNumbersOfCorrectionReceivingByCriteria(Criteria criteria, boolean orderByAscending) { ReportQueryByCriteria rqbc = new ReportQueryByCriteria(CorrectionReceivingDocument.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); if (orderByAscending) { rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); } else { rqbc.addOrderByDescending(KFSPropertyConstants.DOCUMENT_NUMBER); } return getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); }
/** * @see org.kuali.kfs.module.purap.document.dataaccess.PurchaseOrderDao#itemExistsOnPurchaseOrder(java.lang.Integer, java.lang.String) */ public boolean itemExistsOnPurchaseOrder(Integer poItemLineNumber, String docNumber){ boolean existsInPo = false; Criteria criteria = new Criteria(); criteria.addEqualTo("documentNumber", docNumber); criteria.addEqualTo("itemLineNumber", poItemLineNumber); ReportQueryByCriteria rqbc = new ReportQueryByCriteria(PurchaseOrderItem.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); Iterator<Object[]> iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); if (iter.hasNext()) { existsInPo = true; } return existsInPo; }
/** * Retrieves a document number for a payment request by user defined criteria and sorts the values ascending if orderByAscending * parameter is true, descending otherwise. * * @param criteria - list of criteria to use in the retrieve * @param orderByAscending - boolean to sort results ascending if true, descending otherwise * @return - Iterator of document numbers */ protected Iterator<Object[]> getDocumentNumbersOfReceivingLineByCriteria(Criteria criteria, boolean orderByAscending) { ReportQueryByCriteria rqbc = new ReportQueryByCriteria(LineItemReceivingDocument.class, criteria); rqbc.setAttributes(new String[] { KFSPropertyConstants.DOCUMENT_NUMBER }); if (orderByAscending) { rqbc.addOrderByAscending(KFSPropertyConstants.DOCUMENT_NUMBER); } else { rqbc.addOrderByDescending(KFSPropertyConstants.DOCUMENT_NUMBER); } return getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rqbc); }
/** * Given an origin entry group source type (defined in OriginEntrySource) * * @param sourceCode the source code of the groups to find * @return a OriginEntryGroup with the given source code and max ORIGIN_ENTRY_GRP_ID * @see org.kuali.kfs.gl.businessobject.OriginEntrySource * @see org.kuali.kfs.gl.dataaccess.OriginEntryGroupDao#getGroupWithMaxIdFromSource(java.lang.String) */ public OriginEntryGroup getGroupWithMaxIdFromSource(String sourceCode) { LOG.debug("getGroupWithMaxIdFromSource() started"); Criteria crit = new Criteria(); Criteria subCrit = new Criteria(); subCrit.addEqualTo(SOURCE_CODE, sourceCode); ReportQueryByCriteria subQuery = new ReportQueryByCriteria(OriginEntryGroup.class, subCrit); subQuery.setAttributes(new String[]{MAX_ORIGIN_ENTRY_GRP_ID}); crit.addGreaterOrEqualThan(ORIGIN_ENTRY_GRP_ID, subQuery); QueryByCriteria qbc = QueryFactory.newQuery(OriginEntryGroup.class, crit); return (OriginEntryGroup) getPersistenceBrokerTemplate().getObjectByQuery(qbc); }