org.rhq.core.domain.drift
Class JPADriftChangeSet

java.lang.Object
  extended by org.rhq.core.domain.drift.JPADriftChangeSet
All Implemented Interfaces:
Serializable, DriftChangeSet<JPADrift>

public class JPADriftChangeSet
extends Object
implements Serializable, DriftChangeSet<JPADrift>

The JPA Drift Server plugin (the RHQ default) implementation of DriftChangeSet. A change set instance has slightly different behavior based on whether or not it is version zero, that is the initial change set. This is due to the way in which pinned templates are supported.

All change sets belong to a drift definition, and the definition is created from a DriftDefinitionTemplate. Templates can be pinned or unpinned. Each change set encapsulates a collection of changes that are represented by JPADrift. When a template is pinned there is a corresponding pinned snapshot that belongs to the template. Each definition created from that template uses that same pinned snapshot. In terms of implementation, the pinned snapshot is always change set version zero. As an optimization (of the default driftserver plugin data model design), the pinned snapshot is shared among definitions to avoid the overhead of making copies of what could potentially be very large numbers of Drift entities.

When an instance of this class represents change set version zero, different fields will be "live" (i.e., non-null and in use) versus when it is not the initial change set.

Note: Because persistence of this entity is managed by a drift server plugin, other entities managed by the RHQ core server cannot maintain direct references or JPA associations to this class. This restriction is necessary because entities managed by the RHQ core server interact with instance of this class through its drift entity interface which may have multiple implementation. Those implementations need not even be based on a RDBMS. Even though this entity is managed via a drift server plugin, it can maintain direct references and JPA associations to entities managed by the RHQ core server since they reside in the same database. That is however an implementation detail only of this class. It cannot be exposed in the drift interfaces.

See Also:
Serialized Form

Field Summary
static String QUERY_DELETE_BY_DRIFTDEF_RESOURCE
           
static String QUERY_DELETE_BY_RESOURCES
           
 
Constructor Summary
protected JPADriftChangeSet()
           
  JPADriftChangeSet(Resource resource, int version, DriftChangeSetCategory category, DriftDefinition driftDefinition)
           
 
Method Summary
 DriftChangeSetCategory getCategory()
          Retturns the category that identifies the change set type.
 Long getCtime()
           
 DriftDefinition getDriftDefinition()
           
 int getDriftDefinitionId()
          Returns the id of the owning drift definition.
 DriftConfigurationDefinition.DriftHandlingMode getDriftHandlingMode()
          Returns the drift handling mode of the owning drift definition at the time of change set creation.
 Set<JPADrift> getDrifts()
           
 String getId()
          Returns a string that uniquely identifies the change set.
 JPADriftSet getInitialDriftSet()
           
 Resource getResource()
           
 int getResourceId()
          Returns the id of the resource to which the drift definition is assigned.
 int getVersion()
          Every change set must be assigned a version that is unique within the context of the owning DriftDefinition.
 void setCategory(DriftChangeSetCategory category)
          Sets the change set category.
 void setDriftDefinition(DriftDefinition driftDefinition)
           
 void setDriftDefinitionId(int id)
          Sets the id of the owning drift definition.
 void setDriftHandlingMode(DriftConfigurationDefinition.DriftHandlingMode driftHandlingMode)
          Sets the drift handling mode for the change set.
 void setDrifts(Set<JPADrift> drifts)
           
 void setId(String id)
          Sets the change set id which should be unique.
 void setInitialDriftSet(JPADriftSet driftSet)
           
 void setResource(Resource resource)
           
 void setResourceId(int id)
          Sets the id of the resource to which the drift definition is assigned.
 void setVersion(int version)
          Sets the change set version number.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_DELETE_BY_RESOURCES

public static final String QUERY_DELETE_BY_RESOURCES
See Also:
Constant Field Values

QUERY_DELETE_BY_DRIFTDEF_RESOURCE

public static final String QUERY_DELETE_BY_DRIFTDEF_RESOURCE
See Also:
Constant Field Values
Constructor Detail

JPADriftChangeSet

protected JPADriftChangeSet()

JPADriftChangeSet

public JPADriftChangeSet(Resource resource,
                         int version,
                         DriftChangeSetCategory category,
                         DriftDefinition driftDefinition)
Method Detail

getId

public String getId()
Description copied from interface: DriftChangeSet
Returns a string that uniquely identifies the change set. The format of the string is implementation dependent and as such there is no requirement that the id be stored as a string, only that it has a string representation.

Specified by:
getId in interface DriftChangeSet<JPADrift>
Returns:
A unique id as a string

setId

public void setId(String id)
Description copied from interface: DriftChangeSet
Sets the change set id which should be unique. Implementations are free to store the id in any format.

Specified by:
setId in interface DriftChangeSet<JPADrift>
Parameters:
id - The change set identifier that should be unique

