How to call process variable into user interface in bonita 7 [ need tutorial ]

1
0
-1

Hello guys,

I'm interested about BPM and I've installed bonita 5 and 7 in my computer.
I've created my process business into bpm modeling, and now i'm in phase of developing my business process into application ( UI Designer ).
In my modeling process, i've created a process variable ( Java Object - java.util.List [No Coding, Just Created] ) to stored my MySQL - query ( Created using Graphical Connector In ).

I've tried on bonita 5 and i stored the connector into a suggestbox and it's work but not on bonita 7, it's pretty hard to show the process variable into UI, i did the same thing as bonita 5. I read in bonita documentation it's needed REST API, so i tried REST API.
1. ../API/bpm/caseVariable?p=0&c=10&f=case_id={{caseId}}
2. ../API/bpm/activityVariable/{{ActivityName}}/{{Variable}}
but it still didn't work too.

Can anyone give me a short tutorial how to use or call process variable into user interface on bonita 7 ?

Thank you,
Best Regards.

Dhany Lugina.

4 answers

1
0
-1
This one is the BEST answer!

Better than that, here is a prepared example:
http://community.bonitasoft.com/project/process-variable-example

regards
Sean

PS: If this post solves your question, please mark as Resolved.

Comments

Submitted by dhanilugina.acc on Tue, 12/15/2015 - 00:08

Hello Sean,

Thanks for your reply and the examples, you're so kind, but it's still not answer my question.
I've concern about MySQL that i stored into the process variable, then i can call those variable back into user interface for the examples ( select, check list, radio button or etc ).

Lemme give you an explanation about what i mean and include pictures :
1. Table that i will show in ui ( Suggest, list box, selected box )
rm79YTO.png

  1. Create a variable ( list.util )
    5mhfgy.jpg

  2. Create Connection
    fwrn1y.jpg

  3. Query
    11hw0pc.jpg

  4. Graphic Select
    aw594j.jpg

  5. output store to variable
    xlc9ra.jpg

  6. create page flow
    1581g0i.jpg

  7. add variable into suggest box
    5f2ddc.jpg

  8. result
    2ns13sg.jpg

It worked on bonita 6, but i don't know how to implement on bonita 7.

You've said that in the example

Note: it is generally recommended to use business variables instead of process variables.

so do you have any examples to show me the way how to get the database ( MySQL ) result data into BDM until it called into user interface and it implement on select, check list, or etc.

Thank you,
Best Regards.

Dhany Lugina.

Submitted by Sean McP on Tue, 12/15/2015 - 06:52

Hi Dhany,

Apologies that you didn't think I answered your question however, now that I've seen what you are doing I definitely did...it's an interpretive thing.

And it's not mySQL you are storing in the variable, it is the mySQL Returned Data you are storing in the variable. I understand that english may not be your first language so apologies for assuming it was, it's easy to misunderstand sometimes.

Anyway - you are close.

In Step 1 Create a variable ( list.util ) , do not create a list but create a String
In Step 3 Query change the select to something like

  1. SELECT
  2. CONCAT("[",
  3. GROUP_CONCAT(
  4. CONCAT("{username:'",username,"'"),
  5. CONCAT(",email:'",email),"'}")
  6. )
  7. ,"]")
  8. AS json FROM users;

In Step 4 Graphic Select select Single Value as String

Now you can use this variable as your process data into your Select Dropdown List.

The important thing here is that nearly everything in 7 UI should be represented to the UI in JSON format.

You can see this in the process example I gave.

regards
Sean

PS if you really want to get sophisticated you can use code similar to this to do the mySQL resultset to Json

  1. public String getJSONFromResultSet(ResultSet rs,String keyName) {
  2. Map json = new HashMap();
  3. List list = new ArrayList();
  4. if(rs!=null)
  5. {
  6. try {
  7. ResultSetMetaData metaData = rs.getMetaData();
  8. while(rs.next())
  9. {
  10. Map<String,Object> columnMap = new HashMap<String, Object>();
  11. for(int columnIndex=1;columnIndex<=metaData.getColumnCount();columnIndex++)
  12. {
  13. if(rs.getString(metaData.getColumnName(columnIndex))!=null)
  14. columnMap.put(metaData.getColumnLabel(columnIndex), rs.getString(metaData.getColumnName(columnIndex)));
  15. else
  16. columnMap.put(metaData.getColumnLabel(columnIndex), "");
  17. }
  18. list.add(columnMap);
  19. }
  20. } catch (SQLException e) {
  21. e.printStackTrace();
  22. }
  23. json.put(keyName, list);
  24. }
  25. return JSONValue.toJSONString(json);
  26. }
Submitted by dhanilugina.acc on Thu, 12/17/2015 - 05:02

hi sean,

i've tried your suggestion and short tutorial about how to store in variable.
This below is what i did :

Here is my sql result in mysql.
![sqls][sqls]

i created the variable
![variable][variable]

select query as json
![query][query]

this is what i got, it isn't as same as your suggestion. I can't choose single result because bonita read "," as separator. i tried to give command separator as "," and ";", and it still doesn't work too..
![can't select single][can't select single]

then i tried another code that you suggest.
here my sql query:

SELECT * FROM mst_deployment_type

!

  1. [code]
  2.  
  3. groovy can't read function "try and catch".
  4. ![got error][got error]
  5.  
  6. so i delete "try and catch", it's ok, no error.
  7. but when i tried the connection, there's an error.
  8.  
  9. > java.lang.reflect.InvocationTargetException
  10. org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: USERNAME=install | org.bonitasoft.engine.core.connector.exception.SConnectorException: org.bonitasoft.engine.connector.exception.SConnectorException: java.util.concurrent.ExecutionException: org.bonitasoft.engine.connector.exception.SConnectorException: org.bonitasoft.engine.connector.ConnectorException: org.bonitasoft.engine.connector.ConnectorException: java.sql.BatchUpdateException: Can not issue SELECT via executeUpdate().
  11.  
  12. so do you have any idea how to fix it ? thanks anyway.
  13.  
  14. regards,
  15.  
  16. dhany
  17.  
  18. <!-- Images -->
  19. [can't select single]: http://i66.tinypic.com/10z77cw_th.png
  20. [code]: http://i68.tinypic.com/34529l1_th.png
  21. [got error]: http://oi65.tinypic.com/fc7n1z.jpg
  22. [sqls]: http://i64.tinypic.com/2drarki_th.png

1
0
-1

dear sean,

thanks for your help.
i just forget to mention {taskid} on my user interface - url parameter.
that's why it doesn't work on my bonita.

thanks so much,
best regards.

dhany lugina

1
0
-1

You missed out the single quotes from the select...

have a look again....

  1. SELECT
  2. CONCAT("[",
  3. GROUP_CONCAT(
  4. CONCAT("{username:'",username,"'"),
  5. CONCAT(",email:'",email),"'}")
  6. )
  7. ,"]")
  8. AS json FROM users;

1
0
-1
Notifications