KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > sessions > AggregateChangeRecord


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.sessions;
23
24 /**
25  * This change Record is used to record the changes for AggregateObjectMapping.
26  */

27 public class AggregateChangeRecord extends ChangeRecord implements oracle.toplink.essentials.changesets.AggregateChangeRecord {
28     protected oracle.toplink.essentials.changesets.ObjectChangeSet changedObject;
29
30     /**
31      * This default constructor is reference internally by SDK XML project to mapp this class
32      */

33     public AggregateChangeRecord() {
34         super();
35     }
36
37     /**
38      * This constructor returns an ChangeRecord representing.
39      * an AggregateMapping.
40      * @param owner prototype.changeset.ObjectChangeSet represents the changeSet that uses this record
41      */

42     public AggregateChangeRecord(ObjectChangeSet owner) {
43         this.owner = owner;
44     }
45
46     /**
47      * ADVANCED:
48      * This method is used to return the ObjectChangeSet representing the changed Aggregate.
49      * @return prototype.changeset.ObjectChanges
50      */

51     public oracle.toplink.essentials.changesets.ObjectChangeSet getChangedObject() {
52         return changedObject;
53     }
54
55     /**
56      * INTERNAL:
57      * This method will be used to merge one record into another
58      */

59     public void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) {
60         if (this.changedObject == null) {
61             this.changedObject = ((AggregateChangeRecord)mergeFromRecord).getChangedObject();
62             if(this.changedObject == null) {
63                 return;
64             } else {
65                 mergeToChangeSet.addObjectChangeSetForIdentity((ObjectChangeSet)this.changedObject, mergeFromChangeSet.getUOWCloneForObjectChangeSet(this.changedObject));
66                 ((ObjectChangeSet)this.changedObject).updateReferences(mergeToChangeSet, mergeFromChangeSet);
67                 return;
68             }
69         }
70         ((ObjectChangeSet)this.changedObject).mergeObjectChanges((ObjectChangeSet)((AggregateChangeRecord)mergeFromRecord).getChangedObject(), mergeToChangeSet, mergeFromChangeSet);
71     }
72
73     /**
74      * INTERNAL:
75      * This method is used to set the changed value or values
76      * @param newValue prototype.changeset.ObjectChanges
77      */

78     public void setChangedObject(oracle.toplink.essentials.changesets.ObjectChangeSet newValue) {
79         changedObject = newValue;
80     }
81
82     /**
83      * INTERNAL:
84      * This method will be used to update the objectsChangeSets references
85      * If this is an aggregate change set then there is no need to update the
86      * reference as the ChangeSet has no identity outside of this record
87      * Check to see if it exists here already to prevent us from creating a little
88      * extra garbage.
89      */

90     public void updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) {
91         Object JavaDoc localChangeSet = mergeToChangeSet.getUOWCloneForObjectChangeSet(this.changedObject);
92         if (localChangeSet == null) {
93             mergeToChangeSet.addObjectChangeSetForIdentity((ObjectChangeSet)this.changedObject, mergeFromChangeSet.getUOWCloneForObjectChangeSet(this.changedObject));
94         }
95     }
96 }
97
Popular Tags