1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.bo;
17
18 import java.io.Serializable;
19 import java.util.HashMap;
20 import java.util.Map;
21
22
23
24
25
26
27
28
29
30
31
32
33
34 @Deprecated
35 public class DataObjectRelationship implements Serializable {
36 private Class<?> relatedClass;
37 private Class<?> parentClass;
38 private String parentAttributeName;
39 private String userVisibleIdentifierKey = null;
40
41 private Map<String, String> parentToChildReferences = new HashMap<String, String>(4);
42
43 public DataObjectRelationship() {
44 }
45
46 public DataObjectRelationship(Class<?> parentClass, String parentAttributeName, Class<?> relatedClass) {
47 super();
48
49 this.relatedClass = relatedClass;
50 this.parentClass = parentClass;
51 this.parentAttributeName = parentAttributeName;
52 }
53
54
55
56
57
58
59 public Class<?> getParentClass() {
60 return parentClass;
61 }
62
63
64
65
66
67
68 public Class<?> getRelatedClass() {
69 return this.relatedClass;
70 }
71
72
73
74
75
76
77
78
79
80
81 public String getParentAttributeName() {
82 return parentAttributeName;
83 }
84
85
86
87
88
89
90
91
92 public Map<String, String> getParentToChildReferences() {
93 return parentToChildReferences;
94 }
95
96
97
98
99
100
101 public void setParentToChildReferences(Map<String, String> referenceAttributes) {
102 this.parentToChildReferences = referenceAttributes;
103 }
104
105
106
107
108
109
110
111
112 public String getParentAttributeForChildAttribute(String childAttributeName) {
113 for (Map.Entry<String, String> entry : parentToChildReferences.entrySet()) {
114 if (entry.getValue().equals(childAttributeName)) {
115 return entry.getKey();
116 }
117 }
118 return null;
119 }
120
121
122
123
124
125
126
127
128 public String getChildAttributeForParentAttribute(String parentAttributeName) {
129 return parentToChildReferences.get(parentAttributeName);
130 }
131
132 public String getUserVisibleIdentifierKey() {
133 return userVisibleIdentifierKey;
134 }
135
136 public void setUserVisibleIdentifierKey(String userVisibleIdentifierKey) {
137 this.userVisibleIdentifierKey = userVisibleIdentifierKey;
138 }
139
140 @Override
141 public String toString() {
142 StringBuffer sb = new StringBuffer();
143 sb.append("Relationship: ").append(parentClass.getName()).append(" -> ").append(relatedClass.getName());
144 for (Map.Entry<String, String> refs : parentToChildReferences.entrySet()) {
145 sb.append("\n ").append(refs.getKey()).append(" -> ").append(refs.getValue());
146 }
147 return sb.toString();
148 }
149
150 public void setRelatedClass(Class<?> relatedClass) {
151 this.relatedClass = relatedClass;
152 }
153
154 public void setParentClass(Class<?> parentClass) {
155 this.parentClass = parentClass;
156 }
157
158 public void setParentAttributeName(String parentAttributeName) {
159 this.parentAttributeName = parentAttributeName;
160 }
161 }