Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Stardust/Knowledge Base/API/ExamplesofAPIUsage/ActivityEventHibernateInitially"
< Stardust | Knowledge Base
m (STP/Stardust/KnowledgeBase/API/ExamplesofAPIUsage/ActivityEventHibernateInitially moved to Stardust/Knowledge Base/API/ExamplesofAPIUsage/ActivityEventHibernateInitially) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | == Checking Activity Events, Hand to Hand activity, Hibernate Initially (Runtime) | + | == Checking Activity Events, Hand to Hand activity, Hibernate Initially (Runtime) == |
− | ==== Purpose<br> ==== | + | ==== Purpose<br> ==== |
There are certain instances when you want to find out the following during process execution(Runtime): | There are certain instances when you want to find out the following during process execution(Runtime): | ||
− | *If an Activity has configured events at design time.<br> | + | *If an Activity has configured events at design time.<br> |
*If an Activity has "Hibernate Initially" checked during design time. | *If an Activity has "Hibernate Initially" checked during design time. | ||
*What are the closest activities from a certain activity. Following code would help you achieve this, You will have to retrieve the Model Object, retrieve a specific process definition, or get all the process within a model. <br> | *What are the closest activities from a certain activity. Following code would help you achieve this, You will have to retrieve the Model Object, retrieve a specific process definition, or get all the process within a model. <br> | ||
− | Please Note: How you retrieve the model object would depend from where you execute this function, client or server side. | + | Please Note: How you retrieve the model object would depend from where you execute this function, client or server side. |
− | ==== Sample Model ==== | + | ==== Sample Model ==== |
[[Image:Stardust ActivityEvent Hibernate.png|575x250px|Stardust Activity Event and Hibernate Initially]] <source lang="java"> | [[Image:Stardust ActivityEvent Hibernate.png|575x250px|Stardust Activity Event and Hibernate Initially]] <source lang="java"> | ||
Line 57: | Line 57: | ||
IActivity activity = (IActivity) pDef.getActivities().get(i); | IActivity activity = (IActivity) pDef.getActivities().get(i); | ||
− | System.out.println("Activity Name : + activity.getName()); | + | System.out.println("Activity Name :" + activity.getName()); |
// checks is hibernate on creation flag is set | // checks is hibernate on creation flag is set | ||
Line 83: | Line 83: | ||
} | } | ||
} | } | ||
− | </source> | + | </source> |
+ | |||
+ | Above function will return the following: | ||
+ | |||
+ | *Activity Names | ||
+ | *Hibernate : true/false (if checked during activity creation) | ||
+ | *Handler: Timer event Name | ||
+ | *To Activity: The closest activities this activity can reach out to. Similar Iterations can be done for other event types. <br><br> |
Latest revision as of 11:04, 25 June 2013
Checking Activity Events, Hand to Hand activity, Hibernate Initially (Runtime)
Purpose
There are certain instances when you want to find out the following during process execution(Runtime):
- If an Activity has configured events at design time.
- If an Activity has "Hibernate Initially" checked during design time.
- What are the closest activities from a certain activity. Following code would help you achieve this, You will have to retrieve the Model Object, retrieve a specific process definition, or get all the process within a model.
Please Note: How you retrieve the model object would depend from where you execute this function, client or server side.
Sample Model
import java.io.File; import java.util.Iterator; import ag.carnot.bpm.client.common.ModelCache; import ag.carnot.workflow.model.IModel; import ag.carnot.workflow.model.IProcessDefinition; import ag.carnot.workflow.model.IActivity; import ag.carnot.workflow.model.IEventHandler; import ag.carnot.workflow.model.ITransition; import ag.carnot.workflow.model.xpdl.XpdlUtils; import ag.carnot.workflow.runtime.QueryService; import ag.carnot.workflow.runtime.ServiceFactory; import ag.carnot.workflow.runtime.ServiceFactoryLocator; import ag.carnot.workflow.runtime.WorkflowService; public class WorkList { static IModel model; // this should be cached / fetched from the ModelCache static String modelRBname; public void getWList(){ ServiceFactory sf = ServiceFactoryLocator.get("motu","motu"); WorkflowService wfs = sf.getWorkflowService(); QueryService qs = null; qs = sf.getQueryService(); //Get model if this routine runs server side. //IModel model = (IModel) ModelCache.findModelCache().getAllModels(); //Get model if this routine runs client side. //IModel model = XpdlUtils.loadXpdlModel(new File("E:\\Worklist.xpdl")); IModel model = ModelManagerFactory.getCurrent().findActiveModel(); for (int k=0; k <model.getProcessDefinitions().size(); k++) { IProcessDefinition pDef = (IProcessDefinition) model.getProcessDefinitions().get(k); for (int i=0; i<pDef.getActivities().size(); i++) { IActivity activity = (IActivity) pDef.getActivities().get(i); System.out.println("Activity Name :" + activity.getName()); // checks is hibernate on creation flag is set boolean isHibernateOnCreattion = activity.isHibernateOnCreation(); System.out.println("Hibernate: " + isHibernateOnCreattion); // retrieves all timer events for (Iterator _iterator = activity.getAllEventHandlers("timer"); _iterator.hasNext();) { IEventHandler eventHandler = (IEventHandler) _iterator.next(); System.out.println("Handler: " + eventHandler.getName()); } // gets all possible to activities for (int j=0; j<activity.getOutTransitions().size(); j++) { ITransition transition = (ITransition) activity.getOutTransitions().get(j); IActivity toActivity = transition.getToActivity(); System.out.println("To Actvitiy: " + toActivity.getName()); } } } sf.close(); } }
Above function will return the following:
- Activity Names
- Hibernate : true/false (if checked during activity creation)
- Handler: Timer event Name
- To Activity: The closest activities this activity can reach out to. Similar Iterations can be done for other event types.