Coverage Report - org.kuali.rice.krad.datadictionary.exporter.RelationshipsMapBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
RelationshipsMapBuilder
0%
0/17
0%
0/4
1.667
 
 1  
 /*
 2  
  * Copyright 2006-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.krad.datadictionary.exporter;
 17  
 
 18  
 import org.kuali.rice.krad.datadictionary.DataDictionaryEntryBase;
 19  
 import org.kuali.rice.krad.datadictionary.PrimitiveAttributeDefinition;
 20  
 import org.kuali.rice.krad.datadictionary.RelationshipDefinition;
 21  
 
 22  
 /**
 23  
  * RelationshipsMapBuilder
 24  
  * 
 25  
  * 
 26  
  */
 27  
 public class RelationshipsMapBuilder {
 28  
 
 29  
     /**
 30  
      * Default constructor
 31  
      */
 32  0
     public RelationshipsMapBuilder() {
 33  0
     }
 34  
 
 35  
 
 36  
     /**
 37  
      * @param entry
 38  
      * @return ExportMap containing the standard entries for the entry's RelationshipDefinitions
 39  
      */
 40  
     public ExportMap buildRelationshipsMap(DataDictionaryEntryBase entry) {
 41  0
         ExportMap relationshipsMap = new ExportMap("relationships");
 42  
 
 43  0
         for ( RelationshipDefinition relationship : entry.getRelationships() ) {
 44  0
             relationshipsMap.set(buildRelationshipMap(relationship));
 45  
         }
 46  
 
 47  0
         return relationshipsMap;
 48  
     }
 49  
 
 50  
     private ExportMap buildRelationshipMap(RelationshipDefinition relationship) {
 51  0
         ExportMap relationshipMap = new ExportMap(relationship.getObjectAttributeName());
 52  
 
 53  0
         ExportMap attributesMap = new ExportMap("primitiveAttributes");
 54  
 
 55  0
         int count = 0;
 56  0
         for (PrimitiveAttributeDefinition primitiveAttributeDefinition : relationship.getPrimitiveAttributes()) {
 57  0
             ExportMap attributeMap = new ExportMap(Integer.toString(count++));
 58  0
             attributeMap.set("sourceName", primitiveAttributeDefinition.getSourceName());
 59  0
             attributeMap.set("targetName", primitiveAttributeDefinition.getTargetName());
 60  
 
 61  0
             attributesMap.set(attributeMap);
 62  0
         }
 63  
 
 64  0
         relationshipMap.set(attributesMap);
 65  
 
 66  0
         return relationshipMap;
 67  
     }
 68  
 
 69  
 }