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

Add try-with-resources to model run client

parent fdf0cb66
No related branches found
No related tags found
No related merge requests found
...@@ -706,20 +706,21 @@ public class ForecastBean { ...@@ -706,20 +706,21 @@ public class ForecastBean {
* catch(JsonProcessingException ex) { ex.printStackTrace(); } * catch(JsonProcessingException ex) { ex.printStackTrace(); }
*/ */
Response resp = this.getManagerResource(modelInformation).runModel(config.getModelId(), request); try(Response resp = this.getManagerResource(modelInformation).runModel(config.getModelId(), request)) {
if (resp.getStatus() == Response.Status.OK.getStatusCode()) {
// System.out.println(resp.readEntity(String.class)); if (resp.getStatus() == Response.Status.OK.getStatusCode()) {
List<Result> results = (List<Result>) resp.readEntity(new GenericType<List<Result>>() {}); // System.out.println(resp.readEntity(String.class));
// System.out.println("ForecastConfigId=" + forecastConfiguration.getForecastConfigurationId() + ", List<Result> results = (List<Result>) resp.readEntity(new GenericType<List<Result>>() {});
// resultsize=" + results.size()); // System.out.println("ForecastConfigId=" + forecastConfiguration.getForecastConfigurationId() + ",
// We delete all former results before we store the new ones // resultsize=" + results.size());
forecastBean.storeResults(forecastConfiguration, results); // We delete all former results before we store the new ones
} else { forecastBean.storeResults(forecastConfiguration, results);
throw new RunModelException(resp.readEntity(String.class)); } else {
throw new RunModelException(resp.readEntity(String.class));
}
// System.out.println("Finished runModel for wsId" +
// forecastConfiguration.getWeatherStationPointOfInterestId());
} }
// System.out.println("Finished runModel for wsId" +
// forecastConfiguration.getWeatherStationPointOfInterestId());
} else { } else {
throw new PreprocessorException( throw new PreprocessorException(
"Could not find model with id=|" + forecastConfiguration.getModelId() + "|"); "Could not find model with id=|" + forecastConfiguration.getModelId() + "|");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment