001/** 002 * Copyright 2005-2017 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.rice.krms.impl.repository; 017 018import org.kuali.rice.core.api.util.ConcreteKeyValue; 019import org.kuali.rice.core.api.util.KeyValue; 020import org.kuali.rice.kns.service.KNSServiceLocator; 021import org.kuali.rice.krad.service.KeyValuesService; 022import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase; 023import org.kuali.rice.krad.uif.view.ViewModel; 024 025import java.util.ArrayList; 026import java.util.Collection; 027import java.util.HashMap; 028import java.util.List; 029import java.util.Map; 030 031/** 032 * Helper class that returns all valid types for contexts. 033 */ 034public class ContextTypeValuesFinder extends UifKeyValuesFinderBase { 035 036 @Override 037 public List<KeyValue> getKeyValues(ViewModel model) { 038 List<KeyValue> keyValues = new ArrayList<KeyValue>(); 039 040 // ToDo: Currently we hardcoded any types named "CONTEXT" to be valid with contexts. 041 KeyValuesService boService = KNSServiceLocator.getKeyValuesService(); 042 Map<String,Object> fieldValues = new HashMap<String, Object>(); 043 fieldValues.put("name", "CONTEXT"); 044 Collection<KrmsTypeBo> types = boService.findMatching(KrmsTypeBo.class, fieldValues); 045 046 for (KrmsTypeBo type : types) { 047 keyValues.add(new ConcreteKeyValue(type.getId(), type.getName() + " [" + type.getNamespace() + "]")); 048 } 049 050 return keyValues; 051 } 052}