E9.2 Passing Dataset from Data Request to Groovy

malam28269

Member
I am able to pull JSON dataset out of Data Request but I want to pass that data to the next step (Custom function) Groovy, may someone please help to provide a simple groovy code just to print (echo) the data of the previous step once I get the data in Groovy step I will figure out how to manipulate that data. by the way I am using E1 9.2.5
Thanks,
 

Kevin Long

Member
I would pass in the output from your data request and then use JsonSlurper to convert the json into groovy object that you can manipulate. Here is an example that takes the json passed in to a Custom Request to a Groovy Object, and then converts the Groovy Object back to json.

import groovy.json.JsonSlurper;
import groovy.json.JsonBuilder;
import com.oracle.e1.common.OrchestrationAttributes;
import java.text.SimpleDateFormat;
HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();

// convert the json into a Groovy object
def jsonIn = new JsonSlurper().parseText(inputMap.get("Input"));

// convert the Groovy object back to json
def jsonOut = new JsonBuilder(jsonIn).toString();

returnMap.put("Output", jsonOut);

return returnMap;
}
 
Top