diff --git a/nb-configuration.xml b/nb-configuration.xml index 03617286196c59c96b61224615af8ca9dc9c48be..77a7b4eb1a5ef5bb7ca32c0069661d83dcad4309 100755 --- a/nb-configuration.xml +++ b/nb-configuration.xml @@ -25,5 +25,6 @@ Any value defined here will override the pom.xml file value but is only applicab <org-netbeans-modules-css-prep.less_2e_compiler_2e_options/> <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language> <netbeans.compile.on.save>none</netbeans.compile.on.save> + <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>WildFly</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server> </properties> </project-shared-configuration> diff --git a/pom.xml b/pom.xml index d39c4af76013d32cac1efdce545466d0e3ff47ed..3d90876a1b874bd83c01bb3137942b001c9f9896 100755 --- a/pom.xml +++ b/pom.xml @@ -75,13 +75,13 @@ <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> - <version>3.0.9.Final</version> + <version>3.6.3.Final</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-client</artifactId> - <version>3.0.9.Final</version> + <version>3.6.3.Final</version> <scope>provided</scope> </dependency> <dependency> @@ -140,19 +140,19 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> - <version>2.7.4</version> + <version>2.9.8</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> - <version>2.7.4</version> + <version>2.9.8</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.7.4</version> + <version>2.9.8</version> </dependency> <dependency> <groupId>log4j</groupId> @@ -180,20 +180,20 @@ <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-csv</artifactId> - <version>2.6.2</version> + <version>2.9.8</version> <type>jar</type> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> - <version>7.0</version> + <version>8.0</version> <type>jar</type> <scope>provided</scope> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> - <version>7.0</version> + <version>8.0</version> <type>jar</type> <scope>provided</scope> </dependency> diff --git a/src/main/java/no/nibio/vips/logic/VIPSLogicApplication.java b/src/main/java/no/nibio/vips/logic/VIPSLogicApplication.java index 329f1f0b04924e43899dbc5bdc2437055cd05e24..4fd0aa61cfa6bf59a567afac418cb5cea84f8268 100755 --- a/src/main/java/no/nibio/vips/logic/VIPSLogicApplication.java +++ b/src/main/java/no/nibio/vips/logic/VIPSLogicApplication.java @@ -56,6 +56,7 @@ public class VIPSLogicApplication extends Application resources.add(no.nibio.vips.logic.service.ObservationService.class); resources.add(no.nibio.vips.logic.service.ModelFormService.class); resources.add(no.nibio.vips.logic.service.JacksonConfig.class); + //resources.add(no.nibio.vips.logic.service.JSONBConfig.class); //resources.add(no.nibio.vips.coremanager.service.ManagerResourceImpl.class); } @@ -70,6 +71,7 @@ public class VIPSLogicApplication extends Application resources.add(no.nibio.vips.logic.modules.barleynetblotch.BarleyNetBlotchModelService.class); resources.add(no.nibio.vips.logic.modules.roughage.RoughageService.class); resources.add(no.nibio.vips.logic.modules.wheatleafblotch.WheatLeafBlotchModelService.class); + resources.add(no.nibio.vips.logic.service.JSONBConfig.class); resources.add(no.nibio.vips.logic.service.JacksonConfig.class); resources.add(no.nibio.vips.logic.service.LogicService.class); resources.add(no.nibio.vips.logic.service.ModelFormService.class); diff --git a/src/main/java/no/nibio/vips/logic/controller/session/ForecastBean.java b/src/main/java/no/nibio/vips/logic/controller/session/ForecastBean.java index 8f8d4036cafef4c60105787b42f62cb4d42252aa..a9713273a57fa8a444b67a9f67e5c72a952458ed 100755 --- a/src/main/java/no/nibio/vips/logic/controller/session/ForecastBean.java +++ b/src/main/java/no/nibio/vips/logic/controller/session/ForecastBean.java @@ -600,6 +600,7 @@ public class ForecastBean { Response resp = this.getManagerResource().runModel(config.getModelId(), request); if(resp.getStatus() == Response.Status.OK.getStatusCode()) { + //System.out.println(resp.readEntity(String.class)); List<Result> results = (List<Result>) resp.readEntity(new GenericType<List<Result>>(){}); //System.out.println("ForecastConfigId=" + forecastConfiguration.getForecastConfigurationId() + ", resultsize=" + results.size()); // We delete all former results before we store the new ones diff --git a/src/main/java/no/nibio/vips/logic/messaging/ForecastEvent.java b/src/main/java/no/nibio/vips/logic/messaging/ForecastEvent.java index 8ad75d14cce60b39f4cc410d954c7d923ed30925..3f5ac9bc48a12b18efa073a09a6ade950d5e2abc 100755 --- a/src/main/java/no/nibio/vips/logic/messaging/ForecastEvent.java +++ b/src/main/java/no/nibio/vips/logic/messaging/ForecastEvent.java @@ -20,20 +20,16 @@ package no.nibio.vips.logic.messaging; import java.io.Serializable; -import java.util.Set; import javax.persistence.Basic; -import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; /** * @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a> diff --git a/src/main/java/no/nibio/vips/logic/service/JSONBConfig.java b/src/main/java/no/nibio/vips/logic/service/JSONBConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..47cb1ef46bc902b10edd6d3ad21fe07801e2f96a --- /dev/null +++ b/src/main/java/no/nibio/vips/logic/service/JSONBConfig.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015 NIBIO <http://www.nibio.no/>. + * + * This file is part of VIPSLogic. + * VIPSLogic is free software: you can redistribute it and/or modify + * it under the terms of the NIBIO Open Source License as published by + * NIBIO, either version 1 of the License, or (at your option) any + * later version. + * + * VIPSLogic is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * NIBIO Open Source License for more details. + * + * You should have received a copy of the NIBIO Open Source License + * along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. + * + */ + +package no.nibio.vips.logic.service; + +import javax.json.bind.Jsonb; +import javax.json.bind.JsonbBuilder; +import javax.json.bind.JsonbConfig; +import javax.json.bind.annotation.JsonbDateFormat; +import javax.ws.rs.Consumes; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.ext.ContextResolver; +import javax.ws.rs.ext.Provider; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Add this to no.nibio.vips.logic.VIPSLogicApplication if you want all + * dates to be serialized as ISO formatted date strings + * @copyright 2018 <a href="http://www.nibio.no/">NIBIO</a> + * @author Tor-Einar Skog <tor-einar.skog@nibio.no> + */ +@Provider +@Produces(MediaType.APPLICATION_JSON) +//@Consumes(MediaType.APPLICATION_JSON) +public class JSONBConfig implements ContextResolver<javax.json.bind.Jsonb> +{ + //private final ObjectMapper objectMapper; + private final Jsonb jsonB; + private Logger log; + + public JSONBConfig() throws Exception + { + log = Logger.getLogger(JacksonConfig.class.getName()); + log.log(Level.INFO,"Created JSONBConfig"); + //System.out.println("This is what you should expect"); + JsonbConfig config = new JsonbConfig(); + config.setProperty(JsonbConfig.DATE_FORMAT, JsonbDateFormat.DEFAULT_FORMAT); + jsonB = JsonbBuilder.create(config); + } + + @Override + public Jsonb getContext(Class objectType) + { + log.log(Level.INFO,"Retrieved Objectmapper "+objectType.toGenericString()); + return jsonB; + } + } \ No newline at end of file diff --git a/src/main/java/no/nibio/vips/logic/service/JacksonConfig.java b/src/main/java/no/nibio/vips/logic/service/JacksonConfig.java index 4cf59885b06eb8b397758bcc0bbdab3983ca3896..5d48d4e7d3b15a5b978bd97c5f84953e12e5c819 100755 --- a/src/main/java/no/nibio/vips/logic/service/JacksonConfig.java +++ b/src/main/java/no/nibio/vips/logic/service/JacksonConfig.java @@ -20,8 +20,11 @@ package no.nibio.vips.logic.service; import com.bedatadriven.jackson.datatype.jts.JtsModule; +import com.fasterxml.jackson.databind.DeserializationConfig; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import java.text.SimpleDateFormat; import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @@ -45,6 +48,8 @@ public class JacksonConfig implements ContextResolver<ObjectMapper> { objectMapper = new ObjectMapper().configure( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.registerModule(new JtsModule()); }