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.api.util.ConcreteKeyValue;
23 import org.kuali.rice.core.api.util.KeyValue;
24 import org.kuali.student.r2.core.search.dto.SearchRequestInfo;
25 import org.kuali.student.r2.core.search.dto.SearchResultCellInfo;
26 import org.kuali.student.r2.core.search.dto.SearchResultInfo;
27 import org.kuali.student.r2.core.search.dto.SearchResultRowInfo;
28 import org.kuali.student.common.util.security.ContextUtils;
29
30 public abstract class CocValuesFinder extends StudentKeyValuesBase {
31
32
33
34
35
36
37
38
39
40 public static List<KeyValue> findCocOrgs(String orgType) {
41 List<KeyValue> orgEntities = new ArrayList<KeyValue>();
42
43 SearchRequestInfo searchRequest = new SearchRequestInfo("org.search.orgQuickViewByRelationTypeOrgTypeRelatedOrgType");
44 searchRequest.addParam("org.queryParam.relationType","kuali.org.CurriculumParent");
45 searchRequest.addParam("org.queryParam.orgType",orgType);
46 searchRequest.addParam("org.queryParam.relatedOrgType","kuali.org.COC");
47
48 try {
49 SearchResultInfo results = null;
50 results = getOrganizationService().search(searchRequest, ContextUtils.getContextInfo());
51 for (SearchResultRowInfo result : results.getRows()) {
52 String orgId = "";
53 String orgShortName = "";
54 String orgLongName = "";
55 for (SearchResultCellInfo resultCell : result.getCells()) {
56 if ("org.resultColumn.orgId".equals(resultCell.getKey())) {
57 orgId = resultCell.getValue();
58 } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) {
59 orgShortName = resultCell.getValue();
60 } else if("org.resultColumn.orgLongName".equals(resultCell.getKey())){
61 orgLongName = resultCell.getValue();
62 }
63 }
64 if (StringUtils.isBlank(orgLongName)) {
65
66 orgEntities.add(buildKeyLabelPair(orgId, orgShortName, null, null));
67 }
68 else {
69
70
71
72
73
74 orgEntities.add(new ConcreteKeyValue(orgId, orgLongName));
75 }
76 }
77
78 return orgEntities;
79 } catch (Exception e) {
80 throw new RuntimeException(e);
81 }
82 }
83 }