Coverage Report - org.kuali.rice.krms.impl.ui.ValidTermsValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidTermsValuesFinder
0%
0/12
0%
0/4
3
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.krms.impl.ui;
 17  
 
 18  
 
 19  
 import org.kuali.rice.core.api.util.ConcreteKeyValue;
 20  
 import org.kuali.rice.core.api.util.KeyValue;
 21  
 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
 22  
 import org.kuali.rice.krad.service.KRADServiceLocator;
 23  
 import org.kuali.rice.krms.impl.repository.ContextValidTermBo;
 24  
 import org.kuali.rice.krms.impl.repository.TermBo;
 25  
 
 26  
 import java.util.ArrayList;
 27  
 import java.util.Collection;
 28  
 import java.util.Collections;
 29  
 import java.util.HashMap;
 30  
 import java.util.Map;
 31  
 import java.util.List;
 32  
 
 33  
 /**
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  *
 37  
  */
 38  0
 public class ValidTermsValuesFinder extends KeyValuesBase {
 39  
 
 40  
     @Override
 41  
         public List<KeyValue> getKeyValues() {
 42  0
         List<KeyValue> keyValues = new ArrayList<KeyValue>();
 43  
         //TODO: get the list of valid terms for this context. (currently gets all)
 44  0
         Collection<ContextValidTermBo> contextValidTerms = KRADServiceLocator.getBusinessObjectService().findAll(ContextValidTermBo.class);
 45  0
         List<String> termSpecIds = new ArrayList();
 46  0
         for (ContextValidTermBo validTerm : contextValidTerms) {
 47  0
             termSpecIds.add(validTerm.getTermSpecificationId());
 48  
         }
 49  0
         Map<String,Object> criteria = new HashMap<String,Object>();
 50  0
         criteria.put("term_spec_id", termSpecIds);
 51  0
         Collection<TermBo> terms = KRADServiceLocator.getBusinessObjectService().findMatching(TermBo.class, criteria);
 52  
 
 53  0
         for (TermBo term : terms) {
 54  0
             keyValues.add(new ConcreteKeyValue(term.getId(), term.getDescription()));
 55  
         }
 56  0
         return keyValues;
 57  
     }
 58  
 }