1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.bo; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.HashMap; |
20 | |
import java.util.Map; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class BusinessObjectRelationship implements Serializable { |
28 | |
private Class relatedClass; |
29 | |
private Class parentClass; |
30 | |
private String parentAttributeName; |
31 | 0 | private Map<String,String> parentToChildReferences = new HashMap<String,String>( 4 ); |
32 | 0 | private String userVisibleIdentifierKey = null; |
33 | |
|
34 | 0 | public BusinessObjectRelationship() { |
35 | 0 | } |
36 | |
|
37 | |
|
38 | |
public BusinessObjectRelationship(Class parent, String parentAttributeName, Class relatedClass ) { |
39 | 0 | super(); |
40 | 0 | this.relatedClass = relatedClass; |
41 | 0 | this.parentClass = parent; |
42 | 0 | this.parentAttributeName = parentAttributeName; |
43 | 0 | } |
44 | |
|
45 | |
|
46 | |
public Class getRelatedClass() { |
47 | 0 | return this.relatedClass; |
48 | |
} |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
public Class getParentClass() { |
55 | 0 | return parentClass; |
56 | |
} |
57 | |
|
58 | |
|
59 | |
public String toString() { |
60 | 0 | StringBuffer sb = new StringBuffer(); |
61 | 0 | sb.append( "Relationship: " ).append( parentClass.getName() ).append( " -> " ).append( relatedClass.getName() ); |
62 | 0 | for ( Map.Entry<String,String> refs : parentToChildReferences.entrySet() ) { |
63 | 0 | sb.append( "\n " ).append( refs.getKey() ).append( " -> " ).append( refs.getValue() ); |
64 | |
} |
65 | 0 | return sb.toString(); |
66 | |
} |
67 | |
|
68 | |
|
69 | |
public String getParentAttributeName() { |
70 | 0 | return parentAttributeName; |
71 | |
} |
72 | |
|
73 | |
|
74 | |
public Map<String, String> getParentToChildReferences() { |
75 | 0 | return parentToChildReferences; |
76 | |
} |
77 | |
|
78 | |
|
79 | |
public void setParentToChildReferences(Map<String, String> referenceAttribues) { |
80 | 0 | this.parentToChildReferences = referenceAttribues; |
81 | 0 | } |
82 | |
|
83 | |
|
84 | |
public String getUserVisibleIdentifierKey() { |
85 | 0 | return userVisibleIdentifierKey; |
86 | |
} |
87 | |
|
88 | |
|
89 | |
public void setUserVisibleIdentifierKey(String userVisibleIdentifierKey) { |
90 | 0 | this.userVisibleIdentifierKey = userVisibleIdentifierKey; |
91 | 0 | } |
92 | |
|
93 | |
public String getParentAttributeForChildAttribute( String childAttributeName ) { |
94 | 0 | for ( Map.Entry<String,String> entry : parentToChildReferences.entrySet() ) { |
95 | 0 | if ( entry.getValue().equals( childAttributeName ) ) { |
96 | 0 | return entry.getKey(); |
97 | |
} |
98 | |
} |
99 | 0 | return null; |
100 | |
} |
101 | |
|
102 | |
public String getChildAttributeForParentAttribute( String parentAttributeName ) { |
103 | 0 | return parentToChildReferences.get( parentAttributeName ); |
104 | |
} |
105 | |
} |