|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.imixs.workflow.jee.ejb.EntityServiceBean
@DeclareRoles(value={"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"})
@RolesAllowed(value={"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"})
public class EntityServiceBeanThe EntityServiceBean is the a stateless session EJB implementation of the Interface org.imixs.workflow.jee.ejb.EntityService
This session bean is used to persist and find instances of the generic value transfer object org.imixs.workflow.ItemCollection. The Bean holds an instance of an EntityPersistenceManager for the persistence unit 'org.imixs.workflow.jee.ejb' to manage the following Entity EJBs:
The save() method persists any instance of an ItemCollection. If a ItemCollection is saved the first time the EntityServiceBean generates the attribute $uniqueid which will be included in the ItemCollection returned by this method. If a ItemCollection was saved before the method updates the corresponding Entity Object.
The load() and findAllEntities() methods are used to read ItemCollections from the database. The remove() Method deletes a saved ItemCollection from the database.
All methods expect and return Instances of the object org.imixs.workflow.ItemCollection which is no entity EJB. So these objects are not managed by any instance of an EntityPersistenceManager.
A collection of ItemCollections can be read using the findAllEntites() method using EQL syntax.
This EntityServiceBean has methods to brand out different Attributes of a ItemCollection into external properties (TextIndex, IntegerIndex, DoubleIndex, CalendarIndex) With these functionality a client can query a set of ItemCollections later with EJB Query Language (EQL).
To define which attributes should be expended into external properties the Session EJB supports the method addIndex(). This method creates an index entry and ensures that every Entity saved before will be updated and future calls of the save() method will care about the new index to separate attributes into the Index Properties.
So each call of the save method automatically disassemble a ItemCollection into predefined Index properties and stores attributes which have an Index into a corresponding IndexData Object (TextIndex, IntegerIndex, DoubleIndex, CalendarIndex). On the other hand the load() method reassembles the ItemCollection including all attributes form the data property an any external index property. The EntiyService did not allow to access a managed Entity EJB directly. This simplifies the usage as a client works only with ItemCollections and so there is no need to handle managed and detached entity EJB instances.
Additional to the basic functionality to save and load instances of the object org.imixs.workflow.ItemCollection the method also manages the read- and writeAccess for each instance of an ItemCollection. Therefore the save() method scans an ItemCollection for the attributes '$ReadAccess' and '$WriteAccess' and saves these informations into the Entity EJBs ReadAccessEntity and WriteAccessEntity controlled by each instance of the EJB Entity. The EntityServiceBean implementation verifies in each call of the save() load(), remove() and findAllEntities() methods if the current callerPrincipal is granted to the affected entities. If an ItemCollection was saved with read- or writeAccess the access to an Instance of a saved ItemCollection will be protected for a callerPrincipal with missing read- or writeAccess. The default Read- and WriteAccess attributes '$ReadAccess' and '$WriteAccess' can be overwritten by the environment settings 'READ_ACCESS_FIELDS' and 'WRITE_ACCESS_FIELDS'
Some useful links about the oneToMany Relationship http://www.avaje.org/manydatatypes.html http://thomas-schuett.de/2008/11/14/ordered-lists-in-jpa-do-it-yourself/ http: //javaehrsson.blogspot.com/2005/10/ejb3-onetomany-and-orderby-set-versus.html http://forums.java.net/jive/thread.jspa?threadID=30869&start=0&tstart=0
org.imixs.workflow.jee.ejb.EntityPersistenceManager| Field Summary |
|---|
| Fields inherited from interface org.imixs.workflow.jee.ejb.EntityService |
|---|
ACCESSLEVEL_AUTHORACCESS, ACCESSLEVEL_EDITORACCESS, ACCESSLEVEL_MANAGERACCESS, ACCESSLEVEL_NOACCESS, ACCESSLEVEL_READERACCESS, TYP_AUTHOR, TYP_CALENDAR, TYP_DOUBLE, TYP_INT, TYP_READER, TYP_TEXT |
| Constructor Summary | |
|---|---|
EntityServiceBean()
|
|
| Method Summary | |
|---|---|
void |
addIndex(String stitel,
int ityp)
This method adds a new index field to the current index list and updates existing entities. |
Collection<org.imixs.workflow.ItemCollection> |
findAllEntities(String query,
int startpos,
int count)
returns a collection of ItemCollections defined by a query. |
Collection<org.imixs.workflow.jee.jpa.EntityIndex> |
findAllEntityIndices()
returns a collection of all defined entityIndex fields. |
Collection<org.imixs.workflow.ItemCollection> |
findChildEntities(org.imixs.workflow.ItemCollection child,
int start,
int count)
The method returns a collection of child ItemCollections. |
org.imixs.workflow.ItemCollection |
findParentEntity(org.imixs.workflow.ItemCollection child)
The method returns the parent ItemCollection to a given ItemCollection. |
String |
getAccessRoles()
|
String |
getReadAccessFields()
|
String |
getWriteAccessFields()
|
org.imixs.workflow.ItemCollection |
load(String id)
This method loads a entity by its id and assembles all existing index attributes which were breaded out to subdata objects into one single ItemCollection. |
void |
remove(org.imixs.workflow.ItemCollection itemcol)
removes an ItemCollection from the Database. |
void |
removeIndex(String stitel)
This method removes an existing index from the current indexlist and updates existing entities. |
org.imixs.workflow.ItemCollection |
save(org.imixs.workflow.ItemCollection itemcol)
This Method saves an ItemCollection as an Entity Bean Instance using the JPA EntityManager. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EntityServiceBean()
| Method Detail |
|---|
public String getAccessRoles()
getAccessRoles in interface org.imixs.workflow.jee.ejb.EntityServicepublic String getReadAccessFields()
getReadAccessFields in interface org.imixs.workflow.jee.ejb.EntityServicepublic String getWriteAccessFields()
getWriteAccessFields in interface org.imixs.workflow.jee.ejb.EntityServicepublic Collection<org.imixs.workflow.jee.jpa.EntityIndex> findAllEntityIndices()
findAllEntityIndices in interface org.imixs.workflow.jee.ejb.EntityService
public Collection<org.imixs.workflow.ItemCollection> findAllEntities(String query,
int startpos,
int count)
Unfortunately we need to call the manager.refresh() method to ensure that the entity will be synchronized with database. I saw situations with the remote session ejb where the entityManager returns old relationships :-(. The reason for this behavior is the second level cache of the TopLink driver.
findAllEntities in interface org.imixs.workflow.jee.ejb.EntityService://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t
.html
public Collection<org.imixs.workflow.ItemCollection> findChildEntities(org.imixs.workflow.ItemCollection child,
int start,
int count)
findChildEntities in interface org.imixs.workflow.jee.ejb.EntityServiceparententity - startpos - count -
findParentEntitypublic org.imixs.workflow.ItemCollection findParentEntity(org.imixs.workflow.ItemCollection child)
findParentEntity in interface org.imixs.workflow.jee.ejb.EntityServicechildentity -
public org.imixs.workflow.ItemCollection load(String id)
load in interface org.imixs.workflow.jee.ejb.EntityServiceid - of the entity to be loaded
public void remove(org.imixs.workflow.ItemCollection itemcol)
throws org.imixs.workflow.exceptions.AccessDeniedException,
org.imixs.workflow.exceptions.InvalidWorkitemException
remove in interface org.imixs.workflow.jee.ejb.EntityServiceorg.imixs.workflow.exceptions.AccessDeniedException
org.imixs.workflow.exceptions.InvalidWorkitemException#62
public void addIndex(String stitel,
int ityp)
throws Exception
addIndex in interface org.imixs.workflow.jee.ejb.EntityServicestitel - - will be automatical transformed to lowercase!ityp - - Type of EntityIndex
Exception#62
public void removeIndex(String stitel)
throws Exception
removeIndex in interface org.imixs.workflow.jee.ejb.EntityServicestitel - - will be automatical lowercased!
Exception
public org.imixs.workflow.ItemCollection save(org.imixs.workflow.ItemCollection itemcol)
throws org.imixs.workflow.exceptions.AccessDeniedException
If the ItemCollection dose not contain the property $uniqueid then the method will create a new Entity Bean instance calling the persist() method of the EntityManager. If the ItemColleciton contains a property $uniqueid but no Entity Bean instance with this ID exists in the database than a new Entity will be created using the provided $uniqueid as its primary key (id).
The method looks for a property "type" in the provided ItemCollection and maps this property to the corresponding Bean property. If no property with the name "type" is specified the method defaults this property to the value 'Entity'. The type property is used by the Entity Bean to categorize entities. @see org.imixs.workflow.jee.jpa.Entity
After persisting the provided ItemCollection the method returns a new updated instance of an ItemCollection containing the properties '$uniqueid' '$modified', '$created' and 'type'
save in interface org.imixs.workflow.jee.ejb.EntityServiceorg.imixs.workflow.exceptions.AccessDeniedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||