ccc.domain
Class WorkingCopySupport<T extends RevisionEntity<U>,U,V extends WorkingCopy<U>>

java.lang.Object
  extended by ccc.domain.Entity
      extended by ccc.domain.ResourceEntity
          extended by ccc.domain.HistoricalResource<U,T>
              extended by ccc.domain.WorkingCopySupport<T,U,V>
Type Parameters:
T - The type of revision this class requires.
U - The type of jsonable this class requires.
V - The type of working copy this class requires.
All Implemented Interfaces:
Lockable, SnapshotSupport<Resource>, WCAware<U>, Jsonable, java.io.Serializable
Direct Known Subclasses:
FileEntity, PageEntity

public abstract class WorkingCopySupport<T extends RevisionEntity<U>,U,V extends WorkingCopy<U>>
extends HistoricalResource<U,T>
implements WCAware<U>

Abstract helper class that provides working copy support for resources.

Author:
Civic Computing Ltd.
See Also:
Serialized Form

Constructor Summary
protected WorkingCopySupport()
          Constructor: for persistence only.
 
Method Summary
 void applyWorkingCopy(RevisionMetadata metadata)
          Apply the current working copy.
 void clearWorkingCopy()
          Clear the current working copy.
protected abstract  V createWorkingCopy(U delta)
          Create a working copy from a delta.
 U getOrCreateWorkingCopy()
          Accessor.
 V getWorkingCopy()
          Accessor.
 boolean hasWorkingCopy()
          Query method.
 void setOrUpdateWorkingCopy(U snapshot)
          Mutator.
protected  void setWorkingCopy(V wc)
          Mutator.
 void setWorkingCopyFromRevision(int revisionNumber)
          Set the working copy for this resource from an existing revision.
protected abstract  void update(U delta, RevisionMetadata metadata)
          Update the resource from the specified delta.
 
Methods inherited from class ccc.domain.HistoricalResource
addRevision, currentRevision, currentRevisionNo, revision, revisions, toJson
 
Methods inherited from class ccc.domain.ResourceEntity
addGroupPermission, addMetadata, addMetadatum, addUserPermission, as, canUnlock, clearGroupAcl, clearMetadata, clearMetadatum, clearUserAcl, computeCache, computeMetadata, computeTemplate, confirmLock, delete, getAbsolutePath, getAcl, getCacheDuration, getChangedBy, getCreatedBy, getDateChanged, getDateCreated, getDescription, getGroupAcl, getIndex, getLockedBy, getMetadata, getMetadatum, getName, getParent, getPublishedBy, getRoot, getTags, getTemplate, getTitle, getType, getUserAcl, isDeleted, isIncludedInMainMenu, isIndexable, isLocked, isPublished, isReadableBy, isSecure, isVisible, isWriteableBy, lock, mapResource, mapResources, publish, setCacheDuration, setDateChanged, setDateCreated, setDescription, setDtoProps, setIncludedInMainMenu, setIndexPosition, setName, setTags, setTemplate, setTitle, undelete, unlock, unpublish
 
Methods inherited from class ccc.domain.Entity
equals, getId, getVersion, hashCode, setId, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ccc.domain.SnapshotSupport
forCurrentRevision, forSpecificRevision, forWorkingCopy
 

Constructor Detail

WorkingCopySupport

protected WorkingCopySupport()
Constructor: for persistence only.

Method Detail

clearWorkingCopy

public void clearWorkingCopy()
Clear the current working copy.

Specified by:
clearWorkingCopy in interface WCAware<U>

hasWorkingCopy

public boolean hasWorkingCopy()
Query method.

Specified by:
hasWorkingCopy in interface WCAware<U>
Returns:
True if this object has a working copy, false otherwise.

getWorkingCopy

public V getWorkingCopy()
Accessor.

Returns:
The current working copy or NULL if no working copy exists.

setWorkingCopy

protected void setWorkingCopy(V wc)
Mutator.

Parameters:
wc - The working copy to set.

applyWorkingCopy

public void applyWorkingCopy(RevisionMetadata metadata)
Apply the current working copy.

Specified by:
applyWorkingCopy in interface WCAware<U>
Parameters:
metadata - The metadata describing the revision.

setOrUpdateWorkingCopy

public void setOrUpdateWorkingCopy(U snapshot)
Mutator.

Specified by:
setOrUpdateWorkingCopy in interface WCAware<U>
Parameters:
snapshot - The new working copy for this page.

setWorkingCopyFromRevision

public void setWorkingCopyFromRevision(int revisionNumber)
Set the working copy for this resource from an existing revision.

Parameters:
revisionNumber - The revision number to use as the source for the working copy.

getOrCreateWorkingCopy

public U getOrCreateWorkingCopy()
Accessor.

Specified by:
getOrCreateWorkingCopy in interface WCAware<U>
Returns:
The current working copy for this page, or a new working copy if none exists.

createWorkingCopy

protected abstract V createWorkingCopy(U delta)
Create a working copy from a delta.

Parameters:
delta - The delta for the working copy.
Returns:
The new working copy.

update

protected abstract void update(U delta,
                               RevisionMetadata metadata)
Update the resource from the specified delta.

Parameters:
delta - The delta to apply.
metadata - The metadata for the update.


Copyright © 2010. All Rights Reserved.