getCtime

public Long getCtime()
Specified by:
getCtime in interface DriftChangeSet<JPADrift>
Returns:
The time that the change set was created

getVersion

public int getVersion()
Description copied from interface: DriftChangeSet
Every change set must be assigned a version that is unique within the context of the owning DriftDefinition. This is analgous to a revision number in a version control system like SVN.

Specified by:
getVersion in interface DriftChangeSet<JPADrift>
Returns:
The change set version number that is unique within the context of its owning DriftDefinition.

setVersion

public void setVersion(int version)
Description copied from interface: DriftChangeSet
Sets the change set version number. Note that change set version numbers must be unique within the context of the owning DriftDefinition. Change sets should be assigned version numbers in increasing order. The first change set saved should have a version of N, the second should have a value of N + 1, etc.

Specified by:
setVersion in interface DriftChangeSet<JPADrift>
Parameters:
version - The version number.

getCategory

public DriftChangeSetCategory getCategory()
Description copied from interface: DriftChangeSet
Retturns the category that identifies the change set type.

Specified by:
getCategory in interface DriftChangeSet<JPADrift>
Returns:
The change set category
See Also:
DriftChangeSetCategory

setCategory

public void setCategory(DriftChangeSetCategory category)
Description copied from interface: DriftChangeSet
Sets the change set category.

Specified by:
setCategory in interface DriftChangeSet<JPADrift>
Parameters:
category - The category that identifies the change set type
See Also:
DriftChangeSetCategory

getResourceId

public int getResourceId()
Description copied from interface: DriftChangeSet
Returns the id of the resource to which the drift definition is assigned. Note that the RHQ server and not drift server plugins manage the persistence of the resource.

Specified by:
getResourceId in interface DriftChangeSet<JPADrift>
Returns:
The id of the resource to which the drift definition belongs

setResourceId

public void setResourceId(int id)
Description copied from interface: DriftChangeSet
Sets the id of the resource to which the drift definition is assigned. Note that the RHQ server and not the drift server plugins manage the persistence of the resource

Specified by:
setResourceId in interface DriftChangeSet<JPADrift>
Parameters:
id - The Resource id

getResource

public Resource getResource()

setResource

public void setResource(Resource resource)

getDriftDefinition

public DriftDefinition getDriftDefinition()

setDriftDefinition

public void setDriftDefinition(DriftDefinition driftDefinition)

getDriftHandlingMode

public DriftConfigurationDefinition.DriftHandlingMode getDriftHandlingMode()
Description copied from interface: DriftChangeSet
Returns the drift handling mode of the owning drift definition at the time of change set creation. Because the value set on the owning drift definition can change, the value must be stored with the change set such that it can be applied consistently when handling the associated drift.

Specified by:
getDriftHandlingMode in interface DriftChangeSet<JPADrift>
Returns:
The DriftDefinition.DriftHandlingMode mode

setDriftHandlingMode

public void setDriftHandlingMode(DriftConfigurationDefinition.DriftHandlingMode driftHandlingMode)
Description copied from interface: DriftChangeSet
Sets the drift handling mode for the change set. It should be set to the owning drift definition's drift handling mode at the time of change set creation. Because the value set on the owning drift definition can change, the value must be stored with the change set such that it can be applied consistently when handling the associated drift.

Specified by:
setDriftHandlingMode in interface DriftChangeSet<JPADrift>
Parameters:
driftHandlingMode - The DriftDefinition.DriftHandlingMode mode

getDriftDefinitionId

public int getDriftDefinitionId()
Description copied from interface: DriftChangeSet
Returns the id of the owning drift definition. Note that while server plugins are responsible for managing the persistence of change sets, the RHQ server manages the persistence of the owning drift definition.

Specified by:
getDriftDefinitionId in interface DriftChangeSet<JPADrift>
Returns:
The DriftDefinition id

setDriftDefinitionId

public void setDriftDefinitionId(int id)
Description copied from interface: DriftChangeSet
Sets the id of the owning drift definition. Note that while server plugins are responsible for managing the persistence of change sets, the RHQ server manages the persistence of the drift definition.

Specified by:
setDriftDefinitionId in interface DriftChangeSet<JPADrift>
Parameters:
id - The DriftDefinition id

getDrifts

public Set<JPADrift> getDrifts()
Specified by:
getDrifts in interface DriftChangeSet<JPADrift>
Returns:
The entries that comprise this change set

setDrifts

public void setDrifts(Set<JPADrift> drifts)
Specified by:
setDrifts in interface DriftChangeSet<JPADrift>
Parameters:
drifts - The entries that make up this change set

getInitialDriftSet

public JPADriftSet getInitialDriftSet()

setInitialDriftSet

public void setInitialDriftSet(JPADriftSet driftSet)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.