| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AllOrgsValuesFinder | 
 | 
 | 10.0;10 | 
| 1 |  /** | |
| 2 |   * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 |   * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 |   * not use this file except in compliance with the License. You may | |
| 5 |   * obtain a copy of the License at | |
| 6 |   * | |
| 7 |   * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 |   * | |
| 9 |   * Unless required by applicable law or agreed to in writing, | |
| 10 |   * software distributed under the License is distributed on an "AS IS" | |
| 11 |   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 |   * or implied. See the License for the specific language governing | |
| 13 |   * permissions and limitations under the License. | |
| 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.core.search.dto.SearchRequest; | |
| 23 |  import org.kuali.student.core.search.dto.SearchResultCell; | |
| 24 |  import org.kuali.student.core.search.dto.SearchResultRow; | |
| 25 | ||
| 26 | 0 |  public class AllOrgsValuesFinder extends StudentKeyValuesBase { | 
| 27 | 0 |          private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AllOrgsValuesFinder.class); | 
| 28 | ||
| 29 |          public List<KeyLabelPair> getKeyValues() { | |
| 30 | 0 |          List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>(); | 
| 31 | ||
| 32 | 0 |          SearchRequest searchRequest = new SearchRequest(); | 
| 33 | 0 |          searchRequest.setSearchKey("org.search.generic"); | 
| 34 | ||
| 35 |          try { | |
| 36 | 0 |              for (SearchResultRow result : getOrganizationService().search(searchRequest).getRows()) { | 
| 37 | 0 |                  String orgId = ""; | 
| 38 | 0 |                  String orgShortName = ""; | 
| 39 | 0 |                  String orgOptionalLongName = ""; | 
| 40 | 0 |                  String orgType = ""; | 
| 41 | 0 |                  for (SearchResultCell resultCell : result.getCells()) { | 
| 42 | 0 |                      if ("org.resultColumn.orgId".equals(resultCell.getKey())) { | 
| 43 | 0 |                          orgId = resultCell.getValue(); | 
| 44 | 0 |                      } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) { | 
| 45 | 0 |                          orgShortName = resultCell.getValue(); | 
| 46 | 0 |                      } else if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) { | 
| 47 | 0 |                              orgOptionalLongName = resultCell.getValue(); | 
| 48 | 0 |                      } else if ("org.resultColumn.orgType".equals(resultCell.getKey())) { | 
| 49 | 0 |                              orgType = resultCell.getValue(); | 
| 50 | } | |
| 51 | } | |
| 52 | 0 |                  departments.add(buildKeyLabelPair(orgId, orgShortName, orgOptionalLongName, orgType)); | 
| 53 | 0 |              } | 
| 54 | ||
| 55 | 0 |              return departments; | 
| 56 | 0 |          } catch (Exception e) { | 
| 57 | 0 |                  LOG.error("Error building KeyValues List", e); | 
| 58 | 0 |              throw new RuntimeException(e); | 
| 59 | } | |
| 60 | } | |
| 61 | ||
| 62 | } |