org.opensubsystems.patterns.versioneddata.data
Class VersionedDataObject

java.lang.Object
  extended by org.opensubsystems.core.data.DataObject
      extended by org.opensubsystems.core.data.BasicDataObject
          extended by org.opensubsystems.core.data.ModifiableDataObject
              extended by org.opensubsystems.patterns.versioneddata.data.VersionedDataObject
All Implemented Interfaces:
java.io.Serializable

public abstract class VersionedDataObject
extends org.opensubsystems.core.data.ModifiableDataObject

Base class for all data objects, which can be versioned and therefore has to track the current version, if they are tip and the base version of, which this is a new version.

Version:
$Id: VersionedDataObject.java,v 1.2 2007/01/07 06:15:40 bastafidli Exp $
Author:
Peter Satury
See Also:
Serialized Form
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Field Summary
static int FIRST_VERSION_NUMBER
          This is the first version number for any versionable data object.
protected  boolean m_bTip
          Flag if this data object is the latest (newest) version called tip.
protected  int m_iBaseVersionId
          Id of the data object, which is base version of this data object.
protected  int m_iVersion
          Data object version number.
 
Fields inherited from class org.opensubsystems.core.data.ModifiableDataObject
m_modificationTimestamp
 
Fields inherited from class org.opensubsystems.core.data.BasicDataObject
m_creationTimestamp, m_iDomainId
 
Fields inherited from class org.opensubsystems.core.data.DataObject
NEW_ID, NEW_ID_OBJ, NEW_ID_STR
 
Constructor Summary
VersionedDataObject()
          Default constructor.
VersionedDataObject(int iDomainId)
          Simple constructor creating new data object in particular domain.
VersionedDataObject(int iId, int iDomainId, int iBaseVersionId, boolean bTip, int iVersion, java.sql.Timestamp creationTimestamp, java.sql.Timestamp modificationTimestamp)
          Full constructor.
 
Method Summary
 boolean equals(java.lang.Object oObject)
          
 int getBaseVersionId()
          Get id of the data object, which is base version of this data object.
 int getVersion()
          Get the actual version number of this data object.
 int hashCode()
          
 boolean isTip()
          Get flag if this data object is the latest (newest) version called tip.
protected  void restore(int iId, int iDomainId, int iBaseVersionId, boolean bTip, int iVersion, java.sql.Timestamp creationTimestamp, java.sql.Timestamp modificationTimestamp)
          Restore all values from specified values.
 void setBaseVersionId(int baseVersionId)
          Set id of the data object, which is base version of this data object.
 void setTip(boolean tip)
          Set flag if this data object is the latest (newest) version called tip.
 void setVersion(int version)
          Set the actual version number of this data object.
 
Methods inherited from class org.opensubsystems.core.data.ModifiableDataObject
getModificationTimestamp, restore, setModificationTimestamp
 
Methods inherited from class org.opensubsystems.core.data.BasicDataObject
getCreationTimestamp, getDomainId, getId, getIdAsObject, restore, setCreationTimestamp, setId
 
Methods inherited from class org.opensubsystems.core.data.DataObject
isFromPersistenceStore, isSame, setFromPersistenceStore
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST_VERSION_NUMBER

public static final int FIRST_VERSION_NUMBER
This is the first version number for any versionable data object.

See Also:
Constant Field Values

m_iBaseVersionId

protected int m_iBaseVersionId
Id of the data object, which is base version of this data object. If this data object is the base version (it is the first version) then this is equal to the id.


m_bTip

protected boolean m_bTip
Flag if this data object is the latest (newest) version called tip.


m_iVersion

protected int m_iVersion
Data object version number. This is the actual version number of this data object.

Constructor Detail

VersionedDataObject

public VersionedDataObject()
Default constructor.


VersionedDataObject

public VersionedDataObject(int iDomainId)
Simple constructor creating new data object in particular domain.

Parameters:
iDomainId - - domain this data object belongs to

VersionedDataObject

public VersionedDataObject(int iId,
                           int iDomainId,
                           int iBaseVersionId,
                           boolean bTip,
                           int iVersion,
                           java.sql.Timestamp creationTimestamp,
                           java.sql.Timestamp modificationTimestamp)
Full constructor.

Parameters:
iId - - id of this data object
iDomainId - - domain this data object belongs to
iBaseVersionId - - data object base version ID
bTip - - flag if this data object is TIP
iVersion - - version number of this data object
creationTimestamp - - timestamp when the data object was created.
modificationTimestamp - - timestamp when the data object was last time modified.
Method Detail

getBaseVersionId

public int getBaseVersionId()
Get id of the data object, which is base version of this data object.

Returns:
int

setBaseVersionId

public void setBaseVersionId(int baseVersionId)
Set id of the data object, which is base version of this data object.

Parameters:
baseVersionId - - id of the version on which is this object based on

isTip

public boolean isTip()
Get flag if this data object is the latest (newest) version called tip.

Returns:
boolean - true if this is the latest version

setTip

public void setTip(boolean tip)
Set flag if this data object is the latest (newest) version called tip.

Parameters:
tip - - true if this is the tip - latest (newest) version

getVersion

public int getVersion()
Get the actual version number of this data object.

Returns:
int

setVersion

public void setVersion(int version)
Set the actual version number of this data object.

Parameters:
version - - version of this object

equals

public boolean equals(java.lang.Object oObject)

Overrides:
equals in class org.opensubsystems.core.data.ModifiableDataObject

hashCode

public int hashCode()

Overrides:
hashCode in class org.opensubsystems.core.data.ModifiableDataObject

restore

protected void restore(int iId,
                       int iDomainId,
                       int iBaseVersionId,
                       boolean bTip,
                       int iVersion,
                       java.sql.Timestamp creationTimestamp,
                       java.sql.Timestamp modificationTimestamp)
Restore all values from specified values. This is here to reinitialize object in case it needs to be reused or reconstructed (e.g. when rollback is issued).

Parameters:
iId - - id of this data object
iDomainId - - domain this data object belongs to
iBaseVersionId - - data object base version ID
bTip - - flag if this data object is TIP
iVersion - - version number of this data object
creationTimestamp - - timestamp when the data object was created.
modificationTimestamp - - timestamp when the data object was last time modified.


Copyright © 2003 - 2006 OpenSubsystems s.r.o.