1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.student.lookup.keyvalues;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.rice.core.util.KeyLabelPair;
22 import org.kuali.student.common.search.dto.SearchParam;
23 import org.kuali.student.common.search.dto.SearchRequest;
24 import org.kuali.student.common.search.dto.SearchResult;
25 import org.kuali.student.common.search.dto.SearchResultCell;
26 import org.kuali.student.common.search.dto.SearchResultRow;
27
28 public class OrgCocValuesFinder extends StudentKeyValuesBase {
29 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AllOrgsValuesFinder.class);
30
31 public static List<KeyLabelPair> findCocOrgs() {
32 List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>();
33
34 List<String> types = new ArrayList<String>();
35 types.add("kuali.org.College");
36 types.add("kuali.org.Department");
37 types.add("kuali.org.Division");
38
39 List<SearchParam> queryParamValues = new ArrayList<SearchParam>(2);
40 SearchParam qpOrgType = new SearchParam();
41 qpOrgType.setKey("org.queryParam.relationType");
42 qpOrgType.setValue("kuali.org.CurriculumChild");
43 queryParamValues.add(qpOrgType);
44
45 qpOrgType = new SearchParam();
46 qpOrgType.setKey("org.queryParam.orgTypeList");
47 qpOrgType.setValue(types);
48 queryParamValues.add(qpOrgType);
49
50 qpOrgType = new SearchParam();
51 qpOrgType.setKey("org.queryParam.relatedOrgType");
52 qpOrgType.setValue("kuali.org.COC");
53 queryParamValues.add(qpOrgType);
54
55 SearchRequest searchRequest = new SearchRequest();
56 searchRequest.setSearchKey("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgTypeAltr");
57 searchRequest.setParams(queryParamValues);
58
59 try {
60 SearchResult results = getOrganizationService().search(searchRequest);
61
62 for (SearchResultRow result : results.getRows()) {
63 String orgId = "";
64 String orgShortName = "";
65 for (SearchResultCell resultCell : result.getCells()) {
66 if ("org.resultColumn.orgId".equals(resultCell
67 .getKey())) {
68 orgId = resultCell.getValue();
69 } else if ("org.resultColumn.orgShortName"
70 .equals(resultCell.getKey())) {
71 orgShortName = resultCell.getValue();
72 }
73 }
74 departments.add(buildKeyLabelPair(orgId, orgShortName, null, null));
75 }
76
77 return departments;
78 } catch (Exception e) {
79 LOG.error("Error building KeyValues List", e);
80 throw new RuntimeException(e);
81 }
82 }
83
84 @Override
85 public List getKeyValues() {
86
87 return findCocOrgs();
88 }
89
90 }