Bonita Data Types
Let’s talk about handling data.
In Bonita BPM there are 4 different types of data.
There is business variables which is handled using the BDM system which we will go over in detail.
There are task level variables. This will be at the task itself.
As I click on “Do Something”, you can see we have Local Variables enabled below:
There are pool level variables which you can see as I select the pool.
The final type of data is external databases. These are accessed using connectors and custom data types and are stored in external databases.
Let’s talk about each of the different types.
The simplest to get started with are the pool level variables and you can see at the pool level, we have Business Variables and Process Variables. Business Variables integrate with the BDM. A Process level variable would be a simple data type that can be passed between tasks.
To give an example, let’s add a simple Boolean value which is a flag – a true or a false, named “moveForward”.
You can see the different data types here: Boolean, Date, Double, Integer, Java Object, Long, Text and XML.
For what we’re doing, we just need to have a Boolean and we’re gonna default it to False.
What this let us do is we can create some simple logic on the Pool itself so if I created a gateway here.
and I want this gateway to be an Exclusive gateway and we’re gonna give it a name of “Move forward?”. There you can see if it moves forward or not.
Out of that we’re gonna create “Do something else” and we’ll make this a human task…
or End it, if we don’t want it to move forward.
Then after this, we’ll take “Do Something Else” task directly to the same end process. We could create a second end state but for what we are trying to do, we’ll just keep it very very simple.
Now you can see once I’ve done this, there’s a little “x” showing in the gateway because “Move forward?” is exclusive. It should pick one or the other of these two routes and it doesn’t know which to take.
When you click on the “Move forward?” gateway, the validation status says “All output transitions must be default or conditional”
so what we can do is we can take this one and say “we don’t want it to move forward” – our default is False and so we are gonna select this point here and we’re gonna make this the default flow.
Then, we’re gonna take the second flow and we’re gonna use a variable moveForward and we’re gonna say moveForward == true or in this case we could have just use moveForward but this makes it a little bit more explicit.
Now, if we select our validations status and when we refresh, you can see that there are other things going on here.
We need to create forms for each one of these things. Since we’re not dealing with forms directly right now, we’re going to skip over these warnings. All they’re looking for is specific form to show on those human level tasks. It doesn’t matter for our data at this point but if we actually look at the data itself, you can see Boolean moveForward the default value is true. That’s at the Pool-level.
At a task-level, that would be something specific to a specific task. If we add in a new value, just something simple like shouldIMoveForward and mark it as a Boolean with a default value of True,
So shouldIMoveForward is now available to the “Do Something” task but it’s not available in the rest of the pool and it’s certainly not available on one of the other tasks. So these are generally a task-level local variable. It would be something that will be encapsulated within a task that does something.
The third type of data is called Business Objects or Business Data and this is handled using the Business Data Model System. I’m using the subscription version but both the community edition and all of these subscription editions have a business data model manager.
If I click into this, you can see we have the ability to create quite complex data types. If I went in and I change my package, this would be the package as it’s referenced in the rest of the system. Generally, the best way to do this would be to reverse the domain of your company that you are working for.
So if we say com.bonitatraining.model, that allows us to create data models that don’t collide with other systems. We could have com.yourcompany.model, com.mycompany.model. In this case, we’re gonna go with com.bonitatraining.model and we’re going to create a simple business object. We’re gonna call it an Invoice and we’ll give it a description.
You should always put a description because it becomes confusing otherwise. The description is “This is the general invoice object”.
Now, an Invoice always has an invoiceNumber or ID (we use ID as a better name for this). We’re gonna change the ID from a String data type to an Integer Data type. Then, a clientName which is a String. Then, dueDate with a data type Date.
Now, invoices generally have multiple lines. Similar to what we’re doing here, they would have a number of items that would be done say, 10 hours done on Tuesday; 4 hours done on Thursday or a product purchase of set value. You can see that that is difficult to do within a single business object but what we can do is add line items.
So, we add InvoiceLine with a description “the line item details for an invoice”.
Next, we add the attributes. Add “description” with a String data type and “price” as Double.
The difference between a double and an integer is that a double allows you to put in decimal places, so, it’s better for currency.
There are several other ones that we could put in there as well but for our purposes we’re just gonna do this as a simple double and that’s all we’re gonna add to that. We could of course make this significantly more complex but it’s not necessary right now.
Now that we got the InvoiceLine in place, we go back to the Invoice.
Add attribute “lines” of type InvoiceLine and select multiple.
You could also see that we would have to define an ID, clientName and dueDate as mandatory or not. To keep things simple right now, I’m just doing this as non-mandatory.
Within the business object itself you can see that there are queries for when you had to reference it to the database.
If you need to modify these things, you can using custom queries. Generally, the business object itself creates the simple details if you have some sort of stored procedures or something you wanted to work with, you could modify that.
Indexes allows you to make the system search faster. We could add details on those.
Unique constraints this would allow… for example: if we have a client name and we don’t want our own business name to show up as something to be invoiced, we could put it as a constraint as we don’t want that value in here.
Again, we’re trying to keep things simple so for the time being we just got the three details and the line items on the Invoice.
As we click Finish, it creates an XML file and zips it and stores it within our work space directory. Then, it deploys it to the local system so that it can be used in our diagrams.
Now, click the pool level diagram and create a business variable (this is a variable that references the BDM).
Hit Add and type “localInvoice”. Then, set the type to Invoice.
The “Default value” is where we can actually define some of those default settings: the ID Number, Company Name; that’s where you actually create the object.
This gets a little bit more into code so for the time being were just gonna leave it blank. We’ll go back to this later.
The final data type that’s available is the External Database data type and this is completely custom. So if we’re going to refer to some of that, what we would do is create some local data to reference the value that we’re looking for.
Select the task “Do Something” and click Add button in Local variables to create externalDataCopy
Add new local variable “externalDataCopy” and set data type to Text.
When we finish, what we can do is we can create a reference to that external database using the connector. That’s done at the execution level for the Connectors In.
I would like to add a connector to a database and there are quite a number of different database connectors available. We have Access, AS400, DB2, H2, Microsoft SQL Server, MySQL, Oracle… I mean, there are many different types that are here.
I’ll pick a simple one, let’s say MySQL 5.5 and name it lookupData. If the data is not available, do some different logic within the process itself. For the time being, we’re gonna say “Ignore error…”
Make sure that we have the .jar to make the connection that we need.
You can either use a graphical query builder or use a text editor. For me, it’s simpler to use a text editor. As a developer, I can go in and make the changes
Next, we enter username and password. In my case, it would be myUserName and password would be password.
Then, this is where you can create your scripts
It’s very simple SQL statement. This gives you the details to be able to pull the details from your external database. Again, this is completely freeform. It can be done using whatever database, datamodel you have in place.
Then, it comes back as a single value or we can just have to come back as a Scripting mode, it just makes things a little simpler.
Then, the value gets set: externalDataCopy Takes value of resultset
And in resultset we could scroll down here to see the values available within resultset.
It might be simplest to look for the value itself toString(). But, if we wanted to see the specific details of what’s coming in, we can go first() *assuming that there’s multiple results coming back* and then toString().
That gives us the details of the first result that’s coming back.
This is a very very quick overview of the data that comes in but you can see there are the 3 different types, we have:
- Pool level data with process variables within there.
- Task level data that is specific to an individual task.
- Business variables that are referenced through the business data model and
- Finally, external data run through external databases.
I hope this clears up the different data types for you. If you have any questions, let us know.