Coverage Report - org.kuali.rice.krad.datadictionary.KimDataDictionaryAttributeDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
KimDataDictionaryAttributeDefinition
0%
0/22
0%
0/4
1.5
 
 1  
 /*
 2  
  * Copyright 2007-2008 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;
 17  
 
 18  
 import org.apache.commons.lang.ClassUtils;
 19  
 import org.apache.commons.lang.builder.ToStringBuilder;
 20  
 import org.kuali.rice.core.api.util.ClassLoaderUtils;
 21  
 import org.kuali.rice.krad.bo.BusinessObject;
 22  
 import org.kuali.rice.krad.datadictionary.exception.ClassValidationException;
 23  
 
 24  
 import java.util.Map;
 25  
 
 26  
 /**
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public class KimDataDictionaryAttributeDefinition extends KimAttributeDefinition {
 30  
         private static final long serialVersionUID = 7006569761728813805L;
 31  
         
 32  
         protected Map<String, String> lookupInputPropertyConversions;
 33  
         protected Map<String, String> lookupReturnPropertyConversions;
 34  
         protected String lookupBoClass;
 35  
 
 36  
         /**
 37  
          * 
 38  
          */
 39  0
         public KimDataDictionaryAttributeDefinition() {
 40  0
         }
 41  
 
 42  
         /**
 43  
          * @return the lookupInputPropertyConversions
 44  
          */
 45  
         public Map<String, String> getLookupInputPropertyConversions() {
 46  0
                 return this.lookupInputPropertyConversions;
 47  
         }
 48  
 
 49  
         /**
 50  
          * @param lookupInputPropertyConversions
 51  
          *            the lookupInputPropertyConversions to set
 52  
          */
 53  
         public void setLookupInputPropertyConversions(Map<String, String> lookupInputPropertyConversions) {
 54  0
                 this.lookupInputPropertyConversions = lookupInputPropertyConversions;
 55  0
         }
 56  
 
 57  
         /**
 58  
          * @return the lookupReturnPropertyConversions
 59  
          */
 60  
         public Map<String, String> getLookupReturnPropertyConversions() {
 61  0
                 return this.lookupReturnPropertyConversions;
 62  
         }
 63  
 
 64  
         /**
 65  
          * @param lookupReturnPropertyConversions
 66  
          *            the lookupReturnPropertyConversions to set
 67  
          */
 68  
         public void setLookupReturnPropertyConversions(Map<String, String> lookupReturnPropertyConversions) {
 69  0
                 this.lookupReturnPropertyConversions = lookupReturnPropertyConversions;
 70  0
         }
 71  
 
 72  
         /**
 73  
          * @see java.lang.Object#toString()
 74  
          */
 75  
         public String toString() {
 76  0
                 return new ToStringBuilder( this )
 77  
                         .append( "name", getName() )
 78  
                         .append( "label", getLabel() )
 79  
                         .append( "lookupBoClass", this.lookupBoClass )
 80  
                         .append( "required", isRequired() )
 81  
                         .append( "lookupInputPropertyConversions", this.lookupInputPropertyConversions )
 82  
                         .append( "lookupReturnPropertyConversions", this.lookupReturnPropertyConversions )
 83  
                         .toString();
 84  
         }
 85  
 
 86  
         public String getLookupBoClass() {
 87  0
                 return this.lookupBoClass;
 88  
         }
 89  
 
 90  
         public void setLookupBoClass(String lookupBoClass) {
 91  0
                 this.lookupBoClass = lookupBoClass;
 92  0
         }
 93  
 
 94  
     @Override
 95  
     public boolean isHasLookupBoDefinition() {
 96  0
         return true;
 97  
     }
 98  
 
 99  
 
 100  
         @SuppressWarnings("unchecked")
 101  
         @Override
 102  
         public void completeValidation(Class rootObjectClass, Class otherObjectClass) {
 103  0
                 if (lookupBoClass != null) {
 104  
                 try {
 105  0
                         Class lookupBoClassObject = ClassUtils.getClass(ClassLoaderUtils.getDefaultClassLoader(), getLookupBoClass());
 106  0
                         if (!BusinessObject.class.isAssignableFrom(lookupBoClassObject)) {
 107  0
                                 throw new ClassValidationException("lookupBoClass is not a valid instance of " + BusinessObject.class.getName() + " instead was: " + lookupBoClassObject.getName());
 108  
                         }
 109  0
                 } catch (ClassNotFoundException e) {
 110  0
                         throw new ClassValidationException("lookupBoClass could not be found: " + getLookupBoClass(), e);
 111  0
                 }
 112  
         }
 113  0
                 super.completeValidation(rootObjectClass, otherObjectClass);
 114  0
         }
 115  
     
 116  
     
 117  
 
 118  
         
 119  
 }