hero.session
Class UserSessionBean

java.lang.Object
  extended byhero.session.UserSessionBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, hero.util.EventConstants, java.io.Serializable, javax.ejb.SessionBean

public class UserSessionBean
extends java.lang.Object
implements javax.ejb.SessionBean, hero.util.EventConstants

The User Session Bean, is an stateful session bean that provides the user API to get information on Todo list and started activities and to produce events on activities (start, terminate, cancel).
This Session Bean is based on Engine Session Bean: a recursive implementation that manage the previous execution operations and propagates the activity state changes to the activities that are connected to this one.

The User Session Bean API provides information about user projects and activites (project list, todo list and activity list) and also useful information about project instances or user preferences. With this API users can performs his task/activities by using start, terminate and cancel methods and also terminates workflow processes.

The following lines shows a sample code to use this API in your application:


First of all you have to import the User Session files:

import hero.interfaces.UserSessionLocalHome;
import hero.interfaces.UserSessionLocal;
import hero.interfaces.UserSessionHome;
import hero.interfaces.UserSession;
import hero.interfaces.UserSessionUtil;

Now, it is time to create the User Session instance:

Like this if you want to use local interfaces:

UserSessionLocalHome userh = (UserSessionLocalHome)hero.interfaces.UserSessionUtil.getLocalHome();
UserSessionLocal usersession = userh.create();

or like this if you use remote interfaces:

UserSessionHome userh = (UserSessionHome)hero.interfaces.UserSessionUtil.getHome();
UserSession usersession = userh.create();


after that, you can init the User Session API for this user by using the init method:

usersession.init();

Now you can call all User Sessions methods...

Author:
Miguel Valdes
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface hero.util.EventConstants
ADDEDGE, ADDNODE, ADDROLE, ADDUSERPROJECT, ANTICIPATING, CANCELED, CHANGEROLE, DELETEEDGE, DELETENODE, DELETEPROJECT, EDGE, EDGENAME, EVENT, LOG, NODE, NODEDEADLINE, NODEIN, NODENAME, NODEOUT, NODESTATE, NODETYPE, PROJECT, PROJECTNAME, READYINITIAL, ROLE, ROLENAME, SETEDGESTATE, SETNODEDEADLINE, SETNODEEXECUTOR, SETNODESTATE, SETUSERROLE, START, TERMINATED, UNSETUSERROLE, USER, USERNAME, USERROLE
 
Constructor Summary
UserSessionBean()
           
 
Method Summary
 void cancelActivity(java.lang.String projectName, java.lang.String nodeName)
          Tries to cancel an activity (when activity is executing or anticipating)
 void deleteUserProperty(java.lang.String key)
          Delete a property of a user
 void ejbActivate()
          Internal Enterprise Java Beans method.
 void ejbCreate()
          Creates the User Session Bean.
 void ejbPassivate()
          Internal Enterprise Java Beans method.
 void ejbRemove()
          Internal Enterprise Java Beans method.
 java.util.Collection getActivityList(java.lang.String projectName)
          Obtain all user activities from specific project (executing and anticipating state)
 java.util.Collection getActivityListAllInstances()
          Obtain executing user activities for all instances (ready and anticipable state)
 java.util.Collection getActivityListByProperty(java.lang.String key, java.lang.String value)
          Obtain executing user activities matching with property value (executing and anticipating state activities)
 java.util.Collection getInstancesByProperty(java.lang.String key, java.lang.String value)
          Get Workflow instances from a property
 java.util.Collection getInstancesByPropertyNames(java.lang.String key, java.lang.String value)
          Get Workflow instances from a property
 java.util.Collection getInstancesList()
          Get user instances list.
 java.util.Collection getInstancesListNames()
          Get instances list names for this user.
 hero.interfaces.BnNodeValue getNode(java.lang.String projectName, java.lang.String nodeName)
          Get Node Value from a specific project
 java.util.Collection getProjectInstances(java.lang.String projectName)
          Get Workflow instances of this project
 java.util.Collection getProjectInstancesNames(java.lang.String projectName)
          Get workflow instances names of this project
 java.util.Collection getProjectList()
          Get user project list.
 java.util.Collection getProjectListNames()
          Get project list names for this user
 java.util.Collection getProjectsByProperty(java.lang.String key, java.lang.String value)
          Get Workflow projects from a property
 java.util.Collection getProjectsByPropertyNames(java.lang.String key, java.lang.String value)
          Get Workflow projects from a property
 java.util.Collection getToDoList(java.lang.String projectName)
          Obtain all user activities from specific project (ready and anticipable state)
 java.util.Collection getToDoListAllInstances()
          Obtain todo user activities for all instances (ready and anticipable state)
 java.util.Collection getToDoListByProperty(java.lang.String key, java.lang.String value)
          Obtain todo user activities matching with property value (ready and anticipable state activities)
 java.lang.String getUser()
          Get the user name
 hero.interfaces.BnUserLightValue getUserLightValue()
          Get the user light value
 java.lang.String getUserMail(java.lang.String userName)
          Get the mail of this user from Bonita database.
 java.lang.String getUserPassword()
          Get the user password
 java.util.Collection getUserProperties()
          Get User properties
 void removeProject(java.lang.String projectName)
          Delete a Workflow project
 void setSessionContext(javax.ejb.SessionContext context)
          Internal Enterprise Java Beans method.
 void setUserMail(java.lang.String userName, java.lang.String mail)
          Set the mail of this user into Bonita database.
 void setUserProperty(java.lang.String key, java.lang.String value)
          Set a property of a user
 void startActivity(java.lang.String projectName, java.lang.String nodeName)
          Tries to start an activity (when activity state is ready or anticipable)
 void terminate(java.lang.String projectName)
          Tries to terminate a project (only when all project activities are terminated)
 void terminateActivity(java.lang.String projectName, java.lang.String nodeName)
          Tries to terminate an activity (when activity state is executing or anticipating)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserSessionBean

