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.module.tem.businessobject.options; 020 021import java.util.ArrayList; 022import java.util.Collection; 023import java.util.List; 024 025import org.kuali.kfs.module.tem.businessobject.JobClassification; 026import org.kuali.kfs.sys.KFSConstants; 027import org.kuali.kfs.sys.context.SpringContext; 028import org.kuali.rice.core.api.util.ConcreteKeyValue; 029import org.kuali.rice.core.api.util.KeyValue; 030import org.kuali.rice.krad.keyvalues.KeyValuesBase; 031import org.kuali.rice.krad.service.BusinessObjectService; 032import org.kuali.rice.krad.service.KeyValuesService; 033 034public class JobClassificationCodeValuesFinder extends KeyValuesBase { 035 protected static volatile KeyValuesService keyValuesService; 036 037 protected BusinessObjectService businessObjectService; 038 039 /** 040 * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues() 041 */ 042 @Override 043 public List<KeyValue> getKeyValues() { 044 045 Collection<JobClassification> codes = getKeyValuesService().findAll(JobClassification.class); 046 List<KeyValue> labels = new ArrayList<KeyValue>(); 047 labels.add(new ConcreteKeyValue(KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING)); 048 for (JobClassification reason : codes) { 049 if(reason.isActive()) { 050 labels.add(new ConcreteKeyValue(reason.getJobClsCode(), reason.getJobClsName())); 051 } 052 } 053 054 return labels; 055 } 056 057 protected KeyValuesService getKeyValuesService() { 058 if (keyValuesService == null) { 059 keyValuesService = SpringContext.getBean(KeyValuesService.class); 060 } 061 return keyValuesService; 062 } 063 064}