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 | 0 | public class OrgCocValuesFinder extends StudentKeyValuesBase { |
29 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AllOrgsValuesFinder.class); |
30 | |
|
31 | |
public static List<KeyLabelPair> findCocOrgs() { |
32 | 0 | List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>(); |
33 | |
|
34 | 0 | List<String> types = new ArrayList<String>(); |
35 | 0 | types.add("kuali.org.College"); |
36 | 0 | types.add("kuali.org.Department"); |
37 | 0 | types.add("kuali.org.Division"); |
38 | |
|
39 | 0 | List<SearchParam> queryParamValues = new ArrayList<SearchParam>(2); |
40 | 0 | SearchParam qpOrgType = new SearchParam(); |
41 | 0 | qpOrgType.setKey("org.queryParam.relationType"); |
42 | 0 | qpOrgType.setValue("kuali.org.CurriculumChild"); |
43 | 0 | queryParamValues.add(qpOrgType); |
44 | |
|
45 | 0 | qpOrgType = new SearchParam(); |
46 | 0 | qpOrgType.setKey("org.queryParam.orgTypeList"); |
47 | 0 | qpOrgType.setValue(types); |
48 | 0 | queryParamValues.add(qpOrgType); |
49 | |
|
50 | 0 | qpOrgType = new SearchParam(); |
51 | 0 | qpOrgType.setKey("org.queryParam.relatedOrgType"); |
52 | 0 | qpOrgType.setValue("kuali.org.COC"); |
53 | 0 | queryParamValues.add(qpOrgType); |
54 | |
|
55 | 0 | SearchRequest searchRequest = new SearchRequest(); |
56 | 0 | searchRequest.setSearchKey("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgTypeAltr"); |
57 | 0 | searchRequest.setParams(queryParamValues); |
58 | |
|
59 | |
try { |
60 | 0 | SearchResult results = getOrganizationService().search(searchRequest); |
61 | |
|
62 | 0 | for (SearchResultRow result : results.getRows()) { |
63 | 0 | String orgId = ""; |
64 | 0 | String orgShortName = ""; |
65 | 0 | for (SearchResultCell resultCell : result.getCells()) { |
66 | 0 | if ("org.resultColumn.orgId".equals(resultCell |
67 | |
.getKey())) { |
68 | 0 | orgId = resultCell.getValue(); |
69 | 0 | } else if ("org.resultColumn.orgShortName" |
70 | |
.equals(resultCell.getKey())) { |
71 | 0 | orgShortName = resultCell.getValue(); |
72 | |
} |
73 | |
} |
74 | 0 | departments.add(buildKeyLabelPair(orgId, orgShortName, null, null)); |
75 | 0 | } |
76 | |
|
77 | 0 | return departments; |
78 | 0 | } catch (Exception e) { |
79 | 0 | LOG.error("Error building KeyValues List", e); |
80 | 0 | throw new RuntimeException(e); |
81 | |
} |
82 | |
} |
83 | |
|
84 | |
@Override |
85 | |
public List getKeyValues() { |
86 | |
|
87 | 0 | return findCocOrgs(); |
88 | |
} |
89 | |
|
90 | |
} |