001 /** 002 * Copyright 2010 The Kuali Foundation Licensed under the 003 * Educational Community License, Version 2.0 (the "License"); you may 004 * not use this file except in compliance with the License. You may 005 * obtain a copy of the License at 006 * 007 * http://www.osedu.org/licenses/ECL-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, 010 * software distributed under the License is distributed on an "AS IS" 011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing 013 * permissions and limitations under the License. 014 */ 015 016 package org.kuali.rice.student.lookup.keyvalues; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 021 import org.kuali.rice.core.util.KeyLabelPair; 022 import org.kuali.student.common.search.dto.SearchRequest; 023 import org.kuali.student.common.search.dto.SearchResultCell; 024 import org.kuali.student.common.search.dto.SearchResultRow; 025 026 public class AllOrgsValuesFinder extends StudentKeyValuesBase { 027 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AllOrgsValuesFinder.class); 028 029 public List<KeyLabelPair> getKeyValues() { 030 List<KeyLabelPair> departments = new ArrayList<KeyLabelPair>(); 031 032 SearchRequest searchRequest = new SearchRequest(); 033 searchRequest.setSearchKey("org.search.generic"); 034 035 try { 036 for (SearchResultRow result : getOrganizationService().search(searchRequest).getRows()) { 037 String orgId = ""; 038 String orgShortName = ""; 039 String orgOptionalLongName = ""; 040 String orgType = ""; 041 for (SearchResultCell resultCell : result.getCells()) { 042 if ("org.resultColumn.orgId".equals(resultCell.getKey())) { 043 orgId = resultCell.getValue(); 044 } else if ("org.resultColumn.orgShortName".equals(resultCell.getKey())) { 045 orgShortName = resultCell.getValue(); 046 } else if ("org.resultColumn.orgOptionalLongName".equals(resultCell.getKey())) { 047 orgOptionalLongName = resultCell.getValue(); 048 } else if ("org.resultColumn.orgType".equals(resultCell.getKey())) { 049 orgType = resultCell.getValue(); 050 } 051 } 052 departments.add(buildKeyLabelPair(orgId, orgShortName, orgOptionalLongName, orgType)); 053 } 054 055 return departments; 056 } catch (Exception e) { 057 LOG.error("Error building KeyValues List", e); 058 throw new RuntimeException(e); 059 } 060 } 061 062 }