Welcome Guest! Log in
×

Notice

The forum is in read only mode.
Stambia versions 2.x, 3.x, S17, S18, S19 and S20 are reaching End of Support January, 15th, 2024. Please consider upgrading to the supported Semarchy xDI versions. See Global Policy Support and the Semarchy Documentation.

The Stambia User Community is moving to Semarchy! All the applicable resources have already been moved or are currently being moved to their new location. Read more…

Topic-icon Question Change Groovy version

More
03 May 2018 09:59 #1 by Jackline
Change Groovy version was created by Jackline
Hello,

I have to parse a JSON string, but the version of groovy actually in runtime (1.6.5) doesn't support the fonction groovy.json.JsonSlurper. How can i securely update my Groovy? is it advised?

Thank's
More
03 May 2018 18:00 #2 by Adrian MATYSIAK
Replied by Adrian MATYSIAK on topic Change Groovy version
Hi,

Can you let us know why do you need to parse a JSON string in your process ?
Updating Groovy might indeed by tricky, especially if you used it before in your developments (in which case you would have to test if all your developments work fine after the update).
Alternatively, since it seems this class is in a dedicated package you can try to copy the jar with the class (groovy-json-x.x.xx.jar) into your runtime installation (stambiaRuntime/lib/scripting/groovy) and see if it works with the groovy version that comes with your runtime.

Kind regards,
Adrian Matysiak
More
04 May 2018 08:44 - 04 May 2018 08:45 #3 by Jackline
Replied by Jackline on topic Change Groovy version
Thanks for your response :)

The idea is to retrieve information from an XML file. But in this XML, one of the values is a string that can be translated into a JSON, and I would like to retrieve specific data in the JSON.

I can't use the new function JSON_VALUES in SQL SERVER because our version is earlier than 2016, so therefore I was going through the scripts. But even when i make Json file from Json String, i dont have a SQL function which can for example aggregate all 'Tables Name' and produce one String.



I tried to replace the jar groovy - 1.6.5 and groovy-all - 1.7.2 by newer versions in my Runtime directory, but old versions are downloaded again at the start of Stambia.

I'm a little short on ideas
Attachments:
Last edit: 04 May 2018 08:45 by Jackline.
More
04 May 2018 11:52 #4 by Adrian MATYSIAK
Replied by Adrian MATYSIAK on topic Change Groovy version
Hi,

The idea was rather to try to add the one file that contains the missing class (without updating the existing jars).
If you download the new version of groovy from this link in the lib folder of the zip archive you will find a file named groovy-json-2.4.15.jar.
Can you try to copy this file to your stambiaRuntime/lib/Scripting/groovy folder to see if it works (you might need to restart your runtime after you copy the file).



However, if you are looking for a way to extract a JSON string from XML as a json file, it might be easier to use a File Metadata with property fields “file_path” and “string_content”.

Then you can use the generated file as a JSON source in another mapping. This way you can have a process with one mapping that extracts the JSON string into a JSON file followed by another mapping that reads the content of the file and puts it into the target table.

Here is an article that explains how to use property fields to create a file with string/binary content :
stambia.org/doc/132-technology-articles/...#usingFieldsAsTarget
Do you think this could work for you?
Attachments:
More
04 May 2018 13:46 #5 by Jackline
Replied by Jackline on topic Change Groovy version
Hi,

I will go through the second option as i don't really want to change Stambia native configuration. But my Json String can be too long and generate 'data truncate' error in mapping. So i create my Json file from Groovy script by parsing XML with XmlSlurper, and i use this Json file in a mapping.

Thanks a lot :)