1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.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 import org.kuali.rice.krad.datadictionary.exporter.ExportMap;
22 import org.kuali.rice.krad.util.LegacyUtils;
23
24
25
26
27
28
29 @Deprecated
30 public class RelationshipsMapBuilder {
31
32
33
34
35 public RelationshipsMapBuilder() {
36 }
37
38
39
40
41
42
43 public ExportMap buildRelationshipsMap(DataDictionaryEntryBase entry) {
44 ExportMap relationshipsMap = new ExportMap("relationships");
45
46 for ( RelationshipDefinition relationship : entry.getRelationships() ) {
47
48
49 if(!(relationship.hasEmbeddedDataObjectMetadata() && LegacyUtils.isInLegacyContext())){
50 relationshipsMap.set(buildRelationshipMap(relationship));
51 }
52 }
53
54 return relationshipsMap;
55 }
56
57 private ExportMap buildRelationshipMap(RelationshipDefinition relationship) {
58 ExportMap relationshipMap = new ExportMap(relationship.getObjectAttributeName());
59
60 ExportMap attributesMap = new ExportMap("primitiveAttributes");
61
62 int count = 0;
63 for (PrimitiveAttributeDefinition primitiveAttributeDefinition : relationship.getPrimitiveAttributes()) {
64 ExportMap attributeMap = new ExportMap(Integer.toString(count++));
65 attributeMap.set("sourceName", primitiveAttributeDefinition.getSourceName());
66 attributeMap.set("targetName", primitiveAttributeDefinition.getTargetName());
67
68 attributesMap.set(attributeMap);
69 }
70
71 relationshipMap.set(attributesMap);
72
73 return relationshipMap;
74 }
75
76 }