Skip to main content

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.

Jump to: navigation, search

Stardust/Knowledge Base/API/JavaAPICookbook/FetchingPIandAIHistoricalEvents

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());        
 
     }           
}

Copyright © Eclipse Foundation, Inc. All Rights Reserved.