Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Stardust/Knowledge Base/API/JavaAPICookbook/FetchingPIandAIHistoricalEvents"
< Stardust | Knowledge Base
(→Purpose) |
(→Process Instance Historical Events:) |
||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
<source lang="java"> | <source lang="java"> | ||
− | + | ProcessInstanceFilter filter = new ProcessInstanceFilter(piOID); //Pass in the Process instance OID | |
− | + | ActivityInstanceQuery query = new ActivityInstanceQuery(); | |
− | + | query.where(filter); | |
− | + | query.setPolicy(HistoricalEventPolicy.ALL_EVENTS); | |
− | + | query.orderBy(ActivityInstanceQuery.START_TIME); | |
− | + | ActivityInstances actInstList = qs.getAllActivityInstances(query); | |
− | + | for(ActivityInstance actInst: actInstList){ | |
− | + | ActivityInstanceHistory actHistory | |
− | + | = new ActivityInstanceHistory(actInst.getOID(), | |
− | + | actInst.getActivity().getId(), | |
− | + | actInst.getHistoricalEvents()); | |
− | + | } | |
</source> | </source> | ||
Line 25: | Line 25: | ||
<source lang="java"> | <source lang="java"> | ||
− | + | ProcessInstanceQuery piQuery = ProcessInstanceQuery.findAlive(); | |
− | + | piQuery.setPolicy(HistoricalEventPolicy.ALL_EVENTS); | |
− | + | ProcessInstances pis = qs.getAllProcessInstances(piQuery); | |
− | + | for (Iterator iterator = pis.iterator(); iterator.hasNext();) { | |
− | + | ProcessInstance pi = (ProcessInstance) iterator.next(); | |
− | + | //log.info("PI: " + pi.getOID()); | |
− | + | ProcessInstanceDetails details = (ProcessInstanceDetails)pi; | |
− | + | List<HistoricalEvent> events = details.getHistoricalEvents(); | |
− | + | for (HistoricalEvent historicalEvent : events) { | |
− | + | System.out.println("PI:" + pi.getOID() + " Event time:" + historicalEvent.getEventTime()); | |
− | + | System.out.println("PI:" + pi.getOID() + " Event type:" + historicalEvent.getEventType()); | |
− | + | System.out.println("PI:" + pi.getOID() + " Event details :" + | |
historicalEvent.getDetails()); | historicalEvent.getDetails()); | ||
− | + | } | |
− | + | } | |
</source> | </source> |
Latest revision as of 01:38, 11 April 2014
Purpose
This article describes how to fetch Process Instance and Activity Instance related Historical Events like Time, Type and Details..etc,
based on the defined Historical Event Policy.
Activity Instance Historical Events:
ProcessInstanceFilter filter = new ProcessInstanceFilter(piOID); //Pass in the Process instance OID ActivityInstanceQuery query = new ActivityInstanceQuery(); query.where(filter); query.setPolicy(HistoricalEventPolicy.ALL_EVENTS); query.orderBy(ActivityInstanceQuery.START_TIME); ActivityInstances actInstList = qs.getAllActivityInstances(query); for(ActivityInstance actInst: actInstList){ ActivityInstanceHistory actHistory = new ActivityInstanceHistory(actInst.getOID(), actInst.getActivity().getId(), actInst.getHistoricalEvents()); }
Process Instance Historical Events:
ProcessInstanceQuery piQuery = ProcessInstanceQuery.findAlive(); piQuery.setPolicy(HistoricalEventPolicy.ALL_EVENTS); ProcessInstances pis = qs.getAllProcessInstances(piQuery); for (Iterator iterator = pis.iterator(); iterator.hasNext();) { ProcessInstance pi = (ProcessInstance) iterator.next(); //log.info("PI: " + pi.getOID()); ProcessInstanceDetails details = (ProcessInstanceDetails)pi; List<HistoricalEvent> events = details.getHistoricalEvents(); for (HistoricalEvent historicalEvent : events) { System.out.println("PI:" + pi.getOID() + " Event time:" + historicalEvent.getEventTime()); System.out.println("PI:" + pi.getOID() + " Event type:" + historicalEvent.getEventType()); System.out.println("PI:" + pi.getOID() + " Event details :" + historicalEvent.getDetails()); } }