001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.datadictionary.exporter; 017 018import org.kuali.rice.krad.datadictionary.DataDictionaryEntryBase; 019import org.kuali.rice.krad.datadictionary.PrimitiveAttributeDefinition; 020import org.kuali.rice.krad.datadictionary.RelationshipDefinition; 021import org.kuali.rice.krad.datadictionary.exporter.ExportMap; 022 023/** 024 * RelationshipsMapBuilder 025 * 026 * 027 */ 028@Deprecated 029public class RelationshipsMapBuilder { 030 031 /** 032 * Default constructor 033 */ 034 public RelationshipsMapBuilder() { 035 } 036 037 038 /** 039 * @param entry 040 * @return ExportMap containing the standard entries for the entry's RelationshipDefinitions 041 */ 042 public ExportMap buildRelationshipsMap(DataDictionaryEntryBase entry) { 043 ExportMap relationshipsMap = new ExportMap("relationships"); 044 045 for ( RelationshipDefinition relationship : entry.getRelationships() ) { 046 relationshipsMap.set(buildRelationshipMap(relationship)); 047 } 048 049 return relationshipsMap; 050 } 051 052 private ExportMap buildRelationshipMap(RelationshipDefinition relationship) { 053 ExportMap relationshipMap = new ExportMap(relationship.getObjectAttributeName()); 054 055 ExportMap attributesMap = new ExportMap("primitiveAttributes"); 056 057 int count = 0; 058 for (PrimitiveAttributeDefinition primitiveAttributeDefinition : relationship.getPrimitiveAttributes()) { 059 ExportMap attributeMap = new ExportMap(Integer.toString(count++)); 060 attributeMap.set("sourceName", primitiveAttributeDefinition.getSourceName()); 061 attributeMap.set("targetName", primitiveAttributeDefinition.getTargetName()); 062 063 attributesMap.set(attributeMap); 064 } 065 066 relationshipMap.set(attributesMap); 067 068 return relationshipMap; 069 } 070 071}