01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.bo;
17:
18: import java.io.Serializable;
19: import java.util.HashMap;
20: import java.util.Map;
21:
22: /**
23: *
24: * This class represents a parentClass/child relationship between two objects
25: * This is used primarily by the <code>BusinessObjectMetaDataService
26: */
27: public class BusinessObjectRelationship implements Serializable {
28: private Class relatedClass;
29: private Class parentClass;
30: private String parentAttributeName;
31: private Map<String, String> parentToChildReferences = new HashMap<String, String>(
32: 4);
33: private String userVisibleIdentifierKey = null;
34:
35: public BusinessObjectRelationship() {
36: }
37:
38: public BusinessObjectRelationship(Class parent,
39: String parentAttributeName, Class relatedClass) {
40: super ();
41: this .relatedClass = relatedClass;
42: this .parentClass = parent;
43: this .parentAttributeName = parentAttributeName;
44: }
45:
46: public Class getRelatedClass() {
47: return this .relatedClass;
48: }
49:
50: /**
51: * Gets the parentClass attribute.
52: * @return Returns the parentClass.
53: */
54: public Class getParentClass() {
55: return parentClass;
56: }
57:
58: public String toString() {
59: StringBuffer sb = new StringBuffer();
60: sb.append("Relationship: ").append(parentClass.getName())
61: .append(" -> ").append(relatedClass.getName());
62: for (Map.Entry<String, String> refs : parentToChildReferences
63: .entrySet()) {
64: sb.append("\n ").append(refs.getKey()).append(" -> ")
65: .append(refs.getValue());
66: }
67: return sb.toString();
68: }
69:
70: public String getParentAttributeName() {
71: return parentAttributeName;
72: }
73:
74: public Map<String, String> getParentToChildReferences() {
75: return parentToChildReferences;
76: }
77:
78: public void setParentToChildReferences(
79: Map<String, String> referenceAttribues) {
80: this .parentToChildReferences = referenceAttribues;
81: }
82:
83: public String getUserVisibleIdentifierKey() {
84: return userVisibleIdentifierKey;
85: }
86:
87: public void setUserVisibleIdentifierKey(
88: String userVisibleIdentifierKey) {
89: this.userVisibleIdentifierKey = userVisibleIdentifierKey;
90: }
91:
92: }
|