View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.dataaccess.impl;
17  
18  import org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao;
19  import org.kuali.rice.core.framework.persistence.jdbc.dao.PlatformAwareDaoBaseJdbc;
20  import org.springframework.dao.DataAccessException;
21  import org.springframework.jdbc.support.rowset.SqlRowSet;
22  import org.springframework.transaction.annotation.Transactional;
23  
24  import java.util.Date;
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  /**
29   * A class to do the database queries needed to prepare documents status codes and descriptions.
30   */
31  @Transactional
32  public class PurapDocumentsStatusCodeMigrationDaoJdbc extends PlatformAwareDaoBaseJdbc implements PurapDocumentsStatusCodeMigrationDao {
33      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurapDocumentsStatusCodeMigrationDaoJdbc.class);
34  
35      /**
36       * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getRequisitionDocumentDetails()
37       */
38      public Map<String, String> getRequisitionDocumentDetails() {
39          LOG.debug("getRequisitionDocumentDetails() started");
40  
41          Map<String, String> requistionDetails = new HashMap<String, String>();
42  
43          try {
44              SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_REQS_T WHERE REQS_STAT_CD IS NOT NULL");
45  
46              while (statusesRowSet.next()) {
47                  requistionDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("REQS_STAT_CD"));
48              }
49  
50              LOG.debug("getRequisitionDocumentDetails() exited");
51              return requistionDetails;
52  
53          } catch (DataAccessException dae) {
54              return requistionDetails;
55          }
56      }
57  
58      /**
59       * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getPurchaseOrderDocumentDetails()
60       */
61      public Map<String, String> getPurchaseOrderDocumentDetails() {
62          LOG.debug("getPurchaseOrderDocumentDetails() started");
63  
64          Map<String, String> purchaseOrderDetails = new HashMap<String, String>();
65  
66          try {
67              SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_PO_T WHERE PO_STAT_CD IS NOT NULL");
68  
69              while (statusesRowSet.next()) {
70                  purchaseOrderDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("PO_STAT_CD"));
71              }
72  
73              LOG.debug("getPurchaseOrderDocumentDetails() exited");
74  
75              return purchaseOrderDetails;
76          } catch (DataAccessException dae) {
77              return purchaseOrderDetails;
78          }
79      }
80  
81      /**
82       * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getPaymentRequestDocumentDetails()
83       */
84      public Map<String, String> getPaymentRequestDocumentDetails() {
85          LOG.debug("getPaymentRequestDocumentDetails() started");
86  
87          Map<String, String> paymentRequestDetails = new HashMap<String, String>();
88  
89          try {
90              SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_PMT_RQST_T WHERE PMT_RQST_STAT_CD IS NOT NULL");
91  
92              while (statusesRowSet.next()) {
93                  paymentRequestDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("PMT_RQST_STAT_CD"));
94              }
95  
96              LOG.debug("getPaymentRequestDocumentDetails() exited");
97  
98              return paymentRequestDetails;
99          } catch (DataAccessException dae) {
100             return paymentRequestDetails;
101         }
102     }
103 
104     /**
105      * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getVendorCreditMemoDocumentDetails()
106      */
107     public Map<String, String> getVendorCreditMemoDocumentDetails() {
108         LOG.debug("getVendorCreditMemoDocumentDetails() started");
109 
110         Map<String, String> vendorCreditMemoDetails = new HashMap<String, String>();
111 
112         try {
113             SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_CRDT_MEMO_T WHERE CRDT_MEMO_STAT_CD IS NOT NULL");
114 
115             while (statusesRowSet.next()) {
116                 vendorCreditMemoDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("CRDT_MEMO_STAT_CD"));
117             }
118 
119             LOG.debug("getVendorCreditMemoDocumentDetails() exited");
120 
121             return vendorCreditMemoDetails;
122         } catch (DataAccessException dae) {
123             return vendorCreditMemoDetails;
124         }
125     }
126 
127     /**
128      * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getLineItemReceivingDocumentDetails()
129      */
130     public Map<String, String> getLineItemReceivingDocumentDetails() {
131         LOG.debug("getLineItemReceivingDocumentDetails() started");
132 
133         Map<String, String> lineItemRecvDetails = new HashMap<String, String>();
134 
135         try {
136             SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_RCVNG_LN_T WHERE RCVNG_LN_STAT_CD IS NOT NULL");
137 
138             while (statusesRowSet.next()) {
139                 lineItemRecvDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("RCVNG_LN_STAT_CD"));
140             }
141 
142             LOG.debug("getLineItemReceivingDocumentDetails() exited");
143 
144             return lineItemRecvDetails;
145         } catch (DataAccessException dae) {
146             return lineItemRecvDetails;
147         }
148     }
149 
150     /**
151      * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#updateAndSaveMigratedApplicationDocumentStatuses(java.lang.String, java.lang.String, java.util.Date)
152      */
153     public boolean updateAndSaveMigratedApplicationDocumentStatuses(String documentNumber, String applicationDocumentStatus, Date applicationDocumentStatusModifiedDate) {
154         boolean success = true;
155 
156         String sql = "UPDATE KREW_DOC_HDR_T SET APP_DOC_STAT = '" + applicationDocumentStatus + "', APP_DOC_STAT_MDFN_DT = '" + applicationDocumentStatusModifiedDate + "' WHERE DOC_HDR_ID = '" + documentNumber + "'";
157 
158         getJdbcTemplate().execute(sql);
159 
160         return success;
161     }
162 
163 }