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.test.entity.cmr.onetomany;
018:
019: import java.util.HashSet;
020: import java.util.Set;
021:
022: import org.apache.openejb.core.cmp.cmp2.Cmp2Entity;
023: import org.apache.openejb.core.cmp.cmp2.SetValuedCmr;
024:
025: public class ExampleABean_ABean extends ArtistBean implements
026: Cmp2Entity {
027: public static Object deploymentInfo;
028: private transient boolean deleted;
029: private Integer field1;
030: private String field2;
031: private Set<ExampleBBean_BBean> b = new HashSet<ExampleBBean_BBean>();
032: private SetValuedCmr bCmr = new SetValuedCmr(this , "b",
033: ExampleBBean_BBean.class, "a");
034:
035: private Set<ExampleBBean_BBean> bNonCascade = new HashSet<ExampleBBean_BBean>();
036: private SetValuedCmr bNonCascadeCmr = new SetValuedCmr(this ,
037: "bNonCascade", ExampleBBean_BBean.class, "aNonCascade");
038:
039: public Integer getId() {
040: return field1;
041: }
042:
043: public void setId(Integer field1) {
044: this .field1 = field1;
045: }
046:
047: public String getName() {
048: return field2;
049: }
050:
051: public void setName(String field2) {
052: this .field2 = field2;
053: }
054:
055: public Set getPerformed() {
056: return bCmr.get(b);
057: }
058:
059: public void setPerformed(Set b) {
060: bCmr.set(this .b, b);
061: }
062:
063: public Set getComposed() {
064: return bNonCascadeCmr.get(bNonCascade);
065: }
066:
067: public void setComposed(Set bNonCascade) {
068: bNonCascadeCmr.set(this .bNonCascade, bNonCascade);
069: }
070:
071: public Object OpenEJB_getPrimaryKey() {
072: return field1;
073: }
074:
075: public void OpenEJB_deleted() {
076: if (deleted)
077: return;
078: deleted = true;
079:
080: bCmr.deleted(b);
081: bNonCascadeCmr.deleted(bNonCascade);
082: }
083:
084: public Object OpenEJB_addCmr(String name, Object bean) {
085: if (deleted)
086: return null;
087:
088: if ("b".equals(name)) {
089: b.add((ExampleBBean_BBean) bean);
090: return null;
091: }
092:
093: if ("bNonCascade".equals(name)) {
094: bNonCascade.add((ExampleBBean_BBean) bean);
095: return null;
096: }
097:
098: throw new IllegalArgumentException("Unknown cmr field " + name
099: + " on entity bean of type " + getClass().getName());
100: }
101:
102: public void OpenEJB_removeCmr(String name, Object value) {
103: if (deleted)
104: return;
105:
106: if ("b".equals(name)) {
107: b.remove(value);
108: return;
109: }
110:
111: if ("bNonCascade".equals(name)) {
112: bNonCascade.remove(value);
113: return;
114: }
115:
116: throw new IllegalArgumentException("Unknown cmr field " + name
117: + " on entity bean of type " + getClass().getName());
118: }
119: }
|