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 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
@Deprecated |
29 | |
public class RelationshipsMapBuilder { |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public RelationshipsMapBuilder() { |
35 | 0 | } |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
public ExportMap buildRelationshipsMap(DataDictionaryEntryBase entry) { |
43 | 0 | ExportMap relationshipsMap = new ExportMap("relationships"); |
44 | |
|
45 | 0 | for ( RelationshipDefinition relationship : entry.getRelationships() ) { |
46 | 0 | relationshipsMap.set(buildRelationshipMap(relationship)); |
47 | |
} |
48 | |
|
49 | 0 | return relationshipsMap; |
50 | |
} |
51 | |
|
52 | |
private ExportMap buildRelationshipMap(RelationshipDefinition relationship) { |
53 | 0 | ExportMap relationshipMap = new ExportMap(relationship.getObjectAttributeName()); |
54 | |
|
55 | 0 | ExportMap attributesMap = new ExportMap("primitiveAttributes"); |
56 | |
|
57 | 0 | int count = 0; |
58 | 0 | for (PrimitiveAttributeDefinition primitiveAttributeDefinition : relationship.getPrimitiveAttributes()) { |
59 | 0 | ExportMap attributeMap = new ExportMap(Integer.toString(count++)); |
60 | 0 | attributeMap.set("sourceName", primitiveAttributeDefinition.getSourceName()); |
61 | 0 | attributeMap.set("targetName", primitiveAttributeDefinition.getTargetName()); |
62 | |
|
63 | 0 | attributesMap.set(attributeMap); |
64 | 0 | } |
65 | |
|
66 | 0 | relationshipMap.set(attributesMap); |
67 | |
|
68 | 0 | return relationshipMap; |
69 | |
} |
70 | |
|
71 | |
} |