* when the job is complete, it returns the response document
*/
public static Document callEstimatePerformance(PesResource resource, Document request, String predictionRespSchema) {
try {
PredictionResponseHanlder respHandler = new PredictionResponseHanlder();
Document response = null;
resource.submitEstimationJob(request);
String status = "";
//loop until job complete
try {
while ((status != null) && (!status.equals(COMPLETED))) {
status = resource.checkStatus();
//sleep
Thread.sleep(intPollPeriod);
}
} catch (Exception ex) {
throw new RuntimeException("error while checking job status ", ex);
}
System.out.println("status= " + status);
//here we have a complete job
response = resource.retrieveEstimationResult();
if (response!=null && respHandler.validate(response, predictionRespSchema)) {
System.out.println("Response Validated OK!!");
}
return response;