|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcrom.dao.AbstractJcrDAO<T>
public abstract class AbstractJcrDAO<T>
An abstract implementation of the JcrDAO interface. This should be extended
for specific entity implementations.
This class implements all the methods defined in the JcrDAO interface, and
provides a few protected methods that are useful for implementing custom
finder methods.
The constructor takes a JCR session, so an instance should be created per
session. The constructor also takes a Jcrom instance that can be shared
across multiple DAOs.
This implementation encapsulates exceptions in JcrMappingException, which
is a RuntimeException.
| Field Summary | |
|---|---|
protected java.lang.Class<T> |
entityClass
|
protected boolean |
isVersionable
|
protected Jcrom |
jcrom
|
protected java.lang.String[] |
mixinTypes
|
protected javax.jcr.Session |
session
|
| Constructor Summary | |
|---|---|
AbstractJcrDAO(java.lang.Class<T> entityClass,
Jcrom jcrom)
Use this constructor when you intend to override the getSession() method to provide your own session management (for example via Guice providers). |
|
AbstractJcrDAO(java.lang.Class<T> entityClass,
javax.jcr.Session session,
Jcrom jcrom)
Constructor. |
|
AbstractJcrDAO(java.lang.Class<T> entityClass,
javax.jcr.Session session,
Jcrom jcrom,
java.lang.String[] mixinTypes)
Constructor. |
|
| Method Summary | |
|---|---|
T |
create(java.lang.String parentNodePath,
T entity)
Creates a new JCR Node from the object supplied, under the parent node with the path specified. |
T |
create(T entity)
Creates a new JCR Node from the object supplied. |
boolean |
exists(java.lang.String path)
Check whether an entity with the path supplied exists in JCR. |
java.util.List<T> |
findAll(java.lang.String rootPath)
Find all entities represented by this DAO. |
java.util.List<T> |
findAll(java.lang.String rootPath,
long startIndex,
long resultSize)
Find all entities represented by this DAO. |
java.util.List<T> |
findAll(java.lang.String rootPath,
java.lang.String childNameFilter,
int maxDepth)
Find all entities represented by this DAO. |
java.util.List<T> |
findAll(java.lang.String rootPath,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
Find all entities represented by this DAO. |
protected java.util.List<T> |
findByXPath(java.lang.String xpath,
java.lang.String childNameFilter,
int maxDepth)
Find JCR nodes that match the xpath supplied, and map to objects. |
protected java.util.List<T> |
findByXPath(java.lang.String xpath,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
Find JCR nodes that match the xpath supplied, and map to objects. |
T |
get(java.lang.String path)
Get an entity from JCR by path (from a @JcrPath field). |
T |
get(java.lang.String path,
java.lang.String childNodeFilter,
int maxDepth)
Get an entity from JCR by path (from a @JcrPath field). |
protected javax.jcr.Session |
getSession()
|
long |
getSize(java.lang.String rootPath)
Get the number of entities. |
protected T |
getVersion(javax.jcr.Node node,
java.lang.String versionName,
java.lang.String childNodeFilter,
int maxDepth)
|
T |
getVersion(java.lang.String path,
java.lang.String versionName)
|
T |
getVersion(java.lang.String path,
java.lang.String versionName,
java.lang.String childNodeFilter,
int maxDepth)
|
T |
getVersionByUUID(java.lang.String uuid,
java.lang.String versionName)
|
T |
getVersionByUUID(java.lang.String uuid,
java.lang.String versionName,
java.lang.String childNodeFilter,
int maxDepth)
|
protected java.util.List<T> |
getVersionList(javax.jcr.Node node,
java.lang.String childNameFilter,
int maxDepth)
|
protected java.util.List<T> |
getVersionList(javax.jcr.Node node,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
|
java.util.List<T> |
getVersionList(java.lang.String path)
|
java.util.List<T> |
getVersionList(java.lang.String path,
java.lang.String childNameFilter,
int maxDepth)
|
java.util.List<T> |
getVersionList(java.lang.String path,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
|
java.util.List<T> |
getVersionListByUUID(java.lang.String uuid)
|
java.util.List<T> |
getVersionListByUUID(java.lang.String uuid,
java.lang.String childNameFilter,
int maxDepth)
|
java.util.List<T> |
getVersionListByUUID(java.lang.String uuid,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
|
protected long |
getVersionSize(javax.jcr.Node node)
|
long |
getVersionSize(java.lang.String path)
|
long |
getVersionSizeByUUID(java.lang.String uuid)
|
protected boolean |
hasMixinType(javax.jcr.Node node,
java.lang.String mixinType)
|
T |
loadByUUID(java.lang.String uuid)
Load an entity from JCR by UUID lookup. |
T |
loadByUUID(java.lang.String uuid,
java.lang.String childNodeFilter,
int maxDepth)
Load an entity from JCR by UUID lookup. |
void |
move(T entity,
java.lang.String newParentPath)
Move an entity to the parent with the path specified. |
protected java.lang.String |
relativePath(java.lang.String absolutePath)
|
void |
remove(java.lang.String path)
Permanently remove the entity with the path supplied (from a @JcrPath field). |
void |
removeByUUID(java.lang.String uuid)
Permanently remove the entity with the UUID supplied. |
protected void |
removeVersion(javax.jcr.Node node,
java.lang.String versionName)
|
void |
removeVersion(java.lang.String path,
java.lang.String versionName)
|
void |
removeVersionByUUID(java.lang.String uuid,
java.lang.String versionName)
|
protected void |
restoreVersion(javax.jcr.Node node,
java.lang.String versionName,
boolean removeExisting)
|
void |
restoreVersion(java.lang.String path,
java.lang.String versionName)
|
void |
restoreVersion(java.lang.String path,
java.lang.String versionName,
boolean removeExisting)
|
void |
restoreVersionByUUID(java.lang.String uuid,
java.lang.String versionName)
|
void |
restoreVersionByUUID(java.lang.String uuid,
java.lang.String versionName,
boolean removeExisting)
|
protected java.util.List<T> |
toList(javax.jcr.NodeIterator nodeIterator,
java.lang.String childNameFilter,
int maxDepth)
Maps JCR nodes to a List of JcrEntity implementations. |
protected java.util.List<T> |
toList(javax.jcr.NodeIterator nodeIterator,
java.lang.String childNameFilter,
int maxDepth,
long resultSize)
Maps JCR nodes to a List of JcrEntity implementations. |
protected java.lang.String |
update(javax.jcr.Node node,
T entity,
java.lang.String childNodeFilter,
int maxDepth)
|
java.lang.String |
update(T entity)
Updates an existing JCR Node with the values extracted from the object supplied. |
java.lang.String |
update(T entity,
java.lang.String childNodeFilter,
int maxDepth)
Updates an existing JCR Node with the values extracted from the object supplied. |
java.lang.String |
updateByUUID(T entity,
java.lang.String uuid)
Updates an existing JCR Node with the values extracted from the object supplied. |
java.lang.String |
updateByUUID(T entity,
java.lang.String uuid,
java.lang.String childNodeFilter,
int maxDepth)
Updates an existing JCR Node with the values extracted from the object supplied. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Jcrom jcrom
protected final javax.jcr.Session session
protected final java.lang.Class<T> entityClass
protected final java.lang.String[] mixinTypes
protected final boolean isVersionable
| Constructor Detail |
|---|
public AbstractJcrDAO(java.lang.Class<T> entityClass,
Jcrom jcrom)
entityClass - the class handled by this DAO implementationjcrom - the Jcrom instance to use for object mapping
public AbstractJcrDAO(java.lang.Class<T> entityClass,
javax.jcr.Session session,
Jcrom jcrom)
entityClass - the class handled by this DAO implementationsession - the current JCR sessionjcrom - the Jcrom instance to use for object mapping
public AbstractJcrDAO(java.lang.Class<T> entityClass,
javax.jcr.Session session,
Jcrom jcrom,
java.lang.String[] mixinTypes)
entityClass - the class handled by this DAO implementationsession - the current JCR sessionjcrom - the Jcrom instance to use for object mappingmixinTypes - an array of mixin types to apply to new nodes| Method Detail |
|---|
protected javax.jcr.Session getSession()
protected java.lang.String relativePath(java.lang.String absolutePath)
public T create(T entity)
JcrDAO
create in interface JcrDAO<T>entity - the object to be mapped to a JCR node
public T create(java.lang.String parentNodePath,
T entity)
JcrDAO
create in interface JcrDAO<T>parentNodePath - path to the parent nodeentity - the object to be mapped to a JCR node
public java.lang.String update(T entity)
JcrDAO
update in interface JcrDAO<T>entity - the object to be mapped to a JCR node
public java.lang.String update(T entity,
java.lang.String childNodeFilter,
int maxDepth)
JcrDAO
update in interface JcrDAO<T>entity - the object to be mapped to a JCR nodechildNodeFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).
public java.lang.String updateByUUID(T entity,
java.lang.String uuid)
JcrDAO
updateByUUID in interface JcrDAO<T>entity - the object to be mapped to a JCR nodeuuid - the JCR UUID of the node to update
public java.lang.String updateByUUID(T entity,
java.lang.String uuid,
java.lang.String childNodeFilter,
int maxDepth)
JcrDAO
updateByUUID in interface JcrDAO<T>entity - the object to be mapped to a JCR nodeuuid - the UUID of the node to updatechildNodeFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).
protected java.lang.String update(javax.jcr.Node node,
T entity,
java.lang.String childNodeFilter,
int maxDepth)
protected boolean hasMixinType(javax.jcr.Node node,
java.lang.String mixinType)
throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void move(T entity,
java.lang.String newParentPath)
JcrDAO
move in interface JcrDAO<T>public void remove(java.lang.String path)
JcrDAO
remove in interface JcrDAO<T>path - the full path of the entitypublic void removeByUUID(java.lang.String uuid)
JcrDAO
removeByUUID in interface JcrDAO<T>uuid - the JCR UUID of the entitypublic boolean exists(java.lang.String path)
JcrDAO
exists in interface JcrDAO<T>path - the path of the entity
public T get(java.lang.String path)
JcrDAO
get in interface JcrDAO<T>path - the full path of the entity to be loaded
public T get(java.lang.String path,
java.lang.String childNodeFilter,
int maxDepth)
JcrDAO
get in interface JcrDAO<T>path - the full path of the entity to be loadedmaxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).
public T loadByUUID(java.lang.String uuid)
JcrDAO
loadByUUID in interface JcrDAO<T>uuid - the UUID generated by JCR
public T loadByUUID(java.lang.String uuid,
java.lang.String childNodeFilter,
int maxDepth)
JcrDAO
loadByUUID in interface JcrDAO<T>uuid - the UUID generated by JCR
public T getVersion(java.lang.String path,
java.lang.String versionName)
getVersion in interface JcrDAO<T>
public T getVersion(java.lang.String path,
java.lang.String versionName,
java.lang.String childNodeFilter,
int maxDepth)
getVersion in interface JcrDAO<T>
public T getVersionByUUID(java.lang.String uuid,
java.lang.String versionName)
getVersionByUUID in interface JcrDAO<T>
public T getVersionByUUID(java.lang.String uuid,
java.lang.String versionName,
java.lang.String childNodeFilter,
int maxDepth)
getVersionByUUID in interface JcrDAO<T>
protected T getVersion(javax.jcr.Node node,
java.lang.String versionName,
java.lang.String childNodeFilter,
int maxDepth)
public void restoreVersion(java.lang.String path,
java.lang.String versionName)
restoreVersion in interface JcrDAO<T>
public void restoreVersionByUUID(java.lang.String uuid,
java.lang.String versionName)
restoreVersionByUUID in interface JcrDAO<T>
public void restoreVersion(java.lang.String path,
java.lang.String versionName,
boolean removeExisting)
restoreVersion in interface JcrDAO<T>
public void restoreVersionByUUID(java.lang.String uuid,
java.lang.String versionName,
boolean removeExisting)
restoreVersionByUUID in interface JcrDAO<T>
protected void restoreVersion(javax.jcr.Node node,
java.lang.String versionName,
boolean removeExisting)
public void removeVersion(java.lang.String path,
java.lang.String versionName)
removeVersion in interface JcrDAO<T>
public void removeVersionByUUID(java.lang.String uuid,
java.lang.String versionName)
removeVersionByUUID in interface JcrDAO<T>
protected void removeVersion(javax.jcr.Node node,
java.lang.String versionName)
public long getVersionSize(java.lang.String path)
getVersionSize in interface JcrDAO<T>public long getVersionSizeByUUID(java.lang.String uuid)
getVersionSizeByUUID in interface JcrDAO<T>protected long getVersionSize(javax.jcr.Node node)
public java.util.List<T> getVersionList(java.lang.String path)
getVersionList in interface JcrDAO<T>
public java.util.List<T> getVersionList(java.lang.String path,
java.lang.String childNameFilter,
int maxDepth)
getVersionList in interface JcrDAO<T>
public java.util.List<T> getVersionList(java.lang.String path,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
getVersionList in interface JcrDAO<T>public java.util.List<T> getVersionListByUUID(java.lang.String uuid)
getVersionListByUUID in interface JcrDAO<T>
public java.util.List<T> getVersionListByUUID(java.lang.String uuid,
java.lang.String childNameFilter,
int maxDepth)
getVersionListByUUID in interface JcrDAO<T>
public java.util.List<T> getVersionListByUUID(java.lang.String uuid,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
getVersionListByUUID in interface JcrDAO<T>
protected java.util.List<T> getVersionList(javax.jcr.Node node,
java.lang.String childNameFilter,
int maxDepth)
protected java.util.List<T> getVersionList(javax.jcr.Node node,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
public long getSize(java.lang.String rootPath)
JcrDAO
getSize in interface JcrDAO<T>public java.util.List<T> findAll(java.lang.String rootPath)
JcrDAO
findAll in interface JcrDAO<T>
public java.util.List<T> findAll(java.lang.String rootPath,
long startIndex,
long resultSize)
JcrDAO
findAll in interface JcrDAO<T>startIndex - the zero based index of the first item to returnresultSize - the number of items to return
public java.util.List<T> findAll(java.lang.String rootPath,
java.lang.String childNameFilter,
int maxDepth)
JcrDAO
findAll in interface JcrDAO<T>childNameFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).
public java.util.List<T> findAll(java.lang.String rootPath,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
JcrDAO
findAll in interface JcrDAO<T>childNameFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).startIndex - the zero based index of the first item to returnresultSize - the number of items to return
protected java.util.List<T> findByXPath(java.lang.String xpath,
java.lang.String childNameFilter,
int maxDepth,
long startIndex,
long resultSize)
xpath - the XPath for finding the nodeschildNameFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).startIndex - the zero based index of the first item to returnresultSize - the number of items to return
protected java.util.List<T> findByXPath(java.lang.String xpath,
java.lang.String childNameFilter,
int maxDepth)
xpath - the XPath for finding the nodeschildNameFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).
protected java.util.List<T> toList(javax.jcr.NodeIterator nodeIterator,
java.lang.String childNameFilter,
int maxDepth)
nodeIterator - the iterator pointing to the nodeschildNameFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).
protected java.util.List<T> toList(javax.jcr.NodeIterator nodeIterator,
java.lang.String childNameFilter,
int maxDepth,
long resultSize)
nodeIterator - the iterator pointing to the nodeschildNameFilter - comma separated list of names of child nodes to
load ("*" loads all, "none" loads no children, and "-" at the beginning
makes it an exclusion filter)maxDepth - the maximum depth of loaded child nodes (0 means no
child nodes are loaded, while a negative value means that no
restrictions are set on the depth).resultSize - the number of items to retrieve from the iterator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||