Coverage Report - org.kuali.rice.krad.datadictionary.impl.BeanOverrideImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BeanOverrideImpl
0%
0/21
0%
0/2
2.4
 
 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.krad.datadictionary.impl;
 17  
 
 18  
 import java.lang.reflect.InvocationTargetException;
 19  
 import java.util.List;
 20  
 
 21  
 import org.apache.commons.beanutils.BeanUtils;
 22  
 import org.apache.commons.beanutils.PropertyUtils;
 23  
 import org.apache.log4j.Logger;
 24  
 import org.kuali.rice.krad.datadictionary.BeanOverride;
 25  
 import org.kuali.rice.krad.datadictionary.FieldOverride;
 26  
 
 27  
 /**
 28  
  * The base implementation of the BeanOverride interface. 
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  *
 32  
  */
 33  0
 public class BeanOverrideImpl implements BeanOverride {
 34  0
         private static final Logger LOG = Logger.getLogger(BeanOverrideImpl.class);
 35  
         private String beanName;
 36  
     private List<FieldOverride> fieldOverrides;
 37  
 
 38  
     /**
 39  
      * 
 40  
      * @see org.kuali.rice.krad.datadictionary.BeanOverride#getFieldOverrides()
 41  
      */
 42  
     public List<FieldOverride> getFieldOverrides() {
 43  0
         return this.fieldOverrides;
 44  
     }
 45  
 
 46  
     public void setFieldOverrides(List<FieldOverride> fieldOverirdes) {
 47  0
         this.fieldOverrides = fieldOverirdes;
 48  0
     }
 49  
 
 50  
     /**
 51  
      * 
 52  
      * @see org.kuali.rice.krad.datadictionary.BeanOverride#getBeanName()
 53  
      */
 54  
     public String getBeanName() {
 55  0
         return this.beanName;
 56  
     }
 57  
 
 58  
     public void setBeanName(String beanName) {
 59  0
         this.beanName = beanName;
 60  0
     }
 61  
 
 62  
     /**
 63  
      * 
 64  
      * @see org.kuali.rice.krad.datadictionary.BeanOverride#performOverride(java.lang.Object)
 65  
      */
 66  
     public void performOverride(Object bean) 
 67  
     {
 68  
         try 
 69  
         {
 70  0
             for (FieldOverride fieldOverride: fieldOverrides)
 71  
             {
 72  0
                 Object property = PropertyUtils.getProperty(bean, fieldOverride.getPropertyName());                
 73  0
                 Object newProperty = fieldOverride.performFieldOverride(bean, property);                
 74  0
                 BeanUtils.setProperty(bean, fieldOverride.getPropertyName(), newProperty);
 75  0
             }
 76  
         }
 77  0
         catch(IllegalAccessException e )
 78  
         {
 79  0
             throw new RuntimeException(e);
 80  
         }
 81  0
         catch(InvocationTargetException e)
 82  
         {
 83  0
             throw new RuntimeException(e);
 84  
             
 85  
         }
 86  0
         catch (NoSuchMethodException e)
 87  
         {
 88  0
             throw new RuntimeException(e);
 89  0
         }
 90  0
     }
 91  
 }