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
Updated jackson and gwt-jackson also modified model JSON config to improve typescript generation without breaking GWT
Rich Turner163883a1440e
diff --git a/client/build.gradle b/client/build.gradleindex 26750f619..35f99d84e 100644--- a/client/build.gradle+++ b/client/build.gradle@@ -21,7 +21,7 @@ dependencies {compile "org.jboss.gwt.elemento:elemento-core:$elementoCoreVersion"// TODO Built from https://github.com/richturner/gwt-jackson- compile files(['lib/gwt-jackson-0.14.3-SNAPSHOT.jar'])+ compile files(['lib/gwt-jackson-0.15.5-SNAPSHOT.jar'])//compile "com.github.nmorel.gwtjackson:gwt-jackson:$gwtJacksonVersion"// This is not on regular classpath, only used when compiling GWT/running codeserverdiff --git a/client/lib/gwt-jackson-0.14.3-SNAPSHOT.jar b/client/lib/gwt-jackson-0.15.5-SNAPSHOT.jarsimilarity index 72%rename from client/lib/gwt-jackson-0.14.3-SNAPSHOT.jarrename to client/lib/gwt-jackson-0.15.5-SNAPSHOT.jarindex 6d33fb140..46df79dc2 100644Binary files a/client/lib/gwt-jackson-0.14.3-SNAPSHOT.jar and b/client/lib/gwt-jackson-0.15.5-SNAPSHOT.jar differdiff --git a/gradle.properties b/gradle.propertiesindex 655ee364d..ced8f1bb2 100644--- a/gradle.properties+++ b/gradle.properties@@ -18,8 +18,8 @@ ginVersion = 2.1.2elementoCoreVersion = 0.7.0elemental2Version = 1.0.0-RC1jsinteropBaseVersion = 1.0.0-RC1-gwtJacksonVersion = 0.14.2-jacksonVersion = 2.8.6+gwtJacksonVersion = 0.15.4+jacksonVersion = 2.9.6groovyVersion = 2.4.13groovySandboxVersion = 1.15sqliteVersion = 3.20.0diff --git a/model/src/main/java/org/openremote/model/AbstractValueHolder.java b/model/src/main/java/org/openremote/model/AbstractValueHolder.javaindex baf086466..2f9983340 100644--- a/model/src/main/java/org/openremote/model/AbstractValueHolder.java+++ b/model/src/main/java/org/openremote/model/AbstractValueHolder.java@@ -19,6 +19,7 @@*/package org.openremote.model;+import com.fasterxml.jackson.annotation.JsonIgnore;import com.fasterxml.jackson.annotation.JsonProperty;import org.openremote.model.value.ArrayValue;import org.openremote.model.value.ObjectValue;@@ -38,20 +39,17 @@ public abstract class AbstractValueHolder implements ValueHolder {protected static final String VALUE_FIELD_NAME = "value";+ @JsonIgnoreprotected ObjectValue objectValue;public AbstractValueHolder(ObjectValue objectValue) {this.objectValue = Objects.requireNonNull(objectValue);}- // JsonProperty needed by GWT jackson- @JsonPropertypublic ObjectValue getObjectValue() {return objectValue;}- // JsonProperty needed by GWT jackson- @JsonPropertyprivate void setObjectValue(ObjectValue objectValue) {this.objectValue = objectValue;}@@ -61,6 +59,7 @@ public abstract class AbstractValueHolder implements ValueHolder {objectValue.remove(VALUE_FIELD_NAME);}+ @JsonIgnore@Overridepublic Optional<Value> getValue() {return objectValue.get(VALUE_FIELD_NAME);@@ -96,6 +95,13 @@ public abstract class AbstractValueHolder implements ValueHolder {return objectValue.getArray(VALUE_FIELD_NAME);}++ @JsonProperty("value")+ private Value getValueInternal() {+ return getValue().orElse(null);+ }++ @JsonProperty("value")@Overridepublic void setValue(Value value) {if (value != null) {diff --git a/model/src/main/java/org/openremote/model/AbstractValueTimestampHolder.java b/model/src/main/java/org/openremote/model/AbstractValueTimestampHolder.javaindex c57a5e62b..5a9a1f332 100644--- a/model/src/main/java/org/openremote/model/AbstractValueTimestampHolder.java+++ b/model/src/main/java/org/openremote/model/AbstractValueTimestampHolder.java@@ -19,6 +19,7 @@*/package org.openremote.model;+import com.fasterxml.jackson.annotation.JsonProperty;import org.openremote.model.value.ObjectValue;import org.openremote.model.value.Value;import org.openremote.model.value.Values;@@ -39,6 +40,11 @@ public abstract class AbstractValueTimestampHolder extends AbstractValueHolder {super(objectValue);}+ @JsonProperty("valueTimestamp")+ private Long getValueTimestampInternal() {+ return getValueTimestamp().orElse(null);+ }+public Optional<Long> getValueTimestamp() {return getObjectValue().getNumber(VALUE_TIMESTAMP_FIELD_NAME).map(Double::longValue);}@@ -46,6 +52,7 @@ public abstract class AbstractValueTimestampHolder extends AbstractValueHolder {/*** Sets the value timestamp to given time.*/+ @JsonProperty@SuppressWarnings("unchecked")public void setValueTimestamp(long timestamp) {getObjectValue().put(VALUE_TIMESTAMP_FIELD_NAME, Values.create(timestamp));diff --git a/model/src/main/java/org/openremote/model/ValueHolder.java b/model/src/main/java/org/openremote/model/ValueHolder.javaindex 9a311aad2..2968e09a3 100644--- a/model/src/main/java/org/openremote/model/ValueHolder.java+++ b/model/src/main/java/org/openremote/model/ValueHolder.java@@ -19,6 +19,7 @@*/package org.openremote.model;+import com.fasterxml.jackson.annotation.JsonProperty;import org.openremote.model.value.ArrayValue;import org.openremote.model.value.ObjectValue;import org.openremote.model.value.Value;@@ -45,6 +46,7 @@ public interface ValueHolder {void clearValue();+ @JsonPropertyOptional<Value> getValue();Optional<String> getValueAsString();diff --git a/model/src/main/java/org/openremote/model/attribute/Attribute.java b/model/src/main/java/org/openremote/model/attribute/Attribute.javaindex cd8d337bc..7bec65d19 100644--- a/model/src/main/java/org/openremote/model/attribute/Attribute.java+++ b/model/src/main/java/org/openremote/model/attribute/Attribute.java@@ -20,6 +20,8 @@package org.openremote.model.attribute;import com.fasterxml.jackson.annotation.JsonIgnore;+import com.fasterxml.jackson.annotation.JsonProperty;+import com.fasterxml.jackson.databind.annotation.JsonSerialize;import com.google.gwt.regexp.shared.RegExp;import org.openremote.model.AbstractValueTimestampHolder;import org.openremote.model.HasUniqueResourceName;@@ -135,6 +137,7 @@ public abstract class Attribute extends AbstractValueTimestampHolder {.isPresent();}+ @JsonPropertypublic Meta getMeta() {if (meta == null) {return new Meta(getObjectValue()@@ -178,6 +181,7 @@ public abstract class Attribute extends AbstractValueTimestampHolder {return getMetaItem(hasUniqueResourceName.getUrn());}+ @JsonPropertypublic void setMeta(List<MetaItem> metaItems) {Meta meta;if (metaItems == null) {diff --git a/model/src/main/java/org/openremote/model/attribute/Meta.java b/model/src/main/java/org/openremote/model/attribute/Meta.javaindex 2f81772b0..b37d20955 100644--- a/model/src/main/java/org/openremote/model/attribute/Meta.java+++ b/model/src/main/java/org/openremote/model/attribute/Meta.java@@ -19,6 +19,10 @@*/package org.openremote.model.attribute;+import com.fasterxml.jackson.annotation.JsonCreator;+import com.fasterxml.jackson.annotation.JsonIgnore;+import com.fasterxml.jackson.annotation.JsonValue;+import com.fasterxml.jackson.databind.annotation.JsonSerialize;import org.openremote.model.value.ArrayValue;import org.openremote.model.value.Values;@@ -31,6 +35,7 @@ import java.util.*;*/public class Meta extends AbstractList<MetaItem> {+ @JsonIgnorefinal protected ArrayValue arrayValue;public Meta() {@@ -46,6 +51,10 @@ public class Meta extends AbstractList<MetaItem> {this.arrayValue = Objects.requireNonNull(arrayValue);}+ public MetaItem[] getItems() {+ return this.toArray(new MetaItem[0]);+ }+public ArrayValue getArrayValue() {return arrayValue;}diff --git a/model/src/main/java/org/openremote/model/attribute/MetaItem.java b/model/src/main/java/org/openremote/model/attribute/MetaItem.javaindex 8a0c7e4a1..7b5d909d7 100644--- a/model/src/main/java/org/openremote/model/attribute/MetaItem.java+++ b/model/src/main/java/org/openremote/model/attribute/MetaItem.java@@ -19,6 +19,7 @@*/package org.openremote.model.attribute;+import com.fasterxml.jackson.annotation.JsonProperty;import com.google.gwt.regexp.shared.RegExp;import org.openremote.model.AbstractValueHolder;import org.openremote.model.HasUniqueResourceName;@@ -77,10 +78,12 @@ public class MetaItem extends AbstractValueHolder {this(hasUniqueResourceName.getUrn(), value);}+ @JsonPropertypublic Optional<String> getName() {return getObjectValue().getString("name");}+ @JsonPropertypublic void setName(String name) {getObjectValue().put("name", TextUtil.requireNonNullAndNonEmpty(name));}diff --git a/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java b/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.javaindex 4463289ce..fa5912aa3 100644--- a/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java+++ b/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java@@ -190,6 +190,7 @@ public interface MetaItemDescriptor extends HasUniqueResourceName {@JsonPropertyValue[] getAllowedValues();+ @JsonIgnore/*** Get optional validation function; this allows {@link MetaItemDescriptor} implementations to do more advanced* validation. If defined this takes priority over all other value checks.diff --git a/model/src/main/java/org/openremote/model/attribute/MetaItemType.java b/model/src/main/java/org/openremote/model/attribute/MetaItemType.javaindex 9b38aa210..536a88f62 100644--- a/model/src/main/java/org/openremote/model/attribute/MetaItemType.java+++ b/model/src/main/java/org/openremote/model/attribute/MetaItemType.java@@ -19,6 +19,7 @@*/package org.openremote.model.attribute;+import com.fasterxml.jackson.annotation.JsonIgnore;import org.openremote.model.ValidationFailure;import org.openremote.model.asset.AssetModelProvider;import org.openremote.model.asset.UserAsset;@@ -432,6 +433,7 @@ public enum MetaItemType implements MetaItemDescriptor {final protected boolean required = false; // All asset meta so far are not mandatoryfinal protected String pattern;final protected String patternFailureMessage;+ @JsonIgnorefinal protected Function<Value, Optional<ValidationFailure>> validator;MetaItemType(String urn, Access access, ValueType valueType, String pattern, String patternFailureMessage, Value initialValue, boolean valueFixed) {diff --git a/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java b/model/src/main/java/org/openremote/model/simulator/SimulatorElement.javaindex 835614305..615955088 100644--- a/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java+++ b/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java@@ -19,6 +19,7 @@*/package org.openremote.model.simulator;+import com.fasterxml.jackson.annotation.JsonProperty;import com.fasterxml.jackson.annotation.JsonSubTypes;import com.fasterxml.jackson.annotation.JsonTypeInfo;import org.openremote.model.ValidationFailure;@@ -54,6 +55,7 @@ public abstract class SimulatorElement implements ValueHolder {public AttributeRef attributeRef;public AttributeValueDescriptor expectedType;// TODO GWT jackson doesn't like fields with the same name as getters in the hierarchy+ @JsonProperty("value")public Value elementValue = null;protected SimulatorElement() {diff --git a/ui/component/model/build.gradle b/ui/component/model/build.gradleindex 0b021b8a7..171d87719 100644--- a/ui/component/model/build.gradle+++ b/ui/component/model/build.gradle@@ -1,3 +1,6 @@+import com.fasterxml.jackson.annotation.JsonAutoDetect+import cz.habarta.typescript.generator.Jackson2Configuration+apply plugin: "groovy"apply plugin: 'cz.habarta.typescript-generator'@@ -13,6 +16,7 @@ buildscript {dependencies {compile resolveProject(":model")+ compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"compile 'cz.habarta.typescript-generator:typescript-generator-core:2.13.489'}@@ -35,17 +39,29 @@ generateTypeScript {customTypeNamingFunction = "function(name, simpleName) { if (name.indexOf(\"\$\") > 0) return name.substr(name.lastIndexOf(\".\")+1).replace(\"\$\",\"\"); }"customTypeMappings = ["org.openremote.model.value.ObjectValue:{ [id: string]: any }",- "org.openremote.model.value.ArrayValue:Array<any>",+ "org.openremote.model.value.ArrayValue:any[]","org.openremote.model.value.NumberValue:number","org.openremote.model.value.StringValue:string","org.openremote.model.value.BooleanValue:boolean",- "org.openremote.model.value.Value:any"+ "org.openremote.model.value.Value:any",+ "org.openremote.model.attribute.Meta:MetaItem[]"]optionalProperties = "all" // TODO: cleanup model to be more explicit about optional paramsmapEnum = cz.habarta.typescript.generator.EnumMapping.asEnumoutputFile = "src/index.ts"outputFileType = "implementationFile"outputKind = "module"+ jackson2Configuration = [+ fieldVisibility: "ANY",+ creatorVisibility: "ANY",+ getterVisibility: "NONE",+ isGetterVisibility: "NONE",+ setterVisibility: "NONE"+ ]+ jackson2Modules = [+ "com.fasterxml.jackson.datatype.jdk8.Jdk8Module",+ "org.openremote.model.ModelModule"+ ]extensionsWithConfiguration = [new cz.habarta.typescript.generator.Settings.ConfiguredExtension(className: "EnumWithInterfacesExtension",diff --git a/ui/component/or-rules-editor/src/or-rule-list.ts b/ui/component/or-rules-editor/src/or-rule-list.tsindex 26d0b541b..41bfa733e 100644--- a/ui/component/or-rules-editor/src/or-rule-list.ts+++ b/ui/component/or-rules-editor/src/or-rule-list.ts@@ -32,7 +32,7 @@ class OrRulesList extends LitElement {<a ?selected="${this.ruleset && ruleset.id === this.ruleset.id}" class="d-flex list-item" @click="${() => this.setActiveRule(this.rulesets[index])}"><span class="rule-status ${ruleset.enabled ? "bg-green" : "bg-red"}"></span><div class="flex">- <span>${ruleset.name}<span style="color: var(--app-grey-color);">${!ruleset.id ? " [concept]" : ""}</span></span>+ <span>${ruleset.name}<span>${!ruleset.id ? " [concept]" : ""}</span></span></div></a>`;diff --git a/ui/component/or-rules-editor/src/style.ts b/ui/component/or-rules-editor/src/style.tsindex 13815ce48..c7b5525c2 100644--- a/ui/component/or-rules-editor/src/style.ts+++ b/ui/component/or-rules-editor/src/style.ts@@ -1,4 +1,5 @@-import {css} from "lit-element";+import {css, unsafeCSS} from "lit-element";+import {DefaultColor1, DefaultColor2, DefaultColor5} from "@openremote/core";// language=CSSexport const rulesEditorStyle = css`@@ -8,12 +9,14 @@ export const rulesEditorStyle = css`height: 100%;width: 100%;- --internal-or-rule-section-background-color: var(--or-rule-section-background-color, white);- --internal-or-rule-list-background-color: var(--or-rule-list-background-color, white);- --internal-or-rule-header-background-color: var(--or-rule-header-background-color, white);- --internal-or-rule-toolbar-background-color: var(--or-rule-toolbar-background-color, white);- --internal-or-rule-editor-background-color: var(--or-rule-editor-background-color, #f5f5f5);- --internal-or-rule-foreground-color: var(--or-rule-foreground-color, green);+ --internal-or-rule-background-color: var(--or-rule-background-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));+ --internal-or-rule-panel-color: var(--or-rule-panel-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));+ --internal-or-rule-list-background-color: var(--or-rule-list-background-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));+ --internal-or-rule-list-foreground-color: var(--or-rule-list-foreground-color, var(--app-foreground-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)})));+ --internal-or-rule-header-background-color: var(--or-rule-header-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));+ --internal-or-rule-toolbar-background-color: var(--or-rule-toolbar-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));+ --internal-or-rule-editor-background-color: var(--or-rule-editor-background-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));+ --internal-or-rule-text-color: var(--or-rule-text-color, inherit);}.shadow {@@ -41,7 +44,7 @@ export const rulesEditorStyle = css`.bottom-toolbar {display: flex;- border-top: 1px solid var(--app-lightgrey-color);+ border-top: 1px solid var(--app-tertiary-color);background-color: var(--internal-or-rule-toolbar-background-color);}@@ -53,7 +56,7 @@ export const rulesEditorStyle = css`cursor: pointer;padding: 5px;margin: 10px;- border: 1px solid var(--app-lightgrey-color);+ border: 1px solid var(--app-tertiary-color);border-radius: 3px;}@@ -163,7 +166,7 @@ export const ruleSectionStyle = css`padding: 20px;display: flex;flex-direction: column;- background-color: var(--internal-or-rule-section-background-color);+ background-color: var(--internal-or-rule-panel-color);box-shadow: rgba(0, 0, 0, 0.11) 0 1px 2px 0;}@@ -199,7 +202,7 @@ export const ruleListStyle = css`display: block;padding: 30px 30px 5px 20px;text-transform: uppercase;- color: var(--app-grey-color, #808080);+ color: var(, #808080);font-size:14px;font-weight: bold;text-align: left;@@ -210,7 +213,7 @@ export const ruleListStyle = css`font-size: 14px;padding: 13px 15px;border-left: 5px solid transparent;- color: var(--app-grey-color, #808080);+ color: var(--internal-or-rule-list-foreground-color);cursor: pointer;transition: all 200ms ease-in;