ccc.domain
Class TemplateEntity

java.lang.Object
  extended by ccc.domain.Entity
      extended by ccc.domain.ResourceEntity
          extended by ccc.domain.HistoricalResource<Template,TemplateRevision>
              extended by ccc.domain.TemplateEntity
All Implemented Interfaces:
Lockable, SnapshotSupport<Resource>, Jsonable, java.io.Serializable

public class TemplateEntity
extends HistoricalResource<Template,TemplateRevision>

A template is used to define how a resource will be displayed.

Author:
Civic Computing Ltd
See Also:
Serialized Form

Constructor Summary
protected TemplateEntity()
          Constructor: for persistence only.
  TemplateEntity(ResourceName name, java.lang.String title, java.lang.String description, java.lang.String body, java.lang.String definiton, MimeType mimeType, RevisionMetadata metadata)
          Constructor.
  TemplateEntity(java.lang.String title, java.lang.String description, java.lang.String body, java.lang.String definiton, MimeType mimeType, RevisionMetadata metadata)
          Constructor.
 
Method Summary
protected  java.util.Collection<Template> deltaTemplates(java.util.List<TemplateEntity> templates)
          Create deltas for a collection of templates.
 Template forCurrentRevision()
          Create a snapshot for the current revision.
 Template forSpecificRevision(int revNo)
          Create a snapshot for the specified revision.
 Template forWorkingCopy()
          Create a snapshot for the working copy.
 java.lang.String getBody()
          Accessor for the template's body.
 java.lang.String getDefinition()
          Accessor for the template's definition.
 MimeType getMimeType()
          Accessor.
 ResourceType getType()
          Query the type of this resource.
static java.util.List<Template> mapTemplates(java.util.List<TemplateEntity> templates)
          Create summaries for a collection of templates.
 Template summarize()
          Create a summary for a template.
 void update(Template delta, RevisionMetadata metadata)
          Update the contents of this template.
 
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, 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
 

Constructor Detail

TemplateEntity

protected TemplateEntity()
Constructor: for persistence only.


TemplateEntity

public TemplateEntity(java.lang.String title,
                      java.lang.String description,
                      java.lang.String body,
                      java.lang.String definiton,
                      MimeType mimeType,
                      RevisionMetadata metadata)
Constructor.

Parameters:
title - The title of the template.
description - The description for the template.
body - A valid velocity template for rendering a page.
definiton - An xml definition of the fields that the body requires.
mimeType - The mime type this template will produce.
metadata - The metadata describing the initial revision.

TemplateEntity

public TemplateEntity(ResourceName name,
                      java.lang.String title,
                      java.lang.String description,
                      java.lang.String body,
                      java.lang.String definiton,
                      MimeType mimeType,
                      RevisionMetadata metadata)
Constructor.

Parameters:
name - The name of the template.
title - The title of the template.
description - The description for the template.
body - A valid velocity template for rendering a page.
definiton - An xml definition of the fields that the body requires.
mimeType - The mime type this template will produce.
metadata - The metadata of the template.
Method Detail

getType

public final ResourceType getType()
Query the type of this resource.

Specified by:
getType in class ResourceEntity
Returns:
The ResourceType that describes this resource.

getBody

public java.lang.String getBody()
Accessor for the template's body.

Returns:
The body as a string.

getDefinition

public java.lang.String getDefinition()
Accessor for the template's definition.

Returns:
The definition as a String.

getMimeType

public MimeType getMimeType()
Accessor.

Returns:
Returns the mimeType.

update

public void update(Template delta,
                   RevisionMetadata metadata)
Update the contents of this template.

Parameters:
delta - The new content for the template.
metadata - The metadata describing this revision.

forCurrentRevision

public Template forCurrentRevision()
Create a snapshot for the current revision.

Returns:
A read-only snapshot of the resource.

forSpecificRevision

public Template forSpecificRevision(int revNo)
Create a snapshot for the specified revision.

Parameters:
revNo - The revision to create a snapshot for.
Returns:
A read-only snapshot of the resource.

forWorkingCopy

public Template forWorkingCopy()
Create a snapshot for the working copy.

Returns:
A read-only snapshot of the resource.

summarize

public Template summarize()
Create a summary for a template.

Returns:
The corresponding summary.

mapTemplates

public static java.util.List<Template> mapTemplates(java.util.List<TemplateEntity> templates)
Create summaries for a collection of templates.

Parameters:
templates - The templates.
Returns:
The corresponding summaries.

deltaTemplates

protected java.util.Collection<Template> deltaTemplates(java.util.List<TemplateEntity> templates)
Create deltas for a collection of templates.

Parameters:
templates - The templates.
Returns:
The corresponding deltas.


Copyright © 2010. All Rights Reserved.