|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.imixs.workflow.jee.ejb.EntityService
@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 EntityServiceThe EntityService is used to save and load instances of ItemCollections into a Database. The EntityService throws an AccessDeniedException if the CallerPrincipal is not allowed to save or read a specific ItemCollection from the database. So the EntityService can be used to save business objects into a database with individual read- or writeAccess restrictions.
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 | |
|---|---|
static String |
ACCESSLEVEL_AUTHORACCESS
|
static String |
ACCESSLEVEL_EDITORACCESS
|
static String |
ACCESSLEVEL_MANAGERACCESS
|
static String |
ACCESSLEVEL_NOACCESS
|
static String |
ACCESSLEVEL_READERACCESS
|
static int |
TYP_CALENDAR
|
static int |
TYP_DOUBLE
|
static int |
TYP_INT
|
static int |
TYP_TEXT
|
static String |
UNIQUEID
|
| Constructor Summary | |
|---|---|
EntityService()
|
|
| Method Summary | |
|---|---|
void |
addIndex(String stitel,
int ityp)
Adds an Index for a property provided by ItemCollection objects. |
Collection<org.imixs.workflow.ItemCollection> |
findAllEntities(String query,
int startpos,
int count)
The method returns a collection of ItemCollections. |
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 child ItemCollection. |
String |
getAccessRoles()
Returns additional AccessRoles defined for the EJB instance |
Collection<EntityIndex> |
getIndices()
The method returns a list of EntityIndex which defines external properties |
String |
getReadAccessFields()
Returns additional ReadAccessFields defined for the EJB instance. |
String |
getWriteAccessFields()
Returns additional WriteAccessFields defined for the EJB instance. |
org.imixs.workflow.ItemCollection |
load(String id)
This method loads an ItemCollection from the Database. |
void |
remove(org.imixs.workflow.ItemCollection itemcol)
This method 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 into a database. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TYP_TEXT
public static final int TYP_INT
public static final int TYP_DOUBLE
public static final int TYP_CALENDAR
public static final String ACCESSLEVEL_NOACCESS
public static final String ACCESSLEVEL_READERACCESS
public static final String ACCESSLEVEL_AUTHORACCESS
public static final String ACCESSLEVEL_EDITORACCESS
public static final String ACCESSLEVEL_MANAGERACCESS
public static String UNIQUEID
| Constructor Detail |
|---|
public EntityService()
| Method Detail |
|---|
public String getAccessRoles()
getAccessRoles in interface EntityServiceRemotepublic String getReadAccessFields()
getReadAccessFields in interface EntityServiceRemotepublic String getWriteAccessFields()
getWriteAccessFields in interface EntityServiceRemote
public org.imixs.workflow.ItemCollection save(org.imixs.workflow.ItemCollection itemcol)
throws org.imixs.workflow.exceptions.AccessDeniedException,
org.imixs.workflow.exceptions.InvalidWorkitemException
The method throws an AccessDeniedException if the CallerPrincipal is not allowed to save or update the ItemCollection in the database. The CallerPrincipial should have at least the access Role org.imixs.ACCESSLEVEL.AUTHORACCESS
save in interface EntityServiceRemoteItemCollection - to be saved
org.imixs.workflow.exceptions.AccessDeniedException
org.imixs.workflow.exceptions.InvalidWorkitemExceptionpublic org.imixs.workflow.ItemCollection load(String id)
The method checks if the CallerPrincipal has read access to ItemCollection stored in the database. If not the method returns null. The method dose not throw an AccessDeniedException if the user is not allowed to read the entity to prevent a aggressor with informations about the existence of that specific ItemCollection.
CallerPrincipial should have at least the access Role org.imixs.ACCESSLEVEL.READACCESS
load in interface EntityServiceRemoteid - - the $unqiueid of the ItemCollection to be loaded
public void remove(org.imixs.workflow.ItemCollection itemcol)
throws org.imixs.workflow.exceptions.AccessDeniedException,
org.imixs.workflow.exceptions.InvalidWorkitemException
The CallerPrincipial should have at least the access Role org.imixs.ACCESSLEVEL.AUTHORACCESS
Also the method removes all existing relation ships of the entity. This is necessary becaus of the FetchType.LAZY used for most relations.
remove in interface EntityServiceRemoteItemCollection - to be removed
Exception
org.imixs.workflow.exceptions.AccessDeniedException
org.imixs.workflow.exceptions.InvalidWorkitemException
public void addIndex(String stitel,
int ityp)
throws Exception
addIndex in interface EntityServiceRemotename - of a property (not case sensetive)ityp - - Type of EntityIndex
Exception
public void removeIndex(String stitel)
throws Exception
removeIndex in interface EntityServiceRemotestitel - - will be automatical lowercased!
Exceptionpublic Collection<EntityIndex> getIndices()
public Collection<org.imixs.workflow.ItemCollection> findAllEntities(String query,
int startpos,
int count)
findAllEntities in interface EntityServiceRemotequery - startpos - count -
org.imixs.workfow.jee.jpa.Entitypublic org.imixs.workflow.ItemCollection findParentEntity(org.imixs.workflow.ItemCollection child)
findParentEntity in interface EntityServiceRemotechildentity -
public Collection<org.imixs.workflow.ItemCollection> findChildEntities(org.imixs.workflow.ItemCollection child,
int start,
int count)
findChildEntities in interface EntityServiceRemoteparententity - startpos - count -
findParentEntity
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||