Reader small image

You're reading from  Bonita Open Solution 5.x Essentials

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781782167082
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Rohit Bhat
Rohit Bhat
author image
Rohit Bhat

Rohit Bhat is a Computer Science graduate from BITS Pilani, India and is currently working as a Software Specialist in Opera Solutions. He has done projects in a variety of fields of technology encompassing Data Mining, Android Apps, Open CV, Swarm Intelligence, Workflow Automation, and Video Conferencing. He has been extensively using Bonita Open Solution for Workflow Automation and Business Process Modeling for a number of clients for his company. You might find him surfing the Internet for any kind of knowledge and news, or plonked on his bed with a book in his hands. He loves to keep himself abreast of the latest technology and is a gadget freak. He is always ready for a discussion about any topic under the sun. He has a myriad interest in business, startups, entrepreneurship, finance, and current affairs. However, he is always excited to go on trips and tours, especially nature trails and trekking, with a camera around his neck. Apart from reading, he likes to pen his thoughts and is a freelance blogger, too. He can play the keyboard but wishes he had more time to learn a new instrument. He loves to listen to psychedelic, slow, and alternative rock. You can say "Hi" to him at mail@rohitbhat.com. This is his first book as an author. He is, however, a reviewer of Packt's Android Application Programming with OpenCV, published a couple of months ago.
Read more about Rohit Bhat

Right arrow

Chapter 2. Variable Types and Scope

There are many types of variables that can be used in Bonita Studio that are essential in creating processes. This chapter introduces all the variables available and also explores their scope.

Pool variables versus step variables


Bonita gives us the options to create two kinds of variables with regard to scope: pool variables and step variables. Pool variables are akin to global variables in any programming language and step variables correspond to the local variables of a function.

The type of variables, integers or text, are the same for both pool and step variables. Only their scope differs. For example, there might be an integer variable such as an ID number that might be required in all the steps of the workflow. We would have to make this a pool variable so that it can be accessed by all steps. On the other hand, one of the steps might have a field, called name, which might be required only at that step. Hence, it makes sense to make name a step variable that is accessible only by that step.

To define a pool variable, select the pool and click on the Data tab in the details panel. We can add the variables by clicking on the Add... button. Similarly, to define a step variable...

The text variable


The text variable is used to hold text of all kinds in Bonita. Note that this variable is of the type string of Java, found in java.lang.String. The Multiplicity option is used to select whether the variable is a single string variable or an array of strings. We can also state the default value that this variable will take. If left blank, the variable will be initialized to null, the way Java Strings are initialized. This variable is used to store any kind of text value in Bonita.

The variable List of Options... contains a list of text variables that can be used in drop-down boxes or radio buttons. When we select the List of Options... as the data type, a box appears where we define the list that we want to populate. Let's name this list Smartphones. Click on the Add... button, type in Apple, and click on OK. Similarly, add more options. such as Samsung, HTC, and Nokia. We can also rearrange the list options by clicking on the Up and Down tabs. After we have created the...

The Boolean variable


The Boolean variable holds Boolean values, that is, true or false, and is of the type Boolean of Java, found in the package java.lang.Boolean. Its multiplicity can be single or it can be an array of Boolean values. The default value of this variable, if left blank, is null.

The integer variable


Bonita Studio offers integer variables, but they are of the Java type Long (java.lang.Long). Be sure to initialize the integer value here, and if you want to use it for counting or keeping track of a sum of integer values, then give the default value as 0.

Tip

When using external connectors or Java code for evaluating the integer variable, beware that the type of the integer variable is not Integer but Long.

The float variable


In addition to the Integer variable, if we want to deal with decimal points and large numbers, Bonita offers the float variable, which is of the Java type Double (java.lang.Double). You can use the float variable for calculating money values, and so on.

The date variable


The date variable is used to store date values, for example, the date that the date-picker widget is in the Web application stores. It is of the Java type Date (java.util.Date). In addition, while defining the default value of this variable, we are given the option to choose it from a date picker that displays the date and time in a grid fashion.

Figure 2.2: The date variable wizard

Also, the default value can be set to Now, which takes the date and time at execution. This feature is useful in most scenarios when we want to display the default date and time as the time when the end user comes across this variable.

The attachment variable


The attachment variable is used to store any file attachment in Bonita. As the attachment is internally stored in the database as Binary Large Object (BLOB), this gives the flexibility to store any kind of file attachment, regardless of the extension.

The maximum size of the attachment can be 15 MB. The attachment variable is primarily used in the file widget while creating web forms. Whenever the user clicks on any file object from his system, it is uploaded into the Bonita database and stored as an attachment variable.XML Variable.

Another way we can represent data in Bonita Studio is to use an XML variable to store data in the XML format. Relevant data can be represented in a concise way using XML. For creating this variable in Bonita, simply select the data type as XML. Here, we have to choose the XML namespace and element for the data. We can also add a new schema by importing an XSD file.

The Java variable


This variable is the most useful custom variable that Bonita provides. We have the ability to create Java classes and export them into a jar file from any IDE or Java command line. This jar file can be added to the classpath of Bonita. Thereafter, we can create a new Java object of the type of the class that we have created. Let us see how to do this:

  1. Open up an IDE, such as IntelliJIdea or Eclipse. Create a new Java project and a package inside src. Here, we will name it com.rohitbhat.examplepackage. Inside this package, create a new class named TestClass. Enter the following code in it:

    public class TestClass {
      private String testString;
      private int testInt;
    
      public TestClass() {
        this.testString = "";
        this.testInt = 0;
      }
    
      public String getTestString() {
        return testString;
      }
    
      public void setTestString(String testString) {
        this.testString = testString;
      }
    
      public int getTestInt() {
        return testInt;
      }
    
      public void setTestInt(int testInt...

Summary


We have looked through the various types of variables that are available for use in Bonita Studio. We now also know how to initialize these different kinds of variables, and also which variable to use in a particular context. Any kind of information that has to be saved in the workflow can be saved in different kinds of variables. In the next chapter, we will use these variables to create web forms.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Bonita Open Solution 5.x Essentials
Published in: Nov 2013Publisher: PacktISBN-13: 9781782167082
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Rohit Bhat

Rohit Bhat is a Computer Science graduate from BITS Pilani, India and is currently working as a Software Specialist in Opera Solutions. He has done projects in a variety of fields of technology encompassing Data Mining, Android Apps, Open CV, Swarm Intelligence, Workflow Automation, and Video Conferencing. He has been extensively using Bonita Open Solution for Workflow Automation and Business Process Modeling for a number of clients for his company. You might find him surfing the Internet for any kind of knowledge and news, or plonked on his bed with a book in his hands. He loves to keep himself abreast of the latest technology and is a gadget freak. He is always ready for a discussion about any topic under the sun. He has a myriad interest in business, startups, entrepreneurship, finance, and current affairs. However, he is always excited to go on trips and tours, especially nature trails and trekking, with a camera around his neck. Apart from reading, he likes to pen his thoughts and is a freelance blogger, too. He can play the keyboard but wishes he had more time to learn a new instrument. He loves to listen to psychedelic, slow, and alternative rock. You can say "Hi" to him at mail@rohitbhat.com. This is his first book as an author. He is, however, a reviewer of Packt's Android Application Programming with OpenCV, published a couple of months ago.
Read more about Rohit Bhat