1 package org.kuali.student.lum.lu.ui.krms.util;
2
3 import org.kuali.student.lum.lu.ui.krms.dto.CluInformation;
4 import org.kuali.student.r2.common.dto.DtoConstants;
5 import org.kuali.student.r2.core.search.dto.SearchParamInfo;
6 import org.kuali.student.r2.core.search.dto.SearchResultCellInfo;
7 import org.kuali.student.r2.core.search.dto.SearchResultInfo;
8 import org.kuali.student.r2.core.search.dto.SearchResultRowInfo;
9 import org.kuali.student.r2.lum.util.constants.CluServiceConstants;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14
15
16
17
18
19
20
21 public class CluSearchUtil {
22
23 public static SearchParamInfo createSearchParam(String key, String value){
24 SearchParamInfo searchParam = new SearchParamInfo();
25 searchParam.setKey(key);
26 searchParam.getValues().add(value);
27 return searchParam;
28 }
29
30 public static SearchParamInfo createSearchParam(String key, List<String> values){
31 SearchParamInfo searchParam = new SearchParamInfo();
32 searchParam.setKey(key);
33 for(String value : values){
34 searchParam.getValues().add(value);
35 }
36 return searchParam;
37 }
38
39 public static SearchParamInfo getApprovedStateSearchParam() {
40 return createSearchParam("lu.queryParam.luOptionalState", getApprovedStatesForClus());
41 }
42
43 public static List<String> getApprovedStatesForClus() {
44 List<String> states = new ArrayList<String>();
45 states.add(DtoConstants.STATE_APPROVED);
46 states.add(DtoConstants.STATE_ACTIVE);
47 states.add(DtoConstants.STATE_RETIRED);
48 states.add(DtoConstants.STATE_SUSPENDED);
49 return states;
50 }
51
52 public static SearchParamInfo getTypeSearchParamForCourse() {
53 return createSearchParam("lu.queryParam.luOptionalType", getCluTypesForCourse());
54 }
55
56 public static List<String> getCluTypesForCourse(){
57 List<String> types = new ArrayList<String>();
58 types.add(CluServiceConstants.CREDIT_COURSE_LU_TYPE_KEY);
59 return types;
60 }
61
62 public static SearchParamInfo getTypeSearchParamForProgram() {
63 return createSearchParam("lu.queryParam.luOptionalType", getCluTypesForProgram());
64 }
65
66 public static List<String> getCluTypesForProgram(){
67 List<String> types = new ArrayList<String>();
68 types.add("kuali.lu.type.credential.Baccalaureate");
69 types.add("kuali.lu.type.credential.Masters");
70 types.add("kuali.lu.type.credential.Professional");
71 types.add("kuali.lu.type.credential.Doctoral");
72 types.add("kuali.lu.type.credential.UndergraduateCertificate");
73 types.add("kuali.lu.type.credential.GraduateCertificate");
74 types.add("kuali.lu.type.credential.ContinuingEd");
75 types.add("kuali.lu.type.MajorDiscipline");
76 types.add("kuali.lu.type.Variation");
77 types.add("kuali.lu.type.MinorDiscipline");
78 types.add("kuali.lu.type.CoreProgram");
79 types.add("kuali.lu.type.Honors");
80 types.add("kuali.lu.type.LivingLearning");
81 return types;
82 }
83
84 public static List<CluInformation> resolveCluSearchResultSet(SearchResultInfo searchResult) {
85 List<CluInformation> clus = new ArrayList<CluInformation>();
86 List<SearchResultRowInfo> rows = searchResult.getRows();
87 for (SearchResultRowInfo row : rows) {
88 List<SearchResultCellInfo> cells = row.getCells();
89 CluInformation cluInformation = new CluInformation();
90 for (SearchResultCellInfo cell : cells) {
91 if (cell.getKey().equals("lu.resultColumn.cluId")) {
92 cluInformation.setCluId(cell.getValue());
93 } else if (cell.getKey().equals("lu.resultColumn.luOptionalCode")) {
94 cluInformation.setCode(cell.getValue());
95 } else if (cell.getKey().equals("lu.resultColumn.luOptionalLongName")) {
96 cluInformation.setTitle(cell.getValue());
97 } else if (cell.getKey().equals("lu.resultColumn.luOptionalDescr")) {
98 cluInformation.setDescription(cell.getValue());
99 } else if (cell.getKey().equals("lu.resultColumn.luOptionalState")) {
100 cluInformation.setState(cell.getValue());
101 } else if (cell.getKey().equals("lu.resultColumn.luOptionalVersionIndId")) {
102 cluInformation.setVerIndependentId(cell.getValue());
103 } else if (cell.getKey().equals("lu.resultColumn.luOptionalShortName")) {
104 cluInformation.setShortName(cell.getValue());
105 }
106 }
107 clus.add(cluInformation);
108 }
109 return clus;
110 }
111 }