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