The Bonita workflow system allows the programmers to access the values of XPDL variables (both process and activity variables) by means of its application programming interface (API). That access is provided by 2 methods, part of the QueryRuntimeAPI object:
getVariable()getActivityInstanceVariable()
They receive the UUID (Universally Unique IDentifier) of the activity to be used as a reference to get the data and a string with the name of the variable in the XPDL file (process model). In turn, they return a Java object of type java.lang.Object that must be cast to the appropriate Java type, according to the type defined for the variable.
In Nova Bonita 4.0.1, the match between XPDL variable types and Java objects is as follows:
| XPDL Variable Type (ProEd) | Java Object (Bonita API) |
|---|---|
| Integer | java.lang.Long |
| Float | java.lang.Double |
| Boolean | java.lang.Boolean |
| Date | java.util.Date |
| String | java.lang.String |
| Enumeration | org.ow2.bonita.facade.runtime.var.Enumeration |
The Enumeration Java object is part of the Bonita API and provides 2 methods to access of the Enumeration variables:
getPossibleValues(): Returns a java.util.Set of Strings with the list of possible values that this variable can take. Those values are the ones defined by the process developer or business analyst in the ProEd designer.getSelectedValue(): This method returns a String with the value of the variable. It is always going to be one of the possible values defined in the ProEd designer and it will be part of the list of values returned by thegetPossibleValues()method.
Example
As an example, the Java code to access an Integer variable called "myInteger" would look like as follows:
APIAccessor a =AccessorUtil.getAPIAccessor();
QueryRuntimeAPI q = a.getQueryRuntimeAPI();
Object o = q.getVariable(activityUUID, "myInteger");
Long l= (Long)o;
long number = l.longValue();

0 comment(s):
Post a Comment