org.xiruss.repository.server
Class VersionBase

java.lang.Object
  extended by org.xiruss.repository.server.RepositoryObjectBase
      extended by org.xiruss.repository.server.VersionBase
All Implemented Interfaces:
java.lang.Comparable, RepositoryObject, Version
Direct Known Subclasses:
CompoundDocumentBase, OrganizerBase, ReferentTrackingDocument, ReferentTrackingDocument

public class VersionBase
extends RepositoryObjectBase
implements Version

A SnapCM version.


Field Summary
(package private)  boolean isFixed
           
(package private) static org.apache.log4j.Logger logger
           
(package private)  VersionMap nextVersions
           
(package private)  VersionMap previousVersions
           
(package private)  Resource resource
           
 
Fields inherited from class org.xiruss.repository.server.RepositoryObjectBase
id, name, objectTypeConstant, properties, rep
 
Constructor Summary
VersionBase()
           
 
Method Summary
 void accept(RepositoryVisitor visitor)
           
 void addDependency(DependencyLink dependency)
           
 void addNextVersion(Version nextVer)
          Adds a version as being a next version of this version.
 void addPreviousVersion(Version prevVer)
          Adds a version as being a previous version of this version.
 void checkIsNotFixed()
           
 void collectTargetVersions(VersionMap members, Snapshot snapshot, java.lang.String dependencyTypeName)
          Gets all the versions on which this version is dependent for a given dependency class.
 int compareTo(java.lang.Object arg0)
           
 boolean dependsOn(Resource resource)
          Returns true if the version has one or more dependency relationships of any type to the specified resource.
 boolean dependsOn(Resource resource, java.lang.String dependencyTypeName)
          Returns true if the version has one or more dependency relationships to the specified resource.
 DependencyMap getDependencies()
          Returns the set of dependency
 DependencyMap getDependenciesByType(java.lang.String typeName)
          Returns a collection of dependencies of the specififed type, if any.
 VersionMap getNext()
          Gets the previous versions for this version.
 VersionMap getPrevious()
          Gets the previous versions for this version.
 Resource getResource()
           
 void initialize(java.lang.String versionId, java.lang.String versionName, Resource res)
          Initialize the core properties of the version.
 void initialize(java.lang.String versionId, java.lang.String versionName, java.util.Set previousVersions, Resource res)
           
 boolean isFixed()
           
 void setAsFixed()
          Sets the version as "fixed", meaning that it cannot be mutated further.
 void setPrevious(VersionMap previousVersions)
          Sets the previous versions for this version.
protected  void setResource(Resource res)
           
 
Methods inherited from class org.xiruss.repository.server.RepositoryObjectBase
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
getId, getName, getProperties, getProperty, getPropertyNames, getRepository, getType, hasProperty, initialize, isNull, setId, setName, setProperty, toString
 

Field Detail

logger

static org.apache.log4j.Logger logger

resource

Resource resource

nextVersions

VersionMap nextVersions

previousVersions

VersionMap previousVersions

isFixed

boolean isFixed
Constructor Detail

VersionBase

public VersionBase()
Method Detail

initialize

public void initialize(java.lang.String versionId,
                       java.lang.String versionName,
                       Resource res)
                throws VersionMutationException
Initialize the core properties of the version.

Specified by:
initialize in interface Version
Parameters:
versionName -
res -
Throws:
VersionMutationException

initialize

public void initialize(java.lang.String versionId,
                       java.lang.String versionName,
                       java.util.Set previousVersions,
                       Resource res)
                throws VersionMutationException
Specified by:
initialize in interface Version
Parameters:
versionName -
previousVersions -
res -
Throws:
VersionMutationException

setAsFixed

public void setAsFixed()
Sets the version as "fixed", meaning that it cannot be mutated further. This method also adds the version to the resource. While versions know what resource they are a version of, until they are committed to the repository, the resource doesn't know about the version.

Specified by:
setAsFixed in interface Version

isFixed

public boolean isFixed()
Specified by:
isFixed in interface Version

checkIsNotFixed

public void checkIsNotFixed()
                     throws VersionMutationException
Specified by:
checkIsNotFixed in interface Version
Throws:
VersionMutationException

addDependency

public void addDependency(DependencyLink dependency)
                   throws VersionMutationException
Specified by:
addDependency in interface Version
Throws:
VersionMutationException

getDependencies

public DependencyMap getDependencies()
Returns the set of dependency

Specified by:
getDependencies in interface Version
Returns:

getDependenciesByType

public DependencyMap getDependenciesByType(java.lang.String typeName)
Returns a collection of dependencies of the specififed type, if any.

Specified by:
getDependenciesByType in interface Version
Parameters:
typeName - The fully-qualified type name for the dependency (the Java class name for the dependency type.
Returns:
The set of dependencies of the specified type. May be empty.

getResource

public Resource getResource()
Specified by:
getResource in interface Version

setResource

protected void setResource(Resource res)

dependsOn

public boolean dependsOn(Resource resource)
Returns true if the version has one or more dependency relationships of any type to the specified resource.

Specified by:
dependsOn in interface Version
Parameters:
resource -
Returns:
Returns true if there are any dependencies.

dependsOn

public boolean dependsOn(Resource resource,
                         java.lang.String dependencyTypeName)
Returns true if the version has one or more dependency relationships to the specified resource.

Specified by:
dependsOn in interface Version
Parameters:
resource -
dependencyTypeName - The name of the dependency type to check. If null, checks all dependency types.
Returns:
Returns true if there are any dependencies of the specified type.

collectTargetVersions

public void collectTargetVersions(VersionMap members,
                                  Snapshot snapshot,
                                  java.lang.String dependencyTypeName)
Description copied from interface: Version
Gets all the versions on which this version is dependent for a given dependency class.

Specified by:
collectTargetVersions in interface Version
Parameters:
members - The version map to which the target versions are added
snapshot - The snapshot on which to resolve the dependencies
dependencyTypeName - The class name of the dependency type

getPrevious

public VersionMap getPrevious()
Gets the previous versions for this version.

Specified by:
getPrevious in interface Version
Returns:
VersionMapImpl of previous versions, if any.

getNext

public VersionMap getNext()
Gets the previous versions for this version.

Specified by:
getNext in interface Version
Returns:
VersionMapImpl of next versions, if any.

setPrevious

public void setPrevious(VersionMap previousVersions)
                 throws VersionMutationException
Sets the previous versions for this version. Cannot be called once the version is fixed.

Specified by:
setPrevious in interface Version
Parameters:
previousVersions - Versionmap of previous versions.
Throws:
VersionMutationException

compareTo

public int compareTo(java.lang.Object arg0)
Specified by:
compareTo in interface java.lang.Comparable
Specified by:
compareTo in interface RepositoryObject
Overrides:
compareTo in class RepositoryObjectBase

addPreviousVersion

public void addPreviousVersion(Version prevVer)
Adds a version as being a previous version of this version. NOTE: Does not automatically add this version to the previous version's next versions property so as to avoid inadvertant infinite loops. This normally happens when a version is created on a snapshot, although it could be done at other times.

Specified by:
addPreviousVersion in interface Version
Parameters:
prevVer - previous version

addNextVersion

public void addNextVersion(Version nextVer)
Adds a version as being a next version of this version. NOTE: Does not automatically add this version to the next version's previous versions property so as to avoid inadvertant infinite loops.

Specified by:
addNextVersion in interface Version
Parameters:
nextVer -

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