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.core.search.dto.SearchParam; |
23 | |
import org.kuali.student.core.search.dto.SearchRequest; |
24 | |
import org.kuali.student.core.search.dto.SearchResult; |
25 | |
import org.kuali.student.core.search.dto.SearchResultCell; |
26 | |
import org.kuali.student.core.search.dto.SearchResultRow; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | 0 | public abstract class CocValuesFiinder extends StudentKeyValuesBase { |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public static List<KeyLabelPair> findCocOrgs(String orgType) { |
41 | 0 | List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>(); |
42 | |
|
43 | 0 | List<SearchParam> queryParamValues = new ArrayList<SearchParam>(2); |
44 | 0 | SearchParam qpOrgType = new SearchParam(); |
45 | 0 | qpOrgType.setKey("org.queryParam.relationType"); |
46 | 0 | qpOrgType.setValue("kuali.org.CurriculumChild"); |
47 | 0 | queryParamValues.add(qpOrgType); |
48 | |
|
49 | 0 | qpOrgType = new SearchParam(); |
50 | 0 | qpOrgType.setKey("org.queryParam.orgType"); |
51 | 0 | qpOrgType.setValue(orgType); |
52 | 0 | queryParamValues.add(qpOrgType); |
53 | |
|
54 | 0 | qpOrgType = new SearchParam(); |
55 | 0 | qpOrgType.setKey("org.queryParam.relatedOrgType"); |
56 | 0 | qpOrgType.setValue("kuali.org.COC"); |
57 | 0 | queryParamValues.add(qpOrgType); |
58 | |
|
59 | 0 | SearchRequest searchRequest = new SearchRequest(); |
60 | 0 | searchRequest.setParams(queryParamValues); |
61 | 0 | searchRequest.setSearchKey("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgType"); |
62 | |
|
63 | |
try { |
64 | 0 | SearchResult results = getOrganizationService().search(searchRequest); |
65 | |
|
66 | 0 | for (SearchResultRow result : results.getRows()) { |
67 | 0 | String orgId = ""; |
68 | 0 | String orgShortName = ""; |
69 | 0 | for (SearchResultCell resultCell : result.getCells()) { |
70 | 0 | if ("org.resultColumn.orgId".equals(resultCell |
71 | |
.getKey())) { |
72 | 0 | orgId = resultCell.getValue(); |
73 | 0 | } else if ("org.resultColumn.orgShortName" |
74 | |
.equals(resultCell.getKey())) { |
75 | 0 | orgShortName = resultCell.getValue(); |
76 | |
} |
77 | |
} |
78 | 0 | departments.add(buildKeyLabelPair(orgId, orgShortName, null, null)); |
79 | 0 | } |
80 | |
|
81 | 0 | return departments; |
82 | 0 | } catch (Exception e) { |
83 | 0 | throw new RuntimeException(e); |
84 | |
} |
85 | |
} |
86 | |
} |