1 package org.kuali.kpme.edo.dossier.dao;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.LinkedList;
6 import java.util.List;
7
8 import org.apache.ojb.broker.query.Criteria;
9 import org.apache.ojb.broker.query.Query;
10 import org.apache.ojb.broker.query.QueryFactory;
11 import org.kuali.kpme.edo.dossier.EdoDossierBo;
12 import org.kuali.kpme.edo.util.EdoConstants;
13 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
14
15
16 public class EdoDossierDaoImpl extends PlatformAwareDaoBaseOjb implements EdoDossierDao {
17
18 public EdoDossierBo getCurrentDossierPrincipalName(String candidatePrincipalName) {
19 Criteria cConditions = new Criteria();
20
21 cConditions.addEqualTo("candidatePrincipalName", candidatePrincipalName );
22 cConditions.addIn("dossierStatus", EdoConstants.DOSSIER_STATUS_CURRENT);
23
24 Query query = QueryFactory.newQuery(EdoDossierBo.class, cConditions);
25
26 return (EdoDossierBo) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
27 }
28
29 public List<EdoDossierBo> getDossierList() {
30
31 List<EdoDossierBo> dossierList = new LinkedList<EdoDossierBo>();
32
33 Criteria cConditions = new Criteria();
34
35 Query query = QueryFactory.newQuery(EdoDossierBo.class, cConditions);
36 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
37
38 if (c != null && c.size() != 0) {
39 dossierList.addAll(c);
40 }
41 return dossierList;
42 }
43
44 public EdoDossierBo getEdoDossierById( String edoDossierId ) {
45 Criteria cConditions = new Criteria();
46
47 cConditions.addEqualTo("edoDossierId", edoDossierId);
48
49
50 Query query = QueryFactory.newQuery(EdoDossierBo.class, cConditions);
51
52 return (EdoDossierBo) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
53 }
54
55 public void saveOrUpdate(EdoDossierBo edoDossier) {
56 this.getPersistenceBrokerTemplate().store(edoDossier);
57 }
58
59
60
61 public List<EdoDossierBo> getDossierListByUserName(String userName) {
62 List<EdoDossierBo> dossierList = new ArrayList<EdoDossierBo>();
63
64 Criteria cConditions = new Criteria();
65 cConditions.addEqualTo("candidateUsername", userName);
66
67 Query query = QueryFactory.newQuery(EdoDossierBo.class, cConditions);
68 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
69
70 if (c != null && c.size() != 0) {
71 dossierList.addAll(c);
72 }
73 return dossierList;
74
75 }
76
77 public EdoDossierBo getDossier(String documentId) {
78 Criteria crit = new Criteria();
79
80 crit.addLike("documentID", documentId);
81
82 Query query = QueryFactory.newQuery(EdoDossierBo.class, crit);
83
84 return (EdoDossierBo) this.getPersistenceBrokerTemplate().getObjectByQuery(query);
85 }
86
87 }