Skip to content
Snippets Groups Projects
Commit 45ef21bb authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added IPM Decisions model output format

parent 8322d29e
No related branches found
No related tags found
1 merge request!6Ipm decisions
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
...@@ -314,9 +314,28 @@ public class ModelResourceImpl implements ModelResource{ ...@@ -314,9 +314,28 @@ public class ModelResourceImpl implements ModelResource{
@Override @Override
public Response runModelForIPMDecisions(@PathParam("modelId") String modelId, IPMDecisionsModelConfiguration config) public Response runModelForIPMDecisions(@PathParam("modelId") String modelId, IPMDecisionsModelConfiguration config)
{ {
try
{
DataTransformer dt = new DataTransformer(); DataTransformer dt = new DataTransformer();
config.setConfigParameter("observations", dt.getVIPSWeatherData(config.getWeatherData())); 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 @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment