001: /**
002: *
003: * Licensed to the Apache Software Foundation (ASF) under one or more
004: * contributor license agreements. See the NOTICE file distributed with
005: * this work for additional information regarding copyright ownership.
006: * The ASF licenses this file to You under the Apache License, Version 2.0
007: * (the "License"); you may not use this file except in compliance with
008: * the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package org.apache.openejb.jee;
018:
019: import javax.xml.bind.annotation.XmlAccessType;
020: import javax.xml.bind.annotation.XmlAccessorType;
021: import javax.xml.bind.annotation.XmlAttribute;
022: import javax.xml.bind.annotation.XmlElement;
023: import javax.xml.bind.annotation.XmlID;
024: import javax.xml.bind.annotation.XmlType;
025: import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
026: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
027: import java.util.ArrayList;
028: import java.util.List;
029:
030: /**
031: * The ejb-relationship-roleType describes a role within a
032: * relationship. There are two roles in each relationship.
033: * <p/>
034: * The ejb-relationship-roleType contains an optional
035: * description; an optional name for the relationship role; a
036: * specification of the multiplicity of the role; an optional
037: * specification of cascade-delete functionality for the role;
038: * the role source; and a declaration of the cmr-field, if any,
039: * by means of which the other side of the relationship is
040: * accessed from the perspective of the role source.
041: * <p/>
042: * The multiplicity and role-source element are mandatory.
043: * <p/>
044: * The relationship-role-source element designates an entity
045: * bean by means of an ejb-name element. For bidirectional
046: * relationships, both roles of a relationship must declare a
047: * relationship-role-source element that specifies a cmr-field
048: * in terms of which the relationship is accessed. The lack of
049: * a cmr-field element in an ejb-relationship-role specifies
050: * that the relationship is unidirectional in navigability and
051: * the entity bean that participates in the relationship is
052: * "not aware" of the relationship.
053: * <p/>
054: * Example:
055: * <p/>
056: * <ejb-relation>
057: * <ejb-relation-name>Product-LineItem</ejb-relation-name>
058: * <ejb-relationship-role>
059: * <ejb-relationship-role-name>product-has-lineitems
060: * </ejb-relationship-role-name>
061: * <multiplicity>One</multiplicity>
062: * <relationship-role-source>
063: * <ejb-name>ProductEJB</ejb-name>
064: * </relationship-role-source>
065: * </ejb-relationship-role>
066: * </ejb-relation>
067: */
068: @XmlAccessorType(XmlAccessType.FIELD)
069: @XmlType(name="ejb-relationship-roleType",propOrder={"description","ejbRelationshipRoleName","multiplicity","cascadeDelete","relationshipRoleSource","cmrField"})
070: public class EjbRelationshipRole {
071:
072: @XmlElement(required=true)
073: protected List<Text> description;
074: @XmlElement(name="ejb-relationship-role-name")
075: protected String ejbRelationshipRoleName;
076: @XmlElement(required=true)
077: protected Multiplicity multiplicity;
078: @XmlElement(name="cascade-delete")
079: protected EmptyType cascadeDelete;
080: @XmlElement(name="relationship-role-source",required=true)
081: protected RelationshipRoleSource relationshipRoleSource;
082: @XmlElement(name="cmr-field")
083: protected CmrField cmrField;
084: @XmlAttribute
085: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
086: @XmlID
087: protected String id;
088:
089: public List<Text> getDescription() {
090: if (description == null) {
091: description = new ArrayList<Text>();
092: }
093: return this .description;
094: }
095:
096: public String getEjbRelationshipRoleName() {
097: return ejbRelationshipRoleName;
098: }
099:
100: public void setEjbRelationshipRoleName(String value) {
101: this .ejbRelationshipRoleName = value;
102: }
103:
104: public Multiplicity getMultiplicity() {
105: return multiplicity;
106: }
107:
108: public void setMultiplicity(Multiplicity value) {
109: this .multiplicity = value;
110: }
111:
112: public boolean getCascadeDelete() {
113: return cascadeDelete != null;
114: }
115:
116: public void setCascadeDelete(boolean value) {
117: this .cascadeDelete = value ? new EmptyType() : null;
118: }
119:
120: public RelationshipRoleSource getRelationshipRoleSource() {
121: return relationshipRoleSource;
122: }
123:
124: public void setRelationshipRoleSource(RelationshipRoleSource value) {
125: this .relationshipRoleSource = value;
126: }
127:
128: public CmrField getCmrField() {
129: return cmrField;
130: }
131:
132: public void setCmrField(CmrField value) {
133: this .cmrField = value;
134: }
135:
136: public String getId() {
137: return id;
138: }
139:
140: public void setId(String value) {
141: this.id = value;
142: }
143:
144: }
|