Dekoh platform API

dekoh.portal.fwk.persistence
Class DIOEntityManagerImpl

java.lang.Object
  extended by dekoh.portal.fwk.persistence.DIOEntityManagerImpl
All Implemented Interfaces:
DIOEntityManager

public class DIOEntityManagerImpl
extends Object
implements DIOEntityManager

DIOEntityManager is a wraper over EntityManager. It provides business methods which are useful for Dekoh Persistence. Its lifecycle is to be maintained by the applications using Dekoh framewwork

Since:
Oct 10, 2006

Constructor Summary
protected DIOEntityManagerImpl(DIOEntityManager dioEntityManager)
           
  DIOEntityManagerImpl(EntityManager em)
           
 
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, Class dioClass, String applicationId, LocalUser owner, String[] tags)
           
 Page findAllDigitalObjectsHavingTags(int maximumResultSetSize, int pageNumber, int totalTags, Class dioClass, String applicationId, String[] tags)
           
 Page findAllDigitalObjectsHavingTags(int maximumResultSetSize, int pageNumber, int totalTags, String applicationId, LocalUser owner, String[] tags)
          Returns the page Object with all matching digitalobects.
 Page findAllDigitalObjectsHavingTags(int maximumResultSetSize, int pageNumber, int totalTags, String applicationId, String[] tags)
           
 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 dioExtendingClass, 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)
          Deprecated. use DIOEntityManagerImpl.findByProperty(Class,String,String)} instead
 Set findByTag(String tag, String applicationId)
           
 Set findByTag(String tag, String applicationId, LocalUser owner)
          Find all DigitalObjects that have been tagged with given tag.
 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 queryToPaginate, Query countQuery, int index, int pageSize, Map mapOfParameterObject, Class cls)
          Applications can pass total no of dios on subsiquent call to this query for optimization.
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DIOEntityManagerImpl

protected DIOEntityManagerImpl(DIOEntityManager dioEntityManager)

DIOEntityManagerImpl

public DIOEntityManagerImpl(EntityManager em)
Method Detail

persist

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

Specified by:
persist in interface DIOEntityManager
Parameters:
entity -

beginTx

public void beginTx()
Specified by:
beginTx in interface DIOEntityManager

commitTx

public void commitTx()
Specified by:
commitTx in interface DIOEntityManager

merge

public void merge(Object entity)
Specified by:
merge in interface DIOEntityManager

refresh

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

Specified by:
refresh in interface DIOEntityManager
Parameters:
entity -

remove

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

Specified by:
remove in interface DIOEntityManager
Parameters:
digitalObject -

find

public Object find(Class entityClass,
                   Object primaryKey)
Description copied from interface: DIOEntityManager
Find an entity by primary key.

Specified by:
find in interface DIOEntityManager
Returns:
entity instanace null if no such entity exists for given primary key

getReference

public Object getReference(Class entityClass,
                           Object primaryKey)
Specified by:
getReference in interface DIOEntityManager

findById

public DigitalObject findById(Object primaryKey)
Find by primary key.

Specified by:
findById in interface DIOEntityManager
Parameters:
primaryKey -
Returns:
an instance of digitalObjectClass

findAllDioCollections

public List findAllDioCollections(String applicationId,
                                  int maxResults)

Specified by:
findAllDioCollections in interface DIOEntityManager
Parameters:
applicationId - this is httpServletRequest.getContextPath() for web applications.
Returns:
all DioCollection entities created by the application with supplied id

findAllDioCollections

public List findAllDioCollections(String applicationId,
                                  LocalUser owner,
                                  int maxResults)

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

findAllDigitalObjectsHavingTags

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

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

findAllDigitalObjectsHavingTags

public Page findAllDigitalObjectsHavingTags(int maximumResultSetSize,
                                            int pageNumber,
                                            int totalTags,
                                            String applicationId,
                                            String[] tags)

findAllDigitalObjectsHavingTags

public Page findAllDigitalObjectsHavingTags(int maximumResultSetSize,
                                            int pageNumber,
                                            int totalTags,
                                            Class dioClass,
                                            String applicationId,
                                            String[] tags)

findAllDigitalObjectsHavingTags

public Page findAllDigitalObjectsHavingTags(int maximumResultSetSize,
                                            int pageNumber,
                                            int totalTags,
                                            Class dioClass,
                                            String applicationId,
                                            LocalUser owner,
                                            String[] tags)

