100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Bug fixes for GWT jackson
Rich Turner03fbde43080f
diff --git a/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeDescriptorMapper.java b/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeDescriptorMapper.javanew file mode 100644index 000000000..98412458e--- /dev/null+++ b/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeDescriptorMapper.java@@ -0,0 +1,31 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program 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+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.app.client.assets.attributes;++import com.github.nmorel.gwtjackson.client.ObjectMapper;+import com.github.nmorel.gwtjackson.client.annotation.JsonMixIns;+import org.openremote.app.client.interop.jackson.DefaultJsonMixin;+import org.openremote.model.attribute.AttributeDescriptorImpl;+import org.openremote.model.attribute.AttributeValueDescriptorImpl;++@JsonMixIns({@JsonMixIns.JsonMixIn(target = AttributeDescriptorImpl.class, mixIn = DefaultJsonMixin.class)})+public interface AttributeDescriptorMapper+ extends ObjectMapper<AttributeDescriptorImpl> {+}diff --git a/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeValueDescriptorMapper.java b/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeValueDescriptorMapper.javanew file mode 100644index 000000000..830f3d949--- /dev/null+++ b/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeValueDescriptorMapper.java@@ -0,0 +1,34 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program 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+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.app.client.assets.attributes;++import com.github.nmorel.gwtjackson.client.ObjectMapper;+import com.github.nmorel.gwtjackson.client.annotation.JsonMixIns;+import org.openremote.app.client.interop.jackson.DefaultJsonMixin;+import org.openremote.app.client.rest.EntityReader;+import org.openremote.app.client.rest.EntityWriter;+import org.openremote.model.attribute.AttributeLink;+import org.openremote.model.attribute.AttributeValueDescriptor;+import org.openremote.model.attribute.AttributeValueDescriptorImpl;++@JsonMixIns({@JsonMixIns.JsonMixIn(target = AttributeValueDescriptorImpl.class, mixIn = DefaultJsonMixin.class)})+public interface AttributeValueDescriptorMapper+ extends ObjectMapper<AttributeValueDescriptorImpl> {+}diff --git a/client/src/main/java/org/openremote/app/client/interop/jackson/AttributeDescriptorDeserializer.java b/client/src/main/java/org/openremote/app/client/interop/jackson/AttributeDescriptorDeserializer.javanew file mode 100644index 000000000..cf4dca82c--- /dev/null+++ b/client/src/main/java/org/openremote/app/client/interop/jackson/AttributeDescriptorDeserializer.java@@ -0,0 +1,46 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program 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+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.app.client.interop.jackson;++import com.github.nmorel.gwtjackson.client.JsonDeserializationContext;+import com.github.nmorel.gwtjackson.client.JsonDeserializer;+import com.github.nmorel.gwtjackson.client.JsonDeserializerParameters;+import com.github.nmorel.gwtjackson.client.stream.JsonReader;+import com.google.gwt.core.client.GWT;+import org.openremote.app.client.assets.attributes.AttributeDescriptorMapper;+import org.openremote.app.client.assets.attributes.AttributeValueDescriptorMapper;+import org.openremote.model.attribute.AttributeDescriptor;+import org.openremote.model.attribute.AttributeValueDescriptor;++public class AttributeDescriptorDeserializer extends JsonDeserializer<AttributeDescriptor> {++ private static final AttributeDescriptorDeserializer INSTANCE = new AttributeDescriptorDeserializer();+ private static final AttributeDescriptorMapper MAPPER = GWT.create(AttributeDescriptorMapper.class);++ public static AttributeDescriptorDeserializer getInstance() {+ return INSTANCE;+ }++ @Override+ protected AttributeDescriptor doDeserialize(JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params) {+ // Read entire object in+ return MAPPER.read(reader.nextValue());+ }+}diff --git a/client/src/main/java/org/openremote/app/client/interop/jackson/AttributeValueDescriptorDeserializer.java b/client/src/main/java/org/openremote/app/client/interop/jackson/AttributeValueDescriptorDeserializer.javanew file mode 100644index 000000000..745bcb5f2--- /dev/null+++ b/client/src/main/java/org/openremote/app/client/interop/jackson/AttributeValueDescriptorDeserializer.java@@ -0,0 +1,44 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program 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+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.app.client.interop.jackson;++import com.github.nmorel.gwtjackson.client.JsonDeserializationContext;+import com.github.nmorel.gwtjackson.client.JsonDeserializer;+import com.github.nmorel.gwtjackson.client.JsonDeserializerParameters;+import com.github.nmorel.gwtjackson.client.stream.JsonReader;+import com.google.gwt.core.client.GWT;+import org.openremote.app.client.assets.attributes.AttributeValueDescriptorMapper;+import org.openremote.model.attribute.AttributeValueDescriptor;++public class AttributeValueDescriptorDeserializer extends JsonDeserializer<AttributeValueDescriptor> {++ private static final AttributeValueDescriptorDeserializer INSTANCE = new AttributeValueDescriptorDeserializer();+ private static final AttributeValueDescriptorMapper MAPPER = GWT.create(AttributeValueDescriptorMapper.class);++ public static AttributeValueDescriptorDeserializer getInstance() {+ return INSTANCE;+ }++ @Override+ protected AttributeValueDescriptor doDeserialize(JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params) {+ // Read entire object in+ return MAPPER.read(reader.nextValue());+ }+}diff --git a/client/src/main/java/org/openremote/app/client/interop/jackson/SerializationConfiguration.java b/client/src/main/java/org/openremote/app/client/interop/jackson/SerializationConfiguration.javaindex 4fc5fbaa9..18897f290 100644--- a/client/src/main/java/org/openremote/app/client/interop/jackson/SerializationConfiguration.java+++ b/client/src/main/java/org/openremote/app/client/interop/jackson/SerializationConfiguration.java@@ -22,6 +22,8 @@ package org.openremote.app.client.interop.jackson;import com.fasterxml.jackson.annotation.JsonAutoDetect;import com.github.nmorel.gwtjackson.client.AbstractConfiguration;import org.openremote.model.ValidationFailure;+import org.openremote.model.attribute.AttributeDescriptor;+import org.openremote.model.attribute.AttributeValueDescriptor;import org.openremote.model.attribute.MetaItemDescriptor;import org.openremote.model.geo.Position;import org.openremote.model.value.*;@@ -48,5 +50,7 @@ public class SerializationConfiguration extends AbstractConfiguration {type(StringValue.class).serializer(ModelValueSerializer.class).deserializer(ModelValueDeserializer.class);type(BooleanValue.class).serializer(ModelValueSerializer.class).deserializer(ModelValueDeserializer.class);type(Position.class).serializer(PositionSerializer.class).deserializer(PositionDeserializer.class);+ type(AttributeValueDescriptor.class).deserializer(AttributeValueDescriptorDeserializer.class);+ type(AttributeDescriptor.class).deserializer(AttributeDescriptorDeserializer.class);}}diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java b/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.javaindex 39280480b..74e4fa7f6 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java@@ -19,14 +19,10 @@*/package org.openremote.model.attribute;-import com.fasterxml.jackson.annotation.JsonFormat;import com.fasterxml.jackson.annotation.JsonProperty;import com.fasterxml.jackson.databind.annotation.JsonDeserialize;import org.openremote.model.value.Value;-import java.util.Optional;--@JsonFormat(shape = JsonFormat.Shape.OBJECT)@JsonDeserialize(as = AttributeDescriptorImpl.class)public interface AttributeDescriptor {diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeType.java b/model/src/main/java/org/openremote/model/attribute/AttributeType.javaindex 6689568a8..5f27b1c38 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeType.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeType.java@@ -19,11 +19,13 @@*/package org.openremote.model.attribute;+import com.fasterxml.jackson.annotation.JsonFormat;import org.openremote.model.value.Value;import org.openremote.model.value.Values;import static org.openremote.model.attribute.MetaItemType.*;+@JsonFormat(shape = JsonFormat.Shape.OBJECT)public enum AttributeType implements AttributeDescriptor {CONSOLE_NAME("consoleName", AttributeValueType.STRING),diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java b/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.javaindex 8f2446ef1..cb0079ec2 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java@@ -19,7 +19,6 @@*/package org.openremote.model.attribute;-import com.fasterxml.jackson.annotation.JsonFormat;import com.fasterxml.jackson.annotation.JsonIgnore;import com.fasterxml.jackson.annotation.JsonProperty;import com.fasterxml.jackson.databind.annotation.JsonDeserialize;@@ -30,7 +29,6 @@ import org.openremote.model.value.ValueType;import java.util.Optional;import java.util.function.Function;-@JsonFormat(shape = JsonFormat.Shape.OBJECT)@JsonDeserialize(as = AttributeValueDescriptorImpl.class)public interface AttributeValueDescriptor {diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java b/model/src/main/java/org/openremote/model/attribute/AttributeValueType.javaindex 09a3343fb..8adfcc072 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java@@ -19,6 +19,7 @@*/package org.openremote.model.attribute;+import com.fasterxml.jackson.annotation.JsonFormat;import com.fasterxml.jackson.annotation.JsonIgnore;import org.openremote.model.ValidationFailure;import org.openremote.model.ValueHolder;@@ -40,6 +41,7 @@ import static org.openremote.model.attribute.AttributeValueType.AttributeValueTy* Additional constraints and integrity rules upon attribute values can be declared by* adding arbitrary {@link Meta} to an {@link Attribute}.*/+@JsonFormat(shape = JsonFormat.Shape.OBJECT)public enum AttributeValueType implements AttributeValueDescriptor {STRING("edit", ValueType.STRING),diff --git a/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java b/model/src/main/java/org/openremote/model/simulator/SimulatorElement.javaindex 615955088..6eaad5277 100644--- a/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java+++ b/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java@@ -22,11 +22,13 @@ package org.openremote.model.simulator;import com.fasterxml.jackson.annotation.JsonProperty;import com.fasterxml.jackson.annotation.JsonSubTypes;import com.fasterxml.jackson.annotation.JsonTypeInfo;+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;import org.openremote.model.ValidationFailure;import org.openremote.model.ValueHolder;import org.openremote.model.attribute.AttributeRef;-import org.openremote.model.attribute.AttributeValueType;import org.openremote.model.attribute.AttributeValueDescriptor;+import org.openremote.model.attribute.AttributeValueDescriptorImpl;+import org.openremote.model.attribute.AttributeValueType;import org.openremote.model.simulator.element.ColorSimulatorElement;import org.openremote.model.simulator.element.NumberSimulatorElement;import org.openremote.model.simulator.element.SwitchSimulatorElement;@@ -47,7 +49,6 @@ import java.util.Optional;})@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,- include = JsonTypeInfo.As.PROPERTY,property = "elementType")public abstract class SimulatorElement implements ValueHolder {