001    /*
002     * Copyright 2007 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     */
016    package org.kuali.rice.krad.keyvalues;
017    
018    import org.kuali.rice.core.api.util.ConcreteKeyValue;
019    import org.kuali.rice.core.api.util.KeyValue;
020    import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
021    import org.kuali.rice.krad.service.ModuleService;
022    
023    import java.util.ArrayList;
024    import java.util.List;
025    
026    public class ModuleValuesFinder extends KeyValuesBase {
027    
028        /*
029         * @see org.kuali.keyvalues.KeyValuesFinder#getKeyValues()
030         */
031        @Override
032            public List<KeyValue> getKeyValues() {
033            List<KeyValue> keyValues = new ArrayList<KeyValue>();
034            keyValues.add(new ConcreteKeyValue("", ""));
035            //keyValues.add(getKeyValue(RiceConstants.CROSS_MODULE_CODE, RiceConstants.CROSS_MODULE_NAME));
036            for (ModuleService moduleService : KRADServiceLocatorWeb.getKualiModuleService().getInstalledModuleServices()) {
037                keyValues.add(getKeyValue(moduleService.getModuleConfiguration().getNamespaceCode(), 
038                            KRADServiceLocatorWeb.getKualiModuleService().getNamespaceName(moduleService.getModuleConfiguration().getNamespaceCode())));
039            }
040            return keyValues;
041        }
042        
043        private KeyValue getKeyValue(String moduleCode, String moduleName) {
044            return new ConcreteKeyValue(moduleCode, moduleCode + " - " + moduleName);
045        }
046    }