001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.module.bc.document.dataaccess.impl; 017 018 import java.util.ArrayList; 019 020 import org.kuali.kfs.module.bc.batch.dataaccess.impl.SQLForStep; 021 import org.kuali.kfs.module.bc.document.dataaccess.BudgetConstructionAccountFundingDetailReportDao; 022 import org.kuali.rice.kns.service.PersistenceService; 023 024 /** 025 * 026 */ 027 028 public class BudgetConstructionAccountFundingDetailReportDaoJdbc extends BudgetConstructionDaoJdbcBase implements BudgetConstructionAccountFundingDetailReportDao { 029 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BudgetConstructionAccountFundingDetailReportDaoJdbc.class); 030 031 private static ArrayList<SQLForStep> updateReportsAccountFundingDetailTable = new ArrayList<SQLForStep>(1); 032 033 private PersistenceService persistenceService; 034 035 public BudgetConstructionAccountFundingDetailReportDaoJdbc() { 036 037 /* get accounts for selected orgs and objects */ 038 StringBuilder sqlText = new StringBuilder(500); 039 sqlText.append("INSERT INTO LD_BCN_OBJT_DUMP_T \n"); 040 sqlText.append(" (PERSON_UNVL_ID, ORG_FIN_COA_CD, ORG_CD, SUB_FUND_GRP_CD, UNIV_FISCAL_YR, FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR, FIN_OBJECT_CD)\n"); 041 sqlText.append("SELECT DISTINCT \n"); 042 sqlText.append(" ?, ctrl.sel_org_fin_coa, ctrl.sel_org_cd, ctrl.sel_sub_fund_grp, ctrl.univ_fiscal_yr, ctrl.fin_coa_cd, \n"); 043 sqlText.append(" ctrl.account_nbr, ctrl.sub_acct_nbr, pick.fin_object_cd \n"); 044 sqlText.append("FROM LD_PNDBC_APPTFND_T af, LD_BCN_CTRL_LIST_T ctrl, LD_BCN_OBJ_PICK_T pick \n"); 045 sqlText.append("WHERE ctrl.person_unvl_id = ? \n"); 046 sqlText.append(" AND af.univ_fiscal_yr = ctrl.univ_fiscal_yr \n"); 047 sqlText.append(" AND af.fin_coa_cd = ctrl.fin_coa_cd \n"); 048 sqlText.append(" AND af.account_nbr = ctrl.account_nbr \n"); 049 sqlText.append(" AND af.sub_acct_nbr = ctrl.sub_acct_nbr \n"); 050 sqlText.append(" AND pick.fin_object_cd = af.fin_object_cd \n"); 051 sqlText.append(" AND pick.person_unvl_id = ctrl.person_unvl_id \n"); 052 sqlText.append(" AND pick.select_flag > 0 \n"); 053 054 updateReportsAccountFundingDetailTable.add(new SQLForStep(sqlText)); 055 sqlText.delete(0, sqlText.length()); 056 } 057 public void cleanReportsAccountFundingDetailTable(String principalName) { 058 clearTempTableByUnvlId("LD_BCN_OBJT_DUMP_T", "PERSON_UNVL_ID", principalName); 059 /** 060 * this is necessary to clear any rows for the tables we have just updated from the OJB cache. otherwise, subsequent calls to OJB will fetch the old, unupdated cached rows. 061 */ 062 persistenceService.clearCache(); 063 } 064 065 public void updateReportsAccountFundingDetailTable(String principalName) { 066 cleanReportsAccountFundingDetailTable(principalName); 067 getSimpleJdbcTemplate().update(updateReportsAccountFundingDetailTable.get(0).getSQL(), principalName, principalName); 068 /** 069 * this is necessary to clear any rows for the tables we have just updated from the OJB cache. otherwise, subsequent calls to OJB will fetch the old, unupdated cached rows. 070 */ 071 persistenceService.clearCache(); 072 } 073 074 public void setPersistenceService(PersistenceService persistenceService) 075 { 076 this.persistenceService = persistenceService; 077 } 078 079 } 080