View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  /*
17   * Created on 2005/08/09
18   *
19   * TODO To change the template for this generated file go to
20   * Window - Preferences - Java - Code Style - Code Templates
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  	// [Start] ----- Concrete Method -----
47  
48  	public String getType() {
49  		return TYPE_FK;
50  	}
51  
52  	// [End] ----- Concrete Method -----
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  	// ----- Visitor -----
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 }