1 package org.kuali.kpme.edo.workflow.dao;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.apache.ojb.broker.query.Criteria;
5 import org.apache.ojb.broker.query.Query;
6 import org.apache.ojb.broker.query.QueryFactory;
7 import org.kuali.kpme.edo.dossier.type.EdoDossierTypeBo;
8 import org.kuali.kpme.edo.util.EdoConstants;
9 import org.kuali.kpme.edo.workflow.EdoDossierDocumentInfoBo;
10 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
11
12 import java.util.*;
13
14 public class EdoDossierDocumentInfoDaoImpl extends PlatformAwareDaoBaseOjb implements EdoDossierDocumentInfoDao {
15
16 @Override
17 public void saveOrUpdate(EdoDossierDocumentInfoBo edoDossierDocumentInfoBo) {
18 if (edoDossierDocumentInfoBo != null) {
19 this.getPersistenceBrokerTemplate().store(edoDossierDocumentInfoBo);
20 }
21 }
22
23 @Override
24 public EdoDossierDocumentInfoBo getEdoDossierDocumentInfoByDocId(String edoDocumentId) {
25 Criteria crit = new Criteria();
26 crit.addEqualTo("edoDocumentId", edoDocumentId);
27 return (EdoDossierDocumentInfoBo) this.getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(EdoDossierDocumentInfoBo.class, crit));
28
29 }
30
31 @Override
32 public EdoDossierDocumentInfoBo getEdoDossierDocumentInfoByDossierId(String edoDossierId) {
33 Criteria crit = new Criteria();
34 crit.addEqualTo("edoDossierId", edoDossierId);
35 crit.addNotLike("documentTypeName", "%Supplemental%");
36 crit.addNotLike("documentStatus", "%F%");
37 return (EdoDossierDocumentInfoBo) this.getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(EdoDossierDocumentInfoBo.class, crit));
38 }
39
40 @Override
41 public List<EdoDossierDocumentInfoBo> getEdoDossierDocumentInfoByDocType(String edoDossierId, String docTypeName) {
42 List<EdoDossierDocumentInfoBo> dossierProcessDocumentHeaders = new ArrayList<EdoDossierDocumentInfoBo>();
43 Criteria crit = new Criteria();
44 crit.addEqualTo("edoDossierId", edoDossierId);
45 crit.addEqualTo("documentTypeName", docTypeName);
46 Query query = QueryFactory.newQuery(EdoDossierDocumentInfoBo.class, crit);
47 dossierProcessDocumentHeaders.addAll(this.getPersistenceBrokerTemplate().getCollectionByQuery(query));
48
49 return dossierProcessDocumentHeaders;
50 }
51
52 public boolean hasPendingSupplementalDocument(String edoDossierId) {
53
54 Criteria crit = new Criteria();
55 crit.addEqualTo("edoDossierId", edoDossierId);
56 crit.addEqualTo("documentTypeName", EdoConstants.SUPPLEMENTAL_DOC_TYPE_TENURE);
57 crit.addNotEqualTo("documentStatus", "F");
58
59 Collection c_tenure = this.getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(EdoDossierDocumentInfoBo.class, crit));
60 if (CollectionUtils.isNotEmpty(c_tenure)) {
61 return true;
62 }
63 crit = new Criteria();
64 crit.addEqualTo("edoDossierId", edoDossierId);
65 crit.addEqualTo("documentTypeName", EdoConstants.SUPPLEMENTAL_DOC_TYPE_PROMOTION);
66 crit.addNotEqualTo("documentStatus", "F");
67
68 Collection c_promotion = this.getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(EdoDossierDocumentInfoBo.class, crit));
69 if (CollectionUtils.isNotEmpty(c_promotion)) {
70 return true;
71
72 }
73 return false;
74 }
75
76 public List<EdoDossierDocumentInfoBo> getPendingSupplementalDocuments(String edoDossierId) {
77 List<EdoDossierDocumentInfoBo> docHeaders = new LinkedList<EdoDossierDocumentInfoBo>();
78
79 Criteria crit = new Criteria();
80 crit.addEqualTo("edoDossierId", edoDossierId);
81 crit.addEqualTo("documentTypeName", EdoConstants.SUPPLEMENTAL_DOC_TYPE_TENURE);
82 crit.addNotEqualTo("documentStatus", "F");
83
84 Collection c_tenure = this.getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(EdoDossierDocumentInfoBo.class, crit));
85 if (CollectionUtils.isNotEmpty(c_tenure)) {
86 docHeaders.addAll(c_tenure);
87 }
88 crit = new Criteria();
89 crit.addEqualTo("edoDossierId", edoDossierId);
90 crit.addEqualTo("documentTypeName", EdoConstants.SUPPLEMENTAL_DOC_TYPE_PROMOTION);
91 crit.addNotEqualTo("documentStatus", "F");
92
93 Collection c_promotion = this.getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(EdoDossierDocumentInfoBo.class, crit));
94 if (CollectionUtils.isNotEmpty(c_promotion)) {
95 docHeaders.addAll(c_promotion);
96 }
97 return docHeaders;
98 }
99 }