public UserSessionBean()
Method Detail

getProjectList

public java.util.Collection getProjectList()
                                    throws hero.util.HeroException
Get user project list. Workflow processes associated to this user

Returns:
a Collection of BnProjectLightValue objects - the projects list of the user
Throws:
hero.util.HeroException

getProjectListNames

public java.util.Collection getProjectListNames()
                                         throws hero.util.HeroException
Get project list names for this user

Returns:
a String Collection - the projects list names of the user
Throws:
hero.util.HeroException

getInstancesList

public java.util.Collection getInstancesList()
                                      throws hero.util.HeroException
Get user instances list. This method is equivalent to getProjectList but it only returns the current instances of the user.

Returns:
a Collection of BnProjectLightValue objects - the projects list of the user
Throws:
hero.util.HeroException

getInstancesListNames

public java.util.Collection getInstancesListNames()
                                           throws hero.util.HeroException
Get instances list names for this user. This method is equivalent to getProjectListNames but it only returns the current instances of the user.

Returns:
a String Collection - the projects list names of the user
Throws:
hero.util.HeroException

removeProject

public void removeProject(java.lang.String projectName)
                   throws hero.util.HeroException
Delete a Workflow project

Parameters:
projectName - the name of the project
Throws:
hero.util.HeroException

getToDoList

public java.util.Collection getToDoList(java.lang.String projectName)
                                 throws hero.util.HeroException
Obtain all user activities from specific project (ready and anticipable state)

Parameters:
projectName - the name of the project
Returns:
a String Collection - the list of todo activities of the user for a project
Throws:
hero.util.HeroException

getActivityList

public java.util.Collection getActivityList(java.lang.String projectName)
                                     throws hero.util.HeroException
Obtain all user activities from specific project (executing and anticipating state)

Parameters:
projectName - the name of the project
Returns:
a String Collectio - the list of active activities of the user for a project
Throws:
hero.util.HeroException

getToDoListAllInstances

public java.util.Collection getToDoListAllInstances()
                                             throws hero.util.HeroException
Obtain todo user activities for all instances (ready and anticipable state)

Returns:
a BnNodeValue Collection - the list of todo activities of the user for all instances
Throws:
hero.util.HeroException

getActivityListAllInstances

public java.util.Collection getActivityListAllInstances()
                                                 throws hero.util.HeroException
Obtain executing user activities for all instances (ready and anticipable state)

Returns:
a BnNodeValue Collection - the list of executing activities ot the user for all instances
Throws:
hero.util.HeroException

getToDoListByProperty

public java.util.Collection getToDoListByProperty(java.lang.String key,
                                                  java.lang.String value)
                                           throws hero.util.HeroException
Obtain todo user activities matching with property value (ready and anticipable state activities)

Parameters:
key - the key of the property
value - the value of the property
Returns:
a BnNodeValue Collection - the list of todo activities matching to property value
Throws:
hero.util.HeroException

getActivityListByProperty

public java.util.Collection getActivityListByProperty(java.lang.String key,
                                                      java.lang.String value)
                                               throws hero.util.HeroException
Obtain executing user activities matching with property value (executing and anticipating state activities)

Parameters:
key - the key of the property
value - the value of the property
Returns:
a BnNodeValue Collection - the list of executing activities matching to property value
Throws:
hero.util.HeroException

getProjectInstancesNames

public java.util.Collection getProjectInstancesNames(java.lang.String projectName)
                                              throws hero.util.HeroException
Get workflow instances names of this project

Parameters:
projectName - the name of the project
Returns:
a String Collection - the names of project instances
Throws:
hero.util.HeroException

getProjectInstances

public java.util.Collection getProjectInstances(java.lang.String projectName)
                                         throws hero.util.HeroException
Get Workflow instances of this project

Parameters:
projectName - the name of the project
Returns:
a BnProjectValue Collection - list of project instances
Throws:
hero.util.HeroException

