Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "Stardust/Knowledge Base/API/JavaAPICookbook/FetchingPIandAIHistoricalEvents"

()
()
Line 41: Line 41:
 
                             System.out.println("PI:" + pi.getOID() + " Event time:" +  historicalEvent.getEventTime());                                         
 
                             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 type:" + historicalEvent.getEventType());                                         
                             System.out.println("PI:" + pi.getOID() + " Event details :" +                     historicalEvent.getDetails());         
+
                             System.out.println("PI:" + pi.getOID() + " Event details :" + historicalEvent.getDetails());         
 
                                      
 
                                      
 
                         }           
 
                         }           

Revision as of 01:14, 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());        
 
                        }           
 
 
                     }

Back to the top