cancel
Showing results for 
Search instead for 
Did you mean: 

The best way to get data from Mysql DB

bargan
Champ in-the-making
Champ in-the-making
Hi all,
I want to create a custom vacation request process.
In my project i have to add somme users in the activiti Mysql DB (i add them in act_user_id), and i create two other tables calls service (this table contains ids, names of services and manager_name) and  a table relationship (id_user and id_serivce) contains foreign key of id_service and ID_ (id of table act_user_id).
So in my process, when a user log on in activiti-explorer, he'll fill and validate the form, if this current user is manager his request will be sent directly to RH manager, else, if the current user is sample employee his request will be send to his manager to validate it.

My questions are:
1) am i right to create ohter users and tables in activiti DB?

2) How can i get the current user ( should i use serivceTask and implemsts a java code and sql queries or other there is other choice)?

3) To store the result of this java class should i use resultVariable ?
4) at last, how can i do the unit test for this ServiceTask to test if i get the true result?

please help for any thing suggestion, links or examples
Thank you
6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

1) am i right to create ohter users and tables in activiti DB?
It is possible. On the other hand engine upgrade can be more difficult.
Another possibility is to use expression to get user's manager.

2) How can i get the current user ( should i use serivceTask and implemsts a java code and sql queries or other there is other choice)?
You can use authenticatedUserId in expressions
http://www.activiti.org/userguide/#apiExpressions

3) To store the result of this java class should i use resultVariable ?
If the class implements JavaDelegate interface you can create/update any process variable.
4) at last, how can i do the unit test for this ServiceTask to test if i get the true result?
http://www.activiti.org/userguide/#apiUnitTesting

Regards
Martin

Thank you Martin,
For the first question, can you please give me an example for how using expressions to get the user's manager.

regards

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

for example you can use beans in expressions to get result.

http://www.activiti.org/userguide/#exposingConfigurationBeans
http://www.activiti.org/userguide/#N10A60

Regards
Martin

bargan
Champ in-the-making
Champ in-the-making
Thank you for your response.
Sorry i have an other question: When i try to test my activiti projetc i get this error:
""couldn't check if tables are already present using metadata.
#Error getting a new connection. Cause: java.sql.ESQLException: No suitable driver found for jdbc.mysql://localhost:3306/activiti"".

All Jars are on the projct ( jdbc.mysql, … etc) , also pom.xml and activiti.cfg.xml are configured.

regards,

bargan
Champ in-the-making
Champ in-the-making
oh i resolved it,
In act.cfg.xml, i made an error "jdbc.mysql://localhost:3306/activiti",  replaced it by "jdbc:mysql://localhost:3306/activiti"

regards,

bargan
Champ in-the-making
Champ in-the-making
oh i resolved it,
In act.cfg.xml, i made an error "jdbc.mysql://localhost:3306/activiti",  replaced it by "jdbc:mysql://localhost:3306/activiti"

regards,