Groovy: List and Map

1
0
-1

Hi everyone,

I'm trying to do something that seems really simple, but I just can't see what I'm missing. :(

I have the following groovy script to get some data from a database (oracle) and set it into a field table on my form.

import groovy.sql.Sql

def mapData=[:];

Sql sql = BonitaSql.newInstance("jdbc:oracle:thin:@192.168.0.18:1521:instance", "DATABASE", "password",new oracle.jdbc.OracleDriver())

def query = "select F1, F2 from VSITUACAODEMANDA WHERE F1 = 3";

sql.eachRow(query,{row-> mapData.put(row.F1, row.F2)});

sql.close()

mapData

It works just fine on the groovy validator.

However, when I go to my form the data is empty. No values at all.

I've found this old topic about that: http://community.bonitasoft.com/groups/usage-operation-5x/resolved-listb...

But I just can't understand how to change my map into a list or even if it's needed in my BOS version (6.1.1).

Thanks in advance for any tip and best regards.

2 answers

1
0
-1

Easy pie.

I was making it harder then it should be.

Create a connector (oracle for me) with your select. In the sweet new pane of Bonita, just select N row x N columms. Set the result into a text variable with the attribute 'multiple' set. Use your variable in your table field. Works just FINE.

My only 'issue' now is how to set the first row as the name of the collums. I tried with the properties of the field table but it keep getting error on load, not sure why yet. But I'll tell when I figure it out. =D

Hope it can helps anyone who needs such a thing. =D

1
0
-1

Hi everyone,

So I just made something more simple to deal with. It was just supposed to list one columm at my screen.

But I'm getting this error:

Dez 18, 2013 9:07:16 AM org.bonitasoft.forms.server.FormsServlet getFormFirstPage
Grave: Error while getting the first page for application Solicitação--1.6.5--Lista de pendências$entry
java.lang.IllegalArgumentException
at org.bonitasoft.forms.server.api.impl.util.FormFieldValuesUtil.getAvailableValues(FormFieldValuesUtil.java:294)
at org.bonitasoft.forms.server.api.impl.util.FormFieldValuesUtil.getTableAvailableValues(FormFieldValuesUtil.java:314)
at org.bonitasoft.forms.server.api.impl.util.FormFieldValuesUtil.setFormWidgetAvailableValues(FormFieldValuesUtil.java:657)
at org.bonitasoft.forms.server.api.impl.util.FormFieldValuesUtil.setFormWidgetValues(FormFieldValuesUtil.java:612)
at org.bonitasoft.forms.server.api.impl.util.FormFieldValuesUtil.setFormWidgetsValues(FormFieldValuesUtil.java:883)
at org.bonitasoft.forms.server.FormsServlet.getFormFirstPage(FormsServlet.java:218)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at org.bonitasoft.forms.server.FormsServlet.processCall(FormsServlet.java:130)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.bonitasoft.console.security.SessionFixationValve.invoke(SessionFixationValve.java:77)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)


And I'm using this script

import groovy.sql.Sql

List list1 =[]

Sql sql = BonitaSql.newInstance("jdbc:oracle:thin:@192.168.0.18:1521:orcl1", "owner", "password",new oracle.jdbc.OracleDriver())

sql.eachRow "SELECT CODIGO_DEMANDA FROM DEMANDA WHERE CODIGO_DEMANDA > 30", {list1 += it.CODIGO_DEMANDA.toString()}

sql.close()

list1

So, any clue?

Notifications