paginate

public Page paginate(Query queryToPaginate,
                     Query countQuery,
                     int index,
                     int pageSize,
                     Map mapOfParameterObject,
                     Class cls)
Applications can pass total no of dios on subsiquent call to this query for optimization. If not specified or or specified as zero or negative , totalDios will for pagination.

Specified by:
paginate in interface DIOEntityManager
Parameters:
queryToPaginate - queryToPaginate to get the list of DigitalObjects
countQuery - @return Page
index - -
pageSize - - Number of object to be displayed in a page
mapOfParameterObject - - the object to be used with query
cls - - class of DigitalObject
Returns:
Page Page

paginate

public Page paginate(Query queryToPaginate,
                     int totalResultCount,
                     int index,
                     int pageSize,
                     Map mapOfParameterObject,
                     Class cls)
Specified by:
paginate in interface DIOEntityManager

findBuddiesByDigitalObject

public List findBuddiesByDigitalObject(DigitalObject digitalObject,
                                       LocalUser localUser)
Description copied from interface: DIOEntityManager
gets List of buddies who got the digital Object shared to

Specified by:
findBuddiesByDigitalObject in interface DIOEntityManager
Parameters:
digitalObject - - DigitalObject
Returns:
- List of buddies who got the digital Object shared to

findLocalUserByName

public LocalUser findLocalUserByName(String localuserName)
Specified by:
findLocalUserByName in interface DIOEntityManager

findByName

public List findByName(String name,
                       Class dioClazz)
Specified by:
findByName in interface DIOEntityManager

findByTag

public Set findByTag(String tag,
                     String applicationId)
Specified by:
findByTag in interface DIOEntityManager

findByTag

public Set findByTag(String tag,
                     String applicationId,
                     LocalUser owner)
Find all DigitalObjects that have been tagged with given tag.

Specified by:
findByTag in interface DIOEntityManager
Parameters:
tag -
applicationId -
owner - owner of the tag
Returns:
list read only

findByProperty

public List findByProperty(String propertyName,
                           String propertyValue)
Deprecated. use DIOEntityManagerImpl.findByProperty(Class,String,String)} instead

Description copied from interface: DIOEntityManager
Find all digitalObjects that are tagged with given property name and value.

Specified by:
findByProperty in interface DIOEntityManager
Returns:
emty List if no such dio is found

findByProperty

public List findByProperty(Class dioExtendingClass,
                           String propertyName,
                           String propertyValue)
Description copied from interface: DIOEntityManager
Find specific digitalObjects with specified property name-value combination

Specified by:
findByProperty in interface DIOEntityManager
Parameters:
dioExtendingClass - class object that extends DigitalObject
Returns:
emty List if no such dio is found

findByProperty

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

Specified by:
findByProperty in interface DIOEntityManager
Parameters:
entityClass - class object that extends DigitalObject
Returns:
emty List if no such dio is found

findDigitalObjectsAddedBetweenTwoDates

public List findDigitalObjectsAddedBetweenTwoDates(Class dioExtendingClass,
                                                   Date begin,
                                                   Date end)
Specified by:
findDigitalObjectsAddedBetweenTwoDates in interface DIOEntityManager

rollbackTx

public void rollbackTx()
Specified by:
rollbackTx in interface DIOEntityManager

createQuery

public Query createQuery(String queryInEJBQL)
Specified by:
createQuery in interface DIOEntityManager

createNativeQuery

public Query createNativeQuery(String queryNative)
Specified by:
createNativeQuery in interface DIOEntityManager

createNativeQuery

public Query createNativeQuery(String queryNative,
                               Class resultClass)
Specified by:
createNativeQuery in interface DIOEntityManager

createNamedQuery

public Query createNamedQuery(String qlString)
Description copied from interface: DIOEntityManager
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.

Specified by:
createNamedQuery in interface DIOEntityManager
Returns:
the new query instance

flush

public void flush()
Specified by:
flush in interface DIOEntityManager

clear

public void clear()
Specified by:
clear in interface DIOEntityManager

close

public void close()
Specified by:
close in interface DIOEntityManager

isOpen

public boolean isOpen()
Specified by:
isOpen in interface DIOEntityManager

isActive

public boolean isActive()
Specified by:
isActive in interface DIOEntityManager

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers