Hi Experts,
I am new to Groovy please help me out,
I was used below script it is converted to Json to XML but Count of records with hasmorerecords is not working,
import com.sap.gateway.ip.core.customdev.util.*;
import groovy.xml.*;
import groovy.json.*;
def Message processData(Message message) {
//Body def body = message.getBody(String)
def json = new JsonSlurper().parseText(body)
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.root { for(employees in json.root.employees){
xml.employees{ firstName(employees.firstName) lastName(employees.lastName) } } } message.setBody(writer.toString()) //return message;
def map = message.getProperties();
def CamelSplitSize = map.get("CamelSplitSize");
def CamelSplitComplete = map.get("CamelSplitComplete");
// Check if CamelSplitSize is 1 and CamelSplitComplete is true if (CamelSplitSize == 1 && CamelSplitComplete == true ) { message.setProperty("hasMoreRecords", ''); } // Check if CamelSplitSize is empty and CamelSplitComplete is false else if (CamelSplitSize == null && CamelSplitComplete == false) { message.setProperty("hasMoreRecords", 'true'); } // Check if CamelSplitSize is Grater than 1 and CamelSplitComplete is true else if (CamelSplitSize > 1 && CamelSplitComplete == true) { message.setProperty("hasMoreRecords", 'false'); }
return message; }
Regards,
Raj