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.common.search.dto.SearchRequest;
23 import org.kuali.student.common.search.dto.SearchResultCell;
24 import org.kuali.student.common.search.dto.SearchResultRow;
25
26 public class AllOrgsValuesFinder extends StudentKeyValuesBase {
27 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AllOrgsValuesFinder.class);
28
29 public List<KeyLabelPair> getKeyValues() {
30 List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>();
31
32 SearchRequest searchRequest = new SearchRequest();
33 searchRequest.setSearchKey("org.search.generic");
34
35 try {
36 for (SearchResultRow result : getOrganizationService().search(searchRequest).getRows()) {
37 String orgId = "";
38 String orgShortName = "";
39 String orgOptionalLongName = "";
40 String orgType = "";
41 for (SearchResultCell resultCell : result.getCells()) {
42 if ("org.resultColumn.orgId".equals(resultCell.getKey())) {
43 orgId = resultCell.getValue();
44 } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) {
45 orgShortName = resultCell.getValue();
46 } else if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) {
47 orgOptionalLongName = resultCell.getValue();
48 } else if ("org.resultColumn.orgType".equals(resultCell.getKey())) {
49 orgType = resultCell.getValue();
50 }
51 }
52 departments.add(buildKeyLabelPair(orgId, orgShortName, orgOptionalLongName, orgType));
53 }
54
55 return departments;
56 } catch (Exception e) {
57 LOG.error("Error building KeyValues List", e);
58 throw new RuntimeException(e);
59 }
60 }
61
62 }