Example - Deserialize the Response to the BatchRequestParent
This sample code shows how after calling forms, you can call the service and deserialize the response to the BatchRequestParent.
public BatchRequestParent batcRequest(){ BatchRequestParent batchParent = null; try{ // Get resource bundle for incident category text BatchFormRequest batchFormRequest = new BatchFormRequest(loginEnv); //recentIncidents - Index 0 SingleFormRequest formRequest = new SingleFormRequest(); //formRequest.setFindOnEntry("TRUE"); formRequest.setReturnControlIDs("1[19,20,21,27,28,41,45,46,47,48,49,50,51,52,54,55,92,174,177,178,181]"); formRequest.setFormName("P54HS220_W54HS220A"); //create event holder FSREvent recentFSREvent = new FSREvent(); //add filter actions in order // Incident From Date recentFSREvent.setFieldValueDate(loginEnv, "150", cal.getTime()); // Potential Incident recentFSREvent.setQBEValue("1[30]", "0"); // Exclude from Safety Statistics recentFSREvent.setQBEValue("1[39]", "0"); // Press Find Button recentFSREvent.doControlAction("15"); //add event holder to the form request formRequest.addFSREvent(recentFSREvent); batchFormRequest.getFormRequests().add(formRequest); //recentInjuryIllnessIncidents - Index 1 formRequest = new SingleFormRequest(); //formRequest.setFindOnEntry("TRUE"); formRequest.setReturnControlIDs("1[19,20,21,27,28,41,45,46,47,48,49,50,51,52,54,55,92,174,177,178,181]"); formRequest.setFormName("P54HS220_W54HS220A"); //create event holder FSREvent injuryFSREvent = new FSREvent(); //add filter actions in order // Incident From Date injuryFSREvent.setFieldValueDate(loginEnv, "150", cal.getTime()); // Potential Incident injuryFSREvent.setQBEValue("1[30]", "0"); // Exclude from Safety Statistics injuryFSREvent.setQBEValue("1[39]", "0"); // Injury/Illness checkbox injuryFSREvent.setQBEValue("1[33]", "1"); // Press Find Button injuryFSREvent.doControlAction("15"); //add event holder to the form request formRequest.addFSREvent(injuryFSREvent); batchFormRequest.getFormRequests().add(formRequest); // recentEnvironmentalIncidents - Index 2 formRequest = new SingleFormRequest(); //formRequest.setFindOnEntry("TRUE"); formRequest.setReturnControlIDs("1[19,20,21,27,28,41,45,46,47,48,49,50,51,52,54,55,92,174,177,178,181]"); formRequest.setFormName("P54HS220_W54HS220A"); //create event holder FSREvent environFSREvent = new FSREvent(); //add filter actions in order // Incident From Date environFSREvent.setFieldValueDate(loginEnv, "150", cal.getTime()); // Potential Incident environFSREvent.setQBEValue("1[30]", "0"); // Exclude from Safety Statistics environFSREvent.setQBEValue("1[39]", "0"); // Environmental checkbox environFSREvent.setQBEValue("1[34]", "1"); // Press Find Button environFSREvent.doControlAction("15"); //add event holder to the form request formRequest.addFSREvent(environFSREvent); batchFormRequest.getFormRequests().add(formRequest); // scoreboard - Index 3 formRequest = new SingleFormRequest(); formRequest.setFindOnEntry("TRUE"); formRequest.setReturnControlIDs("1_20|1_22"); formRequest.setFormName("P54HSPT_S54HSPTA"); batchFormRequest.getFormRequests().add(formRequest); String response = JDERestServiceProvider.jdeRestServiceCall(loginEnv, batchFormRequest, JDERestServiceProvider.POST_METHOD, JDERestServiceProvider.BATCH_FORM_SERVICE_URI); //de-serialize the JSON string into the batchParent object batchParent = loginEnv.getObjectMapper().readValue(response, BatchRequestParent.class); } catch(JDERestServiceException e) { //get more specific error string String error = JDERestServiceProvider.handleServiceException(e); System.out.println(error); } catch(Exception e) { //handle other exceptions System.out.println(e.getMessage()); } return batchParent; }