1 package org.kuali.ole.service;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.apache.ojb.broker.query.Criteria;
5 import org.apache.ojb.broker.query.QueryByCriteria;
6 import org.apache.ojb.broker.query.QueryFactory;
7 import org.kuali.ole.deliver.bo.OleLoanDocument;
8 import org.kuali.ole.select.bo.OLEGOKbPlatform;
9 import org.kuali.ole.select.bo.OLEGOKbTIPP;
10 import org.kuali.ole.select.gokb.OleGokbPlatform;
11 import org.kuali.ole.select.gokb.OleGokbTipp;
12 import org.kuali.ole.select.gokb.OleGokbView;
13 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
14 import org.kuali.rice.krad.service.KRADServiceLocator;
15
16 import java.util.*;
17
18
19
20
21 public class OLEGOKBSearchDaoOjb extends PlatformAwareDaoBaseOjb {
22
23 public List<OleGokbTipp> packageSearch(String packageName, String platformName, List<String> platformProviders, String title, List<String> issnList, String titleInstanceType, List<String> platformStatusList, List<String> packageStatusList, List<String> tippStatusList) {
24
25 List<OleGokbTipp> oleGokbTipps ;
26 Criteria goKbSearchCriteria = new Criteria();
27
28 if(StringUtils.isNotEmpty(packageName)){
29 packageName = packageName.replace("*","%").toUpperCase();
30 goKbSearchCriteria.addLike("UPPER(oleGokbPackage.packageName)",packageName);
31 }
32
33 if(StringUtils.isNotEmpty(platformName)){
34 platformName = platformName.replace("*","%").toUpperCase();
35 goKbSearchCriteria.addLike("UPPER(oleGokbPlatform.platformName)",platformName);
36 }
37
38
39 if(StringUtils.isNotEmpty(title)){
40 title = title.replace("*","%").toUpperCase();
41 goKbSearchCriteria.addLike("UPPER(oleGokbTitle.titleName)",title);
42 }
43
44
45 if(StringUtils.isNotEmpty(titleInstanceType)){
46 titleInstanceType = titleInstanceType.replace("*","%").toUpperCase();
47 goKbSearchCriteria.addLike("UPPER(oleGokbTitle.medium)",titleInstanceType);
48 }
49
50 if(platformProviders.size()>0 && platformProviders.size()>0){
51 goKbSearchCriteria.addIn("oleGokbPlatform.oleGokbOrganization.organizationName", platformProviders);
52 }
53
54 if(platformStatusList.size()>0 && platformStatusList.size()>0){
55 goKbSearchCriteria.addIn("oleGokbPlatform.status",platformStatusList);
56 }
57
58 if(packageStatusList.size()>0 && packageStatusList.size()>0){
59 goKbSearchCriteria.addIn("oleGokbPackage.status",packageStatusList);
60
61 }
62
63 if(issnList.size()>0 && issnList.size()>0){
64 goKbSearchCriteria.addIn("oleGokbTitle.issnOnline",issnList);
65
66
67 }
68
69 if(tippStatusList.size()>0 && tippStatusList.size()>0){
70 goKbSearchCriteria.addIn("status",tippStatusList);
71 }
72
73
74 QueryByCriteria query = QueryFactory.newQuery(OleGokbTipp.class, goKbSearchCriteria);
75 Collection results= getPersistenceBrokerTemplate().getCollectionByQuery(query);
76 return (List<OleGokbTipp>)results;
77 }
78
79
80
81 public List<OleGokbTipp> getTippsByPlatform(Integer platformId,Integer packageId,String title,String titleInstanceType,List<String> platformProviders) {
82 Criteria goKbSearchCriteria = new Criteria();
83 goKbSearchCriteria.addEqualTo("gokbPlatformId",platformId);
84 if(packageId !=null){
85 goKbSearchCriteria.addEqualTo("gokbPackageId",packageId);
86 }
87 if(StringUtils.isNotEmpty(title)){
88 title = title.replace("*","%").toUpperCase();
89 goKbSearchCriteria.addLike("UPPER(oleGokbTitle.titleName)",title);
90 }
91
92
93 if(StringUtils.isNotEmpty(titleInstanceType)){
94 titleInstanceType = titleInstanceType.replace("*","%").toUpperCase();
95 goKbSearchCriteria.addLike("UPPER(oleGokbTitle.medium)",titleInstanceType);
96 }
97
98 if(platformProviders.size()>0 && platformProviders.size()>0){
99 goKbSearchCriteria.addIn("oleGokbPlatform.oleGokbOrganization.organizationName", platformProviders);
100 }
101 QueryByCriteria query = QueryFactory.newQuery(OleGokbTipp.class, goKbSearchCriteria);
102 Collection results= getPersistenceBrokerTemplate().getCollectionByQuery(query);
103 return ( List<OleGokbTipp>)results;
104 }
105
106 }