Coverage Report - org.kuali.rice.kns.bo.BusinessObjectRelationship
 
Classes in this File Line Coverage Branch Coverage Complexity
BusinessObjectRelationship
0%
0/28
0%
0/6
1.333
 
 1  
 /*
 2  
  * Copyright 2007 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.kns.bo;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.HashMap;
 20  
 import java.util.Map;
 21  
 
 22  
 /**
 23  
  * 
 24  
  * This class represents a parentClass/child relationship between two objects
 25  
  * This is used primarily by the <code>BusinessObjectMetaDataService
 26  
  */
 27  
 public class BusinessObjectRelationship implements Serializable {
 28  
     private Class relatedClass;
 29  
     private Class parentClass;
 30  
     private String parentAttributeName;
 31  0
     private Map<String,String> parentToChildReferences = new HashMap<String,String>( 4 );
 32  0
     private String userVisibleIdentifierKey = null;
 33  
     
 34  0
     public BusinessObjectRelationship() {
 35  0
     }
 36  
     
 37  
 
 38  
     public BusinessObjectRelationship(Class parent, String parentAttributeName, Class relatedClass ) {
 39  0
         super();
 40  0
         this.relatedClass = relatedClass;
 41  0
         this.parentClass = parent;
 42  0
         this.parentAttributeName = parentAttributeName;
 43  0
     }
 44  
 
 45  
 
 46  
     public Class getRelatedClass() {
 47  0
         return this.relatedClass;
 48  
     }
 49  
 
 50  
     /**
 51  
      * Gets the parentClass attribute. 
 52  
      * @return Returns the parentClass.
 53  
      */
 54  
     public Class getParentClass() {
 55  0
         return parentClass;
 56  
     }
 57  
 
 58  
 
 59  
     public String toString() {
 60  0
         StringBuffer sb = new StringBuffer();
 61  0
         sb.append( "Relationship: " ).append( parentClass.getName() ).append( " -> " ).append( relatedClass.getName() );
 62  0
         for ( Map.Entry<String,String> refs : parentToChildReferences.entrySet() ) {
 63  0
             sb.append( "\n   " ).append( refs.getKey() ).append( " -> " ).append( refs.getValue() );           
 64  
         }
 65  0
         return sb.toString();
 66  
     }
 67  
 
 68  
 
 69  
     public String getParentAttributeName() {
 70  0
         return parentAttributeName;
 71  
     }
 72  
 
 73  
 
 74  
     public Map<String, String> getParentToChildReferences() {
 75  0
         return parentToChildReferences;
 76  
     }
 77  
 
 78  
 
 79  
     public void setParentToChildReferences(Map<String, String> referenceAttribues) {
 80  0
         this.parentToChildReferences = referenceAttribues;
 81  0
     }
 82  
 
 83  
 
 84  
         public String getUserVisibleIdentifierKey() {
 85  0
                 return userVisibleIdentifierKey;
 86  
         }
 87  
 
 88  
 
 89  
         public void setUserVisibleIdentifierKey(String userVisibleIdentifierKey) {
 90  0
                 this.userVisibleIdentifierKey = userVisibleIdentifierKey;
 91  0
         }
 92  
 
 93  
         public String getParentAttributeForChildAttribute( String childAttributeName ) {
 94  0
                 for ( Map.Entry<String,String> entry : parentToChildReferences.entrySet() ) {
 95  0
                         if ( entry.getValue().equals( childAttributeName ) ) {
 96  0
                                 return entry.getKey();
 97  
                         }
 98  
                 }
 99  0
                 return null;
 100  
         }
 101  
 
 102  
         public String getChildAttributeForParentAttribute( String parentAttributeName ) {
 103  0
                 return parentToChildReferences.get( parentAttributeName );
 104  
         }
 105  
 }