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

Added support for field observations from IPM Decisions

parent d5feaa49
Branches ipm_decisions
Tags
No related merge requests found
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
package no.nibio.vips.core; package no.nibio.vips.core;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.ws.rs.ApplicationPath; import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application; import javax.ws.rs.core.Application;
...@@ -53,6 +52,5 @@ public class VIPSCoreApplication extends Application ...@@ -53,6 +52,5 @@ public class VIPSCoreApplication extends Application
private void addRestResourceClasses(Set<Class<?>> resources) { private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(no.nibio.vips.core.config.JacksonConfig.class); resources.add(no.nibio.vips.core.config.JacksonConfig.class);
resources.add(no.nibio.vips.core.service.ModelResourceImpl.class);
} }
} }
\ No newline at end of file
...@@ -45,10 +45,9 @@ import no.nibio.vips.model.factory.NoSuchModelException; ...@@ -45,10 +45,9 @@ import no.nibio.vips.model.factory.NoSuchModelException;
/** /**
* The available resources in this system * The available resources in this system
* @copyright 2013 {@link http://www.nibio.no NIBIO} * @copyright 2020 {@link http://www.nibio.no NIBIO}
* @author Tor-Einar Skog <tor-einar.skog@nibio.no> * @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/ */
//@Path("")
public class ModelResourceImpl implements ModelResource{ public class ModelResourceImpl implements ModelResource{
@Context @Context
...@@ -317,11 +316,19 @@ public class ModelResourceImpl implements ModelResource{ ...@@ -317,11 +316,19 @@ public class ModelResourceImpl implements ModelResource{
try try
{ {
DataTransformer dt = new DataTransformer(); DataTransformer dt = new DataTransformer();
config.setConfigParameter("observations", dt.getVIPSWeatherData(config.getWeatherData())); if(config.getWeatherData() != null)
{
config.setConfigParameter("observations", dt.getVIPSWeatherData(config.getWeatherData()));
}
config.setConfigParameter("pestObservations", dt.getVIPSPestObservations(
(List) config.getConfigParameter("fieldObservations"),
(List) config.getConfigParameter("fieldObservationQuantifications")
)
);
Model calledModel = ModelFactory.getInstance().getModelInstance(modelId); Model calledModel = ModelFactory.getInstance().getModelInstance(modelId);
calledModel.setConfiguration(config); calledModel.setConfiguration(config);
List<Result> results = calledModel.getResult(); List<Result> results = calledModel.getResult();
return Response.ok().entity(dt.getIPMDecisionsModelOutput(results)).build(); return Response.ok().entity(dt.getIPMDecisionsModelOutput(results)).build();
} }
catch(Exception ex) catch(Exception ex)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment