Showing posts with label bonita. Show all posts
Showing posts with label bonita. Show all posts

June 18, 2012

How to fetch data from custom external DB in bonita using groovy

How to fetch data from custom external DB in bonita using groovy.
Following is the code snippet to fetch data list from external DB. Let say,we want to fetch data from MYSQL. 1) Make connection with MySQL 2) Make query and specify column 3) Make output string

import groovy.sql.Sql;
import com.mysql.jdbc.Driver;

def result = []
Sql sql = providedscripts.BonitaSql.newInstance("jdbc:mysql://localhost:
3306/custdb","root","root", new com.mysql.jdbc.Driver())

sql.eachRow 'select * from table_name;', { result += it.col_name }
sql.close()

result
Please let me know for any further clarifications.

Fetch Email of users whom tasks has been assigned in bonita using bonita runtime and identity API

Following is the code snippet, through which, we can fetch users lists with emails of assigned one:

import org.ow2.bonita.util.AccessorUtil
 def candidates = AccessorUtil.getQueryRuntimeAPI().getTaskCandidates
(activityInstance.getUUID())
 def to=""
 for(user in candidates){
 if(to!="") to+=","
 // If Emails are not stored in Bonita User Experience, 
//please adapt the next line to get email from your system
 to+=AccessorUtil.getIdentityAPI().getUser(user).getEmail()
 }
 return to