getInstancesByProperty

public java.util.Collection getInstancesByProperty(java.lang.String key,
                                                   java.lang.String value)
                                            throws hero.util.HeroException
Get Workflow instances from a property

Returns:
a BnProjectValue Collection - list of project instances
Throws:
hero.util.HeroException

getInstancesByPropertyNames

public java.util.Collection getInstancesByPropertyNames(java.lang.String key,
                                                        java.lang.String value)
                                                 throws hero.util.HeroException
Get Workflow instances from a property

Returns:
a String Collection - list of project instances
Throws:
hero.util.HeroException

getProjectsByProperty

public java.util.Collection getProjectsByProperty(java.lang.String key,
                                                  java.lang.String value)
                                           throws hero.util.HeroException
Get Workflow projects from a property

Returns:
a BnProjectValue Collection - list of projects
Throws:
hero.util.HeroException

getProjectsByPropertyNames

public java.util.Collection getProjectsByPropertyNames(java.lang.String key,
                                                       java.lang.String value)
                                                throws hero.util.HeroException
Get Workflow projects from a property

Returns:
a String Collection - list of project names
Throws:
hero.util.HeroException

startActivity

public void startActivity(java.lang.String projectName,
                          java.lang.String nodeName)
                   throws hero.util.HeroException
Tries to start an activity (when activity state is ready or anticipable)

Parameters:
projectName - the name of the project
nodeName - the name of the node
Throws:
hero.util.HeroException

terminateActivity

public void terminateActivity(java.lang.String projectName,
                              java.lang.String nodeName)
                       throws hero.util.HeroException
Tries to terminate an activity (when activity state is executing or anticipating)

Parameters:
projectName - the name of the project
nodeName - the name of the node
Throws:
hero.util.HeroException

cancelActivity

public void cancelActivity(java.lang.String projectName,
                           java.lang.String nodeName)
                    throws hero.util.HeroException
Tries to cancel an activity (when activity is executing or anticipating)

Parameters:
projectName - the name of the project
nodeName - the name of the node
Throws:
hero.util.HeroException

terminate

public void terminate(java.lang.String projectName)
               throws hero.util.HeroException
Tries to terminate a project (only when all project activities are terminated)

Parameters:
projectName - the name of the project
Throws:
hero.util.HeroException

getNode

public hero.interfaces.BnNodeValue getNode(java.lang.String projectName,
                                           java.lang.String nodeName)
                                    throws hero.util.HeroException
Get Node Value from a specific project

Parameters:
projectName - the name of the project
nodeName - the name of the node
Returns:
a NodeValue object - get node information
Throws:
hero.util.HeroException

getUser

public java.lang.String getUser()
Get the user name

Returns:
a String - get user name

getUserLightValue

public hero.interfaces.BnUserLightValue getUserLightValue()
                                                   throws hero.util.HeroException
Get the user light value

Returns:
a BnUserLightValue object - get user information
Throws:
hero.util.HeroException

getUserMail

public java.lang.String getUserMail(java.lang.String userName)
                             throws hero.util.HeroException
Get the mail of this user from Bonita database.

Parameters:
userName - the name of the user
Throws:
hero.util.HeroException

setUserMail

public void setUserMail(java.lang.String userName,
                        java.lang.String mail)
                 throws hero.util.HeroException
Set the mail of this user into Bonita database.

Parameters:
userName - the name of the user
Throws:
hero.util.HeroException

getUserPassword

public java.lang.String getUserPassword()
                                 throws hero.util.HeroException
Get the user password

Returns:
a String - get user password
Throws:
hero.util.HeroException

getUserProperties

public java.util.Collection getUserProperties()
                                       throws hero.util.HeroException
Get User properties

Returns:
a BnUserPropertyValue Collection - list of user properties
Throws:
hero.util.HeroException

setUserProperty

public void setUserProperty(java.lang.String key,
                            java.lang.String value)
                     throws hero.util.HeroException
Set a property of a user

Parameters:
key - the key of the property
value - the name of the property
Throws:
hero.util.HeroException

deleteUserProperty

public void deleteUserProperty(java.lang.String key)
                        throws hero.util.HeroException
Delete a property of a user

Parameters:
key - the key of the property
Throws:
hero.util.HeroException

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Creates the User Session Bean. This method is the first one to invoke in order to use UserSession API. If the user is not authorized this method throws an exception.

Throws:
javax.ejb.CreateException

setSessionContext

public void setSessionContext(javax.ejb.SessionContext context)
Internal Enterprise Java Beans method.

Specified by:
setSessionContext in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
Internal Enterprise Java Beans method.

Specified by:
ejbRemove in interface javax.ejb.SessionBean

ejbActivate

public void ejbActivate()
Internal Enterprise Java Beans method.

Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Internal Enterprise Java Beans method.

Specified by:
ejbPassivate in interface javax.ejb.SessionBean