Dekoh platform API

dekoh.portal.fwk.persistence
Interface DIOEntityManager

All Known Implementing Classes:
DIOEntityManagerImpl

public interface DIOEntityManager

DIOEntityManager manages the lifecycle of all DigitalObjects. All DigitalObject types are injected with reference to entityManager an implementation of DIOEntityManager.

The DIOEntityManager is similar to javax.persistence.EntityManager, except that this is designed to handle persistence for entities of DigitalObject kind.

An EntityManager instance is associated with a persistence context. A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance.

Since:
Sep 19, 2006

Method Summary
 void beginTx()
           
 void clear()
           
 void close()
           
 void commitTx()
           
 Query createNamedQuery(String qlString)
          em.createQuery(Photo.class,"SELECT c FROM Photo c WHERE c.name LIKE :photoName").setParameter("photoName", name) .getResultList(); Named parameters are parameters in a query that are prefixed with a colon (:).
 Query createNativeQuery(String queryNative)
           
 Query createNativeQuery(String queryNative, Class resultClass)
           
 Query createQuery(String queryInEJBQL)
           
 Object find(Class entityClass, Object primaryKey)
          Find an entity by primary key.
 Page findAllDigitalObjectsHavingTags(int maximumResultSetSize, int pageNumber, int totalTags, String applicationId, LocalUser owner, String[] tags)
          Returns the page Object with all matching digitalobects.
 List findAllDioCollections(String applicationId, int maxResults)
           
 List findAllDioCollections(String applicationId, LocalUser owner, int maxResults)
           
 List findBuddiesByDigitalObject(DigitalObject digitalObject, LocalUser localUser)
          gets List of buddies who got the digital Object shared to
 DigitalObject findById(Object primaryKey)
          Find by primary key.
 List findByName(String name, Class dioClazz)
           
 List findByProperty(Class entityClass, String propertyName, String propertyValue)
          Find specific digitalObjects with specified property name-value combination
 List findByProperty(Class entityClass, String propertyName, String propertyValue, DigitalObjectFilter filter)
          Find specific digitalObjects with specified property name-value combination and whose owner is the passed in parameter owner or null.
 List findByProperty(String propertyName, String propertyValue)
          Find all digitalObjects that are tagged with given property name and value.
 Set findByTag(String tagName, String applicationId)
           
 Set findByTag(String tag, String applicationId, LocalUser owner)
           
 List findDigitalObjectsAddedBetweenTwoDates(Class dioExtendingClass, Date begin, Date end)
           
 LocalUser findLocalUserByName(String localuserName)
           
 void flush()
           
 Object getReference(Class entityClass, Object primaryKey)
           
 boolean isActive()
           
 boolean isOpen()
           
 void merge(Object entity)
           
 Page paginate(Query queryToPaginate, int totalResultCount, int index, int pageSize, Map mapOfParameterObject, Class cls)
           
 Page paginate(Query getObjectsQuery, Query countQuery, int startIndex, int pageSize, Map mapOfParameterObject, Class dioClass)
          Gets the PagePage with the given criteria
countQuery is executed when the totalDios supplied is 0.
 void persist(Object entity)
          Makes a DigitalObject instance mangaged and persistent.
 void refresh(Object entity)
          Refreshes the state of the instance from the database, overwriting changes made to the entity, if any.
 void remove(Object digitalObject)
          Removes the DigitalObject from database.
 void rollbackTx()
           
 

Method Detail

persist

void persist(Object entity)
Makes a DigitalObject instance mangaged and persistent. In other words by invoking this method a new instance of DIgitalObject is created in the 'system'.

Parameters:
entity -

merge

void merge(Object entity)

refresh

void refresh(Object entity)
Refreshes the state of the instance from the database, overwriting changes made to the entity, if any.

Parameters:
entity -

remove

void remove(Object digitalObject)
Removes the DigitalObject from database.

Parameters:
digitalObject -

find

Object find(Class entityClass,
            Object primaryKey)
Find an entity by primary key.

Parameters:
entityClass -
primaryKey -
Returns:
entity instanace null if no such entity exists for given primary key

getReference

Object getReference(Class entityClass,
                    Object primaryKey)

findById

DigitalObject findById(Object primaryKey)
Find by primary key.

Parameters:
primaryKey -
Returns:
an instance of digitalObjectClass

findByName

List findByName(String name,
                Class dioClazz)

findAllDioCollections

List findAllDioCollections(String applicationId,
                           int maxResults)
Parameters:
applicationId - this is httpServletRequest.getContextPath() for web applications.
maxResults -
Returns:
all DioCollection entities created by the application with supplied id

