1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class RelationshipsMapBuilder { |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | 0 | public RelationshipsMapBuilder() { |
33 | 0 | } |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
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 | |
} |