001/* 002 * The Kuali Financial System, a comprehensive financial management system for higher education. 003 * 004 * Copyright 2005-2014 The Kuali Foundation 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU Affero General Public License as 008 * published by the Free Software Foundation, either version 3 of the 009 * License, or (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU Affero General Public License for more details. 015 * 016 * You should have received a copy of the GNU Affero General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package org.kuali.kfs.coa.businessobject.options; 020 021import java.util.ArrayList; 022import java.util.Collection; 023import java.util.List; 024 025import org.kuali.kfs.coa.businessobject.RestrictedStatus; 026import org.kuali.kfs.sys.context.SpringContext; 027import org.kuali.rice.core.api.util.ConcreteKeyValue; 028import org.kuali.rice.core.api.util.KeyValue; 029import org.kuali.rice.krad.keyvalues.KeyValuesBase; 030import org.kuali.rice.krad.service.KeyValuesService; 031 032/** 033 * This class creates a new finder for our forms view (creates a drop-down of {@link RestrictedStatus}s) 034 */ 035public class RestrictedStatusValuesFinder extends KeyValuesBase { 036 037 /** 038 * Creates a list of {@link OrgType}s using their code as their key, and their code "-" name as the display value 039 * 040 * @see org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues() 041 */ 042 public List getKeyValues() { 043 044 Collection<RestrictedStatus> codes = SpringContext.getBean(KeyValuesService.class).findAll(RestrictedStatus.class); 045 List<KeyValue> labels = new ArrayList<KeyValue>(); 046 labels.add(new ConcreteKeyValue("", "")); 047 for (RestrictedStatus restrictedStatus : codes) { 048 if(restrictedStatus.isActive()) { 049 labels.add(new ConcreteKeyValue(restrictedStatus.getAccountRestrictedStatusCode(), restrictedStatus.getCodeAndDescription())); 050 } 051 } 052 053 return labels; 054 } 055 056}