Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

On demand business process life cycle, Part 8: Business process monitoring - Creating key performance indicators

Return to article


Query historical events
				------------------------------------------------------------------------
public boolean start() {
 boolean result = true;
 try {
  //Get Event Access EJB
  …

  //get OTMPS start events
  CommonBaseEvent [] mmStartCbes = 
eAccessEjb.queryEventsByEventGroup(EventSelectors.START_EVENT_GROUP, 
EventSelectors.MILESTONEMANAGER_EVENT_SELECTOR, true);
			
  //for every start event get the related events and
  //initialize the corresponding metric classes
  for (int i = 0; i < mmStartCbes.length; i++) {
   // create OTMPSStartEvent
   OTMPSStartEvent otmpsStartEvent = new 
OTMPSStartEvent(mmStartCbes[i]);
				
   // get the context id from the start event
   String contextId = otmpsStartEvent.getContextId();
				
   //complete the context event selector
   Object [] args = {contextId};
   String contextEventSelector = 
EventSelectors.contextEventSelector.format(args);

   // get the corresponding stop event
   CommonBaseEvent [] stopCbes = 
eAccessEjb.queryEventsByEventGroup(EventSelectors.STOP_EVENT_GROUP,
contextEventSelector, true);
				
   //if the process instance has not stopped yet then 
skip to the next instance we will revisit this process instance when we 
receive the stop event
   if (stopCbes.length > 0) {
    OTMPSStopEvent otmpsStopEvent = new 
OTMPSStopEvent(stopCbes[0]);
					
    //get the corresponding orders data event
    CommonBaseEvent [] ordersDataCbes = 
eAccessEjb.queryEventsByEventGroup(EventSelectors.ORDERS_DATA_EVENT_GRO
UP, contextEventSelector, true);
					
    OrdersDataEvent ordersDataEvent = new 
OrdersDataEvent(ordersDataCbes[0]);
						
   //create ThroughPut metric and add it to 
ThroughPutCollection
    ThroughPut throughPut = new 
ThroughPut(otmpsStartEvent, ordersDataEvent, otmpsStopEvent);
				
 ThroughPutCollection.eINSTANCE.addMetric(throughPut);
					
    //create Outcome metric and add it to 
OutcomeCollection
    Outcome outcome = new Outcome(otmpsStopEvent);
				
 OutcomeCollection.eINSTANCE.addMetric(outcome);
					
    //get the corresponding invalid orders data 
event which is created by a sub-process therefore we need to first get 
the sub-process start 
  String validationSubprocessEventSelector =
EventSelectors.validationSubprocessEventSelector.format(args);
    CommonBaseEvent [] vpStartCbes = 
eAccessEjb.queryEventsByEventGroup(EventSelectors.START_EVENT_GROUP, 
validationSubprocessEventSelector, true);
					
    if (vpStartCbes.length > 0){
     // get the context id from the start 
event
     String vpContextId = 
Event.getContextId(vpStartCbes[0]);
				
     //complete the context event selector
     Object [] vpArgs = {vpContextId};
     String vpContextEventSelector = 
EventSelectors.contextEventSelector.format(vpArgs);

     CommonBaseEvent [] invalidOrdersDataCbes = eAccessEjb.queryEventsByEventGroup
(EventSelectors.INVALID_ORDERS_DATA_
EVENT_GROUP, vpContextEventSelector, true);
						
     if (invalidOrdersDataCbes.length > 0) {
      InvalidOrdersDataEvent 
invalidOrdersDataEvent = new InvalidOrdersDataEvent 
(invalidOrdersDataCbes[0]);
		
      //create NumberOfInvalidOrders 
metric and add it to NumberOfInvalidOrdersCollection
      NumberOfInvalidOrders 
numberOfInvalidOrders = new 
NumberOfInvalidOrders(invalidOrdersDataEvent);
						
 NumberOfInvalidOrdersCollection.eINSTANCE.addMetric(numberOfInvalidOrders);
     }
    }
   }
  }
			
  //get ExceptionHandler start events
  CommonBaseEvent [] ehStartCbes = 
eAccessEjb.queryEventsByEventGroup(EventSelectors.START_EVENT_GROUP, 
EventSelectors.EXCEPTIONHANDLER_EVENT_SELECTOR, true);
			
  //for every start event get the related events and
  //initialize the corresponding metric classes
  …
		
 } catch (Exception e) {
  e.printStackTrace(System.out);
  result = false;
 }

 return result;
}

Return to article