ccc.domain
Class FolderEntity

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

public final class FolderEntity
extends ResourceEntity

A folder that can contain other resources.

Author:
Civic Computing Ltd
See Also:
Serialized Form

Constructor Summary
protected FolderEntity()
          Constructor: for persistence only.
  FolderEntity(java.lang.String title)
          Constructor.
 
Method Summary
 void add(ResourceEntity resource)
          Add a resource to this folder.
 void delete()
          Mark this file as deleted.
 Folder forCurrentRevision()
          Create a snapshot for the current revision.
 Folder forSpecificRevision(int revNo)
          Create a snapshot for the specified revision.
 Folder forWorkingCopy()
          Create a snapshot for the working copy.
 ResourceEntity getChild(java.util.UUID id)
          Get a child element via its ID.
 java.util.List<ResourceEntity> getEntries()
          Accessor for entries.
<T extends ResourceEntity>
java.util.List<T>
getEntries(java.lang.Class<T> resourceType)
          Retrieve the entries in this folder in a type-safe list.
 java.util.List<ResourceEntity> getEntries(int count, int page, java.lang.String sortOrder)
          Accessor for entries.
 ResourceEntity getEntryWithName(ResourceName resourceName)
          Retrieve an entry from this folder.
 ResourceEntity getEntryWithName2(ResourceName name)
          Find the entry in this folder with the specified name.
 AliasEntity getFirstAlias()
          Accessor method for the first alias in this folder.
 PageEntity getFirstPage()
          Accessor method for the first page in this folder.
 int getFolderCount()
          Query method - returns the number of folders that are children of this folder.
 java.util.List<FolderEntity> getFolders()
          Retrieve a list of all the folders in this folder.
 PageEntity getIndexPage()
          Accessor for the index page.
 java.util.List<PageEntity> getPages()
          Retrieve a list of all the pages in this folder with sort order applied.
 ResourceType getType()
          Query the type of this resource.
 boolean hasAliases()
          Query method to determine if this folder contains any aliases.
 boolean hasEntryWithName(ResourceName resourceName)
          Query whether this folder has an entry with the specified name.
 boolean hasPages()
          Query method to determine if this folder contains any pages.
 boolean isAncestorOf(ResourceEntity resource)
          Determine if this folder is an ancestor of the specified resource.
 ResourceEntity navigateTo(ResourcePath path)
          Navigate from this folder to another resource described by the specified path.
 void remove(ResourceEntity resource)
          Remove a resource from this folder.
 void setIndexPage(PageEntity indexPage)
          Mutator for the index page.
 int size()
          Accessor for size.
 void toJson(Json json)
          Convert to JSON.
 void undelete()
          Mark this file as un-deleted.
 
Methods inherited from class ccc.domain.ResourceEntity
addGroupPermission, addMetadata, addMetadatum, addUserPermission, as, canUnlock, clearGroupAcl, clearMetadata, clearMetadatum, clearUserAcl, computeCache, computeMetadata, computeTemplate, confirmLock, 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, 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

FolderEntity

protected FolderEntity()
Constructor: for persistence only.


FolderEntity

public FolderEntity(java.lang.String title)
Constructor.

Parameters:
title - The title for this resource.
Method Detail

getType

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

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

size

public int size()
Accessor for size.

Returns:
The number of resources contained by this folder.

add

public void add(ResourceEntity resource)
Add a resource to this folder.

Parameters:
resource - The resource to add.

isAncestorOf

public boolean isAncestorOf(ResourceEntity resource)
Determine if this folder is an ancestor of the specified resource.

Parameters:
resource - The potential child.
Returns:
Returns true if the resource is a child of this folder.

getEntries

public java.util.List<ResourceEntity> getEntries()
Accessor for entries.

Returns:
A list of all the resources in this folder.

getEntries

public java.util.List<ResourceEntity> getEntries(int count,
                                                 int page,
                                                 java.lang.String sortOrder)
Accessor for entries.

For example, calling entries(10, 3) will return the resources with positions 20..29 in the list.

Parameters:
count - The number of entries to return.
page - The page of entries to return.
sortOrder - The order in which the entries should be sorted.
Returns:
A list of all the resources in this folder.

navigateTo

public ResourceEntity navigateTo(ResourcePath path)
Navigate from this folder to another resource described by the specified path.

Parameters:
path - The path to a resource, relative to this folder.
Returns:
The resource at the specified path.

getEntryWithName2

public ResourceEntity getEntryWithName2(ResourceName name)
Find the entry in this folder with the specified name. Throws a CCCException if no resource exists with the specified name.

Parameters:
name - The name of the resource.
Returns:
The resource with the specified name.

getFolderCount

public int getFolderCount()
Query method - returns the number of folders that are children of this folder.

Returns:
The number of folders that are children of this folder, as an integer.

hasEntryWithName

public boolean hasEntryWithName(ResourceName resourceName)
Query whether this folder has an entry with the specified name.

Parameters:
resourceName - The name of the resource.
Returns:
True if an entry exists, false otherwise.

getEntryWithName

public ResourceEntity getEntryWithName(ResourceName resourceName)
Retrieve an entry from this folder.

Parameters:
resourceName - The name of the resource to retrieve.
Returns:
The corresponding resource of NULL if no such resource exists.

getEntries

public <T extends ResourceEntity> java.util.List<T> getEntries(java.lang.Class<T> resourceType)
Retrieve the entries in this folder in a type-safe list.

Type Parameters:
T - The type of the resources in this folder.
Parameters:
resourceType - A class representing the type of resources in this folder.
Returns:
The entries in this folder as a type-safe list.

hasPages

public boolean hasPages()
Query method to determine if this folder contains any pages.

Returns:
true if the folder contains any pages, false otherwise.

getFirstPage

public PageEntity getFirstPage()
Accessor method for the first page in this folder.

Returns:
The first page in the list of entries.

remove

public void remove(ResourceEntity resource)
Remove a resource from this folder.

Parameters:
resource - The resource to remove.

getPages

public java.util.List<PageEntity> getPages()
Retrieve a list of all the pages in this folder with sort order applied.

Returns:
A list of pages.

getFolders

public java.util.List<FolderEntity> getFolders()
Retrieve a list of all the folders in this folder.

Returns:
A list of folders.

hasAliases

public boolean hasAliases()
Query method to determine if this folder contains any aliases.

Returns:
true if the folder contains any aliases, false otherwise.

getFirstAlias

public AliasEntity getFirstAlias()
Accessor method for the first alias in this folder.

Returns:
The first alias in the list of entries.

getIndexPage

public PageEntity getIndexPage()
Accessor for the index page.

Returns:
The index page of this folder.

setIndexPage

public void setIndexPage(PageEntity indexPage)
Mutator for the index page.

Parameters:
indexPage - The index page to set.

delete

public void delete()
Mark this file as deleted.

Overrides:
delete in class ResourceEntity

undelete

public void undelete()
Mark this file as un-deleted.

Overrides:
undelete in class ResourceEntity

toJson

public void toJson(Json json)
Convert to JSON.

Specified by:
toJson in interface Jsonable
Overrides:
toJson in class ResourceEntity
Parameters:
json - The JSON object to write to.

getChild

public ResourceEntity getChild(java.util.UUID id)
Get a child element via its ID.

Parameters:
id - The child's ID.
Returns:
The child or NULL if no child exists for the specified ID.

forWorkingCopy

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

Returns:
A read-only snapshot of the resource.

forCurrentRevision

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

Returns:
A read-only snapshot of the resource.

forSpecificRevision

public Folder 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.


Copyright © 2010. All Rights Reserved.