View Javadoc
1   /*
2    * Copyright 2008 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.service.impl;
17  
18  import org.kuali.ole.module.purap.businessobject.PurchaseOrderSensitiveData;
19  import org.kuali.ole.module.purap.businessobject.SensitiveData;
20  import org.kuali.ole.module.purap.businessobject.SensitiveDataAssignment;
21  import org.kuali.ole.module.purap.businessobject.SensitiveDataAssignmentDetail;
22  import org.kuali.ole.module.purap.dataaccess.SensitiveDataDao;
23  import org.kuali.ole.module.purap.document.dataaccess.PurchaseOrderDao;
24  import org.kuali.ole.module.purap.service.SensitiveDataService;
25  import org.kuali.ole.sys.context.SpringContext;
26  import org.kuali.rice.krad.service.BusinessObjectService;
27  
28  import java.util.*;
29  
30  public class SensitiveDataServiceImpl implements SensitiveDataService {
31      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SensitiveDataServiceImpl.class);
32  
33      private SensitiveDataDao sensitiveDataDao;
34      private PurchaseOrderDao purchaseOrderDao;
35  
36      public void setPurchaseOrderDao(PurchaseOrderDao purchaseOrderDao) {
37          this.purchaseOrderDao = purchaseOrderDao;
38      }
39  
40      public SensitiveDataDao getSensitiveDataDao() {
41          return sensitiveDataDao;
42      }
43  
44      public void setSensitiveDataDao(SensitiveDataDao sensitiveDataDao) {
45          this.sensitiveDataDao = sensitiveDataDao;
46      }
47  
48      /**
49       * @see org.kuali.ole.integration.service.SensitiveDataService#getSensitiveDataByCode(java.lang.String)
50       */
51      public SensitiveData getSensitiveDataByCode(String sensitiveDataCode) {
52          LOG.debug("getSensitiveDataByCode(String) started");
53          Map<String, Object> primaryKeys = new HashMap<String, Object>();
54          primaryKeys.put("sensitiveDataCode", sensitiveDataCode);
55          return (SensitiveData) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(SensitiveData.class, primaryKeys);
56      }
57  
58      /**
59       * @see org.kuali.ole.module.purap.service.SensitiveDataService#getAllSensitiveDatas()
60       */
61      public List<SensitiveData> getAllSensitiveDatas() {
62          LOG.debug("getSensitiveDataByPoId(Integer) started");
63  
64          List<SensitiveData> sds = new ArrayList<SensitiveData>();
65          Collection<SensitiveData> sdColl = SpringContext.getBean(BusinessObjectService.class).findAll(SensitiveData.class);
66          for (Object sd : sdColl) {
67              sds.add((SensitiveData) sd);
68          }
69  
70          return sds;
71      }
72  
73      public List<SensitiveData> getSensitiveDatasAssignedByRelatedDocId(Integer accountsPayablePurchasingDocumentLinkIdentifier) {
74          Integer poId = purchaseOrderDao.getPurchaseOrderIdForCurrentPurchaseOrderByRelatedDocId(accountsPayablePurchasingDocumentLinkIdentifier);
75          return getSensitiveDatasAssignedByPoId(poId);
76      }
77  
78      /**
79       * @see org.kuali.ole.module.purap.service.SensitiveDataService#getSensitiveDatasAssignedByPoId()
80       */
81      public List<SensitiveData> getSensitiveDatasAssignedByPoId(Integer poId) {
82          LOG.debug("getSensitiveDatasAssignedByPoId(Integer) started");
83          return sensitiveDataDao.getSensitiveDatasAssignedByPoId(poId);
84      }
85  
86      /**
87       * @see org.kuali.ole.module.purap.service.SensitiveDataService#getSensitiveDatasAssignedByReqId(Integer)
88       */
89      public List<SensitiveData> getSensitiveDatasAssignedByReqId(Integer reqId) {
90          LOG.debug("getSensitiveDatasAssignedByReqId(Integer) started");
91          return sensitiveDataDao.getSensitiveDatasAssignedByReqId(reqId);
92      }
93  
94      /**
95       * @see org.kuali.ole.module.purap.service.SensitiveDataService#deletePurchaseOrderSensitiveDatas(Integer)
96       */
97      public void deletePurchaseOrderSensitiveDatas(Integer poId) {
98          LOG.debug("deletePurchaseOrderSensitiveDatas(Integer) started");
99          sensitiveDataDao.deletePurchaseOrderSensitiveDatas(poId);
100     }
101 
102     /**
103      * @see org.kuali.ole.module.purap.service.SensitiveDataService#savePurchaseOrderSensitiveDatas(List<PurchaseOrderSensitiveData>)
104      */
105     public void savePurchaseOrderSensitiveDatas(List<PurchaseOrderSensitiveData> posds) {
106         LOG.debug("savePurchaseOrderSensitiveDatas(List<PurchaseOrderSensitiveData>) started");
107         SpringContext.getBean(BusinessObjectService.class).save(posds);
108     }
109 
110     /**
111      * @see org.kuali.ole.module.purap.service.SensitiveDataService#getLastSensitiveDataAssignment(Integer)
112      */
113     public SensitiveDataAssignment getLastSensitiveDataAssignment(Integer poId) {
114         LOG.debug("getLastSensitiveDataAssignment(Integer) started");
115         return sensitiveDataDao.getLastSensitiveDataAssignment(poId);
116     }
117 
118     /**
119      * @see org.kuali.ole.module.purap.service.SensitiveDataService#getLastSensitiveDataAssignmentId(Integer)
120      */
121     public Integer getLastSensitiveDataAssignmentId(Integer poId) {
122         LOG.debug("getLastSensitiveDataAssignmentId(Integer) started");
123         return getLastSensitiveDataAssignment(poId).getSensitiveDataAssignmentIdentifier();
124     }
125 
126     /**
127      * @see org.kuali.ole.module.purap.service.SensitiveDataService#saveSensitiveDataAssignment(SensitiveDataAssignment)
128      */
129     public void saveSensitiveDataAssignment(SensitiveDataAssignment sda) {
130         LOG.debug("saveSensitiveDataAssignment(SensitiveDataAssignment) started");
131         SpringContext.getBean(BusinessObjectService.class).save(sda);
132     }
133 
134     /**
135      * @see org.kuali.ole.module.purap.service.SensitiveDataService#getLastSensitiveDataAssignmentDetails(Integer)
136      */
137     public List<SensitiveDataAssignmentDetail> getLastSensitiveDataAssignmentDetails(Integer poId) {
138         LOG.debug("getLastSensitiveDataAssignmentDetails(Integer) started");
139         Integer sdaId = getLastSensitiveDataAssignmentId(poId);
140         Map<String, Object> fieldValues = new HashMap<String, Object>();
141         fieldValues.put("sensitiveDataAssignmentIdentifier", sdaId);
142         return (List<SensitiveDataAssignmentDetail>) SpringContext.getBean(BusinessObjectService.class).findMatching(SensitiveDataAssignmentDetail.class, fieldValues);
143     }
144 
145     /**
146      * @see org.kuali.ole.module.purap.service.SensitiveDataService#saveSensitiveDataAssignmentDetails(List<SensitiveDataAssignmentDetail>)
147      */
148     public void saveSensitiveDataAssignmentDetails(List<SensitiveDataAssignmentDetail> sdads) {
149         LOG.debug("saveSensitiveDataAssignmentDetails(List<SensitiveDataAssignmentDetail>) started");
150         SpringContext.getBean(BusinessObjectService.class).save(sdads);
151     }
152 
153 
154 }