1 | |
package org.kuali.rice.student.lookup.keyvalues; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.apache.commons.lang.StringUtils; |
7 | |
import org.kuali.rice.core.util.KeyLabelPair; |
8 | |
import org.kuali.student.common.search.dto.SearchRequest; |
9 | |
import org.kuali.student.common.search.dto.SearchResult; |
10 | |
import org.kuali.student.common.search.dto.SearchResultCell; |
11 | |
import org.kuali.student.common.search.dto.SearchResultRow; |
12 | |
import org.kuali.student.common.search.dto.SortDirection; |
13 | |
|
14 | 0 | public abstract class OrgsOfTypeValuesFinder extends StudentKeyValuesBase { |
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
public static List<KeyLabelPair> findOrgs(String orgType) { |
23 | 0 | List<KeyLabelPair> orgEntities = new ArrayList<KeyLabelPair>(); |
24 | |
|
25 | 0 | SearchRequest searchRequest = new SearchRequest("org.search.generic"); |
26 | 0 | searchRequest.addParam("org.queryParam.orgOptionalType",orgType); |
27 | 0 | searchRequest.setSortColumn("org.resultColumn.orgOptionalLongName"); |
28 | 0 | searchRequest.setSortDirection(SortDirection.ASC); |
29 | |
try { |
30 | 0 | SearchResult results = getOrganizationService().search(searchRequest); |
31 | |
|
32 | 0 | for (SearchResultRow result : results.getRows()) { |
33 | 0 | String orgId = ""; |
34 | 0 | String orgLongName = ""; |
35 | 0 | for (SearchResultCell resultCell : result.getCells()) { |
36 | 0 | if ("org.resultColumn.orgId".equals(resultCell.getKey())) { |
37 | 0 | orgId = resultCell.getValue(); |
38 | 0 | } else if("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())){ |
39 | 0 | orgLongName = resultCell.getValue(); |
40 | |
} |
41 | |
} |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | 0 | orgEntities.add(new KeyLabelPair(orgId, orgLongName)); |
48 | 0 | } |
49 | |
|
50 | 0 | return orgEntities; |
51 | 0 | } catch (Exception e) { |
52 | 0 | throw new RuntimeException(e); |
53 | |
} |
54 | |
} |
55 | |
} |