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