1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.seasar.tuigwaa.model.core.impl;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.seasar.tuigwaa.model.common.TgwAttributeVisitor;
27 import org.seasar.tuigwaa.model.common.TgwElementVisitor;
28 import org.seasar.tuigwaa.model.core.RelationAttribute;
29 import org.seasar.tuigwaa.model.core.TgwEntity;
30 import org.seasar.tuigwaa.util.TgwUtils;
31
32 /***
33 * タイプが関連データに対応
34 *
35 * @author nishioka
36 */
37 public class FkAttribute extends AbstractLinkAttribute implements
38 RelationAttribute {
39
40 private Log log = LogFactory.getLog(getClass());
41
42 private TgwEntity refEntity_;
43
44 private SetAttribute inverseField;
45
46
47
48 public String getType() {
49 return TYPE_FK;
50 }
51
52
53
54 public TgwEntity getRefEntity() {
55 return refEntity_;
56 }
57
58 public String getRefClassName() {
59 return refEntity_.getJavaClassName();
60 }
61
62 public Class getRefClass() throws ClassNotFoundException {
63 return refEntity_.getJavaClass();
64 }
65
66 public String getRefEntityName() {
67 if (refEntity_ != null) {
68 return refEntity_.getName();
69 }
70 return null;
71 }
72
73 public void setRefEntityName(String refEntityName) {
74 String schema = getEntity().getDomainName();
75 TgwEntity entity = TgwUtils.getEntity(schema, refEntityName);
76 setRefEntity(entity);
77 }
78
79 public void setRefEntity(TgwEntity entity) {
80 log.info("Setting refEntity" + entity);
81 this.refEntity_ = entity;
82 entity.addReferencedFkField(this);
83 }
84
85 public SetAttribute getInverseField() {
86 return inverseField;
87 }
88
89 public void setInverseField(SetAttribute inverseField) {
90 this.inverseField = inverseField;
91 }
92
93
94
95 public Object accept(TgwElementVisitor visitor, Object data) {
96 return visitor.visit(this, data);
97 }
98
99 public Object accept(TgwAttributeVisitor visitor, Object data) {
100 return visitor.visit(this, data);
101 }
102 }