001/** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.deliver.keyvalue; 017 018import org.kuali.rice.core.api.util.ConcreteKeyValue; 019import org.kuali.rice.core.api.util.KeyValue; 020import org.kuali.rice.krad.keyvalues.KeyValuesBase; 021import org.kuali.rice.krad.service.KRADServiceLocator; 022import org.kuali.rice.location.impl.campus.CampusBo; 023 024import java.util.ArrayList; 025import java.util.Collection; 026import java.util.List; 027 028/** 029 * OleAddressTypeKeyValues returns code and name for EntityAddressTypeBo. 030 */ 031public class OleCampusCodeKeyValues extends KeyValuesBase { 032 033 034 /** 035 * This method will populate the code as a key and name as a value and return it as list 036 * 037 * @return keyValues(list) 038 */ 039 @Override 040 public List getKeyValues() { 041 List<KeyValue> keyValues = new ArrayList<KeyValue>(); 042 Collection<CampusBo> campusCodes = KRADServiceLocator.getBusinessObjectService().findAll(CampusBo.class); 043 keyValues.add(new ConcreteKeyValue("", "")); 044 for (CampusBo campusCode : campusCodes) { 045 if (campusCode.isActive()) { 046 keyValues.add(new ConcreteKeyValue(campusCode.getCode(), campusCode.getName())); 047 } 048 } 049 return keyValues; 050 } 051} 052