Thanks for your answer. I tried this and, even though it is not erroring out, it is not returning the four attributes. It only returns the last one. In this case 'crawl_rate'. And it just returns a list of integers.
>(c) ArrayList<E> : [360,480,360,180,360,720,360]
If I change the order, say I leave title for the last one, it returns a list of strings, containing all the titles from the list.
I tried with all variables and all work the same way.It also works mapping the return to a business variable through the java method 'setSources()'.
I tried adding a line 'source' to return the full object. Having the following script:
bodyAsObject.sources.collect{
def source = new com.company.model.Source()
source.url = it.url
source.slug = it.slug
source.title = it.title
source.crawl_rate = it.crawl_rate
source
}
But then I'm back to my original issue returning complex objects:
java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.exception.BonitaRuntimeException: Unable to deserialize object <object-stream>
<map>
<entry>
<string>output0</string>
<list>
<com.company.model.Source>
<title>BBC</title>
<slug>bbc</slug>
<url>http://www.bbc.co.uk/weather/</url>
<crawl__rate>360</crawl__rate>
</com.company.model.Source>
<com.company.model.Source>
<title>Forecast.io</title>
<slug>forecast-io</slug>
<url>http://forecast.io/</url>
<crawl__rate>480</crawl__rate>
</com.company.model.Source>
<com.company.model.Source>
<title>HAMweather</title>
<slug>hamweather</slug>
<url>http://www.hamweather.com/</url>
<crawl__rate>360</crawl__rate>
</com.company.model.Source>
<com.company.model.Source>
<title>Met Office</title>
<slug>met-office</slug>
<url>http://www.metoffice.gov.uk/</url>
<crawl__rate>180</crawl__rate>
</com.company.model.Source>
<com.company.model.Source>
<title>OpenWeatherMap</title>
<slug>openweathermap</slug>
<url>http://openweathermap.org/</url>
<crawl__rate>360</crawl__rate>
</com.company.model.Source>
<com.company.model.Source>
<title>Weather Underground</title>
<slug>wunderground</slug>
<url>https://www.wunderground.com/?apiref=fc30dc3cd224e19b</url>
<crawl__rate>720</crawl__rate>
</com.company.model.Source>
<com.company.model.Source>
<title>World Weather Online</title>
<slug>world-weather-online</slug>
<url>http://www.worldweatheronline.com/</url>
<crawl__rate>360</crawl__rate>
</com.company.model.Source>
</list>
</entry>
</map>
</object-stream>
com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.company.model.Source
class : java.util.ArrayList
required-type : java.util.ArrayList
converter-type : com.thoughtworks.xstream.converters.collections.CollectionConverter
path : /map/entry/list/com.company.model.Source
line number : 6
class[1] : java.util.HashMap
converter-type[1] : com.thoughtworks.xstream.converters.collections.MapConverter
version : 1.4.10
-------------------------------
com.thoughtworks.xstream.mapper.CannotResolveClassException: com.company.model.Source
Full error here:https://www.heypasteit.com/clip/0IUTUS
I am testing it from the test button in the connector wizard.
For any List of Objects in the BDM, I try to return a List of the same objects in the Script of the connector and I keep getting this message.
I need to return these lists of objects to map them in the UI for both tables and select widgets. Is this the correct way to do so? Using a complex multiple variable in the BDM and trying to map it in the connector output wizard?
Is it possible to do what I am trying? Because it looks to me it should be done this way but Bonita is doing something extra in the engine.
Thanks for the help!