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

First version with working existing model (Nærstad model)!!!

parent 95ac7108
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ public class VIPSCoreApplication extends Application ...@@ -25,6 +25,7 @@ public class VIPSCoreApplication extends Application
* given list with all resources defined in the project. * given list with all resources defined in the project.
*/ */
private void addRestResourceClasses(Set<Class<?>> resources) { private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(no.bioforsk.vips.core.config.JacksonConfig.class);
resources.add(no.bioforsk.vips.core.service.ModelResource.class); resources.add(no.bioforsk.vips.core.service.ModelResource.class);
......
package no.bioforsk.vips.core.config;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
/**
* This config ensures that Jackson serializes dates as [ISO-8601 ]-compliant notation,
* and not a timestamp
* @copyright 2013 <a href="http://www.bioforsk.no/">Bioforsk</a>
* @author Tor-Einar Skog <tor-einar.skog@bioforsk.no>
*/
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonConfig implements ContextResolver<ObjectMapper>{
private final ObjectMapper objectMapper;
public JacksonConfig()
{
objectMapper = new ObjectMapper();
objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
}
@Override
public ObjectMapper getContext(Class<?> objectType)
{
return objectMapper;
}
}
...@@ -127,6 +127,7 @@ public class ModelResource { ...@@ -127,6 +127,7 @@ public class ModelResource {
try try
{ {
Model calledModel = ModelFactory.getInstance().getModelInstance(config.getModelId()); Model calledModel = ModelFactory.getInstance().getModelInstance(config.getModelId());
calledModel.setConfiguration(config);
return Response.ok().entity(calledModel.getResult()).build(); return Response.ok().entity(calledModel.getResult()).build();
} }
catch(InstantiationException | IllegalAccessException iae) catch(InstantiationException | IllegalAccessException iae)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment