org.xiruss.repository.server
Class SnapshotBase

java.lang.Object
  extended by org.xiruss.repository.server.RepositoryObjectBase
      extended by org.xiruss.repository.server.SnapshotBase
All Implemented Interfaces:
java.lang.Comparable, RepositoryObject, Snapshot
Direct Known Subclasses:
MutableSnapshotBase

public class SnapshotBase
extends RepositoryObjectBase
implements Snapshot

Implements the access-only methods for snapshots. This class should be used for all snapshots that have been committed to the repository and are therefore fixed.


Field Summary
protected  Branch branch
           
protected  VersionByResourceMap createdVersions
           
protected  java.util.Date creationTime
           
protected  VersionByResourceMap effectiveVersions
           
protected  VersionByResourceMap excludedVersions
           
protected  boolean isFixed
           
protected  Snapshot nextSnapshot
           
protected  Snapshot previousSnapshot
           
protected  VersionByResourceMap versionsByResource
           
protected  VersionMap visibleVersions
           
 
Fields inherited from class org.xiruss.repository.server.RepositoryObjectBase
id, name, objectTypeConstant, properties, rep
 
Constructor Summary
SnapshotBase()
          Create a new read-onlyl Snapshot.
 
Method Summary
 void accept(RepositoryVisitor visitor)
           
 void checkIsNotFixed()
          Throws an exception is the snapshot is fixed.
 Branch getBranch()
           
 VersionByResourceMap getCreatedVersions()
           
protected  java.util.Set getCreatedVersionsSet()
           
 VersionByResourceMap getEffectiveVersions()
          Returns a copy of the effective versions map.
 VersionByResourceMap getExcludedVersions()
          Returns a copy of the excluded versions map.
 Snapshot getNext()
          Returns the snapshot that follows this one on the branch, if any.
 Snapshot getPrevious()
          Returns the previous snapshot on the snapshot's branch, if any.
 Version getVersion(Resource res)
          Given a resource, returns the version of that resource that has been created on or is effective on the snapshot.
 Version getVersionById(java.lang.String verKey)
           
 VersionMap getVersionsByPropertyValue(java.lang.String propertyName, java.lang.Object testValue)
          Returns the set of versions that exhibit the specified value for the specified property.
 VersionByResourceMap getVersionsByResource()
           
 long getVisibleVersionCount()
          Returns the number of versions that are visible on the snapshot.
 VersionByResourceMap getVisibleVersions()
          Returns a VersionMap of the versions visible on this snapshot.
 void initialize(MutableSnapshot baseSnapshot, java.lang.String objId, java.util.Date commitTime)
          Initialize a mutable or immutable snapshot using an existing snapshot as the base.
 boolean isFixed()
          If true, indicates that the snapshot is fixed and committed to the repository.
 boolean resourceIsVisible(Resource res)
           
 void setBranch(Branch branch)
           
 Snapshot setNext(Snapshot snap)
          Sets the next snapshot.
 boolean versionIsVisible(java.lang.String versionId)
          Returns true if the specified version is visible on the snapshot, meaning that it is a created or effective version.
 boolean versionIsVisible(Version ver)
          Returns true if the specified version is visible on the snapshot, meaning that it is a created or effective version.
 
Methods inherited from class org.xiruss.repository.server.RepositoryObjectBase
compareTo, getId, getName, getProperties, getProperty, getPropertyNames, getRepository, getType, hasProperty, initialize, initialize, isNull, setId, setName, setProperties, setProperty, setRepository, setType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xiruss.snapcm.api.RepositoryObject
compareTo, getId, getName, getProperties, getProperty, getPropertyNames, getRepository, getType, hasProperty, initialize, isNull, setId, setName, setProperty, toString
 

Field Detail

isFixed

protected boolean isFixed

branch

protected Branch branch

visibleVersions

protected VersionMap visibleVersions

createdVersions

protected VersionByResourceMap createdVersions

effectiveVersions

protected VersionByResourceMap effectiveVersions

excludedVersions

protected VersionByResourceMap excludedVersions

versionsByResource

protected VersionByResourceMap versionsByResource

nextSnapshot

protected Snapshot nextSnapshot

previousSnapshot

protected Snapshot previousSnapshot

creationTime

protected java.util.Date creationTime
Constructor Detail

SnapshotBase

public SnapshotBase()
Create a new read-onlyl Snapshot.

Method Detail

setBranch

public void setBranch(Branch branch)

initialize

public void initialize(MutableSnapshot baseSnapshot,
                       java.lang.String objId,
                       java.util.Date commitTime)
                throws ObjectMutationException
Description copied from interface: Snapshot
Initialize a mutable or immutable snapshot using an existing snapshot as the base.

Specified by:
initialize in interface Snapshot
Parameters:
baseSnapshot - Snapshot to use as the initialization source.
objId - Object ID of the newly-created snapshot.
Throws:
ObjectMutationException

getPrevious

public Snapshot getPrevious()
Returns the previous snapshot on the snapshot's branch, if any.

Specified by:
getPrevious in interface Snapshot
Returns:
The previous snapshot, or null if this is the first snapshot.

getVersion

public Version getVersion(Resource res)
Given a resource, returns the version of that resource that has been created on or is effective on the snapshot. If the version is either explicitly excluded or simply not on the snapshot, returns null.

Specified by:
getVersion in interface Snapshot
Parameters:
cd1Res -
Returns:

checkIsNotFixed

public void checkIsNotFixed()
                     throws ObjectMutationException
Throws an exception is the snapshot is fixed. A snapshot becomes "fixed" (immutable) when it is committed to the repository. Before that time the snapshot and any created versions on it may be mutated without restriction.

Specified by:
checkIsNotFixed in interface Snapshot
Throws:
ObjectMutationException

getVersionsByPropertyValue

public VersionMap getVersionsByPropertyValue(java.lang.String propertyName,
                                             java.lang.Object testValue)
Returns the set of versions that exhibit the specified value for the specified property.

Specified by:
getVersionsByPropertyValue in interface Snapshot
Parameters:
propertyName - The name of the property to check.
testValue - The property value to check for.
Returns:
The set of versions that exhibit the property and value.

getVisibleVersions

public VersionByResourceMap getVisibleVersions()
Returns a VersionMap of the versions visible on this snapshot.

Specified by:
getVisibleVersions in interface Snapshot

isFixed

public boolean isFixed()
If true, indicates that the snapshot is fixed and committed to the repository.

Specified by:
isFixed in interface Snapshot
Returns:

getVersionById

public Version getVersionById(java.lang.String verKey)
Specified by:
getVersionById in interface Snapshot
Parameters:
verKey - String key for a version
Returns:
The version, if visible on the snapshot, otherwise null.

getBranch

public Branch getBranch()
Specified by:
getBranch in interface Snapshot

getNext

public Snapshot getNext()
Returns the snapshot that follows this one on the branch, if any.

Specified by:
getNext in interface Snapshot
Returns:
The next snapshot, or null if this is the last snapshot on the branch.

getCreatedVersions

public VersionByResourceMap getCreatedVersions()
Specified by:
getCreatedVersions in interface Snapshot
Returns:

getCreatedVersionsSet

protected java.util.Set getCreatedVersionsSet()

getEffectiveVersions

public VersionByResourceMap getEffectiveVersions()
Returns a copy of the effective versions map. Effective versions are versions that were created on another snapshot and simply made visible on this snapshot. By default, when a new snapshot is created, all the versions of all the resources visible on the previous snapshot become effective versions of this snapshot.

Specified by:
getEffectiveVersions in interface Snapshot
Returns:

getExcludedVersions

public VersionByResourceMap getExcludedVersions()
Returns a copy of the excluded versions map. Excluded versions are versions that were initially effective on this snapshot (see getEffectiveVersions) but where then marked as excluded from this snapshot, making them (and therefore their associated resources) no longer visible. Excluded versions will not be automatically made effective on the next snapshot in the branch. Versions that have been excluded can, of course, be re-added to subsequence snapshots on the branch.

Specified by:
getExcludedVersions in interface Snapshot
Returns:

versionIsVisible

public boolean versionIsVisible(java.lang.String versionId)
Returns true if the specified version is visible on the snapshot, meaning that it is a created or effective version.

Specified by:
versionIsVisible in interface Snapshot
Parameters:
versionId - ID of the version to check for
Returns:
True if the version is visible.

versionIsVisible

public boolean versionIsVisible(Version ver)
Returns true if the specified version is visible on the snapshot, meaning that it is a created or effective version.

Specified by:
versionIsVisible in interface Snapshot
Parameters:
ver - The version to check for
Returns:
True if the version is visible.

resourceIsVisible

public boolean resourceIsVisible(Resource res)
Specified by:
resourceIsVisible in interface Snapshot

accept

public void accept(RepositoryVisitor visitor)
            throws java.lang.Throwable
Specified by:
accept in interface RepositoryObject
Overrides:
accept in class RepositoryObjectBase
Throws:
java.lang.Throwable

getVisibleVersionCount

public long getVisibleVersionCount()
Returns the number of versions that are visible on the snapshot.

Specified by:
getVisibleVersionCount in interface Snapshot
Returns:

setNext

public Snapshot setNext(Snapshot snap)
Sets the next snapshot. If the snapshot is fixed, can only be set if it is not already set.

Specified by:
setNext in interface Snapshot

getVersionsByResource

public VersionByResourceMap getVersionsByResource()
Specified by:
getVersionsByResource in interface Snapshot