001/* 002 * Copyright 2008 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 */ 016package org.kuali.ole.module.purap.service.impl; 017 018import org.kuali.ole.module.purap.businessobject.PurchaseOrderSensitiveData; 019import org.kuali.ole.module.purap.businessobject.SensitiveData; 020import org.kuali.ole.module.purap.businessobject.SensitiveDataAssignment; 021import org.kuali.ole.module.purap.businessobject.SensitiveDataAssignmentDetail; 022import org.kuali.ole.module.purap.dataaccess.SensitiveDataDao; 023import org.kuali.ole.module.purap.document.dataaccess.PurchaseOrderDao; 024import org.kuali.ole.module.purap.service.SensitiveDataService; 025import org.kuali.ole.sys.context.SpringContext; 026import org.kuali.rice.krad.service.BusinessObjectService; 027 028import java.util.*; 029 030public class SensitiveDataServiceImpl implements SensitiveDataService { 031 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SensitiveDataServiceImpl.class); 032 033 private SensitiveDataDao sensitiveDataDao; 034 private PurchaseOrderDao purchaseOrderDao; 035 036 public void setPurchaseOrderDao(PurchaseOrderDao purchaseOrderDao) { 037 this.purchaseOrderDao = purchaseOrderDao; 038 } 039 040 public SensitiveDataDao getSensitiveDataDao() { 041 return sensitiveDataDao; 042 } 043 044 public void setSensitiveDataDao(SensitiveDataDao sensitiveDataDao) { 045 this.sensitiveDataDao = sensitiveDataDao; 046 } 047 048 /** 049 * @see org.kuali.ole.integration.service.SensitiveDataService#getSensitiveDataByCode(java.lang.String) 050 */ 051 public SensitiveData getSensitiveDataByCode(String sensitiveDataCode) { 052 LOG.debug("getSensitiveDataByCode(String) started"); 053 Map<String, Object> primaryKeys = new HashMap<String, Object>(); 054 primaryKeys.put("sensitiveDataCode", sensitiveDataCode); 055 return (SensitiveData) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(SensitiveData.class, primaryKeys); 056 } 057 058 /** 059 * @see org.kuali.ole.module.purap.service.SensitiveDataService#getAllSensitiveDatas() 060 */ 061 public List<SensitiveData> getAllSensitiveDatas() { 062 LOG.debug("getSensitiveDataByPoId(Integer) started"); 063 064 List<SensitiveData> sds = new ArrayList<SensitiveData>(); 065 Collection<SensitiveData> sdColl = SpringContext.getBean(BusinessObjectService.class).findAll(SensitiveData.class); 066 for (Object sd : sdColl) { 067 sds.add((SensitiveData) sd); 068 } 069 070 return sds; 071 } 072 073 public List<SensitiveData> getSensitiveDatasAssignedByRelatedDocId(Integer accountsPayablePurchasingDocumentLinkIdentifier) { 074 Integer poId = purchaseOrderDao.getPurchaseOrderIdForCurrentPurchaseOrderByRelatedDocId(accountsPayablePurchasingDocumentLinkIdentifier); 075 return getSensitiveDatasAssignedByPoId(poId); 076 } 077 078 /** 079 * @see org.kuali.ole.module.purap.service.SensitiveDataService#getSensitiveDatasAssignedByPoId() 080 */ 081 public List<SensitiveData> getSensitiveDatasAssignedByPoId(Integer poId) { 082 LOG.debug("getSensitiveDatasAssignedByPoId(Integer) started"); 083 return sensitiveDataDao.getSensitiveDatasAssignedByPoId(poId); 084 } 085 086 /** 087 * @see org.kuali.ole.module.purap.service.SensitiveDataService#getSensitiveDatasAssignedByReqId(Integer) 088 */ 089 public List<SensitiveData> getSensitiveDatasAssignedByReqId(Integer reqId) { 090 LOG.debug("getSensitiveDatasAssignedByReqId(Integer) started"); 091 return sensitiveDataDao.getSensitiveDatasAssignedByReqId(reqId); 092 } 093 094 /** 095 * @see org.kuali.ole.module.purap.service.SensitiveDataService#deletePurchaseOrderSensitiveDatas(Integer) 096 */ 097 public void deletePurchaseOrderSensitiveDatas(Integer poId) { 098 LOG.debug("deletePurchaseOrderSensitiveDatas(Integer) started"); 099 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}