View Javadoc

1   package org.kuali.rice.student.lookup.keyvalues;
2   
3   import org.kuali.rice.core.api.util.ConcreteKeyValue;
4   import org.kuali.rice.core.api.util.KeyValue;
5   import org.kuali.student.r2.common.util.ContextUtils;
6   import org.kuali.student.r2.core.search.dto.SearchRequestInfo;
7   import org.kuali.student.r2.core.search.dto.SearchResultCellInfo;
8   import org.kuali.student.r2.core.search.dto.SearchResultInfo;
9   import org.kuali.student.r2.core.search.dto.SearchResultRowInfo;
10  import org.kuali.student.r2.core.search.dto.SortDirection;
11  
12  import java.util.ArrayList;
13  import java.util.List;
14  
15  /**
16   * Created with IntelliJ IDEA.
17   * User: Daniel
18   * Date: 2/25/13
19   * Time: 11:27 AM
20   * To change this template use File | Settings | File Templates.
21   */
22  public class SubjectAreaValuesFinder extends OrgsOfTypeValuesFinder{
23  
24      /**
25       * Find the Orgs with specified orgType.
26       *
27       * @param orgType
28       * @return
29       */
30      public static List<KeyValue> findOrgs(String orgType) {
31          List<KeyValue> orgEntities = new ArrayList<KeyValue>();
32          SearchRequestInfo searchRequest = new SearchRequestInfo("org.search.generic");
33          searchRequest.addParam("org.queryParam.orgOptionalType",orgType);
34          searchRequest.setSortColumn("org.resultColumn.orgOptionalLongName");
35          searchRequest.setSortDirection(SortDirection.ASC);
36          try {
37              SearchResultInfo results = getOrganizationService().search(searchRequest, ContextUtils.getContextInfo());
38  
39              for (SearchResultRowInfo result : results.getRows()) {
40                  String orgShortName = "";
41                  for (SearchResultCellInfo resultCell : result.getCells()) {
42                      if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) {
43                          orgShortName = resultCell.getValue();
44                      }
45                  }
46                  orgEntities.add(new ConcreteKeyValue(orgShortName, orgShortName));
47              }
48              return orgEntities;
49          } catch (Exception e) {
50              throw new RuntimeException(e);
51          }
52      }
53  
54      @Override
55      public List<KeyValue> getKeyValues() {
56          return findOrgs("kuali.org.SubjectCode");
57      }
58  }
59