Coverage Report - org.kuali.rice.krad.keyvalues.KimAttributeValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
KimAttributeValuesFinder
0%
0/23
0%
0/8
2
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.krad.keyvalues;
 17  
 
 18  
 import org.apache.log4j.Logger;
 19  
 import org.kuali.rice.core.util.ConcreteKeyValue;
 20  
 import org.kuali.rice.core.util.KeyValue;
 21  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 22  
 import org.kuali.rice.kim.api.type.KimType;
 23  
 import org.kuali.rice.kim.api.type.KimTypeService;
 24  
 import org.kuali.rice.kim.service.KIMServiceLocatorWeb;
 25  
 
 26  
 import java.util.ArrayList;
 27  
 import java.util.Collections;
 28  
 import java.util.List;
 29  
 import java.util.Map;
 30  
 
 31  
 /**
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  0
 public class KimAttributeValuesFinder extends KeyValuesBase {
 35  
 
 36  0
         private static final Logger LOG = Logger.getLogger( KimAttributeValuesFinder.class );
 37  
 
 38  
         protected String kimTypeId;
 39  
         protected String kimAttributeName;
 40  
 
 41  
         /**
 42  
          * @see KeyValuesFinder#getKeyValues()
 43  
          */
 44  
         @Override
 45  
         public List<KeyValue> getKeyValues() {
 46  0
         KimType kimType = KimApiServiceLocator.getKimTypeInfoService().getKimType(kimTypeId);
 47  0
         if ( kimType != null ) {
 48  0
                 KimTypeService service = KIMServiceLocatorWeb.getKimTypeService(kimType);
 49  0
                 if ( service != null ) {
 50  0
                                 return toKeyValues(service.getAttributeValidValues(kimTypeId,kimAttributeName));
 51  
                 } 
 52  0
                 LOG.error( "Unable to get type service " + kimType.getServiceName() );
 53  0
         } else {
 54  0
                 LOG.error( "Unable to obtain KIM type for kimTypeId=" + kimTypeId );
 55  
         }
 56  0
         return Collections.emptyList();
 57  
         }
 58  
 
 59  
     private static List<KeyValue> toKeyValues(Map<String, String> m) {
 60  0
         if (m == null) {
 61  0
             return Collections.emptyList();
 62  
         }
 63  
 
 64  0
         final List<KeyValue> kv = new ArrayList<KeyValue>();
 65  0
         for (Map.Entry<String, String> e : m.entrySet()) {
 66  0
             kv.add(new ConcreteKeyValue(e));
 67  
         }
 68  
 
 69  0
         return Collections.unmodifiableList(kv);
 70  
     }
 71  
 
 72  
         /**
 73  
          * @return the kimAttributeName
 74  
          */
 75  
         public String getKimAttributeName() {
 76  0
                 return this.kimAttributeName;
 77  
         }
 78  
 
 79  
         /**
 80  
          * @param kimAttributeName the kimAttributeName to set
 81  
          */
 82  
         public void setKimAttributeName(String kimAttributeName) {
 83  0
                 this.kimAttributeName = kimAttributeName;
 84  0
         }
 85  
 
 86  
         /**
 87  
          * @return the kimTypeId
 88  
          */
 89  
         public String getKimTypeId() {
 90  0
                 return this.kimTypeId;
 91  
         }
 92  
 
 93  
         /**
 94  
          * @param kimTypeId the kimTypeId to set
 95  
          */
 96  
         public void setKimTypeId(String kimTypeId) {
 97  0
                 this.kimTypeId = kimTypeId;
 98  0
         }
 99  
 
 100  
 }