001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * // Copyright (c) 1998, 2007, Oracle. All rights reserved.
005: *
006: *
007: * The contents of this file are subject to the terms of either the GNU
008: * General Public License Version 2 only ("GPL") or the Common Development
009: * and Distribution License("CDDL") (collectively, the "License"). You
010: * may not use this file except in compliance with the License. You can obtain
011: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
012: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
013: * language governing permissions and limitations under the License.
014: *
015: * When distributing the software, include this License Header Notice in each
016: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
017: * Sun designates this particular file as subject to the "Classpath" exception
018: * as provided by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the License
020: * Header, with the fields enclosed by brackets [] replaced by your own
021: * identifying information: "Portions Copyrighted [year]
022: * [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * If you wish your version of this file to be governed by only the CDDL or
027: * only the GPL Version 2, indicate your decision by adding "[Contributor]
028: * elects to include this software in this distribution under the [CDDL or GPL
029: * Version 2] license." If you don't indicate a single choice of license, a
030: * recipient has the option to distribute your version of this file under
031: * either the CDDL, the GPL Version 2 or to extend the choice of license to
032: * its licensees as provided above. However, if you add GPL Version 2 code
033: * and therefore, elected the GPL Version 2 license, then the option applies
034: * only if the new code is made subject to such option by the copyright
035: * holder.
036: */
037: package oracle.toplink.essentials.internal.sessions;
038:
039: import oracle.toplink.essentials.mappings.*;
040: import oracle.toplink.essentials.internal.sessions.AbstractSession;
041: import java.io.Serializable;
042:
043: /**
044: * <p>
045: * <b>Purpose</b>: This class was designed as a superclass to all possible Change Record types.
046: * These Change Records holds the changes made to the objects
047: * <p>
048: *
049: * @see KnownSubclasses prototype.changeset.CollectionChangeRecord,prototype.changeset.DirectToFieldChangeRecord,prototype.changeset.SingleObjectChangeRecord
050: */
051: public abstract class ChangeRecord implements Serializable,
052: oracle.toplink.essentials.changesets.ChangeRecord {
053:
054: /**
055: * This is the attribute name that this change record represents
056: */
057: protected String attribute;
058:
059: /**
060: * This attribute stores the mapping allong with the attribute so that the mapping does not need to be looked up
061: */
062: protected transient DatabaseMapping mapping;
063:
064: /** This is the object change set that holds this record **/
065: protected ObjectChangeSet owner;
066:
067: /**
068: * ADVANCED:
069: * Returns the name of the attribute this ChangeRecord Represents
070: * @return java.lang.String
071: */
072: public String getAttribute() {
073: return attribute;
074: }
075:
076: /**
077: * ADVANCED:
078: * Returns the mapping for the attribute this ChangeRecord Represents
079: */
080: public DatabaseMapping getMapping() {
081: return mapping;
082: }
083:
084: /**
085: * Insert the method's description here.
086: * Creation date: (5/30/00 3:42:14 PM)
087: * @return prototype.changeset.ObjectChangeSet
088: */
089: public oracle.toplink.essentials.changesets.ObjectChangeSet getOwner() {
090: return (oracle.toplink.essentials.changesets.ObjectChangeSet) owner;
091: }
092:
093: /**
094: * INTERNAL:
095: * This method will be used to merge one record into another
096: */
097: public abstract void mergeRecord(ChangeRecord mergeFromRecord,
098: UnitOfWorkChangeSet mergeToChangeSet,
099: UnitOfWorkChangeSet mergeFromChangeSet);
100:
101: /**
102: * INTERNAL:
103: * Ensure this change record is ready to by sent remotely for cache synchronization
104: * In general, this means setting the CacheSynchronizationType on any ObjectChangeSets
105: * associated with this ChangeRecord
106: */
107: public void prepareForSynchronization(AbstractSession session) {
108: }
109:
110: /**
111: * Sets the name of the attribute that this Record represents
112: * @param newValue java.lang.String
113: */
114: public void setAttribute(String newValue) {
115: this .attribute = newValue;
116: }
117:
118: /**
119: * Sets the mapping for the attribute that this Record represents
120: */
121: public void setMapping(DatabaseMapping mapping) {
122: this .mapping = mapping;
123: }
124:
125: /**
126: * INTERNAL:
127: * This method is used to set the ObjectChangeSet that uses this Record in that Record
128: * @param newOwner prototype.changeset.ObjectChangeSet The changeSet that uses this record
129: */
130: public void setOwner(ObjectChangeSet newOwner) {
131: owner = newOwner;
132: }
133:
134: public String toString() {
135: return this .getClass().getName() + "(" + getAttribute() + ")";
136: }
137:
138: /**
139: * INTERNAL:
140: * used by the record to update the new value ignores the value in the default implementation
141: */
142: public void updateChangeRecordWithNewValue(Object newValue) {
143: //no op
144: }
145:
146: /**
147: * INTERNAL:
148: * This method will be used to update the objectsChangeSets references
149: */
150: public abstract void updateReferences(
151: UnitOfWorkChangeSet mergeToChangeSet,
152: UnitOfWorkChangeSet mergeFromChangeSet);
153: }
|