findAllDioCollections

List findAllDioCollections(String applicationId,
                           LocalUser owner,
                           int maxResults)
Parameters:
applicationId - this is httpServletRequest.getContextPath() for web applications.
owner - owner of the digital object
maxResults -
Returns:
all DioCollection entities created by the application with supplied id and whose owner is the passed in parameter or null

findLocalUserByName

LocalUser findLocalUserByName(String localuserName)

findAllDigitalObjectsHavingTags

Page findAllDigitalObjectsHavingTags(int maximumResultSetSize,
                                     int pageNumber,
                                     int totalTags,
                                     String applicationId,
                                     LocalUser owner,
                                     String[] tags)
Returns the page Object with all matching digitalobects. Total number of tags is calculated if the parameter totalTags is 0 or less

Parameters:
maximumResultSetSize - - maximum result-set "-1" indicates all
pageNumber - - get the parameters from index
totalTags - - total number of tags
applicationId -
owner -
tags - - array of tags to search on @return - List of matching digitalObjects @return pageObject with the given parameters @return Page Page

findBuddiesByDigitalObject

List findBuddiesByDigitalObject(DigitalObject digitalObject,
                                LocalUser localUser)
gets List of buddies who got the digital Object shared to

Parameters:
digitalObject - - DigitalObject
localUser -
Returns:
- List of buddies who got the digital Object shared to

paginate

Page paginate(Query getObjectsQuery,
              Query countQuery,
              int startIndex,
              int pageSize,
              Map mapOfParameterObject,
              Class dioClass)
Gets the PagePage with the given criteria
countQuery is executed when the totalDios supplied is 0.

After getting the first page save on execution of countQuery by calling paginate(getObjectQuery, firstPage.getTotalDios(), startIndex, pageSize, map,dioClass)

Parameters:
getObjectsQuery - - the query to be executed to get the list of entities
countQuery - - the query to get the total count
startIndex - - index from where the results should start (starts from 0)
pageSize - - number of entities to include in a page
mapOfParameterObject - - the object to be used with query
dioClass - - class of DigitalObject
Returns:
Page Page
Throws:
IllegalStateException - getObjectQuery.getResultList throws if called for a Java Persistence query language UPDATE or DELETE statement
PersistenceException - propagate the exception thrown when executing countQuery

paginate

Page paginate(Query queryToPaginate,
              int totalResultCount,
              int index,
              int pageSize,
              Map mapOfParameterObject,
              Class cls)

findByTag

Set findByTag(String tagName,
              String applicationId)

findByTag

Set findByTag(String tag,
              String applicationId,
              LocalUser owner)

findByProperty

List findByProperty(String propertyName,
                    String propertyValue)
Find all digitalObjects that are tagged with given property name and value.

Parameters:
propertyName -
propertyValue -
Returns:
emty List if no such dio is found

findByProperty

List findByProperty(Class entityClass,
                    String propertyName,
                    String propertyValue)
Find specific digitalObjects with specified property name-value combination

Parameters:
entityClass - class object that extends DigitalObject
propertyName -
propertyValue -
Returns:
emty List if no such dio is found

findByProperty

List findByProperty(Class entityClass,
                    String propertyName,
                    String propertyValue,
                    DigitalObjectFilter filter)
Find specific digitalObjects with specified property name-value combination and whose owner is the passed in parameter owner or null.

Parameters:
entityClass - class object that extends DigitalObject
propertyName -
propertyValue -
filter -
Returns:
emty List if no such dio is found

findDigitalObjectsAddedBetweenTwoDates

List findDigitalObjectsAddedBetweenTwoDates(Class dioExtendingClass,
                                            Date begin,
                                            Date end)

createNamedQuery

Query createNamedQuery(String qlString)
em.createQuery(Photo.class,"SELECT c FROM Photo c WHERE c.name LIKE :photoName").setParameter("photoName", name) .getResultList(); Named parameters are parameters in a query that are prefixed with a colon (:).

Named parameters in a query are bound to an argument by the javax.persistence.Query.setParameter(String name, Object value) method.

Returns:
the new query instance
Throws:
IllegalArgumentException - - if query string is not valid

createQuery

Query createQuery(String queryInEJBQL)

createNativeQuery

Query createNativeQuery(String queryNative)

createNativeQuery

Query createNativeQuery(String queryNative,
                        Class resultClass)

flush

void flush()

clear

void clear()

beginTx

void beginTx()

commitTx

void commitTx()

rollbackTx

void rollbackTx()

isOpen

boolean isOpen()

isActive

boolean isActive()

close

void close()

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers