access to dbm from a java class filter

1
0
-1

Hello!!

Anybody know how can i access to the bdm database from a java class actor filter???

i know that database is a h2, and i need to access throw a jdbc but i haven't found how to make this.

please help.

9 answers

1
0
-1
This one is the BEST answer!

i got the solution.

I was making this bad, the only way to access to DAO variables is on a groovy script but not on the java class implementation, its over a single actor filter.

step by step.

1 construct your BDM.
2 on the step that you want filter users, clic on step and then go to actors.
3 on the actor filter button clic on set, you can make a single user, list of managers and those.
4 in my case i put Single user.
5 then click on edit.
6 put a name and a description and click on next.
7 click on the icon of the pencil.
8 select script
9 in my case i make this script.

`import java.util.logging.Logger

//final long processInstanceId = apiAccessor.getExecutionContext().getProcessInstanceId();
long processInitiator = apiAccessor.getProcessAPI().getProcessInstance(processInstanceId).getStartedBy();
String UserInitiator=apiAccessor.getIdentityAPI().getUser(processInitiator).getUserName();
Logger logger = Logger.getLogger("org.bonitasoft");
logger.severe("Usuario Iniciador: " + UserInitiator);
String reviewname="";

def us = usersDAO.findByUserinit(UserInitiator, 0, 10);
reviewname=us.get(0).userrev1;
logger.severe("Usuario Revisor: " + reviewname);
long IdManager=apiAccessor.getIdentityAPI().getUserByUserName(reviewname).getId();
return IdManager;`

on this case this script get the instanceid, and with that get the user that execute the process, i go for the DAO object, that have the name of the table+DAO(Every table that you create on the BDM have a DAO object) and i could access to the methods. and find a userreview custom.

11 click on finish.
12 run process.

i hope its clear, the DAO cant be reached on a JavaClass actor filter (class of the implementation), you can access on scripts but on connectors or things like that.

1
0
-1

And it also works with this:

def users = usersDAO.findByUserinit("juan", 0, 100)

return new Long(users[0].userrev1);

Same result, goes to william.jobs

1
0
-1

I have it working. Here is the actor filter code:

def users = usersDAO.buscauser("juan", 0, 100)

return new Long(users[0].userrev1);

I populated the data in the BDM so juan has 1 for userrev1 and 2 for userrev2. The task goes straight to william.jobs who has an id of 1

1
0
-1

Still not working...

tried everything, i am starting to think that i want to do its imposible to do.....

if anybody have an example of how should i do this step by step please please please help.

I deploy my BDM and this show that is correctly deploy but when i try to access on the groovy code, the error show that cant get the method.

groovy.lang.MissingMethodException: No signature of method: static com.company.model.usersDAO.buscauser() is applicable for argument types: (java.lang.String, java.lang.Integer, java.lang.Integer) values: [juan, 0, 100]

the method exist on the table of the BDM, but i don't know why the object DAO can't access to that method.

Comments

Submitted by joe.pappas on Thu, 04/05/2018 - 15:17

If you have a file sharing site drop your .bos file there and put link here

Submitted by abertiboni_1364056 on Thu, 04/05/2018 - 15:24
Submitted by abertiboni_1364056 on Thu, 04/05/2018 - 16:55

could you access???

Submitted by joe.pappas on Thu, 04/05/2018 - 17:20

working on another issue. will get to it this afternoon

Submitted by abertiboni_1364056 on Thu, 04/05/2018 - 17:22

Okay, and again thanks a lot for taking a time for help me its really appreciated.

Submitted by joe.pappas on Thu, 04/05/2018 - 19:25

For that custom query there are no int parameters:

SELECT u
FROM users u
WHERE u.userinit= :userinit
ORDER BY u.persistenceId

Just a String

Submitted by joe.pappas on Thu, 04/05/2018 - 19:26

Oh, I see what you're talking about now...one sec

1
0
-1

What does your Users object look like?

Comments

Submitted by abertiboni_1364056 on Wed, 04/04/2018 - 22:23

users is a table of the data model

this table have 3 columns

userinit, userrev1, userrev2

this table also have querys, and one of those querys is called findByUserinit.

i try to use the method calling him

def user=usersDAO.findByUsuarioInit("juan",0,100);

but i got an error always the same.

groovy.lang.MissingMethodException: No signature of method: static com.company.model.usersDAO.buscauser() is applicable for argument types: (java.lang.String, java.lang.Integer, java.lang.Integer) values: [juan, 0, 100]

any idea why is that wrong???

Submitted by joe.pappas on Wed, 04/04/2018 - 22:28

when you pull up the query with content assist what s the signature? String, Integer, Integer or String, Long, Long?

Submitted by abertiboni_1364056 on Wed, 04/04/2018 - 22:35

the definition of the interfase usersDAO, tell that method is defined

public List findByUserinit(String userinit, int startIndex, int maxResults);

but i tried to making this
List user=usersDAO.findByUsuarioInit("juan",0,100);

but i always got the same error, that the missing static.

about the question you make, content i have not tried, on a UI form to pull up, i will try to do that with the ../API to see if i can get access.

1
0
-1

You need to do something like

com.company.model.UsersDAO[] udao = (com.company.model.UsersDAO) usersDAO.find(0, 100);

then you should be able to access data inside the object like

udao[0].name etc

Comments

Submitted by abertiboni_1364056 on Wed, 04/04/2018 - 22:15

so, on groovy i can't access to the other methods?

can you please put an example!!!

i mean, do i need to do something before, like create a session variable or a conector or something like that???

please if you know how to do this please, explain that step by step.

1
0
-1

1
0
-1

For example, let's say you want to get back some data from a table called HotelRequest. In your script go to "Provided Variables" and you'll see hotelRequestDAO. Next, in your script you can access BDM queries like so:

hotelRequestDAO.(see methods of queries that are available)

It should return a List of objects you'll need to go through to get the data you need.

1
0
-1

Hello,
You'll need to access the DAO of the type you're trying to access.

yourBDMModelDAO.find and so on

Comments

Submitted by abertiboni_1364056 on Tue, 04/03/2018 - 17:42

Hello!

Thanks a lot for the help.

i have a question, when i access to my data, how can i interact with the columns of the table, i mean.

import com.company.model.users;
import com.company.model.usersDAO;

def user=usersDAO.findByUsuarioInit(UserInitiator,0,100);

i need to extract the column called usermanager1

but when i try

String reviewname=usuario[Usuariorevew1];

i am getting an error message.

No signature of method: static com.company.model.usersDAO.findByUsuarioInit() is applicable for argument types: (java.lang.String) values: [walter.bates]";

if somebody know how to do this please help step by step, i am new on bonita.

help please.

Notifications