Business Process enhancement: Arbitrary Context/Context Data for metrics
Business Processes now let you store Arbitrary Context/Context Data for use with calculating metrics for a business process. The contextClassName attribute specifies the fully qualified name of the class of the context data – this can be a Collection for storing Lists or Sets of arbitrary java objects. Arbitrary Context adds additional flexibility in the way that BP metrics can be calculated. Without it, only metrics that could be derived solely from the context of the current datapoint were possible (the 2 below examples were not possible before; Some metric (numeric values) couldn't be calculated/evaluated from the data in the current datapoint alone).
- if you wanted to calculate how many times an attribute changes you need additional context, i.e. the last known value of the attribute. The last known value can be stored in the BP metrics evaluation context, that is now available. Counting the number of user changes, the BP would be configured with a “java.lang.String” context object that hold the last username, for each datapoint the username is compared to the context value (in the “evaluateExpr”) and if it matches nothing needs to be done, but if it is different, the metricValue is incremented and the context is updated to the current username.
- Another example could be count the number of distinct users involved in a BP. In this case the context object would be a “java.util.Set”. The “evaluateExpr” would check whether the current username is contained in the context. If it is, nothing needs to be done, but if it isn’t, the metricValue is incremented and the current username is added to the context.
- If you want to track the number of call transfers that occur (for our purposes, assume that the sessionId attribute of the data seen by the business process changes for each transfer), we can then configure the business process to have a String context and for each piece of data we will store the session and count how many times the session changes.
The evaluateExpr would be as follows (shown on multiple lines, but in the config a single line is fine)
If (context != data.sessionId) metricValue = metricValue + 1;
context = data.sessionId;