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

Merge branch 'feature/vipsutv-737-map-module' of...

Merge branch 'feature/vipsutv-737-map-module' of gitlab.nibio.no:VIPS/VIPSLogic into feature/vipsutv-737-map-module
parents 308d712b b458b85f
Branches
No related tags found
1 merge request!191Add map module and Open-Meteo support
...@@ -137,7 +137,7 @@ public class BarleyNetBlotchModelService { ...@@ -137,7 +137,7 @@ public class BarleyNetBlotchModelService {
public Response runModel( public Response runModel(
@PathParam("organizationId") Integer organizationId, @PathParam("organizationId") Integer organizationId,
@QueryParam("timeZone") String timeZoneStr, @QueryParam("timeZone") String timeZoneStr,
@QueryParam("weatherdataType") String weatherdataType, @QueryParam("weatherDataSourceType") String weatherDataSourceType,
@QueryParam("latitude") String latitude, @QueryParam("latitude") String latitude,
@QueryParam("longitude") String longitude, @QueryParam("longitude") String longitude,
@QueryParam("weatherStationId") Integer weatherStationId, @QueryParam("weatherStationId") Integer weatherStationId,
...@@ -181,7 +181,7 @@ public class BarleyNetBlotchModelService { ...@@ -181,7 +181,7 @@ public class BarleyNetBlotchModelService {
List<WeatherObservation> observations; List<WeatherObservation> observations;
if (weatherdataType != null && "weatherstation".equals(weatherdataType.trim())) { if (weatherDataSourceType != null && "weatherstation".equals(weatherDataSourceType.trim())) {
PointOfInterestWeatherStation weatherStation = PointOfInterestWeatherStation weatherStation =
em.find(PointOfInterestWeatherStation.class, weatherStationId); em.find(PointOfInterestWeatherStation.class, weatherStationId);
LOGGER.info("Run model with weatherdata from weatherstation {}", weatherStation.getName()); LOGGER.info("Run model with weatherdata from weatherstation {}", weatherStation.getName());
...@@ -223,6 +223,7 @@ public class BarleyNetBlotchModelService { ...@@ -223,6 +223,7 @@ public class BarleyNetBlotchModelService {
new HashSet<>(Collections.singletonList(WeatherObservation.LOG_INTERVAL_ID_1H)) new HashSet<>(Collections.singletonList(WeatherObservation.LOG_INTERVAL_ID_1H))
); );
} catch (WeatherDataSourceException ex) { } catch (WeatherDataSourceException ex) {
LOGGER.error("Exception while getting observations for latitude={} longitude={}", latitude, longitude, ex);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex.getMessage()).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex.getMessage()).build();
} }
if (observations == null || observations.isEmpty()) { if (observations == null || observations.isEmpty()) {
......
...@@ -53,6 +53,8 @@ import no.nibio.vips.util.ParseRESTParamUtil; ...@@ -53,6 +53,8 @@ import no.nibio.vips.util.ParseRESTParamUtil;
import no.nibio.vips.util.WeatherUtil; import no.nibio.vips.util.WeatherUtil;
import no.nibio.vips.util.XDate; import no.nibio.vips.util.XDate;
import no.nibio.vips.util.weather.WeatherDataSourceUtil; import no.nibio.vips.util.weather.WeatherDataSourceUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* This is a collection of (one) service(s) for models run from forms (not as part of batch) * This is a collection of (one) service(s) for models run from forms (not as part of batch)
...@@ -62,7 +64,9 @@ import no.nibio.vips.util.weather.WeatherDataSourceUtil; ...@@ -62,7 +64,9 @@ import no.nibio.vips.util.weather.WeatherDataSourceUtil;
@Path("rest/modelform") @Path("rest/modelform")
@Facet("restricted") @Facet("restricted")
public class ModelFormService { public class ModelFormService {
private static final Logger LOGGER = LoggerFactory.getLogger(ModelFormService.class);
@EJB @EJB
UserBean userBean; UserBean userBean;
@EJB @EJB
...@@ -196,14 +200,15 @@ public class ModelFormService { ...@@ -196,14 +200,15 @@ public class ModelFormService {
Integer VIPSCoreUserId = organization.getDefaultVipsCoreUserId(); Integer VIPSCoreUserId = organization.getDefaultVipsCoreUserId();
List<Result>results = forecastBean.runForecast(mConf, VIPSCoreUserId); List<Result> results = forecastBean.runForecast(mConf, VIPSCoreUserId);
return Response.ok().entity(results).build(); return Response.ok().entity(results).build();
} }
catch(PreprocessorException |RunModelException ex) catch(PreprocessorException |RunModelException ex)
{ {
LOGGER.error("Exception occurred when attempting to run the septoria humidity model", ex);
return Response.serverError().entity(ex.getMessage()).build(); return Response.serverError().entity(ex.getMessage()).build();
} }
} }
private ForecastModelConfiguration getForecastModelConfiguration(String modelId, String key, String value) private ForecastModelConfiguration getForecastModelConfiguration(String modelId, String key, String value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment