1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.dataaccess.impl;
17
18 import org.apache.ojb.broker.query.Criteria;
19 import org.apache.ojb.broker.query.QueryByCriteria;
20 import org.kuali.ole.module.purap.businessobject.PurchaseOrderSensitiveData;
21 import org.kuali.ole.module.purap.businessobject.SensitiveData;
22 import org.kuali.ole.module.purap.businessobject.SensitiveDataAssignment;
23 import org.kuali.ole.module.purap.dataaccess.SensitiveDataDao;
24 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
25
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.List;
29
30 public class SensitiveDataDaoOjb extends PlatformAwareDaoBaseOjb implements SensitiveDataDao {
31
32 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SensitiveDataDaoOjb.class);
33
34 public SensitiveDataDaoOjb() {
35 super();
36 }
37
38
39
40
41 public List<SensitiveData> getSensitiveDatasAssignedByPoId(Integer poId) {
42 LOG.debug("getSensitiveDatasAssignedByPoId(Integer) started");
43
44 Criteria criteria = new Criteria();
45 criteria.addEqualTo("purapDocumentIdentifier", poId);
46 Collection<PurchaseOrderSensitiveData> posdColl = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(PurchaseOrderSensitiveData.class, criteria));
47 List<SensitiveData> sdList = new ArrayList<SensitiveData>();
48 for (PurchaseOrderSensitiveData posd : posdColl) {
49 sdList.add(posd.getSensitiveData());
50 }
51
52 return sdList;
53 }
54
55
56
57
58 public List<SensitiveData> getSensitiveDatasAssignedByReqId(Integer reqId) {
59 LOG.debug("getSensitiveDatasAssignedByReqId(Integer) started");
60
61 Criteria criteria = new Criteria();
62 criteria.addEqualTo("requisitionIdentifier", reqId);
63 Collection<PurchaseOrderSensitiveData> posdColl = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(PurchaseOrderSensitiveData.class, criteria));
64 List<SensitiveData> sdList = new ArrayList<SensitiveData>();
65 for (PurchaseOrderSensitiveData posd : posdColl) {
66 sdList.add(posd.getSensitiveData());
67 }
68
69 return sdList;
70 }
71
72
73
74
75 public void deletePurchaseOrderSensitiveDatas(Integer poId) {
76 LOG.debug("deletePurchaseOrderSensitiveDatas(Integer) started");
77 Criteria criteria = new Criteria();
78 criteria.addEqualTo("purapDocumentIdentifier", poId);
79 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(PurchaseOrderSensitiveData.class, criteria));
80 }
81
82
83
84
85 public SensitiveDataAssignment getLastSensitiveDataAssignment(Integer poId) {
86 LOG.debug("getLastSensitiveDataAssignment(Integer) started");
87
88 Criteria criteria = new Criteria();
89 criteria.addEqualTo("purapDocumentIdentifier", poId);
90 Collection<SensitiveDataAssignment> sdaColl = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SensitiveDataAssignment.class, criteria));
91
92
93 int max = 0;
94 SensitiveDataAssignment lastsda = null;
95 for (SensitiveDataAssignment sda : sdaColl) {
96 if (sda.getSensitiveDataAssignmentIdentifier() >= max) {
97 max = sda.getSensitiveDataAssignmentIdentifier();
98 lastsda = sda;
99 }
100 }
101
102 return lastsda;
103 }
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121 }