1 package org.kuali.kpme.edo.reviewernote.dao;
2
3 import java.util.Collection;
4 import java.util.LinkedList;
5 import java.util.List;
6
7 import org.apache.ojb.broker.query.Criteria;
8 import org.apache.ojb.broker.query.Query;
9 import org.apache.ojb.broker.query.QueryFactory;
10
11 import org.kuali.kpme.edo.reviewernote.EdoReviewerNoteBo;
12 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
13
14 public class EdoReviewerNoteDaoImpl extends PlatformAwareDaoBaseOjb implements EdoReviewerNoteDao {
15
16
17
18
19
20
21
22 public EdoReviewerNoteBo getReviewerNoteById(String edoReviewerNoteId) {
23
24 Criteria cConditions = new Criteria();
25
26 cConditions.addEqualTo("edoReviewerNoteId", edoReviewerNoteId);
27
28 Query query = QueryFactory.newQuery(EdoReviewerNoteBo.class, cConditions);
29 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
30
31 if (c != null && c.size() != 0) {
32 if (c.size() == 1) {
33 return (EdoReviewerNoteBo)c.toArray()[0];
34 }
35 }
36
37 return null;
38 }
39
40 public List<EdoReviewerNoteBo> getReviewerNotesByDossierId(String edoDossierId) {
41
42 List<EdoReviewerNoteBo> reviewerNoteList = new LinkedList<EdoReviewerNoteBo>();
43
44 Criteria cConditions = new Criteria();
45 cConditions.addEqualTo("edoDossierId", edoDossierId);
46
47
48 Query query = QueryFactory.newQuery(EdoReviewerNoteBo.class, cConditions);
49 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
50
51 if (c != null && c.size() != 0) {
52 if (c.size() > 0) {
53 reviewerNoteList.addAll(c);
54 return reviewerNoteList;
55 }
56 }
57
58 return null;
59 }
60
61 public List<EdoReviewerNoteBo> getReviewerNotesByUserPrincipalId(String userPrincipalId) {
62 List<EdoReviewerNoteBo> reviewerNoteList = new LinkedList<EdoReviewerNoteBo>();
63
64 Criteria cConditions = new Criteria();
65 cConditions.addEqualTo("userPrincipalId", userPrincipalId);
66
67
68 Query query = QueryFactory.newQuery(EdoReviewerNoteBo.class, cConditions);
69 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
70
71 if (c != null && c.size() != 0) {
72 if (c.size() > 0) {
73 reviewerNoteList.addAll(c);
74 return reviewerNoteList;
75 }
76 }
77
78 return null;
79
80 }
81
82
83
84
85
86
87 public void saveOrUpdate(EdoReviewerNoteBo edoReviewerNoteBo) {
88 this.getPersistenceBrokerTemplate().store( edoReviewerNoteBo );
89 }
90
91 }