From 45ef21bbfbf07ee1da61c60513c8f116b782ab74 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Sat, 23 May 2020 16:03:22 +0200 Subject: [PATCH] Added IPM Decisions model output format --- .../vips/core/service/ModelResourceImpl.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/no/nibio/vips/core/service/ModelResourceImpl.java b/src/main/java/no/nibio/vips/core/service/ModelResourceImpl.java index 373b6ed..f33c1c6 100755 --- a/src/main/java/no/nibio/vips/core/service/ModelResourceImpl.java +++ b/src/main/java/no/nibio/vips/core/service/ModelResourceImpl.java @@ -314,9 +314,28 @@ public class ModelResourceImpl implements ModelResource{ @Override public Response runModelForIPMDecisions(@PathParam("modelId") String modelId, IPMDecisionsModelConfiguration config) { + try + { DataTransformer dt = new DataTransformer(); config.setConfigParameter("observations", dt.getVIPSWeatherData(config.getWeatherData())); - return this.runModel(modelId, config); + Model calledModel = ModelFactory.getInstance().getModelInstance(modelId); + calledModel.setConfiguration(config); + List<Result> results = calledModel.getResult(); + return Response.ok().entity(dt.getIPMDecisionsModelOutput(results)).build(); + + } + catch(Exception ex) + { + Logger.getLogger(ModelResourceImpl.class.getName()).log(Level.SEVERE, null, ex); + if(ex instanceof ConfigValidationException){ + + throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(ex).build()); + } + else + { + throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex).build()); + } + } } @Override -- GitLab