Bonita Connector
Bonita Connector
Bonita Connector
Oszkr Semerth
April 6, 2014
Gbor Szrnyas
Contents
1 Integrating Bonita
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SoapUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
Chapter 1
Integrating Bonita
Source code snippets and URLs are available in https://svn.inf.mit.bme.hu/edu/trunk/mdsd/handout/public/
2014/.
A detailed guide in Hungarian is available in https://njszt.hu/sites/default/files/Informatikai-Navigator-10.pdf.
1.1 Introduction
1. Start the Bonita BPM Community application and choose the ApplicationStore (1.0) process.
2. Start the workflow and inspect it. The Show the application names step shows the applications available
in our application store. Currently this list is generated by the Groovy connector of the Download the
application names task.
3. Go to the Connectors of the Download the application names task and delete the Groovy connector.
@Override
protected void executeBusinessLogic() throws ConnectorException {
//Get access to the connector input parameters
//WARNING : Set the output of the connector execution.
//If outputs are not set, connector fails
List<String> applications = new ArrayList<String>();
applications.add("App1");
Edit the
applications.add("App2");
setApplications(applications);
}
5. The connector can be tested in Development | Connectors | Test connector. Choose the ApplicationConnector and click Test and OK.
6. Add this connector to the Download the application names task. On the Output operations page, set that
the applications variable takes the value of the applications output of the connector.
7. Delete the connector from the Download the application names task.
8. Test the workflow.
1. In this section, we integrate our workflow with a MySQL database. Start the MySQL Workbench 6.0 CE
application.
2. Choose the SQL development section and select the applications database.
3. The username and password are both root.
4. An SQL development environment will appear. We have created a database table for the workflow: select the
application table in the applications database, right click and select Select Rows - Limit 1000.
5. The query and the results will appear with the applications Flashlight, News and Weather.
6. Go back to Bonita. Select the Download the application names task and add a MySQL 5.5 JDBC4 database
query connector. Name it MySQLConnector and click Next.
7. On the Database access information page, set the following and click Next:
Driver: com.mysql.jdbc.Driver
URL: jdbc:mysql://localhost:3306/applications
Username: root
Password: root
8. On the Enter query page, use the Switch editor button to switch to a single line editor (defining a Constant
expression). Else you would get an error message (Unsupported expression type for testing: . . . ).
Set the Query or Batch Script field in the next page:
def res = []
while (resultset.next()) {
res.add(resultset.getString("name"))
}
res
Set the return type to java.util.List
11. Use the Back button and press Test. The connector should work now and list the applications available in the
database.
SoapUI
SoapUI (http://www.soapui.org/) is a tool capable of generating SOA envelopes from the WSDL file.
Just create a New SOAP Project, add the ApplicationManager.wsdl WSDL file as Initial WSDL. Tick Create
Requests and click OK. The SOA envelope will be generated.
and add a SOAP Web Services | WebService SOAP 1.2 and name it
ApplicationRestConnector.
Figure 1.5: Using the Advanced REST client for accessing the REST service
@Override
protected void executeBusinessLogic() throws ConnectorException {
ArrayList<String> results;
URL url;
try {
url = new URL("http://localhost:80/appstore-rest/rest/applicationmanager/generate/3");
} catch (MalformedURLException e1) {
throw new ConnectorException(e1);
}
URLConnection connection;
try {
connection = url.openConnection();
Document document = parseXmlDom(connection.getInputStream());
results = new ArrayList<String>();
NodeList apps = document.getElementsByTagName("applications").item(0)
.getChildNodes();
for (int i = 0; i < apps.getLength(); i++) {
results.add(apps.item(i).getTextContent());
}
} catch (IOException e) {
throw new ConnectorException(e);
}
setResults(results);
}
public static Document parseXmlDom(InputStream is) {
Document document = null;
try {
// getting the default implementation of DOM builder
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setIgnoringComments(true);
dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
DocumentBuilder builder = dbf.newDocumentBuilder();
9
<dependency>
<groupId>org.bonitasoft.engine</groupId>
<artifactId>bonita-client</artifactId>
<version>6.2.6</version>
</dependency>
Do not forget to set the version to the actual version number of your Bonita installation.
The BonitaAPI.zip file in https://svn.inf.mit.bme.hu/edu/trunk/mdsd/handout/public/2014/bonita_connector_
materials/ contains an example Java code.
10