Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Did some renaming of Attribute classes. Fixed tests.

Michael Rademaker8061eaebc11d
diff --git a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
index 1cdf5171a..7833b4d1d 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
@@ -344,7 +344,7 @@ public abstract class AbstractProtocol implements Protocol {
}
// Do basic value conversion
- Optional<ValueType> attributeValueType = attribute.getType().map(AttributeType::getValueType);
+ Optional<ValueType> attributeValueType = attribute.getType().map(AttributeValueType::getValueType);
if (value != null && attributeValueType.isPresent()) {
if (attributeValueType.get() != value.getType()) {
diff --git a/agent/src/main/java/org/openremote/agent/protocol/Protocol.java b/agent/src/main/java/org/openremote/agent/protocol/Protocol.java
index dff178a73..1a3020295 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/Protocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/Protocol.java
@@ -90,7 +90,7 @@ import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;
* header {@link #ACTUATOR_TOPIC_TARGET_PROTOCOL}.
* <p>
* Data type conversion is also delegated to the protocol implementation: If an attribute has a particular
- * {@link AttributeType} and therefore a base {@link ValueType}, the protocol implementation must
+ * {@link AttributeValueType} and therefore a base {@link ValueType}, the protocol implementation must
* receive and send value change messages with values of that type.
* <p>
* Generic protocols should implement support for filtering state messages from devices (or services) before the
diff --git a/agent/src/main/java/org/openremote/agent/protocol/knx/KNXProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/knx/KNXProtocol.java
index 8d19172a7..196cd0aa0 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/knx/KNXProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/knx/KNXProtocol.java
@@ -514,7 +514,7 @@ public class KNXProtocol extends AbstractProtocol implements ProtocolLinkedAttri
}
String attrName = assetName.replaceAll(" ", "");
- AttributeType type = TypeMapper.toAttributeType(datapoint);
+ AttributeValueType type = TypeMapper.toAttributeType(datapoint);
AssetAttribute attr = asset.getAttribute(attrName).orElse(new AssetAttribute(attrName, type).setMeta(
new MetaItem(AssetMeta.LABEL, Values.create(name)),
diff --git a/agent/src/main/java/org/openremote/agent/protocol/knx/TypeMapper.java b/agent/src/main/java/org/openremote/agent/protocol/knx/TypeMapper.java
index 48951558f..6edee0819 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/knx/TypeMapper.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/knx/TypeMapper.java
@@ -1,6 +1,6 @@
package org.openremote.agent.protocol.knx;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.value.ArrayValue;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
@@ -19,134 +19,134 @@ public class TypeMapper {
private static final Logger LOG = Logger.getLogger(TypeMapper.class.getName());
/** map dpt to OpenRemote type */
- static private Map<String, AttributeType> dptToTypeMap;
+ static private Map<String, AttributeValueType> dptToTypeMap;
/** map KNX DPT to OpenRemote type */
- static private Map<AttributeType, String> typeToDptMap;
+ static private Map<AttributeValueType, String> typeToDptMap;
static {
dptToTypeMap = new HashMap<>();
// Main number 1
- dptToTypeMap.put(DPTXlatorBoolean.DPT_SWITCH.getID(), AttributeType.BOOLEAN);
- dptToTypeMap.put(DPTXlatorBoolean.DPT_BOOL.getID(), AttributeType.BOOLEAN);
- dptToTypeMap.put(DPTXlatorBoolean.DPT_OPENCLOSE.getID(), AttributeType.BOOLEAN);
+ dptToTypeMap.put(DPTXlatorBoolean.DPT_SWITCH.getID(), AttributeValueType.BOOLEAN);
+ dptToTypeMap.put(DPTXlatorBoolean.DPT_BOOL.getID(), AttributeValueType.BOOLEAN);
+ dptToTypeMap.put(DPTXlatorBoolean.DPT_OPENCLOSE.getID(), AttributeValueType.BOOLEAN);
// Main number 2
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_SWITCH_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_BOOL_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_ENABLE_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_RAMP_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_ALARM_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_BINARY_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_STEP_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_UPDOWN_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_OPENCLOSE_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_START_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_STATE_CONTROL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator1BitControlled.DPT_INVERT_CONTROL.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_SWITCH_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_BOOL_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_ENABLE_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_RAMP_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_ALARM_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_BINARY_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_STEP_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_UPDOWN_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_OPENCLOSE_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_START_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_STATE_CONTROL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator1BitControlled.DPT_INVERT_CONTROL.getID(), AttributeValueType.NUMBER);
// Main number 3
- // dptToTypeMap.put(DPTXlator3BitControlled.DPT_CONTROL_DIMMING.getID(), AttributeType.IncreaseDecrease);
+ // dptToTypeMap.put(DPTXlator3BitControlled.DPT_CONTROL_DIMMING.getID(), AttributeValueType.IncreaseDecrease);
// Datapoint Types "8-Bit Unsigned Value", Main number 5
- dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_SCALING.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_ANGLE.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_PERCENT_U8.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_DECIMALFACTOR.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_TARIFF.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_VALUE_1_UCOUNT.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_SCALING.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_ANGLE.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_PERCENT_U8.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_DECIMALFACTOR.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_TARIFF.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitUnsigned.DPT_VALUE_1_UCOUNT.getID(), AttributeValueType.NUMBER);
// Datapoint Types "8-bit Signed Value", Main number 6
- dptToTypeMap.put(DPTXlator8BitSigned.DPT_PERCENT_V8.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator8BitSigned.DPT_VALUE_1_UCOUNT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator8BitSigned.DPT_STATUS_MODE3.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitSigned.DPT_PERCENT_V8.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitSigned.DPT_VALUE_1_UCOUNT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator8BitSigned.DPT_STATUS_MODE3.getID(), AttributeValueType.NUMBER);
// Datapoint Types "2-Octet Unsigned Value", Main number 7
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_VALUE_2_UCOUNT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_100.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_SEC.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_MIN.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_HOURS.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_PROP_DATATYPE.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_LENGTH.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_ELECTRICAL_CURRENT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_BRIGHTNESS.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_VALUE_2_UCOUNT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_100.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_SEC.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_MIN.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_HOURS.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_PROP_DATATYPE.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_LENGTH.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_ELECTRICAL_CURRENT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteUnsigned.DPT_BRIGHTNESS.getID(), AttributeValueType.NUMBER);
// Datapoint Types "2-Octet Float Value", Main number 9
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMPERATURE.getID(), AttributeType.TEMPERATURE_CELCIUS);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMPERATURE_DIFFERENCE.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMPERATURE_GRADIENT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_INTENSITY_OF_LIGHT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_WIND_SPEED.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_AIR_PRESSURE.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_HUMIDITY.getID(), AttributeType.HUMIDITY_PERCENTAGE);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_AIRQUALITY.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TIME_DIFFERENCE1.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TIME_DIFFERENCE2.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_VOLTAGE.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_ELECTRICAL_CURRENT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_POWERDENSITY.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_KELVIN_PER_PERCENT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_POWER.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_VOLUME_FLOW.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_RAIN_AMOUNT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMP_F.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator2ByteFloat.DPT_WIND_SPEED_KMH.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMPERATURE.getID(), AttributeValueType.TEMPERATURE_CELCIUS);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMPERATURE_DIFFERENCE.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMPERATURE_GRADIENT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_INTENSITY_OF_LIGHT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_WIND_SPEED.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_AIR_PRESSURE.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_HUMIDITY.getID(), AttributeValueType.HUMIDITY_PERCENTAGE);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_AIRQUALITY.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TIME_DIFFERENCE1.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TIME_DIFFERENCE2.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_VOLTAGE.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_ELECTRICAL_CURRENT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_POWERDENSITY.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_KELVIN_PER_PERCENT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_POWER.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_VOLUME_FLOW.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_RAIN_AMOUNT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_TEMP_F.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator2ByteFloat.DPT_WIND_SPEED_KMH.getID(), AttributeValueType.NUMBER);
// Datapoint Types "Time", Main number 10
- dptToTypeMap.put(DPTXlatorTime.DPT_TIMEOFDAY.getID(), AttributeType.DATETIME);
+ dptToTypeMap.put(DPTXlatorTime.DPT_TIMEOFDAY.getID(), AttributeValueType.DATETIME);
// Datapoint Types "Date", Main number 11
- dptToTypeMap.put(DPTXlatorDate.DPT_DATE.getID(), AttributeType.DATETIME);
+ dptToTypeMap.put(DPTXlatorDate.DPT_DATE.getID(), AttributeValueType.DATETIME);
// Datapoint Types "4-Octet Unsigned Value", Main number 12
- dptToTypeMap.put(DPTXlator4ByteUnsigned.DPT_VALUE_4_UCOUNT.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteUnsigned.DPT_VALUE_4_UCOUNT.getID(), AttributeValueType.NUMBER);
// Datapoint Types "4-Octet Signed Value", Main number 13
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_COUNT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_FLOWRATE.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_ACTIVE_ENERGY.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_APPARENT_ENERGY.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_REACTIVE_ENERGY.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_ACTIVE_ENERGY_KWH.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_APPARENT_ENERGY_KVAH.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_REACTIVE_ENERGY_KVARH.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteSigned.DPT_DELTA_TIME.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_COUNT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_FLOWRATE.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_ACTIVE_ENERGY.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_APPARENT_ENERGY.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_REACTIVE_ENERGY.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_ACTIVE_ENERGY_KWH.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_APPARENT_ENERGY_KVAH.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_REACTIVE_ENERGY_KVARH.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteSigned.DPT_DELTA_TIME.getID(), AttributeValueType.NUMBER);
// Datapoint Types "4-Octet Float Value", Main number 14
- dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ACCELERATION_ANGULAR.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ANGLE_DEG.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ELECTRIC_CURRENT.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ELECTRIC_POTENTIAL.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteFloat.DPT_FREQUENCY.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteFloat.DPT_POWER.getID(), AttributeType.NUMBER);
- dptToTypeMap.put(DPTXlator4ByteFloat.DPT_PRESSURE.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ACCELERATION_ANGULAR.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ANGLE_DEG.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ELECTRIC_CURRENT.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteFloat.DPT_ELECTRIC_POTENTIAL.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteFloat.DPT_FREQUENCY.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteFloat.DPT_POWER.getID(), AttributeValueType.NUMBER);
+ dptToTypeMap.put(DPTXlator4ByteFloat.DPT_PRESSURE.getID(), AttributeValueType.NUMBER);
// Datapoint Types "String", Main number 16
- dptToTypeMap.put(DPTXlatorString.DPT_STRING_8859_1.getID(), AttributeType.STRING);
+ dptToTypeMap.put(DPTXlatorString.DPT_STRING_8859_1.getID(), AttributeValueType.STRING);
// Datapoint Types "Scene Number", Main number 17
- dptToTypeMap.put(DPTXlatorSceneNumber.DPT_SCENE_NUMBER.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlatorSceneNumber.DPT_SCENE_NUMBER.getID(), AttributeValueType.NUMBER);
// Datapoint Types "Scene Control", Main number 18
- dptToTypeMap.put(DPTXlatorSceneControl.DPT_SCENE_CONTROL.getID(), AttributeType.NUMBER);
+ dptToTypeMap.put(DPTXlatorSceneControl.DPT_SCENE_CONTROL.getID(), AttributeValueType.NUMBER);
// Datapoint Types "DateTime", Main number 19
- dptToTypeMap.put(DPTXlatorDateTime.DPT_DATE_TIME.getID(), AttributeType.DATETIME);
+ dptToTypeMap.put(DPTXlatorDateTime.DPT_DATE_TIME.getID(), AttributeValueType.DATETIME);
// Datapoint Types "RGB Color", Main number 232
- dptToTypeMap.put(DPTXlatorRGB.DPT_RGB.getID(), AttributeType.COLOR_RGB);
+ dptToTypeMap.put(DPTXlatorRGB.DPT_RGB.getID(), AttributeValueType.COLOR_RGB);
typeToDptMap = new HashMap<>();
- typeToDptMap.put(AttributeType.BOOLEAN, DPTXlatorBoolean.DPT_SWITCH.getID());
- typeToDptMap.put(AttributeType.PERCENTAGE, DPTXlator8BitUnsigned.DPT_SCALING.getID());
- typeToDptMap.put(AttributeType.NUMBER, DPTXlator2ByteFloat.DPT_TEMPERATURE.getID());
- typeToDptMap.put(AttributeType.DATETIME, DPTXlatorTime.DPT_TIMEOFDAY.getID());
- typeToDptMap.put(AttributeType.STRING, DPTXlatorString.DPT_STRING_8859_1.getID());
- typeToDptMap.put(AttributeType.COLOR_RGB, DPTXlatorRGB.DPT_RGB.getID());
+ typeToDptMap.put(AttributeValueType.BOOLEAN, DPTXlatorBoolean.DPT_SWITCH.getID());
+ typeToDptMap.put(AttributeValueType.PERCENTAGE, DPTXlator8BitUnsigned.DPT_SCALING.getID());
+ typeToDptMap.put(AttributeValueType.NUMBER, DPTXlator2ByteFloat.DPT_TEMPERATURE.getID());
+ typeToDptMap.put(AttributeValueType.DATETIME, DPTXlatorTime.DPT_TIMEOFDAY.getID());
+ typeToDptMap.put(AttributeValueType.STRING, DPTXlatorString.DPT_STRING_8859_1.getID());
+ typeToDptMap.put(AttributeValueType.COLOR_RGB, DPTXlatorRGB.DPT_RGB.getID());
}
@SuppressWarnings("ConstantConditions")
@@ -190,20 +190,20 @@ public class TypeMapper {
return value;
}
- static public AttributeType toAttributeType(Datapoint datapoint) {
+ static public AttributeValueType toAttributeType(Datapoint datapoint) {
LOG.finer("toTypeClass looking for dptId = " + datapoint.getDPT());
- AttributeType t = dptToTypeMap.get(datapoint.getDPT());
+ AttributeValueType t = dptToTypeMap.get(datapoint.getDPT());
if (t == null) {
if (datapoint.getMainNumber() == 1) {
- t = AttributeType.BOOLEAN;
+ t = AttributeValueType.BOOLEAN;
} else {
- t = AttributeType.STRING;
+ t = AttributeValueType.STRING;
}
}
return t;
}
- static public String toDPTid(AttributeType type) {
+ static public String toDPTid(AttributeValueType type) {
// TODO we might need to support more different DPT types
return typeToDptMap.get(type);
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java
index 12b7e0a3a..a0754f0d1 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java
@@ -241,7 +241,7 @@ public class MacroProtocol extends AbstractProtocol {
// Verify the type of the attribute matches the action value
if (attribute
.getType()
- .map(AttributeType::getValueType)
+ .map(AttributeValueType::getValueType)
.orElse(null) != actionValue.getType()) {
// Use a value of null so it is clear that the attribute isn't linked correctly
actionValue = null;
diff --git a/agent/src/main/java/org/openremote/agent/protocol/upnp/UpnpProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/upnp/UpnpProtocol.java
index 5d4d642fd..696339e22 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/upnp/UpnpProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/upnp/UpnpProtocol.java
@@ -1,6 +1,5 @@
package org.openremote.agent.protocol.upnp;
-import com.fasterxml.uuid.Generators;
import org.fourthline.cling.UpnpService;
import org.fourthline.cling.UpnpServiceImpl;
import org.fourthline.cling.model.message.header.STAllHeader;
@@ -28,7 +27,7 @@ import java.util.logging.Logger;
import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;
import static org.openremote.model.asset.AssetMeta.LABEL;
-import static org.openremote.model.attribute.AttributeType.STRING;
+import static org.openremote.model.attribute.AttributeValueType.STRING;
// TODO Experimental
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java
index 586af0471..f27d88a0b 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java
@@ -198,7 +198,7 @@ public abstract class AbstractVelbusProtocol extends AbstractProtocol implements
String property = getVelbusDevicePropertyLink(attribute);
AttributeRef attributeRef = attribute.getReferenceOrThrow();
- ValueType valueType = attribute.getType().orElse(AttributeType.STRING).getValueType();
+ ValueType valueType = attribute.getType().orElse(AttributeValueType.STRING).getValueType();
LOG.fine("Linking attribute to device '" +deviceAddress + "' and property '" + property + "': " + attributeRef);
Consumer<DevicePropertyValue> propertyValueConsumer = propertyValue ->
@@ -301,12 +301,12 @@ public abstract class AbstractVelbusProtocol extends AbstractProtocol implements
name = isNullOrEmpty(name) ? deviceType.toString() : name;
Asset device = new Asset(name, AssetType.THING);
device.setAttributes(
- new AssetAttribute("build", AttributeType.STRING, Values.create(build))
+ new AssetAttribute("build", AttributeValueType.STRING, Values.create(build))
.setMeta(
new MetaItem(AssetMeta.LABEL, Values.create("Build")),
new MetaItem(AssetMeta.READ_ONLY, Values.create(true))
),
- new AssetAttribute("serialNumber", AttributeType.STRING, Values.create(serial))
+ new AssetAttribute("serialNumber", AttributeValueType.STRING, Values.create(serial))
.setMeta(
new MetaItem(AssetMeta.LABEL, Values.create("Serial No")),
new MetaItem(AssetMeta.READ_ONLY, Values.create(true))
@@ -315,7 +315,7 @@ public abstract class AbstractVelbusProtocol extends AbstractProtocol implements
getLinkedAttributeDescriptors(deviceType.get(), baseAddress)
.forEach(descriptor -> {
- AssetAttribute attribute = new AssetAttribute(descriptor.getName(), descriptor.getAttributeType())
+ AssetAttribute attribute = new AssetAttribute(descriptor.getName(), descriptor.getAttributeValueType())
.setMeta(
agentLink,
new MetaItem(AssetMeta.LABEL, Values.create(descriptor.getDisplayName()))
@@ -374,7 +374,7 @@ public abstract class AbstractVelbusProtocol extends AbstractProtocol implements
new LinkedAttributeDescriptor(
propertyDescriptor.getName(),
propertyDescriptor.getDisplayName(),
- propertyDescriptor.getAttributeType(),
+ propertyDescriptor.getAttributeValueType(),
propertyDescriptor.isReadOnly(),
false,
createLinkedAttributeMetaItems(
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogInputProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogInputProcessor.java
index 4a1caed8a..2b2f939e2 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogInputProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogInputProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
@@ -115,28 +115,28 @@ public class AnalogInputProcessor extends FeatureProcessor {
protected static final String EmptySensorText = " ";
protected static final List<PropertyDescriptor> METEO_PROPERTIES = Arrays.asList(
- new PropertyDescriptor("rainfall", "Rainfall", "RAINFALL", AttributeType.RAINFALL, true),
- new PropertyDescriptor("lightLevel", "Light Level", "LIGHT", AttributeType.BRIGHTNESS_LUX, true),
- new PropertyDescriptor("windSpeed", "Wind Speed", "WIND", AttributeType.SPEED_KPH, true)
+ new PropertyDescriptor("rainfall", "Rainfall", "RAINFALL", AttributeValueType.RAINFALL, true),
+ new PropertyDescriptor("lightLevel", "Light Level", "LIGHT", AttributeValueType.BRIGHTNESS_LUX, true),
+ new PropertyDescriptor("windSpeed", "Wind Speed", "WIND", AttributeValueType.SPEED_KPH, true)
);
protected static final List<PropertyDescriptor> IO_PROPERTIES = Arrays.asList(
- new PropertyDescriptor("sensor1", "Sensor 1", "SENSOR1", AttributeType.NUMBER, true),
- new PropertyDescriptor("sensor2", "Sensor 2", "SENSOR2", AttributeType.NUMBER, true),
- new PropertyDescriptor("sensor3", "Sensor 3", "SENSOR3", AttributeType.NUMBER, true),
- new PropertyDescriptor("sensor4", "Sensor 4", "SENSOR4", AttributeType.NUMBER, true),
- new PropertyDescriptor("sensor1Text", "Sensor 1 Text", "SENSOR1_TEXT", AttributeType.STRING, true),
- new PropertyDescriptor("sensor2Text", "Sensor 2 Text", "SENSOR2_TEXT", AttributeType.STRING, true),
- new PropertyDescriptor("sensor3Text", "Sensor 3 Text", "SENSOR3_TEXT", AttributeType.STRING, true),
- new PropertyDescriptor("sensor4Text", "Sensor 4 Text", "SENSOR4_TEXT", AttributeType.STRING, true),
- new PropertyDescriptor("sensor1Type", "Sensor 1 Type", "SENSOR1_TYPE", AttributeType.STRING, true),
- new PropertyDescriptor("sensor2Type", "Sensor 2 Type", "SENSOR2_TYPE", AttributeType.STRING, true),
- new PropertyDescriptor("sensor3Type", "Sensor 3 Type", "SENSOR3_TYPE", AttributeType.STRING, true),
- new PropertyDescriptor("sensor4Type", "Sensor 4 Type", "SENSOR4_TYPE", AttributeType.STRING, true),
- new PropertyDescriptor("sensor1Mode", "Sensor 1 Mode", "SENSOR1_MODE", AttributeType.STRING, true),
- new PropertyDescriptor("sensor2Mode", "Sensor 2 Mode", "SENSOR2_MODE", AttributeType.STRING, true),
- new PropertyDescriptor("sensor3Mode", "Sensor 3 Mode", "SENSOR3_MODE", AttributeType.STRING, true),
- new PropertyDescriptor("sensor4Mode", "Sensor 4 Mode", "SENSOR4_MODE", AttributeType.STRING, true)
+ new PropertyDescriptor("sensor1", "Sensor 1", "SENSOR1", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("sensor2", "Sensor 2", "SENSOR2", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("sensor3", "Sensor 3", "SENSOR3", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("sensor4", "Sensor 4", "SENSOR4", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("sensor1Text", "Sensor 1 Text", "SENSOR1_TEXT", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor2Text", "Sensor 2 Text", "SENSOR2_TEXT", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor3Text", "Sensor 3 Text", "SENSOR3_TEXT", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor4Text", "Sensor 4 Text", "SENSOR4_TEXT", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor1Type", "Sensor 1 Type", "SENSOR1_TYPE", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor2Type", "Sensor 2 Type", "SENSOR2_TYPE", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor3Type", "Sensor 3 Type", "SENSOR3_TYPE", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor4Type", "Sensor 4 Type", "SENSOR4_TYPE", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor1Mode", "Sensor 1 Mode", "SENSOR1_MODE", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor2Mode", "Sensor 2 Mode", "SENSOR2_MODE", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor3Mode", "Sensor 3 Mode", "SENSOR3_MODE", AttributeValueType.STRING, true),
+ new PropertyDescriptor("sensor4Mode", "Sensor 4 Mode", "SENSOR4_MODE", AttributeValueType.STRING, true)
);
@Override
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogOutputProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogOutputProcessor.java
index 2703f56f9..7bf0f1cfc 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogOutputProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogOutputProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.util.Pair;
import org.openremote.model.value.Value;
@@ -96,29 +96,29 @@ public class AnalogOutputProcessor extends OutputChannelProcessor {
protected final static String IO_PREFIX = "OUTPUT";
protected static final Pattern IO_CHANNEL_REGEX = Pattern.compile("^OUTPUT(\\d+)(.*$|$)");
- protected final static List<Pair<String, AttributeType>> CHANNEL_PROPERTIES = Arrays.asList(
+ protected final static List<Pair<String, AttributeValueType>> CHANNEL_PROPERTIES = Arrays.asList(
// RW - ChannelState
- new Pair<>("", AttributeType.STRING),
+ new Pair<>("", AttributeValueType.STRING),
// R - ChannelSetting
- new Pair<>("_SETTING", AttributeType.STRING),
+ new Pair<>("_SETTING", AttributeValueType.STRING),
// R - Read LED status
- new Pair<>("_LED", AttributeType.STRING),
+ new Pair<>("_LED", AttributeValueType.STRING),
// RW - True/False
- new Pair<>("_LOCKED", AttributeType.BOOLEAN),
+ new Pair<>("_LOCKED", AttributeValueType.BOOLEAN),
// RW - True/False
- new Pair<>("_INHIBITED", AttributeType.BOOLEAN),
+ new Pair<>("_INHIBITED", AttributeValueType.BOOLEAN),
// W - Dim level and speed (LEVEL:SPEED)
- new Pair<>("_LEVEL_AND_SPEED", AttributeType.STRING),
+ new Pair<>("_LEVEL_AND_SPEED", AttributeValueType.STRING),
// RW - Dim level 0-100% (-1 to stop current dimming)
- new Pair<>("_LEVEL", AttributeType.NUMBER),
+ new Pair<>("_LEVEL", AttributeValueType.NUMBER),
// W - On for specified time in seconds (0 to cancel)
- new Pair<>("_ON", AttributeType.NUMBER),
+ new Pair<>("_ON", AttributeValueType.NUMBER),
// W - Forced on for specified time in seconds (0 to cancel)
- new Pair<>("_FORCE_ON", AttributeType.NUMBER),
+ new Pair<>("_FORCE_ON", AttributeValueType.NUMBER),
// W - Lock (force off) for specified time in seconds (0 to unlock)
- new Pair<>("_LOCK", AttributeType.NUMBER),
+ new Pair<>("_LOCK", AttributeValueType.NUMBER),
// W - Inhibit for specified time in seconds (0 to un-inhibit)
- new Pair<>("_INHIBIT", AttributeType.NUMBER)
+ new Pair<>("_INHIBIT", AttributeValueType.NUMBER)
);
@Override
@@ -131,12 +131,12 @@ public class AnalogOutputProcessor extends OutputChannelProcessor {
@Override
public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
- List<Pair<String, AttributeType>> propertySuffixes = new ArrayList<>(CHANNEL_PROPERTIES);
+ List<Pair<String, AttributeValueType>> propertySuffixes = new ArrayList<>(CHANNEL_PROPERTIES);
final String chPrefix = deviceType == VelbusDeviceType.VMB4AN ? "Output " : "CH";
if (deviceType == VelbusDeviceType.VMB4AN) {
- propertySuffixes.add(new Pair<>("_VALUE", AttributeType.NUMBER));
- propertySuffixes.add(new Pair<>("_VALUE_AND_SPEED", AttributeType.STRING));
+ propertySuffixes.add(new Pair<>("_VALUE", AttributeValueType.NUMBER));
+ propertySuffixes.add(new Pair<>("_VALUE_AND_SPEED", AttributeValueType.STRING));
}
int channelCount = deviceType == VelbusDeviceType.VMB4AN ? 4 : ChannelProcessor.getMaxChannelNumber(deviceType);
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/BlindProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/BlindProcessor.java
index 077b6414e..9ca5a689f 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/BlindProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/BlindProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.util.Pair;
import org.openremote.model.value.Value;
@@ -128,37 +128,37 @@ public class BlindProcessor extends OutputChannelProcessor {
}
}
- protected final static List<Pair<String, AttributeType>> CHANNEL_PROPERTIES = Arrays.asList(
+ protected final static List<Pair<String, AttributeValueType>> CHANNEL_PROPERTIES = Arrays.asList(
// RW - ChannelState
- new Pair<>("", AttributeType.STRING),
+ new Pair<>("", AttributeValueType.STRING),
// R - ChannelSetting
- new Pair<>("_SETTING", AttributeType.STRING),
+ new Pair<>("_SETTING", AttributeValueType.STRING),
// R - Read LED status for up
- new Pair<>("_LED_UP", AttributeType.STRING),
+ new Pair<>("_LED_UP", AttributeValueType.STRING),
// R - Read LED status for down
- new Pair<>("_LED_DOWN", AttributeType.STRING),
+ new Pair<>("_LED_DOWN", AttributeValueType.STRING),
// RW - True/False
- new Pair<>("_LOCKED", AttributeType.BOOLEAN),
+ new Pair<>("_LOCKED", AttributeValueType.BOOLEAN),
// RW - True/False
- new Pair<>("_INHIBITED", AttributeType.BOOLEAN),
+ new Pair<>("_INHIBITED", AttributeValueType.BOOLEAN),
// W - Position 0-100% (0 = halt)
- new Pair<>("_POSITION", AttributeType.NUMBER),
+ new Pair<>("_POSITION", AttributeValueType.NUMBER),
// W - Up for specified time in seconds (0 = halt, -1 = indefinitely)
- new Pair<>("_UP", AttributeType.NUMBER),
+ new Pair<>("_UP", AttributeValueType.NUMBER),
// W - Down for specified time in seconds (0 = halt, -1 = indefinitely)
- new Pair<>("_DOWN", AttributeType.NUMBER),
+ new Pair<>("_DOWN", AttributeValueType.NUMBER),
// W - Forced up for specified time in seconds (0 = halt, -1 = indefinitely)
- new Pair<>("_FORCE_UP", AttributeType.NUMBER),
+ new Pair<>("_FORCE_UP", AttributeValueType.NUMBER),
// W - Forced down for specified time in seconds (0 = cancel, -1 = indefinitely)
- new Pair<>("_FORCE_DOWN", AttributeType.NUMBER),
+ new Pair<>("_FORCE_DOWN", AttributeValueType.NUMBER),
// W - Lock (force off) for specified time in seconds (0 = unlock, -1 = indefinitely)
- new Pair<>("_LOCK", AttributeType.NUMBER),
+ new Pair<>("_LOCK", AttributeValueType.NUMBER),
// W - Inhibit for specified time in seconds (0 = unlock, -1 = indefinitely)
- new Pair<>("_INHIBIT", AttributeType.NUMBER),
+ new Pair<>("_INHIBIT", AttributeValueType.NUMBER),
// W - Inhibit up for specified time in seconds (0 = un-inhibit, -1 = indefinitely)
- new Pair<>("_INHIBIT_UP", AttributeType.NUMBER),
+ new Pair<>("_INHIBIT_UP", AttributeValueType.NUMBER),
// W - Inhibit down for specified time in seconds (0 = un-inhibit, -1 = indefinitely)
- new Pair<>("_INHIBIT_DOWN", AttributeType.NUMBER)
+ new Pair<>("_INHIBIT_DOWN", AttributeValueType.NUMBER)
);
@Override
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/CounterProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/CounterProcessor.java
index 18445fb50..0dd1c8edd 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/CounterProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/CounterProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
@@ -71,22 +71,22 @@ public class CounterProcessor extends FeatureProcessor {
}
public static final List<PropertyDescriptor> SUPPORTED_PROPERTIES = Arrays.asList(
- new PropertyDescriptor("counter1Enabled", "Counter 1 Enabled", "COUNTER1_ENABLED", AttributeType.BOOLEAN, true),
- new PropertyDescriptor("counter2Enabled", "Counter 2 Enabled", "COUNTER2_ENABLED", AttributeType.BOOLEAN, true),
- new PropertyDescriptor("counter3Enabled", "Counter 3 Enabled", "COUNTER3_ENABLED", AttributeType.BOOLEAN, true),
- new PropertyDescriptor("counter4Enabled", "Counter 4 Enabled", "COUNTER4_ENABLED", AttributeType.BOOLEAN, true),
- new PropertyDescriptor("counter1Units", "Counter 1 Units", "COUNTER1_UNITS", AttributeType.STRING, true),
- new PropertyDescriptor("counter2Units", "Counter 2 Units", "COUNTER2_UNITS", AttributeType.STRING, true),
- new PropertyDescriptor("counter3Units", "Counter 3 Units", "COUNTER3_UNITS", AttributeType.STRING, true),
- new PropertyDescriptor("counter4Units", "Counter 4 Units", "COUNTER4_UNITS", AttributeType.STRING, true),
- new PropertyDescriptor("counter1Instant", "Counter 1 Instant", "COUNTER1_INSTANT", AttributeType.NUMBER, true),
- new PropertyDescriptor("counter2Instant", "Counter 2 Instant", "COUNTER2_INSTANT", AttributeType.NUMBER, true),
- new PropertyDescriptor("counter3Instant", "Counter 3 Instant", "COUNTER3_INSTANT", AttributeType.NUMBER, true),
- new PropertyDescriptor("counter4Instant", "Counter 4 Instant", "COUNTER4_INSTANT", AttributeType.NUMBER, true),
- new PropertyDescriptor("counter1", "Counter 1", "COUNTER1", AttributeType.NUMBER),
- new PropertyDescriptor("counter2", "Counter 2", "COUNTER2", AttributeType.NUMBER),
- new PropertyDescriptor("counter3", "Counter 3", "COUNTER3", AttributeType.NUMBER),
- new PropertyDescriptor("counter4", "Counter 4", "COUNTER4", AttributeType.NUMBER)
+ new PropertyDescriptor("counter1Enabled", "Counter 1 Enabled", "COUNTER1_ENABLED", AttributeValueType.BOOLEAN, true),
+ new PropertyDescriptor("counter2Enabled", "Counter 2 Enabled", "COUNTER2_ENABLED", AttributeValueType.BOOLEAN, true),
+ new PropertyDescriptor("counter3Enabled", "Counter 3 Enabled", "COUNTER3_ENABLED", AttributeValueType.BOOLEAN, true),
+ new PropertyDescriptor("counter4Enabled", "Counter 4 Enabled", "COUNTER4_ENABLED", AttributeValueType.BOOLEAN, true),
+ new PropertyDescriptor("counter1Units", "Counter 1 Units", "COUNTER1_UNITS", AttributeValueType.STRING, true),
+ new PropertyDescriptor("counter2Units", "Counter 2 Units", "COUNTER2_UNITS", AttributeValueType.STRING, true),
+ new PropertyDescriptor("counter3Units", "Counter 3 Units", "COUNTER3_UNITS", AttributeValueType.STRING, true),
+ new PropertyDescriptor("counter4Units", "Counter 4 Units", "COUNTER4_UNITS", AttributeValueType.STRING, true),
+ new PropertyDescriptor("counter1Instant", "Counter 1 Instant", "COUNTER1_INSTANT", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("counter2Instant", "Counter 2 Instant", "COUNTER2_INSTANT", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("counter3Instant", "Counter 3 Instant", "COUNTER3_INSTANT", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("counter4Instant", "Counter 4 Instant", "COUNTER4_INSTANT", AttributeValueType.NUMBER, true),
+ new PropertyDescriptor("counter1", "Counter 1", "COUNTER1", AttributeValueType.NUMBER),
+ new PropertyDescriptor("counter2", "Counter 2", "COUNTER2", AttributeValueType.NUMBER),
+ new PropertyDescriptor("counter3", "Counter 3", "COUNTER3", AttributeValueType.NUMBER),
+ new PropertyDescriptor("counter4", "Counter 4", "COUNTER4", AttributeValueType.NUMBER)
);
@Override
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/FeatureProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/FeatureProcessor.java
index aeeead2d6..908f5d52c 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/FeatureProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/FeatureProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
@@ -41,27 +41,27 @@ public abstract class FeatureProcessor {
protected final String name;
protected final String displayName;
protected final String linkName;
- protected final AttributeType attributeType;
+ protected final AttributeValueType attributeValueType;
protected final boolean readOnly;
public PropertyDescriptor(
String name,
String displayName,
String linkName,
- AttributeType attributeType) {
- this(name, displayName, linkName, attributeType, false);
+ AttributeValueType attributeValueType) {
+ this(name, displayName, linkName, attributeValueType, false);
}
public PropertyDescriptor(
String name,
String displayName,
String linkName,
- AttributeType attributeType,
+ AttributeValueType attributeValueType,
boolean readOnly) {
this.name = name;
this.displayName = displayName;
this.linkName = linkName;
- this.attributeType = attributeType;
+ this.attributeValueType = attributeValueType;
this.readOnly = readOnly;
}
@@ -73,8 +73,8 @@ public abstract class FeatureProcessor {
return displayName;
}
- public AttributeType getAttributeType() {
- return attributeType;
+ public AttributeValueType getAttributeValueType() {
+ return attributeValueType;
}
public boolean isReadOnly() {
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/InputProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/InputProcessor.java
index 253bd0cba..a7353dc53 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/InputProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/InputProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.util.Pair;
import org.openremote.model.value.Value;
@@ -144,25 +144,25 @@ public class InputProcessor extends ChannelProcessor {
switch (propertyType) {
case CHANNEL_STATE:
if (deviceType != VelbusDeviceType.VMB4AN) {
- properties.add(new PropertyDescriptor("ch"+i+"State", "CH" + i, "CH" + i, AttributeType.STRING));
+ properties.add(new PropertyDescriptor("ch"+i+"State", "CH" + i, "CH" + i, AttributeValueType.STRING));
}
break;
case LED_STATE:
if (deviceType != VelbusDeviceType.VMB4AN) {
- properties.add(new PropertyDescriptor("ch"+i+"LedState", "CH" + i + "LED State", "CH" + i + propertyType.getPropertySuffix(), AttributeType.STRING));
+ properties.add(new PropertyDescriptor("ch"+i+"LedState", "CH" + i + "LED State", "CH" + i + propertyType.getPropertySuffix(), AttributeValueType.STRING));
}
break;
case LOCK_STATE:
- properties.add(new PropertyDescriptor("ch"+i+"Locked", "CH" + i + " Locked", "CH" + i + propertyType.getPropertySuffix(), AttributeType.BOOLEAN));
+ properties.add(new PropertyDescriptor("ch"+i+"Locked", "CH" + i + " Locked", "CH" + i + propertyType.getPropertySuffix(), AttributeValueType.BOOLEAN));
break;
case LOCK_DURATION:
- properties.add(new PropertyDescriptor("ch"+i+"LockDuration", "CH" + i + " Lock Duration (s)", "CH" + i + propertyType.getPropertySuffix(), AttributeType.NUMBER));
+ properties.add(new PropertyDescriptor("ch"+i+"LockDuration", "CH" + i + " Lock Duration (s)", "CH" + i + propertyType.getPropertySuffix(), AttributeValueType.NUMBER));
break;
case ENABLED_STATE:
- properties.add(new PropertyDescriptor("ch"+i+"Enabled", "CH" + i + " Enabled", "CH" + i + propertyType.getPropertySuffix(), AttributeType.BOOLEAN, true));
+ properties.add(new PropertyDescriptor("ch"+i+"Enabled", "CH" + i + " Enabled", "CH" + i + propertyType.getPropertySuffix(), AttributeValueType.BOOLEAN, true));
break;
case INVERTED_STATE:
- properties.add(new PropertyDescriptor("ch"+i+"Inverted", "CH" + i + " Inverted", "CH" + i + propertyType.getPropertySuffix(), AttributeType.BOOLEAN, true));
+ properties.add(new PropertyDescriptor("ch"+i+"Inverted", "CH" + i + " Inverted", "CH" + i + propertyType.getPropertySuffix(), AttributeValueType.BOOLEAN, true));
break;
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OledProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OledProcessor.java
index 58768c87c..068810740 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OledProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OledProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.value.Value;
import org.openremote.model.value.Values;
@@ -44,7 +44,7 @@ public class OledProcessor extends FeatureProcessor {
@Override
public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
return Collections.singletonList(
- new PropertyDescriptor("memoText", "Memo Text", "MEMO_TEXT", AttributeType.STRING)
+ new PropertyDescriptor("memoText", "Memo Text", "MEMO_TEXT", AttributeValueType.STRING)
);
}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ProgramsProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ProgramsProcessor.java
index 6458714eb..4407dfb82 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ProgramsProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ProgramsProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.util.Pair;
import org.openremote.model.value.Value;
@@ -81,19 +81,19 @@ public class ProgramsProcessor extends ChannelProcessor {
protected static final String PROGRAM_STEPS_ENABLED_SUFFIX = "_PROGRAM_STEPS_ENABLED";
protected static final String PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX = "_PROGRAM_STEPS_DISABLED_SECONDS";
protected static final List<PropertyDescriptor> STATIC_PROPERTIES = Arrays.asList(
- new PropertyDescriptor("allProgramStepsEnabled", "All Program Steps Enabled", "ALL" + PROGRAM_STEPS_ENABLED_SUFFIX, AttributeType.BOOLEAN),
- new PropertyDescriptor("allProgramStepsDisableSeconds", "All Program Steps Disable (s)", "ALL" + PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, AttributeType.NUMBER),
- new PropertyDescriptor("sunriseEnabled", "Sunrise Enabled", "SUNRISE_ENABLED", AttributeType.BOOLEAN),
- new PropertyDescriptor("sunsetEnabled", "Sunset Enabled", "SUNSET_ENABLED", AttributeType.BOOLEAN),
- new PropertyDescriptor("alarm1Enabled", "Alarm 1 Enabled", "ALARM1_ENABLED", AttributeType.BOOLEAN),
- new PropertyDescriptor("alarm2Enabled", "Alarm 2 Enabled", "ALARM2_ENABLED", AttributeType.BOOLEAN),
- new PropertyDescriptor("alarm1Master", "Alarm 1 Master", "ALARM1_MASTER", AttributeType.BOOLEAN),
- new PropertyDescriptor("alarm2Master", "Alarm 2 Master", "ALARM2_MASTER", AttributeType.BOOLEAN),
- new PropertyDescriptor("alarm1WakeTime", "Alarm 1 Wake Time", "ALARM1_WAKE_TIME", AttributeType.STRING),
- new PropertyDescriptor("alarm2WakeTime", "Alarm 2 Wake Time", "ALARM2_WAKE_TIME", AttributeType.STRING),
- new PropertyDescriptor("alarm1BedTime", "Alarm 1 Bed Time", "ALARM1_BED_TIME", AttributeType.STRING),
- new PropertyDescriptor("alarm2BedTime", "Alarm 2 Bed Time", "ALARM2_BED_TIME", AttributeType.STRING),
- new PropertyDescriptor("program", "Current Program", "Program", AttributeType.STRING)
+ new PropertyDescriptor("allProgramStepsEnabled", "All Program Steps Enabled", "ALL" + PROGRAM_STEPS_ENABLED_SUFFIX, AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("allProgramStepsDisableSeconds", "All Program Steps Disable (s)", "ALL" + PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, AttributeValueType.NUMBER),
+ new PropertyDescriptor("sunriseEnabled", "Sunrise Enabled", "SUNRISE_ENABLED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("sunsetEnabled", "Sunset Enabled", "SUNSET_ENABLED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("alarm1Enabled", "Alarm 1 Enabled", "ALARM1_ENABLED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("alarm2Enabled", "Alarm 2 Enabled", "ALARM2_ENABLED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("alarm1Master", "Alarm 1 Master", "ALARM1_MASTER", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("alarm2Master", "Alarm 2 Master", "ALARM2_MASTER", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("alarm1WakeTime", "Alarm 1 Wake Time", "ALARM1_WAKE_TIME", AttributeValueType.STRING),
+ new PropertyDescriptor("alarm2WakeTime", "Alarm 2 Wake Time", "ALARM2_WAKE_TIME", AttributeValueType.STRING),
+ new PropertyDescriptor("alarm1BedTime", "Alarm 1 Bed Time", "ALARM1_BED_TIME", AttributeValueType.STRING),
+ new PropertyDescriptor("alarm2BedTime", "Alarm 2 Bed Time", "ALARM2_BED_TIME", AttributeValueType.STRING),
+ new PropertyDescriptor("program", "Current Program", "Program", AttributeValueType.STRING)
);
@@ -103,8 +103,8 @@ public class ProgramsProcessor extends ChannelProcessor {
List<PropertyDescriptor> properties = new ArrayList<>(maxChannelNumber * 2 + STATIC_PROPERTIES.size());
for (int i=1; i<=maxChannelNumber; i++) {
- properties.add(new PropertyDescriptor("ch" + i + "ProgramStepsEnabled", "CH" + i + " Program Steps Enabled", "CH" + i + PROGRAM_STEPS_ENABLED_SUFFIX, AttributeType.BOOLEAN));
- properties.add(new PropertyDescriptor("ch" + i + "ProgramStepsDisableSeconds", "CH" + i + " Program Steps Disable (s)", "CH" + i + PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, AttributeType.NUMBER));
+ properties.add(new PropertyDescriptor("ch" + i + "ProgramStepsEnabled", "CH" + i + " Program Steps Enabled", "CH" + i + PROGRAM_STEPS_ENABLED_SUFFIX, AttributeValueType.BOOLEAN));
+ properties.add(new PropertyDescriptor("ch" + i + "ProgramStepsDisableSeconds", "CH" + i + " Program Steps Disable (s)", "CH" + i + PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, AttributeValueType.NUMBER));
}
properties.addAll(STATIC_PROPERTIES);
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/RelayProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/RelayProcessor.java
index 6ef2d1f58..181d41bc2 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/RelayProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/RelayProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
@@ -107,56 +107,56 @@ public class RelayProcessor extends OutputChannelProcessor {
}
protected final static List<PropertyDescriptor> SUPPORTED_PROPERTIES = Arrays.asList(
- new PropertyDescriptor("ch1State", "CH1", "CH1", AttributeType.STRING),
- new PropertyDescriptor("ch2State", "CH2", "CH2", AttributeType.STRING),
- new PropertyDescriptor("ch3State", "CH3", "CH3", AttributeType.STRING),
- new PropertyDescriptor("ch4State", "CH4", "CH4", AttributeType.STRING),
- new PropertyDescriptor("ch5State", "CH5", "CH5", AttributeType.STRING),
- new PropertyDescriptor("ch1Setting", "CH1 Setting", "CH1_SETTING", AttributeType.STRING),
- new PropertyDescriptor("ch2Setting", "CH2 Setting", "CH2_SETTING", AttributeType.STRING),
- new PropertyDescriptor("ch3Setting", "CH3 Setting", "CH3_SETTING", AttributeType.STRING),
- new PropertyDescriptor("ch4Setting", "CH4 Setting", "CH4_SETTING", AttributeType.STRING),
- new PropertyDescriptor("ch5Setting", "CH5 Setting", "CH5_SETTING", AttributeType.STRING),
- new PropertyDescriptor("ch1Locked", "CH1 Locked", "CH1_LOCKED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch2Locked", "CH2 Locked", "CH2_LOCKED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch3Locked", "CH3 Locked", "CH3_LOCKED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch4Locked", "CH4 Locked", "CH4_LOCKED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch5Locked", "CH5 Locked", "CH5_LOCKED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch1Inhibited", "CH1 Inhibited", "CH1_INHIBITED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch2Inhibited", "CH2 Inhibited", "CH2_INHIBITED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch3Inhibited", "CH3 Inhibited", "CH3_INHIBITED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch4Inhibited", "CH4 Inhibited", "CH4_INHIBITED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch5Inhibited", "CH5 Inhibited", "CH5_INHIBITED", AttributeType.BOOLEAN),
- new PropertyDescriptor("ch1LedState", "CH1 LED State", "CH1_LED", AttributeType.STRING),
- new PropertyDescriptor("ch2LedState", "CH2 LED State", "CH2_LED", AttributeType.STRING),
- new PropertyDescriptor("ch3LedState", "CH3 LED State", "CH3_LED", AttributeType.STRING),
- new PropertyDescriptor("ch4LedState", "CH4 LED State", "CH4_LED", AttributeType.STRING),
- new PropertyDescriptor("ch5LedState", "CH5 LED State", "CH5_LED", AttributeType.STRING),
- new PropertyDescriptor("ch1OnSeconds", "CH1 On (s)", "CH1_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch2OnSeconds", "CH2 On (s)", "CH2_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch3OnSeconds", "CH3 On (s)", "CH3_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch4OnSeconds", "CH4 On (s)", "CH4_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch5OnSeconds", "CH5 On (s)", "CH5_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch1IntermittentSeconds", "CH1 Intermittent (s)", "CH1_INTERMITTENT", AttributeType.NUMBER),
- new PropertyDescriptor("ch2IntermittentSeconds", "CH2 Intermittent (s)", "CH2_INTERMITTENT", AttributeType.NUMBER),
- new PropertyDescriptor("ch3IntermittentSeconds", "CH3 Intermittent (s)", "CH3_INTERMITTENT", AttributeType.NUMBER),
- new PropertyDescriptor("ch4IntermittentSeconds", "CH4 Intermittent (s)", "CH4_INTERMITTENT", AttributeType.NUMBER),
- new PropertyDescriptor("ch5IntermittentSeconds", "CH5 Intermittent (s)", "CH5_INTERMITTENT", AttributeType.NUMBER),
- new PropertyDescriptor("ch1LockSeconds", "CH1 Lock (s)", "CH1_LOCK", AttributeType.NUMBER),
- new PropertyDescriptor("ch2LockSeconds", "CH2 Lock (s)", "CH2_LOCK", AttributeType.NUMBER),
- new PropertyDescriptor("ch3LockSeconds", "CH3 Lock (s)", "CH3_LOCK", AttributeType.NUMBER),
- new PropertyDescriptor("ch4LockSeconds", "CH4 Lock (s)", "CH4_LOCK", AttributeType.NUMBER),
- new PropertyDescriptor("ch5LockSeconds", "CH5 Lock (s)", "CH5_LOCK", AttributeType.NUMBER),
- new PropertyDescriptor("ch1ForceOnSeconds", "CH1 Force On (s)", "CH1_FORCE_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch2ForceOnSeconds", "CH2 Force On (s)", "CH2_FORCE_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch3ForceOnSeconds", "CH3 Force On (s)", "CH3_FORCE_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch4ForceOnSeconds", "CH4 Force On (s)", "CH4_FORCE_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch5ForceOnSeconds", "CH5 Force On (s)", "CH5_FORCE_ON", AttributeType.NUMBER),
- new PropertyDescriptor("ch1InhibitSeconds", "CH1 Inhibit (s)", "CH1_INHIBIT", AttributeType.NUMBER),
- new PropertyDescriptor("ch2InhibitSeconds", "CH2 Inhibit (s)", "CH2_INHIBIT", AttributeType.NUMBER),
- new PropertyDescriptor("ch3InhibitSeconds", "CH3 Inhibit (s)", "CH3_INHIBIT", AttributeType.NUMBER),
- new PropertyDescriptor("ch4InhibitSeconds", "CH4 Inhibit (s)", "CH4_INHIBIT", AttributeType.NUMBER),
- new PropertyDescriptor("ch5InhibitSeconds", "CH5 Inhibit (s)", "CH5_INHIBIT", AttributeType.NUMBER)
+ new PropertyDescriptor("ch1State", "CH1", "CH1", AttributeValueType.STRING),
+ new PropertyDescriptor("ch2State", "CH2", "CH2", AttributeValueType.STRING),
+ new PropertyDescriptor("ch3State", "CH3", "CH3", AttributeValueType.STRING),
+ new PropertyDescriptor("ch4State", "CH4", "CH4", AttributeValueType.STRING),
+ new PropertyDescriptor("ch5State", "CH5", "CH5", AttributeValueType.STRING),
+ new PropertyDescriptor("ch1Setting", "CH1 Setting", "CH1_SETTING", AttributeValueType.STRING),
+ new PropertyDescriptor("ch2Setting", "CH2 Setting", "CH2_SETTING", AttributeValueType.STRING),
+ new PropertyDescriptor("ch3Setting", "CH3 Setting", "CH3_SETTING", AttributeValueType.STRING),
+ new PropertyDescriptor("ch4Setting", "CH4 Setting", "CH4_SETTING", AttributeValueType.STRING),
+ new PropertyDescriptor("ch5Setting", "CH5 Setting", "CH5_SETTING", AttributeValueType.STRING),
+ new PropertyDescriptor("ch1Locked", "CH1 Locked", "CH1_LOCKED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch2Locked", "CH2 Locked", "CH2_LOCKED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch3Locked", "CH3 Locked", "CH3_LOCKED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch4Locked", "CH4 Locked", "CH4_LOCKED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch5Locked", "CH5 Locked", "CH5_LOCKED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch1Inhibited", "CH1 Inhibited", "CH1_INHIBITED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch2Inhibited", "CH2 Inhibited", "CH2_INHIBITED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch3Inhibited", "CH3 Inhibited", "CH3_INHIBITED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch4Inhibited", "CH4 Inhibited", "CH4_INHIBITED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch5Inhibited", "CH5 Inhibited", "CH5_INHIBITED", AttributeValueType.BOOLEAN),
+ new PropertyDescriptor("ch1LedState", "CH1 LED State", "CH1_LED", AttributeValueType.STRING),
+ new PropertyDescriptor("ch2LedState", "CH2 LED State", "CH2_LED", AttributeValueType.STRING),
+ new PropertyDescriptor("ch3LedState", "CH3 LED State", "CH3_LED", AttributeValueType.STRING),
+ new PropertyDescriptor("ch4LedState", "CH4 LED State", "CH4_LED", AttributeValueType.STRING),
+ new PropertyDescriptor("ch5LedState", "CH5 LED State", "CH5_LED", AttributeValueType.STRING),
+ new PropertyDescriptor("ch1OnSeconds", "CH1 On (s)", "CH1_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch2OnSeconds", "CH2 On (s)", "CH2_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch3OnSeconds", "CH3 On (s)", "CH3_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch4OnSeconds", "CH4 On (s)", "CH4_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch5OnSeconds", "CH5 On (s)", "CH5_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch1IntermittentSeconds", "CH1 Intermittent (s)", "CH1_INTERMITTENT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch2IntermittentSeconds", "CH2 Intermittent (s)", "CH2_INTERMITTENT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch3IntermittentSeconds", "CH3 Intermittent (s)", "CH3_INTERMITTENT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch4IntermittentSeconds", "CH4 Intermittent (s)", "CH4_INTERMITTENT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch5IntermittentSeconds", "CH5 Intermittent (s)", "CH5_INTERMITTENT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch1LockSeconds", "CH1 Lock (s)", "CH1_LOCK", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch2LockSeconds", "CH2 Lock (s)", "CH2_LOCK", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch3LockSeconds", "CH3 Lock (s)", "CH3_LOCK", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch4LockSeconds", "CH4 Lock (s)", "CH4_LOCK", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch5LockSeconds", "CH5 Lock (s)", "CH5_LOCK", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch1ForceOnSeconds", "CH1 Force On (s)", "CH1_FORCE_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch2ForceOnSeconds", "CH2 Force On (s)", "CH2_FORCE_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch3ForceOnSeconds", "CH3 Force On (s)", "CH3_FORCE_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch4ForceOnSeconds", "CH4 Force On (s)", "CH4_FORCE_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch5ForceOnSeconds", "CH5 Force On (s)", "CH5_FORCE_ON", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch1InhibitSeconds", "CH1 Inhibit (s)", "CH1_INHIBIT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch2InhibitSeconds", "CH2 Inhibit (s)", "CH2_INHIBIT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch3InhibitSeconds", "CH3 Inhibit (s)", "CH3_INHIBIT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch4InhibitSeconds", "CH4 Inhibit (s)", "CH4_INHIBIT", AttributeValueType.NUMBER),
+ new PropertyDescriptor("ch5InhibitSeconds", "CH5 Inhibit (s)", "CH5_INHIBIT", AttributeValueType.NUMBER)
);
@Override
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/TemperatureProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/TemperatureProcessor.java
index 1c3343373..aff371993 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/TemperatureProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/TemperatureProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.value.Value;
import java.util.Arrays;
@@ -29,9 +29,9 @@ import java.util.List;
public class TemperatureProcessor extends FeatureProcessor {
protected static final List<PropertyDescriptor> SUPPORTED_PROPERTIES = Arrays.asList(
- new PropertyDescriptor("tempCurrent", "Temp Current", "TEMP_CURRENT", AttributeType.TEMPERATURE_CELCIUS, true),
- new PropertyDescriptor("tempMin", "Temp Min", "TEMP_MIN", AttributeType.TEMPERATURE_CELCIUS, true),
- new PropertyDescriptor("tempMax", "Temp Max", "TEMP_MAX", AttributeType.TEMPERATURE_CELCIUS, true)
+ new PropertyDescriptor("tempCurrent", "Temp Current", "TEMP_CURRENT", AttributeValueType.TEMPERATURE_CELCIUS, true),
+ new PropertyDescriptor("tempMin", "Temp Min", "TEMP_MIN", AttributeValueType.TEMPERATURE_CELCIUS, true),
+ new PropertyDescriptor("tempMax", "Temp Max", "TEMP_MAX", AttributeValueType.TEMPERATURE_CELCIUS, true)
);
@Override
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
index 0a2409f7b..f05963054 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
@@ -20,7 +20,7 @@
package org.openremote.agent.protocol.velbus.device;
import org.openremote.agent.protocol.velbus.VelbusPacket;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
@@ -130,36 +130,36 @@ public class ThermostatProcessor extends FeatureProcessor {
}
protected static final List<PropertyDescriptor> THERMOSTAT_PROPERTIES = Arrays.asList(
- new PropertyDescriptor("heater", "Heater", "HEATER", AttributeType.STRING, true),
- new PropertyDescriptor("boost", "Boost", "BOOST", AttributeType.STRING, true),
- new PropertyDescriptor("pump", "Pump", "PUMP", AttributeType.STRING, true),
- new PropertyDescriptor("cooler", "Cooler", "COOLER", AttributeType.STRING, true),
- new PropertyDescriptor("tempAlarm1", "Temp Alarm 1", "TEMP_ALARM1", AttributeType.STRING, true),
- new PropertyDescriptor("tempAlarm2", "Temp Alarm 2", "TEMP_ALARM2", AttributeType.STRING, true),
- new PropertyDescriptor("tempAlarm3", "Temp Alarm 3", "TEMP_ALARM3", AttributeType.STRING, true),
- new PropertyDescriptor("tempAlarm4", "Temp Alarm 4", "TEMP_ALARM4", AttributeType.STRING, true),
- new PropertyDescriptor("tempState", "Thermostat State", "TEMP_STATE", AttributeType.STRING),
- new PropertyDescriptor("tempStateDisable", "Thermostat Disable (s)", "TEMP_STATE_DISABLE_SECONDS", AttributeType.TIME_SECONDS),
+ new PropertyDescriptor("heater", "Heater", "HEATER", AttributeValueType.STRING, true),
+ new PropertyDescriptor("boost", "Boost", "BOOST", AttributeValueType.STRING, true),
+ new PropertyDescriptor("pump", "Pump", "PUMP", AttributeValueType.STRING, true),
+ new PropertyDescriptor("cooler", "Cooler", "COOLER", AttributeValueType.STRING, true),
+ new PropertyDescriptor("tempAlarm1", "Temp Alarm 1", "TEMP_ALARM1", AttributeValueType.STRING, true),
+ new PropertyDescriptor("tempAlarm2", "Temp Alarm 2", "TEMP_ALARM2", AttributeValueType.STRING, true),
+ new PropertyDescriptor("tempAlarm3", "Temp Alarm 3", "TEMP_ALARM3", AttributeValueType.STRING, true),
+ new PropertyDescriptor("tempAlarm4", "Temp Alarm 4", "TEMP_ALARM4", AttributeValueType.STRING, true),
+ new PropertyDescriptor("tempState", "Thermostat State", "TEMP_STATE", AttributeValueType.STRING),
+ new PropertyDescriptor("tempStateDisable", "Thermostat Disable (s)", "TEMP_STATE_DISABLE_SECONDS", AttributeValueType.TIME_SECONDS),
// Get current mode or set mode until next program step
- new PropertyDescriptor("tempMode", "Thermostat Mode", "TEMP_MODE", AttributeType.STRING),
+ new PropertyDescriptor("tempMode", "Thermostat Mode", "TEMP_MODE", AttributeValueType.STRING),
// MINS VALUE: 0 = Until next program step, -1 = Permanent, 1-65279 = for N mins
- new PropertyDescriptor("coolComfortMins", "Thermostat Cool Comfort (mins)", "TEMP_MODE_COOL_COMFORT_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("coolDayMins", "Cool Day (mins)", "TEMP_MODE_COOL_DAY_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("coolNightMins", "Cool Night (mins)", "TEMP_MODE_COOL_NIGHT_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("coolSafeMins", "Cool Safe (mins)", "TEMP_MODE_COOL_SAFE_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("heatComfortMins", "Heat Comfort (mins)", "TEMP_MODE_HEAT_COMFORT_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("heatDayMins", "Heat Day (mins)", "TEMP_MODE_HEAT_DAY_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("heatNightMins", "Heat Night (mins)", "TEMP_MODE_HEAT_NIGHT_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("heatSafeMins", "Heat Safe (mins)", "TEMP_MODE_HEAT_SAFE_MINS", AttributeType.TIME_MINUTES),
- new PropertyDescriptor("tempTargetCurrent", "Temp Target Current", "TEMP_TARGET_CURRENT", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetCoolComfort", "Temp Target Cool Comfort", "TEMP_TARGET_COOL_COMFORT", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetCoolDay", "Temp Target Cool Day", "TEMP_TARGET_COOL_DAY", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetCoolNight", "Temp Target Cool Night", "TEMP_TARGET_COOL_NIGHT", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetCoolSafe", "Temp Target Cool Safe", "TEMP_TARGET_COOL_SAFE", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetHeatComfort", "Temp Target Heat Comfort", "TEMP_TARGET_HEAT_COMFORT", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetHeatDay", "Temp Target Heat Day", "TEMP_TARGET_HEAT_DAY", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetHeatNight", "Temp Target Heat Night", "TEMP_TARGET_HEAT_NIGHT", AttributeType.TEMPERATURE_CELCIUS),
- new PropertyDescriptor("tempTargetHeatSafe", "Temp Target Heat Safe", "TEMP_TARGET_HEAT_SAFE", AttributeType.TEMPERATURE_CELCIUS)
+ new PropertyDescriptor("coolComfortMins", "Thermostat Cool Comfort (mins)", "TEMP_MODE_COOL_COMFORT_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("coolDayMins", "Cool Day (mins)", "TEMP_MODE_COOL_DAY_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("coolNightMins", "Cool Night (mins)", "TEMP_MODE_COOL_NIGHT_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("coolSafeMins", "Cool Safe (mins)", "TEMP_MODE_COOL_SAFE_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("heatComfortMins", "Heat Comfort (mins)", "TEMP_MODE_HEAT_COMFORT_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("heatDayMins", "Heat Day (mins)", "TEMP_MODE_HEAT_DAY_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("heatNightMins", "Heat Night (mins)", "TEMP_MODE_HEAT_NIGHT_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("heatSafeMins", "Heat Safe (mins)", "TEMP_MODE_HEAT_SAFE_MINS", AttributeValueType.TIME_MINUTES),
+ new PropertyDescriptor("tempTargetCurrent", "Temp Target Current", "TEMP_TARGET_CURRENT", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolComfort", "Temp Target Cool Comfort", "TEMP_TARGET_COOL_COMFORT", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolDay", "Temp Target Cool Day", "TEMP_TARGET_COOL_DAY", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolNight", "Temp Target Cool Night", "TEMP_TARGET_COOL_NIGHT", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolSafe", "Temp Target Cool Safe", "TEMP_TARGET_COOL_SAFE", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatComfort", "Temp Target Heat Comfort", "TEMP_TARGET_HEAT_COMFORT", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatDay", "Temp Target Heat Day", "TEMP_TARGET_HEAT_DAY", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatNight", "Temp Target Heat Night", "TEMP_TARGET_HEAT_NIGHT", AttributeValueType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatSafe", "Temp Target Heat Safe", "TEMP_TARGET_HEAT_SAFE", AttributeValueType.TEMPERATURE_CELCIUS)
);
@Override
diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java b/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java
index 9a6bbe97f..f9c102af7 100644
--- a/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java
+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java
@@ -204,9 +204,9 @@ public abstract class AbstractAssetActivity<V
view.getAssetNavigation().setEnabled(assetId != null);
view.setName(asset.getName());
view.setCreatedOn(asset.getCreatedOn());
- view.setLocation(asset.getCoordinates().orElse(null));
+ view.setLocation(asset.getPoint());
view.showDroppedPin(asset.getGeoFeature(20));
- view.flyTo(asset.getCoordinates().orElse(null));
+ view.flyTo(asset.getPoint());
view.setAccessPublicRead(asset.isAccessPublicRead());
}
diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetBaseView.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetBaseView.java
index d3c81a041..e4d138ba6 100644
--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetBaseView.java
+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetBaseView.java
@@ -25,6 +25,7 @@ import org.openremote.app.client.assets.browser.BrowserTreeNode;
import org.openremote.app.client.assets.navigation.AssetNavigation;
import org.openremote.model.asset.Asset;
import org.openremote.model.geo.GeoJSON;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.value.ObjectValue;
import java.util.Date;
@@ -69,11 +70,11 @@ public interface AssetBaseView<P extends AssetBaseView.Presenter> extends IsWidg
boolean isMapInitialised();
- void setLocation(ObjectValue coordinates);
+ void setLocation(GeoJSONPoint point);
void showDroppedPin(GeoJSON geoFeature);
- void flyTo(ObjectValue coordinates);
+ void flyTo(GeoJSONPoint point);
void setAccessPublicRead(boolean enabled);
diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java
index 41a0c4aff..ce8daa1bf 100644
--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java
+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java
@@ -44,15 +44,14 @@ import org.openremote.model.asset.agent.AgentResource;
import org.openremote.model.asset.agent.ProtocolConfiguration;
import org.openremote.model.asset.agent.ProtocolDescriptor;
import org.openremote.model.attribute.*;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.http.ConstraintViolation;
import org.openremote.model.interop.Consumer;
import org.openremote.model.map.MapResource;
import org.openremote.model.util.EnumUtil;
import org.openremote.model.util.Pair;
-import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
-import org.openremote.model.value.Values;
import javax.inject.Inject;
import java.util.*;
@@ -84,7 +83,7 @@ public class AssetEditActivity
protected final Consumer<ConstraintViolation[]> validationErrorHandler;
protected List<ProtocolDescriptor> protocolDescriptors = new ArrayList<>();
protected List<MetaItemDescriptor> metaItemDescriptors = new ArrayList<>(Arrays.asList(AssetMeta.values())); // TODO Get meta item descriptors from server
- ObjectValue selectedCoordinates;
+ protected GeoJSONPoint selectedCoordinates;
protected List<AssetAttribute> initialAssetAttributes;
@Inject
@@ -192,7 +191,7 @@ public class AssetEditActivity
@Override
public void onMapClicked(double lng, double lat) {
- selectedCoordinates = Values.createObject().put("longitude", lng).put("latitude", lat);
+ selectedCoordinates = new GeoJSONPoint(new double[]{lng, lat});
view.hideMapPopup();
view.showMapPopup(lng, lat, environment.getMessages().selectedLocation());
view.setLocation(selectedCoordinates);
@@ -236,16 +235,16 @@ public class AssetEditActivity
// This is a protocol configuration add request
attribute = protocolDescriptor.get().getConfigurationTemplate().deepCopy();
} else {
- AttributeType attributeType = EnumUtil.enumFromString(AttributeType.class, type).orElse(null);
+ AttributeValueType attributeValueType = EnumUtil.enumFromString(AttributeValueType.class, type).orElse(null);
- if (attributeType == null) {
+ if (attributeValueType == null) {
showFailureMessage(environment.getMessages().invalidAttributeType());
return false;
}
attribute = new AssetAttribute();
- attribute.setType(attributeType);
- attribute.addMeta(attributeType.getDefaultMetaItems());
+ attribute.setType(attributeValueType);
+ attribute.addMeta(attributeValueType.getDefaultMetaItems());
}
attribute.setName(name);
@@ -463,9 +462,8 @@ public class AssetEditActivity
public void centerMap() {
if (selectedCoordinates != null) {
view.flyTo(selectedCoordinates);
- }
- else if (asset.getCoordinates().isPresent()) {
- view.flyTo(asset.getCoordinates().get());
+ } else if (asset.getCoordinates() != null) {
+ view.flyTo(asset.getPoint());
}
}
@@ -644,9 +642,9 @@ public class AssetEditActivity
}
protected List<Pair<String, String>> attributeTypesToList() {
- return Arrays.stream(AttributeType.values())
+ return Arrays.stream(AttributeValueType.values())
.map(Enum::name)
- .map(attrType -> new Pair<>(environment.getMessages().attributeType(attrType), attrType))
+ .map(attrType -> new Pair<>(environment.getMessages().attributeValueType(attrType), attrType))
.sorted(Comparator.comparing(a -> a.key))
.collect(Collectors.toList());
}
@@ -664,7 +662,7 @@ public class AssetEditActivity
asset.setType(view.getType());
}
if (selectedCoordinates != null) {
- asset.setCoordinates(selectedCoordinates);
+ asset.setCoordinates(new double[]{selectedCoordinates.getLongitude(), selectedCoordinates.getLatitude()});
}
}
diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditImpl.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditImpl.java
index ce2bdcdf8..153911d6e 100644
--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditImpl.java
+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditImpl.java
@@ -44,6 +44,7 @@ import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetType;
import org.openremote.model.asset.AssetTypeDescriptor;
import org.openremote.model.geo.GeoJSON;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.util.Pair;
import org.openremote.model.value.ObjectValue;
@@ -327,8 +328,8 @@ public class AssetEditImpl extends FormViewImpl implements AssetEdit {
}
@Override
- public void setLocation(ObjectValue coordinates) {
- if (locationOutput.setCoordinates(managerMessages.selectLocation(), coordinates)) {
+ public void setLocation(GeoJSONPoint point) {
+ if (locationOutput.setCoordinates(managerMessages.selectLocation(), point)) {
centerMapButton.setEnabled(true);
} else {
centerMapButton.setEnabled(false);
@@ -374,9 +375,9 @@ public class AssetEditImpl extends FormViewImpl implements AssetEdit {
}
@Override
- public void flyTo(ObjectValue coordinates) {
+ public void flyTo(GeoJSONPoint point) {
if (mapWidget.isMapReady()) {
- mapWidget.flyTo(coordinates);
+ mapWidget.flyTo(point);
}
}
diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java
index 88bf47537..495ed4570 100644
--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java
+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewActivity.java
@@ -164,7 +164,7 @@ public class AssetViewActivity
@Override
public void centerMap() {
- view.flyTo(asset.getCoordinates().orElse(null));
+ view.flyTo(asset.getPoint());
}
@Override
diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewImpl.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewImpl.java
index fcf411ea3..1706d47c3 100644
--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewImpl.java
+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetViewImpl.java
@@ -44,6 +44,7 @@ import org.openremote.model.Constants;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetType;
import org.openremote.model.geo.GeoJSON;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.value.ObjectValue;
import javax.inject.Inject;
@@ -294,8 +295,8 @@ public class AssetViewImpl extends Composite implements AssetView {
/* ############################################################################ */
@Override
- public void setLocation(ObjectValue coordinates) {
- if (locationOutput.setCoordinates(managerMessages.selectLocation(), coordinates)) {
+ public void setLocation(GeoJSONPoint point) {
+ if (locationOutput.setCoordinates(managerMessages.selectLocation(), point)) {
locationGroup.setVisible(true);
mapWidget.setVisible(true);
mapWidget.resize();
@@ -327,9 +328,9 @@ public class AssetViewImpl extends Composite implements AssetView {
}
@Override
- public void flyTo(ObjectValue coordinates) {
+ public void flyTo(GeoJSONPoint point) {
if (mapWidget.isMapReady()) {
- mapWidget.flyTo(coordinates);
+ mapWidget.flyTo(point);
}
}
diff --git a/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeViewImpl.java b/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeViewImpl.java
index 7043da88c..6ea547e1e 100644
--- a/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeViewImpl.java
+++ b/client/src/main/java/org/openremote/app/client/assets/attributes/AttributeViewImpl.java
@@ -27,7 +27,7 @@ import org.openremote.app.client.widget.*;
import org.openremote.app.client.Environment;
import org.openremote.model.asset.AssetAttribute;
import org.openremote.model.asset.agent.ConnectionStatus;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.attribute.AttributeValidationResult;
import org.openremote.model.interop.Consumer;
import org.openremote.model.value.Value;
@@ -195,7 +195,7 @@ public class AttributeViewImpl extends FormGroup implements AttributeView {
protected IsWidget createAttributeValueEditor() {
return valueEditorSupplier.createValueEditor(attribute,
- attribute.getType().map(AttributeType::getValueType).orElse(null),
+ attribute.getType().map(AttributeValueType::getValueType).orElse(null),
style,
null,
this::notifyAttributeModified);
@@ -251,7 +251,7 @@ public class AttributeViewImpl extends FormGroup implements AttributeView {
} else if (attribute.isProtocolConfiguration()) {
formLabel.setIcon("gears");
} else {
- formLabel.setIcon(attribute.getType().map(AttributeType::getIcon).orElse(AttributeType.DEFAULT_ICON));
+ formLabel.setIcon(attribute.getType().map(AttributeValueType::getIcon).orElse(AttributeValueType.DEFAULT_ICON));
}
getFormLabel().setText(getAttributeLabel());
@@ -266,7 +266,7 @@ public class AttributeViewImpl extends FormGroup implements AttributeView {
infoText.append(connectionStatus != null ? connectionStatus.toString() : environment.getMessages().waitingForStatus());
}
} else if (attribute.getType().isPresent()) {
- infoText.append(environment.getMessages().attributeType(attribute.getType().get().name()));
+ infoText.append(environment.getMessages().attributeValueType(attribute.getType().get().name()));
}
getAttributeDescription()
.ifPresent(description -> {
diff --git a/client/src/main/java/org/openremote/app/client/i18n/ManagerMessages.java b/client/src/main/java/org/openremote/app/client/i18n/ManagerMessages.java
index 44d91e346..f7e3382a2 100644
--- a/client/src/main/java/org/openremote/app/client/i18n/ManagerMessages.java
+++ b/client/src/main/java/org/openremote/app/client/i18n/ManagerMessages.java
@@ -327,7 +327,7 @@ public interface ManagerMessages extends Messages {
String commandRequestSent(String name);
- String attributeType(@Select String name);
+ String attributeValueType(@Select String name);
String validationFailureOnAttribute(String attributeName);
diff --git a/client/src/main/java/org/openremote/app/client/map/MapActivity.java b/client/src/main/java/org/openremote/app/client/map/MapActivity.java
index e6a8828eb..e08095e4e 100644
--- a/client/src/main/java/org/openremote/app/client/map/MapActivity.java
+++ b/client/src/main/java/org/openremote/app/client/map/MapActivity.java
@@ -34,7 +34,7 @@ import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
import org.openremote.model.asset.AssetResource;
import org.openremote.model.attribute.AttributeEvent;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.event.bus.EventBus;
import org.openremote.model.event.bus.EventRegistration;
import org.openremote.model.geo.GeoJSON;
@@ -189,7 +189,7 @@ public class MapActivity extends AssetBrowsingActivity<MapPlace> implements MapV
if (asset.hasGeoFeature()) {
GeoJSON geoFeature = asset.getGeoFeature(30);
view.showDroppedPin(geoFeature);
- view.flyTo(asset.getCoordinates().get());
+ view.flyTo(asset.getPoint());
}
}
@@ -197,7 +197,7 @@ public class MapActivity extends AssetBrowsingActivity<MapPlace> implements MapV
List<MapInfoItem> infoItems = dashboardAttributes.stream()
.filter(attribute -> attribute.getLabel().isPresent())
.map(attribute -> new MapInfoItem(
- attribute.getType().map(AttributeType::getIcon).orElse(AttributeType.DEFAULT_ICON),
+ attribute.getType().map(AttributeValueType::getIcon).orElse(AttributeValueType.DEFAULT_ICON),
attribute.getLabel().get(),
attribute.getFormat().orElse(null),
attribute.getValue().orElse(null)
diff --git a/client/src/main/java/org/openremote/app/client/map/MapView.java b/client/src/main/java/org/openremote/app/client/map/MapView.java
index d8132079a..799ec2afd 100644
--- a/client/src/main/java/org/openremote/app/client/map/MapView.java
+++ b/client/src/main/java/org/openremote/app/client/map/MapView.java
@@ -21,6 +21,7 @@ package org.openremote.app.client.map;
import com.google.gwt.user.client.ui.IsWidget;
import org.openremote.model.geo.GeoJSON;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.value.ObjectValue;
import java.util.List;
@@ -41,7 +42,7 @@ public interface MapView extends IsWidget {
void showDroppedPin(GeoJSON geoFeature);
- void flyTo(ObjectValue coordinates);
+ void flyTo(GeoJSONPoint point);
void showInfoItems(List<MapInfoItem> infoItems);
}
diff --git a/client/src/main/java/org/openremote/app/client/map/MapViewImpl.java b/client/src/main/java/org/openremote/app/client/map/MapViewImpl.java
index 7a6fdc939..7718a5093 100644
--- a/client/src/main/java/org/openremote/app/client/map/MapViewImpl.java
+++ b/client/src/main/java/org/openremote/app/client/map/MapViewImpl.java
@@ -34,6 +34,7 @@ import org.openremote.app.client.widget.FlexSplitPanel;
import org.openremote.app.client.widget.Hyperlink;
import org.openremote.app.client.widget.MapWidget;
import org.openremote.model.geo.GeoJSON;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.value.ObjectValue;
import javax.inject.Inject;
@@ -153,9 +154,9 @@ public class MapViewImpl extends Composite implements MapView {
}
@Override
- public void flyTo(ObjectValue coordinates) {
+ public void flyTo(GeoJSONPoint point) {
if (mapWidget.isMapReady()) {
- mapWidget.flyTo(coordinates);
+ mapWidget.flyTo(point);
}
}
diff --git a/client/src/main/java/org/openremote/app/client/widget/FormOutputLocation.java b/client/src/main/java/org/openremote/app/client/widget/FormOutputLocation.java
index 8d69770e6..fdeb29420 100644
--- a/client/src/main/java/org/openremote/app/client/widget/FormOutputLocation.java
+++ b/client/src/main/java/org/openremote/app/client/widget/FormOutputLocation.java
@@ -22,7 +22,7 @@ package org.openremote.app.client.widget;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.InlineLabel;
-import org.openremote.model.value.ObjectValue;
+import org.openremote.model.geo.GeoJSONPoint;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -34,7 +34,7 @@ public class FormOutputLocation extends Composite {
protected FormButton toggleButton = new FormButton();
protected boolean reversed = false;
- protected ObjectValue coordinates;
+ protected GeoJSONPoint coordinates;
public FormOutputLocation() {
initWidget(panel);
@@ -52,9 +52,9 @@ public class FormOutputLocation extends Composite {
});
}
- public boolean setCoordinates(String noLocationText, ObjectValue coordinates) {
- if (coordinates != null && coordinates.hasKey("latitude") && coordinates.hasKey("longitude")) {
- this.coordinates = coordinates;
+ public boolean setCoordinates(String noLocationText, GeoJSONPoint point) {
+ if (point != null && point.hasCoordinates()) {
+ this.coordinates = point;
toggleButton.setVisible(true);
update();
return true;
@@ -68,16 +68,15 @@ public class FormOutputLocation extends Composite {
// TODO: This assumes 0 is Lng and 1 is Lat, which is true for PostGIS backend
// Rounding to 5 decimals gives us precision of about 1 meter, should be enough
if (reversed) {
- coordinatesLabel.setText(round(coordinates.getNumber("latitude").orElse(0d), 5) + " " + round(coordinates.getNumber("longitude").orElse(0d), 5));
+ coordinatesLabel.setText(round(coordinates.getLongitude(), 5) + " " + round(coordinates.getLatitude(), 5));
toggleButton.getUpFace().setText("Lng | Lat");
toggleButton.getDownFace().setText("Lng | Lat");
} else {
- coordinatesLabel.setText(round(coordinates.getNumber("longitude").orElse(0d), 5) + " " + round(coordinates.getNumber("latitude").orElse(0d), 5));
+ coordinatesLabel.setText(round(coordinates.getLatitude(), 5) + " " + round(coordinates.getLongitude(), 5));
toggleButton.getUpFace().setText("Lat | Lng");
toggleButton.getDownFace().setText("Lat | Lng");
}
}
-
protected String round(double d, int places) {
return new BigDecimal(d).setScale(places, RoundingMode.HALF_UP).toString();
}
diff --git a/client/src/main/java/org/openremote/app/client/widget/MapWidget.java b/client/src/main/java/org/openremote/app/client/widget/MapWidget.java
index 324d80de4..fd335eb21 100644
--- a/client/src/main/java/org/openremote/app/client/widget/MapWidget.java
+++ b/client/src/main/java/org/openremote/app/client/widget/MapWidget.java
@@ -24,6 +24,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
import elemental2.dom.DomGlobal;
import org.openremote.app.client.interop.mapbox.*;
import org.openremote.model.geo.GeoJSON;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.value.ArrayValue;
import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Values;
@@ -229,15 +230,15 @@ public class MapWidget extends FlowPanel {
mapboxMap.getSource(featureSourceId).setData(geoFeature.getObjectValue().asAny());
}
- public void flyTo(ObjectValue coordinates) {
+ public void flyTo(GeoJSONPoint point) {
if (!isMapReady())
throw new IllegalStateException("Map not ready");
- if (coordinates == null || !coordinates.hasKey("latitude") || !coordinates.hasKey("longitude"))
+ if (point == null || !point.hasCoordinates())
return;
ObjectValue options = Values.createObject();
ArrayValue center = Values.createArray();
- center.set(0, coordinates.getNumber("longitude").get());
- center.set(1, coordinates.getNumber("latitude").get());
+ center.set(0, point.getLongitude());
+ center.set(1, point.getLatitude());
options.put("center", center);
mapboxMap.flyTo(options.asAny());
}
diff --git a/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties b/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties
index b93e08fa9..fcbc1c408 100644
--- a/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties
+++ b/client/src/main/resources/org/openremote/app/client/i18n/ManagerMessages.properties
@@ -175,53 +175,53 @@ start=Start
repeat=Repeat
getStatus=Get Status
commandRequestSent=Sent command request: {0}
-attributeType=Unknown attribute type
-attributeType[STRING]=Text
-attributeType[NUMBER]=Number
-attributeType[BOOLEAN]=On/Off toggle
-attributeType[OBJECT]=JSON object
-attributeType[ARRAY]=JSON array
-attributeType[PERCENTAGE]=Percentage
-attributeType[TIMESTAMP_MILLIS]=Timestamp milliseconds since epoch
-attributeType[TIMESTAMP_SECONDS]=Timestamp seconds since epoch
-attributeType[DATETIME]=Timestamp in ISO 8601
-attributeType[COLOR_RGB]=Color RGB
-attributeType[COLOR_ARGB]=Color ARGB
-attributeType[COLOR_HEX]=Color HEX
-attributeType[TEMPERATURE_CELCIUS]=Temperature in Celcius
-attributeType[TEMPERATURE_KELVIN]=Temperature in Kelvin
-attributeType[TEMPERATURE_FAHRENHEIT]=Temperature in Fahrenheit
-attributeType[DISTANCE_M]=Distance in metres
-attributeType[DISTANCE_CM]=Distance in centimetres
-attributeType[DISTANCE_MM]=Distance in millimetres
-attributeType[DISTANCE_IN]=Distance in inch
-attributeType[DISTANCE_FT]=Distance in feet
-attributeType[DISTANCE_YARD]=Distance in yard
-attributeType[CO2_PPM]=CO2 Level in PPM
-attributeType[HUMIDITY_PERCENTAGE]=Humidity percentage
-attributeType[HUMIDITY_GPCM]=Humidity in grams per cubic metres
-attributeType[POWER_WATT]=Power in watt
-attributeType[POWER_KILOWATT]=Power in kilowatt
-attributeType[POWER_MEGAWATT]=Power in megawatt
-attributeType[CHARGE_PERCENTAGE]=Charge percentage
-attributeType[CHARGE_KWH]=Charge in kilowatt-hours
-attributeType[ENERGY_KWH]=Energy in kilowatt-hours
-attributeType[ENERGY_JOULE]=Energy in joule
-attributeType[ENERGY_MEGAJOULE]=Energy in megajoule
-attributeType[FLOW_LPM]=Flow in litre per minute
-attributeType[FLOW_CMPS]=Flow in cubic metres per second
-attributeType[FLOW_SCCM]=Flow in cubic centimetres per minute
-attributeType[FLOW_CFPS]=Flow in cubic feet per second
-attributeType[FLOW_GPM]=Flow in gallons per minute
-attributeType[RULES_TEMPLATE_FILTER]=Rules template filter
-attributeType[SPEED_MS]=Metres per second
-attributeType[SPEED_KPH]=Kilometres per hour
-attributeType[SPEED_MPH]=Miles per hour
-attributeType[TIME_SECONDS]=Time seconds
-attributeType[TIME_MINUTES]=Time minutes
-attributeType[RAINFALL]=Rainfall millimetres per hour
-attributeType[BRIGHTNESS_LUX]=Lux brightness
-attributeType[DIRECTION_DECIMAL_DEGREES]=Direction in decimal degrees
+attributeValueType=Unknown attribute type
+attributeValueType[STRING]=Text
+attributeValueType[NUMBER]=Number
+attributeValueType[BOOLEAN]=On/Off toggle
+attributeValueType[OBJECT]=JSON object
+attributeValueType[ARRAY]=JSON array
+attributeValueType[PERCENTAGE]=Percentage
+attributeValueType[TIMESTAMP_MILLIS]=Timestamp milliseconds since epoch
+attributeValueType[TIMESTAMP_SECONDS]=Timestamp seconds since epoch
+attributeValueType[DATETIME]=Timestamp in ISO 8601
+attributeValueType[COLOR_RGB]=Color RGB
+attributeValueType[COLOR_ARGB]=Color ARGB
+attributeValueType[COLOR_HEX]=Color HEX
+attributeValueType[TEMPERATURE_CELCIUS]=Temperature in Celcius
+attributeValueType[TEMPERATURE_KELVIN]=Temperature in Kelvin
+attributeValueType[TEMPERATURE_FAHRENHEIT]=Temperature in Fahrenheit
+attributeValueType[DISTANCE_M]=Distance in metres
+attributeValueType[DISTANCE_CM]=Distance in centimetres
+attributeValueType[DISTANCE_MM]=Distance in millimetres
+attributeValueType[DISTANCE_IN]=Distance in inch
+attributeValueType[DISTANCE_FT]=Distance in feet
+attributeValueType[DISTANCE_YARD]=Distance in yard
+attributeValueType[CO2_PPM]=CO2 Level in PPM
+attributeValueType[HUMIDITY_PERCENTAGE]=Humidity percentage
+attributeValueType[HUMIDITY_GPCM]=Humidity in grams per cubic metres
+attributeValueType[POWER_WATT]=Power in watt
+attributeValueType[POWER_KILOWATT]=Power in kilowatt
+attributeValueType[POWER_MEGAWATT]=Power in megawatt
+attributeValueType[CHARGE_PERCENTAGE]=Charge percentage
+attributeValueType[CHARGE_KWH]=Charge in kilowatt-hours
+attributeValueType[ENERGY_KWH]=Energy in kilowatt-hours
+attributeValueType[ENERGY_JOULE]=Energy in joule
+attributeValueType[ENERGY_MEGAJOULE]=Energy in megajoule
+attributeValueType[FLOW_LPM]=Flow in litre per minute
+attributeValueType[FLOW_CMPS]=Flow in cubic metres per second
+attributeValueType[FLOW_SCCM]=Flow in cubic centimetres per minute
+attributeValueType[FLOW_CFPS]=Flow in cubic feet per second
+attributeValueType[FLOW_GPM]=Flow in gallons per minute
+attributeValueType[RULES_TEMPLATE_FILTER]=Rules template filter
+attributeValueType[SPEED_MS]=Metres per second
+attributeValueType[SPEED_KPH]=Kilometres per hour
+attributeValueType[SPEED_MPH]=Miles per hour
+attributeValueType[TIME_SECONDS]=Time seconds
+attributeValueType[TIME_MINUTES]=Time minutes
+attributeValueType[RAINFALL]=Rainfall millimetres per hour
+attributeValueType[BRIGHTNESS_LUX]=Lux brightness
+attributeValueType[DIRECTION_DECIMAL_DEGREES]=Direction in decimal degrees
validationFailureOnAttribute=Attribute error on ''{0}''
validationFailureOnMetaItem=Meta item error on ''{0}'' meta item ''{1}''
validationFailure=Unknown validation failure.
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
index 9790bccd9..1bdde0caa 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
@@ -27,7 +27,7 @@ import org.openremote.model.Constants;
import org.openremote.model.asset.*;
import org.openremote.model.asset.BaseAssetQuery.Select;
import org.openremote.model.attribute.*;
-import org.openremote.model.geo.GeoJSONGeometry;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.http.RequestParams;
import org.openremote.model.security.Tenant;
import org.openremote.model.util.TextUtil;
@@ -319,7 +319,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
// TODO Only done for update(Asset) and not create(Asset) as we don't need that right now
// TODO Implement "Saved Filter/Searches" properly, allowing restricted users to create rule state flags is not great
resultAsset.getAttributesStream().forEach(attribute -> {
- if (attribute.getType().map(attributeType -> attributeType == AttributeType.RULES_TEMPLATE_FILTER).orElse(false)
+ if (attribute.getType().map(attributeType -> attributeType == AttributeValueType.RULES_TEMPLATE_FILTER).orElse(false)
&& !attribute.hasMetaItem(AssetMeta.RULE_STATE)) {
attribute.addMeta(new MetaItem(AssetMeta.RULE_STATE, Values.create(true)));
}
@@ -601,12 +601,12 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
}
@Override
- public void updateLocation(RequestParams requestParams, String assetId, GeoJSONGeometry location) {
+ public void updateLocation(RequestParams requestParams, String assetId, GeoJSONPoint location) {
try {
Asset asset = get(requestParams, assetId);
- AssetAttribute locationAttribute = asset.getAttribute(AttributeDescriptorImpl.LOCATION.getName())
- .orElse(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION));
+ AssetAttribute locationAttribute = asset.getAttribute(AttributeValue.LOCATION.getName())
+ .orElse(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION));
ObjectValue currentCoordinates = locationAttribute.getValueAsObject().orElse(Values.createObject());
ArrayValue arrayValue = location.getObjectValue().getArray("coordinates").orElseThrow(() -> new IllegalStateException("location doesn't contain 'coordinates' key"));
@@ -622,7 +622,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
}
@Override
- public void updatePublicAssetLocation(RequestParams requestParams, String assetId, GeoJSONGeometry location) {
+ public void updatePublicAssetLocation(RequestParams requestParams, String assetId, GeoJSONPoint location) {
try {
Asset[] result = queryPublicAssets(requestParams, new AssetQuery().id(assetId));
@@ -632,8 +632,9 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
Asset asset = result[0];
- AssetAttribute locationAttribute = asset.getAttribute(AttributeDescriptorImpl.LOCATION.getName())
- .orElse(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION));
+ //TODO do we need a PUBLIC_WRITE metaitem?
+ AssetAttribute locationAttribute = asset.getAttribute(AttributeValue.LOCATION.getName())
+ .orElse(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION));
ObjectValue currentCoordinates = locationAttribute.getValueAsObject().orElse(Values.createObject());
ArrayValue arrayValue = location.getObjectValue().getArray("coordinates").orElseThrow(() -> new IllegalStateException("location doesn't contain 'coordinates' key"));
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
index 57f87ea56..ae7cdbddd 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
@@ -44,6 +44,7 @@ import org.openremote.manager.security.UserConfiguration;
import org.openremote.model.Constants;
import org.openremote.model.ValidationFailure;
import org.openremote.model.asset.*;
+import org.openremote.model.attribute.AttributeValue;
import org.openremote.model.attribute.AttributeEvent;
import org.openremote.model.calendar.CalendarEvent;
import org.openremote.model.calendar.RecurrenceRule;
@@ -63,11 +64,13 @@ import java.util.*;
import java.util.Date;
import java.util.function.Consumer;
import java.util.logging.Logger;
+import java.util.stream.Stream;
import static org.openremote.container.persistence.PersistenceEvent.PERSISTENCE_TOPIC;
import static org.openremote.container.persistence.PersistenceEvent.isPersistenceEventForEntityType;
import static org.openremote.manager.event.ClientEventService.CLIENT_EVENT_TOPIC;
import static org.openremote.manager.event.ClientEventService.getSessionKey;
+import static org.openremote.model.asset.AssetAttribute.attributesFromJson;
import static org.openremote.model.asset.BaseAssetQuery.*;
import static org.openremote.model.asset.BaseAssetQuery.Access.PRIVATE_READ;
import static org.openremote.model.asset.BaseAssetQuery.Access.RESTRICTED_READ;
@@ -1316,6 +1319,23 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic
);
break;
}
+
+ // Did the location change?
+ Stream<AssetAttribute> oldAttributes = attributesFromJson(persistenceEvent.getPreviousState("attributes"), asset.getId());
+ Stream<AssetAttribute> currentAttributes = attributesFromJson(persistenceEvent.getCurrentState("attributes"), asset.getId());
+
+ Optional<AssetAttribute> oldLocation = oldAttributes.filter(assetAttribute -> assetAttribute.name.equals(AttributeValue.LOCATION.getName())).findFirst();
+ Optional<AssetAttribute> currentLocation = currentAttributes.filter(assetAttribute -> assetAttribute.name.equals(AttributeValue.LOCATION.getName())).findFirst();
+
+ if (!(!oldLocation.isPresent() && !currentLocation.isPresent())) {
+ if (!oldLocation.isPresent() || !currentLocation.isPresent() || !oldLocation.get().equals(currentLocation.get())) {
+ clientEventService.publishEvent(
+ new LocationEvent(asset.getId(),
+ asset.getCoordinates(),
+ timerService.getCurrentTimeMillis())
+ );
+ }
+ }
break;
case DELETE:
clientEventService.publishEvent(
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java b/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java
index c01974b2b..b72a1e86a 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesResourceImpl.java
@@ -26,7 +26,7 @@ import org.openremote.manager.web.ManagerWebResource;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetQuery;
import org.openremote.model.asset.BaseAssetQuery;
-import org.openremote.model.attribute.AttributeDescriptorImpl;
+import org.openremote.model.attribute.AttributeValue;
import org.openremote.model.http.RequestParams;
import org.openremote.model.rules.AssetRuleset;
import org.openremote.model.rules.GlobalRuleset;
@@ -316,7 +316,7 @@ public class RulesResourceImpl extends ManagerWebResource implements RulesResour
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
} else //noinspection ConstantConditions
- if (!asset.getAttribute(AttributeDescriptorImpl.CONSOLE_PROVIDER_GEOFENCE.getName()).get().isAccessPublicRead()) {
+ if (!asset.getAttribute(AttributeValue.CONSOLE_PROVIDER_GEOFENCE.getName()).get().isAccessPublicRead()) {
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesService.java b/manager/src/main/java/org/openremote/manager/rules/RulesService.java
index 37d99c250..cea4faafa 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesService.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesService.java
@@ -35,7 +35,7 @@ import org.openremote.manager.notification.NotificationService;
import org.openremote.manager.rules.geofence.GeofenceAssetAdapter;
import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.model.asset.*;
-import org.openremote.model.attribute.AttributeDescriptorImpl;
+import org.openremote.model.attribute.AttributeValue;
import org.openremote.model.attribute.AttributeEvent.Source;
import org.openremote.model.rules.*;
import org.openremote.model.rules.geofence.GeofenceDefinition;
@@ -184,7 +184,7 @@ public class RulesService extends RouteBuilder implements ContainerService, Asse
new AssetQuery()
.select(new BaseAssetQuery.Select(BaseAssetQuery.Include.ALL_EXCEPT_PATH,
false,
- AttributeDescriptorImpl.CONSOLE_PROVIDER_GEOFENCE.getName()))
+ AttributeValue.CONSOLE_PROVIDER_GEOFENCE.getName()))
.attributeMeta(
new AssetQuery.AttributeMetaPredicate(
AssetMeta.GEOFENCE_ADAPTER)
diff --git a/manager/src/main/java/org/openremote/manager/rules/geofence/GeofenceAssetAdapter.java b/manager/src/main/java/org/openremote/manager/rules/geofence/GeofenceAssetAdapter.java
index 562444884..ba15eadee 100644
--- a/manager/src/main/java/org/openremote/manager/rules/geofence/GeofenceAssetAdapter.java
+++ b/manager/src/main/java/org/openremote/manager/rules/geofence/GeofenceAssetAdapter.java
@@ -26,7 +26,7 @@ import org.openremote.model.AbstractValueHolder;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetMeta;
import org.openremote.model.asset.BaseAssetQuery;
-import org.openremote.model.attribute.AttributeDescriptorImpl;
+import org.openremote.model.attribute.AttributeValue;
import org.openremote.model.rules.geofence.GeofenceDefinition;
import java.util.List;
@@ -56,7 +56,7 @@ import java.util.Optional;
public abstract class GeofenceAssetAdapter implements ContainerService {
public static Optional<String> getAssetGeofenceAdapterName(Asset asset) {
- return asset.getAttribute(AttributeDescriptorImpl.CONSOLE_PROVIDER_GEOFENCE.getName())
+ return asset.getAttribute(AttributeValue.CONSOLE_PROVIDER_GEOFENCE.getName())
.flatMap(attr -> attr.getMetaItem(AssetMeta.GEOFENCE_ADAPTER))
.flatMap(AbstractValueHolder::getValueAsString);
}
diff --git a/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java b/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
index 47c6d6e1d..c0e4f9731 100644
--- a/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
+++ b/manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
@@ -25,7 +25,7 @@ import org.openremote.manager.rules.RulesEngine;
import org.openremote.model.asset.AssetMeta;
import org.openremote.model.asset.AssetType;
import org.openremote.model.asset.BaseAssetQuery;
-import org.openremote.model.attribute.AttributeDescriptorImpl;
+import org.openremote.model.attribute.AttributeValue;
import org.openremote.model.rules.AssetState;
import org.openremote.model.rules.geofence.GeofenceDefinition;
@@ -36,7 +36,7 @@ import java.util.*;
* Android and iOS Consoles):
* <ul>
* <li>Asset type: {@link AssetType#CONSOLE}</li>
- * <li>Has the required {@link AttributeDescriptorImpl#CONSOLE_PROVIDER_GEOFENCE} attribute with an
+ * <li>Has the required {@link AttributeValue#CONSOLE_PROVIDER_GEOFENCE} attribute with an
* {@link AssetMeta#GEOFENCE_ADAPTER} with a value of "ORConsole"</li>
* </ul>
* <p>
@@ -121,6 +121,6 @@ public class ORConsoleGeofenceAssetAdapter extends GeofenceAssetAdapter {
protected void notifyAssetGeofencesChanged(String assetId) {
// TODO: implement geofence push notification
- notificationService.findDeviceToken()
+// notificationService.findDeviceToken(assetId);
}
}
diff --git a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
index d62c0a615..ae65a051e 100644
--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
@@ -49,7 +49,7 @@ import static org.openremote.agent.protocol.timer.TimerProtocol.META_TIMER_VALUE
import static org.openremote.model.asset.AssetMeta.*;
import static org.openremote.model.asset.AssetType.*;
import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
-import static org.openremote.model.attribute.AttributeType.*;
+import static org.openremote.model.attribute.AttributeValueType.*;
public abstract class AbstractManagerSetup implements Setup {
@@ -79,7 +79,7 @@ public abstract class AbstractManagerSetup implements Setup {
protected Asset createDemoApartment(Asset parent, String name) {
Asset apartment = new Asset(name, RESIDENCE, parent);
apartment.setAttributes(
- new AssetAttribute("alarmEnabled", AttributeType.BOOLEAN)
+ new AssetAttribute("alarmEnabled", AttributeValueType.BOOLEAN)
.setMeta(new Meta(
new MetaItem(LABEL, Values.create("Alarm enabled")),
new MetaItem(DESCRIPTION, Values.create("Send notifications when presence is detected")),
@@ -88,7 +88,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(RULE_STATE, Values.create(true)),
new MetaItem(SHOW_ON_DASHBOARD, Values.create(true))
)),
- new AssetAttribute("presenceDetected", AttributeType.BOOLEAN)
+ new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN)
.setMeta(new Meta(
new MetaItem(LABEL, Values.create("Presence detected")),
new MetaItem(DESCRIPTION, Values.create("Presence detected in any room")),
@@ -106,7 +106,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),
new MetaItem(RULE_STATE, Values.create(true))
)),
- new AssetAttribute("lastExecutedScene", AttributeType.STRING)
+ new AssetAttribute("lastExecutedScene", AttributeValueType.STRING)
.setMeta(
new MetaItem(LABEL, Values.create("Last executed scene")),
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
@@ -115,7 +115,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(SHOW_ON_DASHBOARD, Values.create(true))
)
/* TODO Unused, can be removed? Port schedule prediction from DRL...
- new AssetAttribute("autoSceneSchedule", AttributeType.BOOLEAN)
+ new AssetAttribute("autoSceneSchedule", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem(LABEL, Values.create("Automatic scene schedule")),
new MetaItem(DESCRIPTION, Values.create("Predict presence and automatically adjust scene schedule")),
@@ -123,7 +123,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("lastDetectedScene", AttributeType.STRING)
+ new AssetAttribute("lastDetectedScene", AttributeValueType.STRING)
.setMeta(
new MetaItem(LABEL, Values.create("Last detected scene by rules")),
new MetaItem(READ_ONLY, Values.create(true)),
@@ -148,7 +148,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(READ_ONLY, Values.create(true)),
new MetaItem(RULE_STATE, Values.create(true))
).addMeta(shouldBeLinked ? agentLinker.get() : null),
- new AssetAttribute("presenceDetected", AttributeType.BOOLEAN)
+ new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem(LABEL, Values.create("Presence detected")),
new MetaItem(DESCRIPTION, Values.create("Someone is moving or resting in the room")),
@@ -431,7 +431,7 @@ public abstract class AbstractManagerSetup implements Setup {
protected void linkDemoApartmentWithSceneAgent(Asset apartment, Asset agent, Scene[] scenes) {
for (Scene scene : scenes) {
apartment.addAttributes(
- new AssetAttribute(scene.attributeName, AttributeType.STRING, Values.create(AttributeExecuteStatus.READY.name()))
+ new AssetAttribute(scene.attributeName, AttributeValueType.STRING, Values.create(AttributeExecuteStatus.READY.name()))
.setMeta(
new MetaItem(LABEL, Values.create(scene.attributeLabel)),
new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),
@@ -439,7 +439,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(EXECUTABLE, Values.create(true)),
new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())
),
- new AssetAttribute(scene.attributeName + "AlarmEnabled", AttributeType.BOOLEAN)
+ new AssetAttribute(scene.attributeName + "AlarmEnabled", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem(LABEL, Values.create(scene.attributeLabel + " alarm enabled")),
new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),
@@ -447,7 +447,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(META_MACRO_ACTION_INDEX, Values.create(0)),
new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName).toArrayValue())
),
- new AssetAttribute(scene.attributeName + "TargetTemperature", AttributeType.NUMBER)
+ new AssetAttribute(scene.attributeName + "TargetTemperature", AttributeValueType.NUMBER)
.setMeta(
new MetaItem(LABEL, Values.create(scene.attributeLabel + " target temperature")),
new MetaItem(ACCESS_RESTRICTED_WRITE, Values.create(true)),
@@ -460,7 +460,7 @@ public abstract class AbstractManagerSetup implements Setup {
// "MONDAY" => "Monday"
String dayOfWeekLabel = dayOfWeek.name().substring(0, 1) + dayOfWeek.name().substring(1).toLowerCase(Locale.ROOT);
apartment.addAttributes(
- new AssetAttribute(scene.attributeName + "Time" + dayOfWeek.name(), AttributeType.STRING)
+ new AssetAttribute(scene.attributeName + "Time" + dayOfWeek.name(), AttributeValueType.STRING)
.setMeta(
new MetaItem(LABEL, Values.create(scene.attributeLabel + " time " + dayOfWeekLabel)),
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
@@ -469,7 +469,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(META_TIMER_VALUE_LINK, Values.create(TimerValue.TIME.toString())),
new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), scene.attributeName + dayOfWeek.name()).toArrayValue())
),
- new AssetAttribute(scene.attributeName + "Enabled" + dayOfWeek.name(), AttributeType.BOOLEAN)
+ new AssetAttribute(scene.attributeName + "Enabled" + dayOfWeek.name(), AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem(LABEL, Values.create(scene.attributeLabel + " enabled " + dayOfWeekLabel)),
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
@@ -481,14 +481,14 @@ public abstract class AbstractManagerSetup implements Setup {
}
}
apartment.addAttributes(
- new AssetAttribute("sceneTimerEnabled", AttributeType.BOOLEAN, Values.create(true)) // The scene timer is enabled when the timer protocol starts
+ new AssetAttribute("sceneTimerEnabled", AttributeValueType.BOOLEAN, Values.create(true)) // The scene timer is enabled when the timer protocol starts
.setMeta(
new MetaItem(LABEL, Values.create("Scene timer enabled")),
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
new MetaItem(SHOW_ON_DASHBOARD, Values.create(true)),
new MetaItem(READ_ONLY, Values.create(true))
),
- new AssetAttribute("enableSceneTimer", AttributeType.STRING)
+ new AssetAttribute("enableSceneTimer", AttributeValueType.STRING)
.setMeta(
new MetaItem(LABEL, Values.create("Enable scene timer")),
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
@@ -496,7 +496,7 @@ public abstract class AbstractManagerSetup implements Setup {
new MetaItem(EXECUTABLE, Values.create(true)),
new MetaItem(AGENT_LINK, new AttributeRef(agent.getId(), "enableSceneTimer").toArrayValue())
),
- new AssetAttribute("disableSceneTimer", AttributeType.STRING)
+ new AssetAttribute("disableSceneTimer", AttributeValueType.STRING)
.setMeta(
new MetaItem(LABEL, Values.create("Disable scene timer")),
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true)),
diff --git a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
index fa472fa7e..97ae85542 100644
--- a/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
@@ -22,10 +22,7 @@ package org.openremote.manager.setup.builtin;
import org.openremote.agent.protocol.simulator.SimulatorProtocol;
import org.openremote.container.Container;
import org.openremote.manager.setup.AbstractManagerSetup;
-import org.openremote.model.asset.Asset;
-import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.AssetMeta;
-import org.openremote.model.asset.UserAsset;
+import org.openremote.model.asset.*;
import org.openremote.model.attribute.*;
import org.openremote.model.security.Tenant;
import org.openremote.model.simulator.element.ColorSimulatorElement;
@@ -43,7 +40,7 @@ import java.util.List;
import static org.openremote.model.asset.AssetMeta.*;
import static org.openremote.model.asset.AssetType.*;
import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
-import static org.openremote.model.attribute.AttributeType.*;
+import static org.openremote.model.attribute.AttributeValueType.*;
public class ManagerDemoSetup extends AbstractManagerSetup {
@@ -106,13 +103,13 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
smartOffice.setName("Smart Office");
smartOffice.setType(BUILDING);
List<AssetAttribute> smartOfficeAttributes = Arrays.asList(
- AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValue),
+ AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValue),
new AssetAttribute("geoStreet", STRING, Values.create("Torenallee 20"))
.setMeta(
new MetaItem(LABEL, Values.create("Street")),
new MetaItem(ABOUT, Values.create("http://project-haystack.org/tag/geoStreet"))
),
- new AssetAttribute("geoPostalCode", AttributeType.NUMBER, Values.create(5617))
+ new AssetAttribute("geoPostalCode", AttributeValueType.NUMBER, Values.create(5617))
.setMeta(
new MetaItem(LABEL, Values.create("Postal Code")),
new MetaItem(ABOUT, Values.create("http://project-haystack.org/tag/geoPostalCode"))
@@ -134,14 +131,14 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
smartOfficeId = smartOffice.getId();
Asset groundFloor = new Asset("Ground Floor", FLOOR, smartOffice)
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValue));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValue));
groundFloor = assetStorageService.merge(groundFloor);
groundFloorId = groundFloor.getId();
Asset lobby = new Asset("Lobby", ROOM, groundFloor)
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValue));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValue));
lobby.addAttributes(
- new AssetAttribute("lobbyLocations", AttributeType.ARRAY)
+ new AssetAttribute("lobbyLocations", AttributeValueType.ARRAY)
);
lobby = assetStorageService.merge(lobby);
@@ -149,7 +146,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
Asset agent = new Asset("Demo Agent", AGENT, lobby);
agent.addAttributes(
- AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValue),
+ AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValue),
initProtocolConfiguration(new AssetAttribute(agentProtocolConfigName), SimulatorProtocol.PROTOCOL_NAME)
.addMeta(
new MetaItem(
@@ -166,7 +163,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
agentId = agent.getId();
Asset thing = new Asset("Demo Thing", THING, agent)
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValue)
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValue)
.setMeta(new MetaItem(RULE_STATE, Values.create(true))));
thing.addAttributes(
new AssetAttribute(thingLightToggleAttributeName, BOOLEAN, Values.create(true))
@@ -368,13 +365,13 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
smartHome.setName("Smart Home");
smartHome.setType(BUILDING);
smartHome.addAttributes(
- AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA),
+ AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA),
new AssetAttribute("geoStreet", STRING, Values.create("Wilhelminaplein 21C"))
.setMeta(
new MetaItem(LABEL, Values.create("Street")),
new MetaItem(ABOUT, Values.create("http://project-haystack.org/tag/geoStreet"))
),
- new AssetAttribute("geoPostalCode", AttributeType.NUMBER, Values.create(5611))
+ new AssetAttribute("geoPostalCode", AttributeValueType.NUMBER, Values.create(5611))
.setMeta(
new MetaItem(LABEL, Values.create("Postal Code")),
new MetaItem(ABOUT, Values.create("http://project-haystack.org/tag/geoPostalCode"))
@@ -395,7 +392,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
// The "Apartment 1" is the demo apartment with complex scenes
Asset apartment1 = createDemoApartment(smartHome, "Apartment 1")
- .addAttributes(new AssetAttribute("location", LOCATION, locationValueA));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA));
apartment1 = assetStorageService.merge(apartment1);
apartment1Id = apartment1.getId();
@@ -414,7 +411,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
/* ############################ ROOMS ############################## */
Asset apartment1Livingroom = createDemoApartmentRoom(apartment1, "Living Room")
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA));
addDemoApartmentRoomMotionSensor(apartment1Livingroom, true, () -> new MetaItem[]{
new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
@@ -440,7 +437,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
apartment1LivingroomId = apartment1Livingroom.getId();
Asset apartment1Kitchen = createDemoApartmentRoom(apartment1, "Kitchen")
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA));
addDemoApartmentRoomMotionSensor(apartment1Kitchen, true, () -> new MetaItem[]{
new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
@@ -482,7 +479,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
apartment1KitchenId = apartment1Kitchen.getId();
Asset apartment1Hallway = createDemoApartmentRoom(apartment1, "Hallway")
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA));
addDemoApartmentRoomMotionSensor(apartment1Hallway, true, () -> new MetaItem[]{
new MetaItem(AGENT_LINK, new AttributeRef(apartment1ServiceAgentId, "apartmentSimulator").toArrayValue()),
new MetaItem(SimulatorProtocol.SIMULATOR_ELEMENT, Values.create(NumberSimulatorElement.ELEMENT_NAME))
@@ -508,7 +505,7 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
Asset demoApartmentSceneAgent = createDemoApartmentSceneAgent(
apartment1, scenes, apartment1Livingroom, apartment1Kitchen, apartment1Hallway
- ).addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA));
+ ).addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA));
demoApartmentSceneAgent = assetStorageService.merge(demoApartmentSceneAgent);
@@ -518,8 +515,8 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
Asset apartment2 = new Asset("Apartment 2", RESIDENCE, smartHome);
apartment2.addAttributes(
- AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA),
- new AssetAttribute("allLightsOffSwitch", AttributeType.BOOLEAN, Values.create(true))
+ AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA),
+ new AssetAttribute("allLightsOffSwitch", AttributeValueType.BOOLEAN, Values.create(true))
.setMeta(
new MetaItem(LABEL, Values.create("All Lights Off Switch")),
new MetaItem(DESCRIPTION, Values.create("When triggered, turns all lights in the apartment off")),
@@ -532,43 +529,43 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
Asset apartment2Livingroom = new Asset("Living Room", ROOM, apartment2);
apartment2Livingroom.addAttributes(
- AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA),
- new AssetAttribute("motionSensor", AttributeType.BOOLEAN, Values.create(false))
+ AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA),
+ new AssetAttribute("motionSensor", AttributeValueType.BOOLEAN, Values.create(false))
.setMeta(
new MetaItem(LABEL, Values.create("Motion Sensor")),
new MetaItem(DESCRIPTION, Values.create("PIR sensor that sends 'true' when motion is sensed")),
new MetaItem(RULE_STATE, Values.create(true)),
new MetaItem(RULE_EVENT, Values.create(true))
),
- new AssetAttribute("presenceDetected", AttributeType.BOOLEAN, Values.create(false))
+ new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN, Values.create(false))
.setMeta(
new MetaItem(LABEL, Values.create("Presence Detected")),
new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("firstPresenceDetected", AttributeType.TIMESTAMP_MILLIS)
+ new AssetAttribute("firstPresenceDetected", AttributeValueType.TIMESTAMP_MILLIS)
.setMeta(
new MetaItem(LABEL, Values.create("First Presence Timestamp")),
new MetaItem(DESCRIPTION, Values.create("Timestamp of the first detected presence")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("lastPresenceDetected", AttributeType.TIMESTAMP_MILLIS)
+ new AssetAttribute("lastPresenceDetected", AttributeValueType.TIMESTAMP_MILLIS)
.setMeta(
new MetaItem(LABEL, Values.create("Last Presence Timestamp")),
new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("co2Level", AttributeType.CO2_PPM, Values.create(350))
+ new AssetAttribute("co2Level", AttributeValueType.CO2_PPM, Values.create(350))
.setMeta(
new MetaItem(LABEL, Values.create("CO2 Level")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("lightSwitch", AttributeType.BOOLEAN, Values.create(true))
+ new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN, Values.create(true))
.setMeta(
new MetaItem(LABEL, Values.create("Light Switch")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("windowOpen", AttributeType.BOOLEAN, Values.create(false))
+ new AssetAttribute("windowOpen", AttributeValueType.BOOLEAN, Values.create(false))
.setMeta(
new MetaItem(ACCESS_RESTRICTED_READ, Values.create(true))
)
@@ -578,33 +575,33 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
Asset apartment2Bathroom = new Asset("Bathroom", ROOM, apartment2);
apartment2Bathroom.addAttributes(
- AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA),
- new AssetAttribute("motionSensor", AttributeType.BOOLEAN, Values.create(false))
+ AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA),
+ new AssetAttribute("motionSensor", AttributeValueType.BOOLEAN, Values.create(false))
.setMeta(
new MetaItem(LABEL, Values.create("Motion Sensor")),
new MetaItem(DESCRIPTION, Values.create("PIR sensor that sends 'true' when motion is sensed")),
new MetaItem(RULE_STATE, Values.create(true)),
new MetaItem(RULE_EVENT, Values.create(true))
),
- new AssetAttribute("presenceDetected", AttributeType.BOOLEAN, Values.create(false))
+ new AssetAttribute("presenceDetected", AttributeValueType.BOOLEAN, Values.create(false))
.setMeta(
new MetaItem(LABEL, Values.create("Presence Detected")),
new MetaItem(DESCRIPTION, Values.create("Someone is currently present in the room")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("firstPresenceDetected", AttributeType.TIMESTAMP_MILLIS)
+ new AssetAttribute("firstPresenceDetected", AttributeValueType.TIMESTAMP_MILLIS)
.setMeta(
new MetaItem(LABEL, Values.create("First Presence Timestamp")),
new MetaItem(DESCRIPTION, Values.create("Timestamp of the first detected presence")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("lastPresenceDetected", AttributeType.TIMESTAMP_MILLIS)
+ new AssetAttribute("lastPresenceDetected", AttributeValueType.TIMESTAMP_MILLIS)
.setMeta(
new MetaItem(LABEL, Values.create("Last Presence Timestamp")),
new MetaItem(DESCRIPTION, Values.create("Timestamp of last detected presence")),
new MetaItem(RULE_STATE, Values.create(true))
),
- new AssetAttribute("lightSwitch", AttributeType.BOOLEAN, Values.create(true))
+ new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN, Values.create(true))
.setMeta(
new MetaItem(LABEL, Values.create("Light Switch")),
new MetaItem(RULE_STATE, Values.create(true))
@@ -614,14 +611,14 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
apartment2BathroomId = apartment2Bathroom.getId();
Asset apartment3 = new Asset("Apartment 3", RESIDENCE, smartHome)
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA));
apartment3 = assetStorageService.merge(apartment3);
apartment3Id = apartment3.getId();
Asset apartment3Livingroom = new Asset("Living Room", ROOM, apartment3)
- .addAttributes(AssetAttribute.createWithDescriptor(AttributeDescriptorImpl.LOCATION, locationValueA));
+ .addAttributes(AssetAttribute.createWithDescriptor(AttributeValue.LOCATION, locationValueA));
apartment3Livingroom.addAttributes(
- new AssetAttribute("lightSwitch", AttributeType.BOOLEAN)
+ new AssetAttribute("lightSwitch", AttributeValueType.BOOLEAN)
);
apartment3Livingroom = assetStorageService.merge(apartment3Livingroom);
@@ -629,11 +626,11 @@ public class ManagerDemoSetup extends AbstractManagerSetup {
Asset console = new Asset("Demo Android Console", CONSOLE, groundFloor)
.addAttributes(
- new AssetAttribute(AttributeDescriptorImpl.LOCATION.getName(),
- AttributeDescriptorImpl.LOCATION.getType())
+ new AssetAttribute(AttributeValue.LOCATION.getName(),
+ AttributeValue.LOCATION.getType())
.setMeta(new MetaItem(RULE_STATE)),
- new AssetAttribute(AttributeDescriptorImpl.CONSOLE_PROVIDER_GEOFENCE.getName(),
- AttributeDescriptorImpl.CONSOLE_PROVIDER_GEOFENCE.getType())
+ new AssetAttribute(AttributeValue.CONSOLE_PROVIDER_GEOFENCE.getName(),
+ AttributeValue.CONSOLE_PROVIDER_GEOFENCE.getType())
.setMeta(
new MetaItem(GEOFENCE_ADAPTER, Values.create("ORConsole")),
new MetaItem(ACCESS_PUBLIC_READ)
diff --git a/model/src/main/java/org/openremote/model/asset/Asset.java b/model/src/main/java/org/openremote/model/asset/Asset.java
index 9e3c0bf49..5ddd17f03 100644
--- a/model/src/main/java/org/openremote/model/asset/Asset.java
+++ b/model/src/main/java/org/openremote/model/asset/Asset.java
@@ -26,7 +26,7 @@ import org.openremote.model.IdentifiableEntity;
import org.openremote.model.attribute.Attribute;
import org.openremote.model.geo.GeoJSON;
import org.openremote.model.geo.GeoJSONFeature;
-import org.openremote.model.geo.GeoJSONGeometry;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.util.ObservableList;
import org.openremote.model.util.TextUtil;
import org.openremote.model.value.ObjectValue;
@@ -48,7 +48,7 @@ import java.util.stream.Stream;
import static org.openremote.model.Constants.PERSISTENCE_JSON_OBJECT_TYPE;
import static org.openremote.model.Constants.PERSISTENCE_UNIQUE_ID_GENERATOR;
import static org.openremote.model.asset.AssetAttribute.*;
-import static org.openremote.model.attribute.AttributeDescriptorImpl.LOCATION;
+import static org.openremote.model.attribute.AttributeValue.LOCATION;
// @formatter:off
@@ -616,37 +616,69 @@ public class Asset implements IdentifiableEntity {
// FUNCTIONAL METHODS BELOW
// ---------------------------------------------------
- public Optional<ObjectValue> getCoordinates() {
+ /**
+ * Complies to the GeoJSON specification RFC 7946, which means the first element in the array is longitude
+ * and the second element is the latitude
+ */
+ public double[] getCoordinates() {
Optional<AssetAttribute> locationAttribute = getAttributesStream()
.filter(attribute -> attribute.getNameOrThrow().equals(LOCATION.getName()))
.findFirst();
if (locationAttribute.isPresent()) {
- return locationAttribute.get().getValueAsObject();
+ double[] coordinates = new double[2];
+ locationAttribute.get().getValueAsObject().ifPresent(objectValue -> {
+ coordinates[1] = objectValue.getNumber("latitude").orElse(0d);
+ coordinates[0] = objectValue.getNumber("longitude").orElse(0d);
+ });
+ return coordinates;
} else {
- return Optional.empty();
+ return null;
}
}
- public void setCoordinates(ObjectValue coordinates) {
- AssetAttribute locationAttribute = getAttributesStream()
- .filter(attribute -> attribute.getNameOrThrow().equals(LOCATION.getName()))
- .findFirst().orElse(new AssetAttribute(LOCATION.getName(), LOCATION.getType()));
+ public GeoJSONPoint getPoint() {
+ if (!hasGeoFeature()) {
+ return null;
+ }
+ return new GeoJSONPoint(getCoordinates());
+ }
- locationAttribute.setValue(coordinates);
- replaceAttribute(locationAttribute);
+ /**
+ * Complies to the GeoJSON specification RFC 7946, which means the first element in {link #coordinates} should be longitude
+ * and the second element should be latitude
+ */
+ public void setCoordinates(double[] coordinates) {
+ if (coordinates == null) {
+ removeAttribute(LOCATION.getName());
+ } else {
+ AssetAttribute locationAttribute = getAttributesStream()
+ .filter(attribute -> attribute.getNameOrThrow().equals(LOCATION.getName()))
+ .findFirst().orElse(new AssetAttribute(LOCATION.getName(), LOCATION.getType()));
+
+ ObjectValue objectValue = locationAttribute.getValueAsObject().orElse(Values.createObject());
+ objectValue
+ .put("latitude", coordinates[1])
+ .put("longitude", coordinates[0]);
+ locationAttribute.setValue(objectValue);
+
+ replaceAttribute(locationAttribute);
+ }
}
/**
- * Use {@link #hasGeoFeature()} before using this method to check if the is a Label to display
+ * - * This assumes {@link #getCoordinates} array index 0 is Lng and index 1 is Lat,
+ * - * which is true for PostGIS backend. Because Lat/Lng is the 'right way', we flip
+ * - * it here for display. Rounding to 5 decimal places gives us precision of about 1 meter.
+ * -
*/
public String getCoordinatesLabel() {
return
- new BigDecimal(getCoordinates().get().getNumber("latitude").orElse(0d)).setScale(5, RoundingMode.HALF_UP) + " " +
- new BigDecimal(getCoordinates().get().getNumber("longitude").orElse(0d)).setScale(5, RoundingMode.HALF_UP) + " Lat|Lng";
+ new BigDecimal(getCoordinates()[1]).setScale(5, RoundingMode.HALF_UP) + " " +
+ new BigDecimal(getCoordinates()[0]).setScale(5, RoundingMode.HALF_UP) + " Lat|Lng";
}
public boolean hasGeoFeature() {
- return getCoordinates().isPresent() && getCoordinates().get().hasKey("latitude") && getCoordinates().get().hasKey("longitude");
+ return getCoordinates() != null && getCoordinates().length == 2;
}
public GeoJSON getGeoFeature(int maxNameLength) {
@@ -656,7 +688,7 @@ public class Asset implements IdentifiableEntity {
new GeoJSONFeature("Feature")
.setProperty("id", getId())
.setProperty("title", TextUtil.ellipsize(getName(), maxNameLength))
- .setGeometry(new GeoJSONGeometry(getCoordinates().get()))
+ .setGeometry(getPoint())
);
}
diff --git a/model/src/main/java/org/openremote/model/asset/AssetAttribute.java b/model/src/main/java/org/openremote/model/asset/AssetAttribute.java
index 38264fa5e..3d43dd212 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetAttribute.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetAttribute.java
@@ -53,15 +53,15 @@ public class AssetAttribute extends Attribute {
super(name);
}
- public AssetAttribute(String name, AttributeType type) {
+ public AssetAttribute(String name, AttributeValueType type) {
super(name, type);
}
- public AssetAttribute(String name, AttributeType type, Value value, long timestamp) {
+ public AssetAttribute(String name, AttributeValueType type, Value value, long timestamp) {
super(name, type, value, timestamp);
}
- public AssetAttribute(String name, AttributeType type, Value value) {
+ public AssetAttribute(String name, AttributeValueType type, Value value) {
super(name, type, value);
}
@@ -70,21 +70,23 @@ public class AssetAttribute extends Attribute {
setAssetId(assetId);
}
- public AssetAttribute(String assetId, String name, AttributeType type) {
+ public AssetAttribute(String assetId, String name, AttributeValueType type) {
super(name, type);
setAssetId(assetId);
}
- public AssetAttribute(String assetId, String name, AttributeType type, Value value) {
+ public AssetAttribute(String assetId, String name, AttributeValueType type, Value value) {
super(name, type, value);
setAssetId(assetId);
}
- public AssetAttribute(String assetId, String name, AttributeType type, Value value, long timestamp) {
+ public AssetAttribute(String assetId, String name, AttributeValueType type, Value value, long timestamp) {
super(name, type, value, timestamp);
setAssetId(assetId);
}
+ //TODO constructor which takes a AttributeDescriptor
+
public Optional<String> getAssetId() {
return Optional.ofNullable(assetId);
}
@@ -494,7 +496,7 @@ public class AssetAttribute extends Attribute {
}
public static AssetAttribute createWithDescriptor(AttributeDescriptor descriptor, Value value) {
- return new AssetAttribute(descriptor.getName(), descriptor.getType(), value)
+ return new AssetAttribute(descriptor.getName(), descriptor.getType(), Optional.ofNullable(value).orElse(descriptor.getDefaultValue()))
.setMeta(descriptor.getDefaultMetaItems());
}
}
diff --git a/model/src/main/java/org/openremote/model/asset/AssetResource.java b/model/src/main/java/org/openremote/model/asset/AssetResource.java
index ddd9640ee..7e34d17a0 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetResource.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetResource.java
@@ -20,9 +20,7 @@
package org.openremote.model.asset;
import jsinterop.annotations.JsType;
-import org.openremote.model.geo.GeoJSON;
-import org.openremote.model.geo.GeoJSONFeature;
-import org.openremote.model.geo.GeoJSONGeometry;
+import org.openremote.model.geo.GeoJSONPoint;
import org.openremote.model.http.RequestParams;
import org.openremote.model.http.SuccessStatusCode;
@@ -274,7 +272,7 @@ public interface AssetResource {
@SuccessStatusCode(204)
@RolesAllowed({"write:assets"})
@SuppressWarnings("unusable-by-js")
- void updateLocation(@BeanParam RequestParams requestParams, @PathParam("assetId") String assetId, GeoJSONGeometry location);
+ void updateLocation(@BeanParam RequestParams requestParams, @PathParam("assetId") String assetId, GeoJSONPoint location);
/**
* Updated the attribute "location" of the public asset
@@ -286,5 +284,5 @@ public interface AssetResource {
@Consumes(APPLICATION_JSON)
@SuccessStatusCode(204)
@SuppressWarnings("unusable-by-js")
- void updatePublicAssetLocation(@BeanParam RequestParams requestParams, @PathParam("assetId") String assetId, GeoJSONGeometry location);
+ void updatePublicAssetLocation(@BeanParam RequestParams requestParams, @PathParam("assetId") String assetId, GeoJSONPoint location);
}
diff --git a/model/src/main/java/org/openremote/model/asset/AssetType.java b/model/src/main/java/org/openremote/model/asset/AssetType.java
index d91a4e5e9..31aefa09c 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetType.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetType.java
@@ -27,8 +27,8 @@ import java.util.stream.Stream;
import static org.openremote.model.Constants.ASSET_NAMESPACE;
import static org.openremote.model.asset.AssetMeta.*;
-import static org.openremote.model.attribute.AttributeType.NUMBER;
-import static org.openremote.model.attribute.AttributeType.STRING;
+import static org.openremote.model.attribute.AttributeValueType.NUMBER;
+import static org.openremote.model.attribute.AttributeValueType.STRING;
/**
* Asset type is an arbitrary string. It should be URI. This enum contains the well-known URIs for functionality we want
diff --git a/model/src/main/java/org/openremote/model/asset/CalendarEventConfiguration.java b/model/src/main/java/org/openremote/model/asset/CalendarEventConfiguration.java
index 67d86802e..0753f07f2 100644
--- a/model/src/main/java/org/openremote/model/asset/CalendarEventConfiguration.java
+++ b/model/src/main/java/org/openremote/model/asset/CalendarEventConfiguration.java
@@ -21,15 +21,13 @@ package org.openremote.model.asset;
import org.openremote.model.AbstractValueHolder;
import org.openremote.model.attribute.Attribute;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.calendar.CalendarEvent;
import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Value;
import java.util.Optional;
-import static org.openremote.model.Constants.NAMESPACE;
-
/**
* An {@link Attribute} that can be added to an {@link Asset} to indicate that the asset is time sensitive. This is to
* be used for informational purposes to; for example, allow console apps to only show Assets that are 'active' at a
@@ -78,6 +76,6 @@ public final class CalendarEventConfiguration {
}
public static AssetAttribute toAttribute(CalendarEvent calendarEvent) {
- return new AssetAttribute(CALENDAR_EVENT_ATTRIBUTE_NAME, AttributeType.OBJECT, calendarEvent.toValue());
+ return new AssetAttribute(CALENDAR_EVENT_ATTRIBUTE_NAME, AttributeValueType.OBJECT, calendarEvent.toValue());
}
}
diff --git a/model/src/main/java/org/openremote/model/asset/DefaultAssetModelProvider.java b/model/src/main/java/org/openremote/model/asset/DefaultAssetModelProvider.java
index 4c60238ee..c96f94268 100644
--- a/model/src/main/java/org/openremote/model/asset/DefaultAssetModelProvider.java
+++ b/model/src/main/java/org/openremote/model/asset/DefaultAssetModelProvider.java
@@ -20,7 +20,7 @@
package org.openremote.model.asset;
import org.openremote.model.attribute.AttributeDescriptor;
-import org.openremote.model.attribute.AttributeDescriptorImpl;
+import org.openremote.model.attribute.AttributeValue;
import org.openremote.model.attribute.MetaItemDescriptor;
/**
@@ -40,7 +40,7 @@ public class DefaultAssetModelProvider implements AssetModelProvider {
@Override
public AttributeDescriptor[] getAttributeDescriptors() {
- return AttributeDescriptorImpl.values();
+ return AttributeValue.values();
}
@Override
diff --git a/model/src/main/java/org/openremote/model/asset/agent/Agent.java b/model/src/main/java/org/openremote/model/asset/agent/Agent.java
index 0ac54c4d7..daa756b4c 100644
--- a/model/src/main/java/org/openremote/model/asset/agent/Agent.java
+++ b/model/src/main/java/org/openremote/model/asset/agent/Agent.java
@@ -23,7 +23,7 @@ import org.openremote.model.AbstractValueHolder;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
import org.openremote.model.asset.AssetType;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.security.UserPasswordCredentials;
import org.openremote.model.value.Values;
@@ -74,7 +74,7 @@ public final class Agent {
if (isNullOrEmpty(url)) {
asset.removeAttribute(URL_ATTRIBUTE_NAME);
} else {
- asset.replaceAttribute(new AssetAttribute(URL_ATTRIBUTE_NAME, AttributeType.STRING, Values.create(url)));
+ asset.replaceAttribute(new AssetAttribute(URL_ATTRIBUTE_NAME, AttributeValueType.STRING, Values.create(url)));
}
}
}
@@ -98,7 +98,7 @@ public final class Agent {
if (Objects.isNull(credentials)) {
asset.removeAttribute(CREDENTIALS_ATTRIBUTE_NAME);
} else {
- asset.replaceAttribute(new AssetAttribute(CREDENTIALS_ATTRIBUTE_NAME, AttributeType.OBJECT, credentials.toObjectValue()));
+ asset.replaceAttribute(new AssetAttribute(CREDENTIALS_ATTRIBUTE_NAME, AttributeValueType.OBJECT, credentials.toObjectValue()));
}
}
}
diff --git a/model/src/main/java/org/openremote/model/asset/agent/ProtocolConfiguration.java b/model/src/main/java/org/openremote/model/asset/agent/ProtocolConfiguration.java
index 098cffdce..d8c001b25 100644
--- a/model/src/main/java/org/openremote/model/asset/agent/ProtocolConfiguration.java
+++ b/model/src/main/java/org/openremote/model/asset/agent/ProtocolConfiguration.java
@@ -21,7 +21,7 @@ package org.openremote.model.asset.agent;
import org.openremote.model.ValidationFailure;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.attribute.MetaItem;
import org.openremote.model.util.TextUtil;
import org.openremote.model.value.Values;
@@ -56,7 +56,7 @@ final public class ProtocolConfiguration {
}
isValidProtocolNameOrThrow(protocolName);
attribute.setReadOnly(true);
- attribute.setType(AttributeType.STRING);
+ attribute.setType(AttributeValueType.STRING);
attribute.setValue(Values.create(protocolName));
attribute.getMeta().add(new MetaItem(PROTOCOL_CONFIGURATION, Values.create(true)));
return attribute;
diff --git a/model/src/main/java/org/openremote/model/attribute/Attribute.java b/model/src/main/java/org/openremote/model/attribute/Attribute.java
index b900d7c93..8bf2f5e9e 100644
--- a/model/src/main/java/org/openremote/model/attribute/Attribute.java
+++ b/model/src/main/java/org/openremote/model/attribute/Attribute.java
@@ -72,19 +72,19 @@ public abstract class Attribute extends AbstractValueTimestampHolder {
setName(name);
}
- protected Attribute(String name, AttributeType type) {
+ protected Attribute(String name, AttributeValueType type) {
this(name);
setName(name);
setType(type);
}
- protected Attribute(String name, AttributeType type, Value value, long timestamp) {
+ protected Attribute(String name, AttributeValueType type, Value value, long timestamp) {
this(name, type);
setValue(value);
setValueTimestamp(timestamp);
}
- protected Attribute(String name, AttributeType type, Value value) {
+ protected Attribute(String name, AttributeValueType type, Value value) {
this(name, type);
setValue(value);
}
@@ -106,19 +106,19 @@ public abstract class Attribute extends AbstractValueTimestampHolder {
this.name = null;
}
- public Optional<AttributeType> getType() {
- return getObjectValue().getString(TYPE_FIELD_NAME).flatMap(name -> EnumUtil.enumFromString(AttributeType.class, name));
+ public Optional<AttributeValueType> getType() {
+ return getObjectValue().getString(TYPE_FIELD_NAME).flatMap(name -> EnumUtil.enumFromString(AttributeValueType.class, name));
}
/**
* The below is used in a sufficient number of places to provide it here as a utility method
* with a standardised exception message.
*/
- public AttributeType getTypeOrThrow() {
+ public AttributeValueType getTypeOrThrow() {
return getType().orElseThrow(() -> new IllegalStateException("Attribute doesn't have a type"));
}
- public void setType(AttributeType type) {
+ public void setType(AttributeValueType type) {
Objects.requireNonNull(type);
getObjectValue().put(TYPE_FIELD_NAME, Values.create(type.name()));
}
@@ -272,7 +272,7 @@ public abstract class Attribute extends AbstractValueTimestampHolder {
return attribute -> isAttributeNameEqualTo(attribute, name);
}
- public static <A extends Attribute> boolean isAttributeTypeEqualTo(A attribute, AttributeType type) {
+ public static <A extends Attribute> boolean isAttributeTypeEqualTo(A attribute, AttributeValueType type) {
if (attribute == null)
return false;
return attribute
@@ -281,7 +281,7 @@ public abstract class Attribute extends AbstractValueTimestampHolder {
.orElse(type == null);
}
- public static <A extends Attribute> Predicate<A> isAttributeTypeEqualTo(AttributeType type) {
+ public static <A extends Attribute> Predicate<A> isAttributeTypeEqualTo(AttributeValueType type) {
return attribute -> isAttributeTypeEqualTo(attribute, type);
}
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java b/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java
index 1061d5f56..0c6f2f1ea 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java
@@ -19,11 +19,15 @@
*/
package org.openremote.model.attribute;
+import org.openremote.model.value.Value;
+
public interface AttributeDescriptor {
String getName();
- AttributeType getType();
+ AttributeValueType getType();
MetaItem[] getDefaultMetaItems();
+
+ Value getDefaultValue();
}
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeDescriptorImpl.java b/model/src/main/java/org/openremote/model/attribute/AttributeDescriptorImpl.java
deleted file mode 100644
index 745d7a2b0..000000000
--- a/model/src/main/java/org/openremote/model/attribute/AttributeDescriptorImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.openremote.model.attribute;
-
-import java.util.Optional;
-
-public enum AttributeDescriptorImpl implements AttributeDescriptor {
-
- LOCATION("location", AttributeType.LOCATION),
-
- CONSOLE_PROVIDER_GEOFENCE("providerGeofence", AttributeType.OBJECT);
-
- final protected String name;
- final protected AttributeType attributeType;
- final protected MetaItem[] defaultMetaItems;
-
- AttributeDescriptorImpl(String name, AttributeType attributeType, MetaItem... defaultMetaItems) {
- this.name = name;
- this.attributeType = attributeType;
- this.defaultMetaItems = defaultMetaItems;
- }
-
- public static Optional<AttributeDescriptor> getByValue(String name) {
- if (name == null)
- return Optional.empty();
-
- for (AttributeDescriptor descriptor : values()) {
- if (name.equals(descriptor.getName()))
- return Optional.of(descriptor);
- }
- return Optional.empty();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public AttributeType getType() {
- return attributeType;
- }
-
- @Override
- public MetaItem[] getDefaultMetaItems() {
- return defaultMetaItems;
- }
-}
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeLink.java b/model/src/main/java/org/openremote/model/attribute/AttributeLink.java
index 6381c034c..840541b09 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeLink.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeLink.java
@@ -48,19 +48,19 @@ public class AttributeLink {
/**
* Toggle the value of the linked attribute; the linked attribute's type must be
- * {@link AttributeType#BOOLEAN}
+ * {@link AttributeValueType#BOOLEAN}
*/
TOGGLE("@TOGGLE"),
/**
* Increment the value of the linked attribute; the linked attribute's type must be
- * {@link AttributeType#NUMBER}
+ * {@link AttributeValueType#NUMBER}
*/
INCREMENT("@INCREMENT"),
/**
* Decrement the value of the linked attribute; the linked attribute's type must be
- * {@link AttributeType#NUMBER}
+ * {@link AttributeValueType#NUMBER}
*/
DECREMENT("@DECREMENT");
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeType.java b/model/src/main/java/org/openremote/model/attribute/AttributeType.java
deleted file mode 100644
index ff2828630..000000000
--- a/model/src/main/java/org/openremote/model/attribute/AttributeType.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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.model.attribute;
-
-import org.openremote.model.ValidationFailure;
-import org.openremote.model.ValueHolder;
-import org.openremote.model.asset.AssetMeta;
-import org.openremote.model.value.Value;
-import org.openremote.model.value.ValueType;
-import org.openremote.model.value.Values;
-
-import java.util.Optional;
-import java.util.function.Function;
-
-import static org.openremote.model.asset.AssetMeta.FORMAT;
-import static org.openremote.model.attribute.AttributeType.AttributeTypeFailureReason.ATTRIBUTE_TYPE_VALUE_DOES_NOT_MATCH;
-
-/**
- * The type of an {@link Attribute}, how its {@link Value} should be
- * interpreted when working with an attribute (e.g. when testing, rendering,
- * or editing the value).
- * <p>
- * Additional constraints and integrity rules upon attribute values can be declared by
- * adding arbitrary {@link Meta} to an {@link Attribute}.
- */
-public enum AttributeType {
-
- STRING("file-text-o", ValueType.STRING, value -> Optional.empty()),
-
- NUMBER("hashtag", ValueType.NUMBER, value -> Optional.empty()),
-
- BOOLEAN("toggle-off", ValueType.BOOLEAN, value -> Optional.empty()),
-
- OBJECT("cubes", ValueType.OBJECT, value -> Optional.empty()),
-
- ARRAY("ellipsis-h", ValueType.ARRAY, value -> Optional.empty()),
-
- // TODO Implement "Saved Filter/Searches" properly, see AssetResourceImpl
- RULES_TEMPLATE_FILTER("filter", ValueType.ARRAY, value -> Optional.empty()),
-
- PERCENTAGE("percent", ValueType.NUMBER,
- value -> Values.getNumber(value)
- .filter(number -> number < 0 || number > 100)
- .map(number -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_PERCENTAGE_OUT_OF_RANGE)),
- new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
- new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
- new MetaItem(AssetMeta.FORMAT, Values.create("%3d %%"))
- ),
-
- TIMESTAMP_MILLIS("clock-o", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%d ms"))
- ),
-
- TIMESTAMP_SECONDS("clock-o", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%d s"))
- ),
-
- TIME_SECONDS("clock-o", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.1f s"))
- ),
-
- TIME_MINUTES("clock-o", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.1f min"))
- ),
-
- DATETIME("calendar", ValueType.STRING, value -> Optional.empty()),
-
- COLOR_RGB("paint-brush", ValueType.ARRAY, value -> Values.getArray(value)
- .filter(array -> array.length() != 3)
- .map(array -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID_COLOR_FORMAT))
- ),
-
- COLOR_ARGB("paint-brush", ValueType.ARRAY, value -> Values.getArray(value)
- .filter(array -> array.length() != 4)
- .map(array -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID_COLOR_FORMAT))
- ),
-
- COLOR_HEX("paint-brush", ValueType.STRING, value -> Values.getString(value)
- .filter(s -> !s.matches("[a-fA-F0-9]{6}"))
- .map(array -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID_COLOR_FORMAT))
- ),
-
- TEMPERATURE_CELCIUS("thermometer", ValueType.NUMBER, value -> Values.getNumber(value)
- .filter(n -> n < -273.15)
- .map(n -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_TEMPERATURE_OUT_OF_RANGE)),
- new MetaItem(FORMAT, Values.create("%0.1f C")
- )
- ),
-
- TEMPERATURE_KELVIN("thermometer", ValueType.NUMBER, value -> Values.getNumber(value)
- .filter(n -> n < 0)
- .map(n -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_TEMPERATURE_OUT_OF_RANGE))
- ),
-
- TEMPERATURE_FAHRENHEIT("thermometer", ValueType.NUMBER, value -> Values.getNumber(value)
- .filter(n -> n < -459.67)
- .map(n -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_TEMPERATURE_OUT_OF_RANGE))
- ),
-
- RAINFALL("tint", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.1f mm/h"))
- ),
-
- BRIGHTNESS_LUX("sun-o", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%d lx"))
- ),
-
- DISTANCE_M("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f m"))
- ),
-
- DISTANCE_CM("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f cm"))
- ),
-
- DISTANCE_MM("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f mm"))
- ),
-
- DISTANCE_IN("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f \""))
- ),
-
- DISTANCE_FT("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f '"))
- ),
-
- DISTANCE_YARD("arrows-h", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f yd"))
- ),
-
- SPEED_MS("rocket", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.3f m/s"))
- ),
-
- SPEED_KPH("rocket", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.1f km/h"))
- ),
-
- SPEED_MPH("rocket", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.1f mi/h"))
- ),
-
- CO2_PPM("leaf", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%4d ppm"))
- ),
-
- HUMIDITY_PERCENTAGE("tint", ValueType.NUMBER, value -> Values.getNumber(value)
- .filter(number -> number < 0 || number > 100)
- .map(number -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_PERCENTAGE_OUT_OF_RANGE)),
- new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
- new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
- new MetaItem(FORMAT, Values.create("%3d %%"))
- ),
-
- HUMIDITY_GPCM("tint", ValueType.NUMBER, value -> Optional.empty()),
-
- POWER_WATT("plug", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f W"))
- ),
-
- POWER_KILOWATT("plug", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f KW"))),
-
- POWER_MEGAWATT("plug", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f MW"))),
-
- CHARGE_PERCENTAGE("battery-full", ValueType.NUMBER, value -> Values.getNumber(value)
- .filter(number -> number < 0 || number > 100)
- .map(number -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_PERCENTAGE_OUT_OF_RANGE)),
- new MetaItem(AssetMeta.RANGE_MIN, Values.create(0)),
- new MetaItem(AssetMeta.RANGE_MAX, Values.create(100)),
- new MetaItem(FORMAT, Values.create("%3d %%"))
- ),
-
- CHARGE_KWH("battery-full", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f KWh"))),
-
- ENERGY_KWH("plug", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f KWh"))
- ),
-
- ENERGY_JOULE("plug", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f J"))
- ),
-
- ENERGY_MEGAJOULE("plug", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f MJ"))),
-
- FLOW_LPM("tachometer", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f l/m"))
- ),
-
- FLOW_CMPS("tachometer", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f m³/s"))
- ),
-
- FLOW_SCCM("tachometer", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f cm³/m"))
- ),
-
- FLOW_CFPS("tachometer", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f cfs"))
- ),
-
- FLOW_GPM("tachometer", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.5f gpm"))
- ),
-
- DIRECTION_DECIMAL_DEGREES("compass", ValueType.NUMBER, value -> Optional.empty(),
- new MetaItem(FORMAT, Values.create("%0.1f deg"))
- ),
-
- LOCATION("map-marker", ValueType.OBJECT, value -> Values.getObject(value)
- .filter(object -> !object.hasKey("latitude") || !object.hasKey("longitude"))
- .map(object -> new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_INVALID))
- );
-
- public static final String DEFAULT_ICON = "circle-thin";
-
- public enum AttributeTypeFailureReason implements ValidationFailure.Reason {
- ATTRIBUTE_TYPE_VALUE_DOES_NOT_MATCH
- }
-
- final protected String icon;
- final protected ValueType valueType;
- final protected Function<Value, Optional<ValidationFailure>> validator;
- final protected MetaItem[] defaultMetaItems;
-
- AttributeType(String icon, ValueType valueType, Function<Value, Optional<ValidationFailure>> validator, MetaItem... defaultMetaItems) {
- this.icon = icon;
- this.valueType = valueType;
- this.validator = value -> {
- // Always perform some basic validation
- if (value != null && getValueType() != value.getType())
- return Optional.of(new ValidationFailure(ATTRIBUTE_TYPE_VALUE_DOES_NOT_MATCH, getValueType().name()));
-
- // Custom attribute type validation
- return validator.apply(value);
- };
- this.defaultMetaItems = defaultMetaItems;
- }
-
- public String getIcon() {
- return icon;
- }
-
- public ValueType getValueType() {
- return valueType;
- }
-
- public MetaItem[] getDefaultMetaItems() {
- return defaultMetaItems;
- }
-
- public Optional<ValidationFailure> isValidValue(Value value) {
- return validator.apply(value);
- }
-}
diff --git a/model/src/main/java/org/openremote/model/attribute/LinkedAttributeDescriptor.java b/model/src/main/java/org/openremote/model/attribute/LinkedAttributeDescriptor.java
index e4b953416..4adc12c19 100644
--- a/model/src/main/java/org/openremote/model/attribute/LinkedAttributeDescriptor.java
+++ b/model/src/main/java/org/openremote/model/attribute/LinkedAttributeDescriptor.java
@@ -23,7 +23,7 @@ public class LinkedAttributeDescriptor {
protected final String name;
protected final String displayName;
- protected final AttributeType attributeType;
+ protected final AttributeValueType attributeValueType;
protected final boolean readOnly;
protected final boolean executable;
protected final MetaItem[] metaItems;
@@ -31,13 +31,13 @@ public class LinkedAttributeDescriptor {
public LinkedAttributeDescriptor(
String name,
String displayName,
- AttributeType attributeType,
+ AttributeValueType attributeValueType,
boolean readOnly,
boolean executable,
MetaItem[] metaItems) {
this.name = name;
this.displayName = displayName;
- this.attributeType = attributeType;
+ this.attributeValueType = attributeValueType;
this.readOnly = readOnly;
this.executable = executable;
this.metaItems = metaItems;
@@ -51,8 +51,8 @@ public class LinkedAttributeDescriptor {
return displayName;
}
- public AttributeType getAttributeType() {
- return attributeType;
+ public AttributeValueType getAttributeValueType() {
+ return attributeValueType;
}
public boolean isReadOnly() {
diff --git a/model/src/main/java/org/openremote/model/device/CapabilityRef.java b/model/src/main/java/org/openremote/model/device/CapabilityRef.java
index d38a96e4b..3cdf4eed4 100644
--- a/model/src/main/java/org/openremote/model/device/CapabilityRef.java
+++ b/model/src/main/java/org/openremote/model/device/CapabilityRef.java
@@ -11,7 +11,7 @@ extends Attribute {
}
public CapabilityRef(String name, String capabilityType, Attributes resourceRefs) {
- super(name, AttributeType.OBJECT);
+ super(name, AttributeValueType.OBJECT);
jsonObject.put("name", name);
setCapabilityType(capabilityType);
setResourceRefs(resourceRefs);
diff --git a/model/src/main/java/org/openremote/model/device/DeviceResource.java b/model/src/main/java/org/openremote/model/device/DeviceResource.java
index 9164b0310..063eb1e4b 100644
--- a/model/src/main/java/org/openremote/model/device/DeviceResource.java
+++ b/model/src/main/java/org/openremote/model/device/DeviceResource.java
@@ -53,7 +53,7 @@ extends Attribute {
return false;
return attribute.hasMetadataElement(DEVICE_RESOURCE)
&& attribute.getMetadata().getElement(DEVICE_RESOURCE).getName().equals(DEVICE_RESOURCE_TYPE)
- && AttributeType.isValid(attribute.getMetadata().getElement(DEVICE_RESOURCE).getValue().asString())
+ && AttributeValueType.isValid(attribute.getMetadata().getElement(DEVICE_RESOURCE).getValue().asString())
&& attribute.hasMetadataElement(ACCESS)
&& attribute.getMetadata().getElement(ACCESS).getName().equals(ACCESS_TYPE);
}
@@ -66,8 +66,8 @@ extends Attribute {
super(name, jsonObject);
}
- public DeviceResource(String name, String key, AttributeType resourceType, Access access) {
- super(name, AttributeType.STRING, Json.create(key));
+ public DeviceResource(String name, String key, AttributeValueType resourceType, Access access) {
+ super(name, AttributeValueType.STRING, Json.create(key));
/*
setMetadata(new Metadata()
.putElement(
@@ -79,12 +79,12 @@ extends Attribute {
);
}
- public AttributeType getResourceType() {
+ public AttributeValueType getResourceType() {
return null;
return getMetadata().hasElement(DEVICE_RESOURCE)
- && AttributeType.isValid(getMetadata().getElement(DEVICE_RESOURCE).getValue().asString())
- ? AttributeType.fromValue(getMetadata().getElement(DEVICE_RESOURCE).getValue().asString())
+ && AttributeValueType.isValid(getMetadata().getElement(DEVICE_RESOURCE).getValue().asString())
+ ? AttributeValueType.fromValue(getMetadata().getElement(DEVICE_RESOURCE).getValue().asString())
: null;
}
@@ -103,7 +103,7 @@ extends Attribute {
public DeviceResource setPassive(boolean passive) {
if (passive) {
getMetadata().putElement(
- new MetadataElement(PASSIVE, AttributeType.BOOLEAN.getValue(), Json.create(true))
+ new MetadataElement(PASSIVE, AttributeValueType.BOOLEAN.getValue(), Json.create(true))
);
} else {
getMetadata().removeElement(PASSIVE);
@@ -119,7 +119,7 @@ extends Attribute {
public DeviceResource setConstant(boolean constant) {
if (constant) {
getMetadata().putElement(
- new MetadataElement(CONSTANT, AttributeType.BOOLEAN.getValue(), Json.create(true))
+ new MetadataElement(CONSTANT, AttributeValueType.BOOLEAN.getValue(), Json.create(true))
);
} else {
getMetadata().removeElement(CONSTANT);
diff --git a/model/src/main/java/org/openremote/model/geo/GeoJSONFeature.java b/model/src/main/java/org/openremote/model/geo/GeoJSONFeature.java
index 81b305f00..47cd64895 100644
--- a/model/src/main/java/org/openremote/model/geo/GeoJSONFeature.java
+++ b/model/src/main/java/org/openremote/model/geo/GeoJSONFeature.java
@@ -42,7 +42,7 @@ public class GeoJSONFeature extends AbstractTypeHolder {
return this;
}
- public GeoJSONFeature setGeometry(GeoJSONGeometry geometry) {
+ public GeoJSONFeature setGeometry(GeoJSONPoint geometry) {
if (geometry != null) {
objectValue.put("geometry", geometry.getObjectValue());
} else {
diff --git a/model/src/main/java/org/openremote/model/geo/GeoJSONGeometry.java b/model/src/main/java/org/openremote/model/geo/GeoJSONPoint.java
similarity index 55%
rename from model/src/main/java/org/openremote/model/geo/GeoJSONGeometry.java
rename to model/src/main/java/org/openremote/model/geo/GeoJSONPoint.java
index 9191ca98b..ac2c0820f 100644
--- a/model/src/main/java/org/openremote/model/geo/GeoJSONGeometry.java
+++ b/model/src/main/java/org/openremote/model/geo/GeoJSONPoint.java
@@ -21,24 +21,32 @@ package org.openremote.model.geo;
import org.openremote.model.AbstractTypeHolder;
import org.openremote.model.value.ArrayValue;
-import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Values;
-public class GeoJSONGeometry extends AbstractTypeHolder {
+public class GeoJSONPoint extends AbstractTypeHolder {
- public GeoJSONGeometry() {}
+ public GeoJSONPoint() {
+ super("Point");
+ }
+
+ public GeoJSONPoint(double[] coordinates) {
+ this();
+ ArrayValue array = Values.createArray();
+ for (int i = 0; i < coordinates.length; i++) {
+ array.set(i, coordinates[i]);
+ }
+ objectValue.put("coordinates", array);
+ }
- public GeoJSONGeometry(String type) {
- super(type);
+ public boolean hasCoordinates() {
+ return objectValue.getArray("coordinates").isPresent();
}
- /**
- * Of type "Point".
- */
- public GeoJSONGeometry(ObjectValue coordinates) {
- this("Point");
+ public double getLatitude() {
+ return objectValue.getArray("coordinates").map(coordinates -> coordinates.getNumber(1).orElse(0d)).orElse(0d);
+ }
- objectValue.put("latitude", coordinates.getNumber("latitude").orElse(0d));
- objectValue.put("longitude", coordinates.getNumber("longitude").orElse(0d));
+ public double getLongitude() {
+ return objectValue.getArray("coordinates").map(coordinates -> coordinates.getNumber(0).orElse(0d)).orElse(0d);
}
}
diff --git a/model/src/main/java/org/openremote/model/rules/AssetState.java b/model/src/main/java/org/openremote/model/rules/AssetState.java
index dd5d4bd4a..df77d7340 100644
--- a/model/src/main/java/org/openremote/model/rules/AssetState.java
+++ b/model/src/main/java/org/openremote/model/rules/AssetState.java
@@ -26,7 +26,7 @@ import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
import org.openremote.model.asset.AssetType;
import org.openremote.model.attribute.AttributeEvent;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.value.ArrayValue;
import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Value;
@@ -51,7 +51,7 @@ public class AssetState implements Comparable<AssetState> {
final protected String attributeName;
- final protected AttributeType attributeType;
+ final protected AttributeValueType attributeValueType;
final protected Value value;
@@ -91,7 +91,7 @@ public class AssetState implements Comparable<AssetState> {
public AssetState(AssetState that) {
this.attributeName = that.attributeName;
- this.attributeType = that.attributeType;
+ this.attributeValueType = that.attributeValueType;
this.value = that.value;
this.timestamp = that.timestamp;
this.time = that.time;
@@ -114,7 +114,7 @@ public class AssetState implements Comparable<AssetState> {
public AssetState(Asset asset, AssetAttribute attribute, AttributeEvent.Source source) {
this.attributeName = attribute.getNameOrThrow();
- this.attributeType = attribute.getTypeOrThrow();
+ this.attributeValueType = attribute.getTypeOrThrow();
this.value = attribute.getValue().orElse(null);
this.timestamp = attribute.getValueTimestamp().orElse(-1L);
this.time = timestamp > 0 ? LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()) : null;
@@ -139,8 +139,8 @@ public class AssetState implements Comparable<AssetState> {
return attributeName;
}
- public AttributeType getAttributeType() {
- return attributeType;
+ public AttributeValueType getAttributeValueType() {
+ return attributeValueType;
}
public Optional<Value> getValue() {
@@ -333,7 +333,7 @@ public class AssetState implements Comparable<AssetState> {
", parentName='" + getParentName() + '\'' +
", type='" + getType() + '\'' +
", attributeName='" + getAttributeName() + '\'' +
- ", attributeType=" + getAttributeType() +
+ ", attributeValueType=" + getAttributeValueType() +
", value=" + (getValue().isPresent() ? getValue().get().toJson() : "null") + // TODO Performance?
", timestamp=" + getTimestamp() +
", time=" + getTime() +
diff --git a/model/src/main/java/org/openremote/model/rules/RulesResource.java b/model/src/main/java/org/openremote/model/rules/RulesResource.java
index 44af35a77..a1e95793c 100644
--- a/model/src/main/java/org/openremote/model/rules/RulesResource.java
+++ b/model/src/main/java/org/openremote/model/rules/RulesResource.java
@@ -21,7 +21,7 @@ package org.openremote.model.rules;
import jsinterop.annotations.JsType;
import org.openremote.model.asset.AssetMeta;
-import org.openremote.model.attribute.AttributeDescriptorImpl;
+import org.openremote.model.attribute.AttributeValue;
import org.openremote.model.http.RequestParams;
import org.openremote.model.http.SuccessStatusCode;
import org.openremote.model.rules.geofence.GeofenceDefinition;
@@ -232,7 +232,7 @@ public interface RulesResource {
/**
* Get the geofences for the specified asset; if this method is accessed anonymously (public read) then the asset
- * must have public read enabled and the {@link AttributeDescriptorImpl#CONSOLE_PROVIDER_GEOFENCE} attribute must
+ * must have public read enabled and the {@link AttributeValue#CONSOLE_PROVIDER_GEOFENCE} attribute must
* have a {@link AssetMeta#ACCESS_PUBLIC_READ} meta item. Otherwise the asset must be linked to the logged in user.
* If neither of these conditions are met then a 403 is returned.
* <p>
diff --git a/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java b/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java
index ac4652180..adae47476 100644
--- a/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java
+++ b/model/src/main/java/org/openremote/model/simulator/SimulatorElement.java
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.openremote.model.ValidationFailure;
import org.openremote.model.ValueHolder;
import org.openremote.model.attribute.AttributeRef;
-import org.openremote.model.attribute.AttributeType;
+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;
@@ -51,14 +51,14 @@ import java.util.Optional;
public abstract class SimulatorElement implements ValueHolder {
public AttributeRef attributeRef;
- public AttributeType expectedType;
+ public AttributeValueType expectedType;
// TODO GWT jackson doesn't like fields with the same name as getters in the hierarchy
public Value elementValue = null;
protected SimulatorElement() {
}
- public SimulatorElement(AttributeRef attributeRef, AttributeType expectedType) {
+ public SimulatorElement(AttributeRef attributeRef, AttributeValueType expectedType) {
this.attributeRef = attributeRef;
this.expectedType = expectedType;
}
@@ -67,7 +67,7 @@ public abstract class SimulatorElement implements ValueHolder {
return attributeRef;
}
- public AttributeType getExpectedType() {
+ public AttributeValueType getExpectedType() {
return expectedType;
}
diff --git a/model/src/main/java/org/openremote/model/simulator/element/ColorSimulatorElement.java b/model/src/main/java/org/openremote/model/simulator/element/ColorSimulatorElement.java
index 9779820d8..c81479abc 100644
--- a/model/src/main/java/org/openremote/model/simulator/element/ColorSimulatorElement.java
+++ b/model/src/main/java/org/openremote/model/simulator/element/ColorSimulatorElement.java
@@ -20,7 +20,7 @@
package org.openremote.model.simulator.element;
import org.openremote.model.attribute.AttributeRef;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.simulator.SimulatorElement;
public class ColorSimulatorElement extends SimulatorElement {
@@ -31,6 +31,6 @@ public class ColorSimulatorElement extends SimulatorElement {
}
public ColorSimulatorElement(AttributeRef attributeRef) {
- super(attributeRef, AttributeType.COLOR_RGB);
+ super(attributeRef, AttributeValueType.COLOR_RGB);
}
}
diff --git a/model/src/main/java/org/openremote/model/simulator/element/NumberSimulatorElement.java b/model/src/main/java/org/openremote/model/simulator/element/NumberSimulatorElement.java
index f67adf78d..f13aaced1 100644
--- a/model/src/main/java/org/openremote/model/simulator/element/NumberSimulatorElement.java
+++ b/model/src/main/java/org/openremote/model/simulator/element/NumberSimulatorElement.java
@@ -21,7 +21,7 @@ package org.openremote.model.simulator.element;
import org.openremote.model.ValidationFailure;
import org.openremote.model.attribute.AttributeRef;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.simulator.SimulatorElement;
import org.openremote.model.value.Values;
@@ -43,7 +43,7 @@ public class NumberSimulatorElement extends SimulatorElement {
}
public NumberSimulatorElement(AttributeRef attributeRef, Integer min, Integer max) {
- super(attributeRef, AttributeType.NUMBER);
+ super(attributeRef, AttributeValueType.NUMBER);
this.min = min;
this.max = max;
}
diff --git a/model/src/main/java/org/openremote/model/simulator/element/SwitchSimulatorElement.java b/model/src/main/java/org/openremote/model/simulator/element/SwitchSimulatorElement.java
index 91c89e539..f0e518572 100644
--- a/model/src/main/java/org/openremote/model/simulator/element/SwitchSimulatorElement.java
+++ b/model/src/main/java/org/openremote/model/simulator/element/SwitchSimulatorElement.java
@@ -20,7 +20,7 @@
package org.openremote.model.simulator.element;
import org.openremote.model.attribute.AttributeRef;
-import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.simulator.SimulatorElement;
public class SwitchSimulatorElement extends SimulatorElement {
@@ -31,6 +31,6 @@ public class SwitchSimulatorElement extends SimulatorElement {
}
public SwitchSimulatorElement(AttributeRef attributeRef) {
- super(attributeRef, AttributeType.BOOLEAN);
+ super(attributeRef, AttributeValueType.BOOLEAN);
}
}
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy
index 657b842d8..fd4a7276f 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy
@@ -38,13 +38,13 @@ class AssetAttributeLinkingTest extends Specification implements ManagerContaine
when: "assets are created"
def asset1 = new Asset("Asset 1", AssetType.THING, null, Constants.MASTER_REALM)
asset1.setAttributes(
- new AssetAttribute("button", AttributeType.STRING, Values.create("RELEASED"), getClockTimeOf(container))
+ new AssetAttribute("button", AttributeValueType.STRING, Values.create("RELEASED"), getClockTimeOf(container))
)
asset1 = assetStorageService.merge(asset1)
def asset2 = new Asset("Asset 2", AssetType.THING, null, Constants.MASTER_REALM)
asset2.setAttributes(
- new AssetAttribute("lightOnOff", AttributeType.BOOLEAN, Values.create(false), getClockTimeOf(container)),
- new AssetAttribute("counter", AttributeType.NUMBER, Values.create(0), getClockTimeOf(container))
+ new AssetAttribute("lightOnOff", AttributeValueType.BOOLEAN, Values.create(false), getClockTimeOf(container)),
+ new AssetAttribute("counter", AttributeValueType.NUMBER, Values.create(0), getClockTimeOf(container))
)
asset2 = assetStorageService.merge(asset2)
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
index 9b75ae70b..1ac7e2913 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetIntegrityTest.groovy
@@ -1,6 +1,5 @@
package org.openremote.test.assets
-import com.fasterxml.uuid.Generators
import org.openremote.manager.setup.SetupService
import org.openremote.manager.setup.builtin.KeycloakDemoSetup
import org.openremote.manager.setup.builtin.ManagerDemoSetup
@@ -8,7 +7,7 @@ import org.openremote.model.asset.AssetResource
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetType
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
import org.openremote.model.value.Values
import org.openremote.test.ManagerContainerTrait
import spock.lang.Specification
@@ -56,7 +55,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
when: "an asset is stored with an illegal attribute name"
testAsset = assetResource.get(null, testAsset.getId())
testAsset.setAttributes(
- new AssetAttribute(testAsset.id, "illegal- Attribute:name&&&", AttributeType.STRING)
+ new AssetAttribute(testAsset.id, "illegal- Attribute:name&&&", AttributeValueType.STRING)
)
assetResource.update(null, testAsset.getId(), testAsset)
@@ -68,7 +67,7 @@ class AssetIntegrityTest extends Specification implements ManagerContainerTrait
when: "an asset is stored with a non-empty attribute value"
testAsset = assetResource.get(null, testAsset.getId())
testAsset.setAttributes(
- new AssetAttribute("foo", AttributeType.STRING, Values.create("bar"), getClockTimeOf(container))
+ new AssetAttribute("foo", AttributeValueType.STRING, Values.create("bar"), getClockTimeOf(container))
)
assetResource.update(null, testAsset.id, testAsset)
testAsset = assetResource.get(null, testAsset.getId())
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetModelTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetModelTest.groovy
index 40cbd5cc1..ac80bd2a0 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetModelTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetModelTest.groovy
@@ -1,6 +1,5 @@
package org.openremote.test.assets
-import com.fasterxml.uuid.Generators
import org.openremote.container.util.UniqueIdentifierGenerator
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
@@ -12,7 +11,7 @@ import java.util.stream.Collectors
import static org.openremote.model.AbstractValueTimestampHolder.VALUE_TIMESTAMP_FIELD_NAME
import static org.openremote.model.asset.AssetAttribute.getAddedOrModifiedAttributes
import static org.openremote.model.asset.AssetType.THING
-import static org.openremote.model.attribute.AttributeType.STRING
+import static org.openremote.model.attribute.AttributeValueType.STRING
class AssetModelTest extends Specification {
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
index ad005fa81..98a9c4e71 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
@@ -8,7 +8,7 @@ import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetQuery
import org.openremote.model.asset.AssetType
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
import org.openremote.model.attribute.Meta
import org.openremote.model.attribute.MetaItem
import org.openremote.model.value.Values
@@ -25,8 +25,8 @@ import static org.openremote.model.Constants.*
import static org.openremote.model.asset.BaseAssetQuery.ParentPredicate
import static org.openremote.model.asset.BaseAssetQuery.TenantPredicate
import static org.openremote.model.asset.AssetMeta.*
-import static org.openremote.model.attribute.AttributeType.BOOLEAN
-import static org.openremote.model.attribute.AttributeType.NUMBER
+import static org.openremote.model.attribute.AttributeValueType.BOOLEAN
+import static org.openremote.model.attribute.AttributeValueType.NUMBER
import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo
class AssetPermissionsTest extends Specification implements ManagerContainerTrait {
@@ -578,8 +578,6 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
apartment1.realmId == keycloakDemoSetup.customerATenant.id
apartment1.type == AssetType.RESIDENCE.value
apartment1.parentId == managerDemoSetup.smartHomeId
- apartment1.coordinates[0] == 5.470945d
- apartment1.coordinates[1] == 51.438d
apartment1.path == null
apartment1.attributesList.size() == 0
@@ -671,7 +669,7 @@ class AssetPermissionsTest extends Specification implements ManagerContainerTrai
def resultAttributes = apartment1Livingroom.getAttributesList()
resultAttributes.size() == 5
def currentTemperature = apartment1Livingroom.getAttribute("currentTemperature").get()
- currentTemperature.getType().get() == AttributeType.TEMPERATURE_CELCIUS
+ currentTemperature.getType().get() == AttributeValueType.TEMPERATURE_CELCIUS
!currentTemperature.getValue().isPresent()
Meta resultMeta = currentTemperature.getMeta()
resultMeta.size() == 6
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
index b6d6ba33d..802de9c94 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
@@ -163,7 +163,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTrait
and: "a mock thing asset is created with a valid protocol attribute, an invalid protocol attribute and a plain attribute"
def mockThing = new Asset("Mock Thing Asset", AssetType.THING, mockAgent)
mockThing.setAttributes(
- new AssetAttribute("light1Toggle", AttributeType.BOOLEAN, Values.create(true))
+ new AssetAttribute("light1Toggle", AttributeValueType.BOOLEAN, Values.create(true))
.setMeta(
new MetaItem(
AssetMeta.DESCRIPTION,
@@ -174,7 +174,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTrait
new AttributeRef(mockAgent.getId(), "mock123").toArrayValue()
)
),
- new AssetAttribute("light2Toggle", AttributeType.BOOLEAN, Values.create(true))
+ new AssetAttribute("light2Toggle", AttributeValueType.BOOLEAN, Values.create(true))
.setMeta(
new MetaItem(
AssetMeta.DESCRIPTION,
@@ -185,7 +185,7 @@ class AssetProcessingTest extends Specification implements ManagerContainerTrait
new AttributeRef("INVALID AGENT ID", managerDemoSetup.agentProtocolConfigName).toArrayValue()
)
),
- new AssetAttribute("plainAttribute", AttributeType.STRING, Values.create("demo"))
+ new AssetAttribute("plainAttribute", AttributeValueType.STRING, Values.create("demo"))
.setMeta(
new MetaItem(
AssetMeta.DESCRIPTION,
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
index 19ed3249e..8b71b5712 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
@@ -22,7 +22,7 @@ import static org.openremote.model.asset.BaseAssetQuery.*
import static org.openremote.model.asset.AssetMeta.ACCESS_PUBLIC_READ
import static org.openremote.model.asset.AssetMeta.LABEL
import static org.openremote.model.asset.AssetType.THING
-import static org.openremote.model.attribute.AttributeType.NUMBER
+import static org.openremote.model.attribute.AttributeValueType.NUMBER
class AssetPublicQueryTest extends Specification implements ManagerContainerTrait {
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
index 783aa7f69..ab030d265 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
@@ -1,7 +1,5 @@
package org.openremote.test.assets
-import com.vividsolutions.jts.geom.Coordinate
-import com.vividsolutions.jts.geom.GeometryFactory
import org.openremote.container.Container
import org.openremote.container.persistence.PersistenceService
import org.openremote.manager.asset.AssetProcessingService
@@ -11,12 +9,11 @@ import org.openremote.manager.setup.SetupService
import org.openremote.manager.setup.builtin.KeycloakDemoSetup
import org.openremote.manager.setup.builtin.ManagerDemoSetup
import org.openremote.model.asset.Asset
-import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetMeta
import org.openremote.model.asset.AssetQuery
import org.openremote.model.asset.AssetType
import org.openremote.model.asset.CalendarEventConfiguration
-import org.openremote.model.attribute.AttributeDescriptorImpl
+import org.openremote.model.attribute.AttributeValue
import org.openremote.model.calendar.CalendarEvent
import org.openremote.model.calendar.RecurrenceRule
import org.openremote.model.value.Values
@@ -675,7 +672,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
when: "one of the assets in the region is moved"
def lobby = assetStorageService.find(managerDemoSetup.lobbyId, true)
- lobby.replaceAttribute(createWithDescriptor(AttributeDescriptorImpl.LOCATION, Values.createObject().put("latitude", 51.44593d).put("longitude", 5.46108d)))
+ lobby.replaceAttribute(createWithDescriptor(AttributeValue.LOCATION, Values.createObject().put("latitude", 51.44593d).put("longitude", 5.46108d)))
lobby = assetStorageService.merge(lobby)
then: "the system should settle down"
@@ -785,18 +782,20 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.orderBy(new OrderBy(NAME))
)
- then: "all 5 realm assets should be returned"
- assets.size() == 5
+ then: "all 6 realm assets should be returned"
+ assets.size() == 6
assets[0].id == managerDemoSetup.agentId
assets[0].name == "Demo Agent"
- assets[1].id == managerDemoSetup.thingId
- assets[1].name == "Demo Thing"
- assets[2].id == managerDemoSetup.groundFloorId
- assets[2].name == "Ground Floor"
- assets[3].id == managerDemoSetup.lobbyId
- assets[3].name == "Lobby"
- assets[4].id == managerDemoSetup.smartOfficeId
- assets[4].name == "Smart Office"
+ assets[1].id == managerDemoSetup.consoleId
+ assets[1].name == "Demo Android Console"
+ assets[2].id == managerDemoSetup.thingId
+ assets[2].name == "Demo Thing"
+ assets[3].id == managerDemoSetup.groundFloorId
+ assets[3].name == "Ground Floor"
+ assets[4].id == managerDemoSetup.lobbyId
+ assets[4].name == "Lobby"
+ assets[5].id == managerDemoSetup.smartOfficeId
+ assets[5].name == "Smart Office"
when: "a calendar event filtering query is executed for future event on a correct day but wrong time"
assets = assetStorageService.findAll(
@@ -808,7 +807,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
)
then: "the calendar event asset should not be included"
- assets.size() == 4
+ assets.size() == 5
!assets.any {it.name == "Lobby"}
when: "a calendar event filtering query is executed for a future event on a wrong day but correct time"
@@ -821,7 +820,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
)
then: "the calendar event asset should not be included"
- assets.size() == 4
+ assets.size() == 5
!assets.any {it.name == "Lobby"}
when: "a calendar event filtering query is executed inside a valid future event date and time"
@@ -833,18 +832,20 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
.orderBy(new OrderBy(NAME))
)
- then: "all 5 realm assets should be returned"
- assets.size() == 5
+ then: "all 6 realm assets should be returned"
+ assets.size() == 6
assets[0].id == managerDemoSetup.agentId
assets[0].name == "Demo Agent"
- assets[1].id == managerDemoSetup.thingId
- assets[1].name == "Demo Thing"
- assets[2].id == managerDemoSetup.groundFloorId
- assets[2].name == "Ground Floor"
- assets[3].id == managerDemoSetup.lobbyId
- assets[3].name == "Lobby"
- assets[4].id == managerDemoSetup.smartOfficeId
- assets[4].name == "Smart Office"
+ assets[1].id == managerDemoSetup.consoleId
+ assets[1].name == "Demo Android Console"
+ assets[2].id == managerDemoSetup.thingId
+ assets[2].name == "Demo Thing"
+ assets[3].id == managerDemoSetup.groundFloorId
+ assets[3].name == "Ground Floor"
+ assets[4].id == managerDemoSetup.lobbyId
+ assets[4].name == "Lobby"
+ assets[5].id == managerDemoSetup.smartOfficeId
+ assets[5].name == "Smart Office"
when: "a calendar event filtering query is executed for some time after the last occurrence"
assets = assetStorageService.findAll(
@@ -856,7 +857,7 @@ class AssetQueryTest extends Specification implements ManagerContainerTrait {
)
then: "the calendar event asset should not be included"
- assets.size() == 4
+ assets.size() == 5
!assets.any {it.name == "Lobby"}
}
}
diff --git a/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy b/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy
index 4e0ea8ca1..3bb57aaca 100644
--- a/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy
@@ -138,7 +138,8 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gw
and: "an assets location is changed"
def asset = assetStorageService.find(managerDemoSetup.thingId, true)
- asset.setLocation(new GeometryFactory().createPoint(new Coordinate(120.1d, 50.43d)))
+ double[] coordinates = [120.1d, 50.43d]
+ asset.setCoordinates(coordinates)
asset = assetStorageService.merge(asset)
then: "the location event should have been received"
@@ -151,7 +152,7 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gw
}
when: "the assets location is set to null"
- asset.setLocation(null)
+ asset.setCoordinates(null)
asset = assetStorageService.merge(asset)
then: "the location event should have been received with null coordinates"
@@ -163,7 +164,8 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gw
}
when: "the location is changed"
- asset.setLocation(new GeometryFactory().createPoint(new Coordinate(-10.11d, -50.233d)))
+ coordinates = [-10.11d, -50.233d]
+ asset.setCoordinates(coordinates)
asset = assetStorageService.merge(asset)
then: "the location event should have been received"
@@ -176,7 +178,8 @@ class ClientEventTest extends Specification implements ManagerContainerTrait, Gw
}
when: "the location is set with the same value"
- asset.setLocation(new GeometryFactory().createPoint(new Coordinate(-10.11d, -50.233d)))
+ coordinates = [-10.11d, -50.233d]
+ asset.setCoordinates(coordinates)
asset = assetStorageService.merge(asset)
then: "no location event should have been received"
diff --git a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
index 54c368a29..4b7b3a157 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
@@ -207,7 +207,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
when: "a mock thing asset is created that links to the mock protocol configurations"
def mockThing = new Asset("Mock Thing Asset", AssetType.THING, mockAgent)
mockThing.setAttributes(
- new AssetAttribute("lightToggle1", AttributeType.BOOLEAN)
+ new AssetAttribute("lightToggle1", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -215,7 +215,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()
)
),
- new AssetAttribute("tempTarget1", AttributeType.NUMBER)
+ new AssetAttribute("tempTarget1", AttributeValueType.NUMBER)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -223,14 +223,14 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()
)
),
- new AssetAttribute("invalidToggle1", AttributeType.BOOLEAN)
+ new AssetAttribute("invalidToggle1", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem(
AssetMeta.AGENT_LINK,
new AttributeRef(mockAgent.getId(), "mockConfig1").toArrayValue()
)
),
- new AssetAttribute("lightToggle2", AttributeType.BOOLEAN)
+ new AssetAttribute("lightToggle2", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -238,7 +238,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig2").toArrayValue()
)
),
- new AssetAttribute("tempTarget2", AttributeType.NUMBER)
+ new AssetAttribute("tempTarget2", AttributeValueType.NUMBER)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -246,7 +246,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig2").toArrayValue()
)
),
- new AssetAttribute("lightToggle3", AttributeType.BOOLEAN)
+ new AssetAttribute("lightToggle3", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -254,7 +254,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig3").toArrayValue()
)
),
- new AssetAttribute("tempTarget3", AttributeType.NUMBER)
+ new AssetAttribute("tempTarget3", AttributeValueType.NUMBER)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -262,7 +262,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig3").toArrayValue()
)
),
- new AssetAttribute("lightToggle4", AttributeType.BOOLEAN)
+ new AssetAttribute("lightToggle4", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -270,7 +270,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig4").toArrayValue()
)
),
- new AssetAttribute("tempTarget4", AttributeType.NUMBER)
+ new AssetAttribute("tempTarget4", AttributeValueType.NUMBER)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -278,14 +278,14 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
new AttributeRef(mockAgent.getId(), "mockConfig4").toArrayValue()
)
),
- new AssetAttribute("invalidToggle5", AttributeType.BOOLEAN, Values.create(false))
+ new AssetAttribute("invalidToggle5", AttributeValueType.BOOLEAN, Values.create(false))
.setMeta(
new MetaItem(
AssetMeta.AGENT_LINK,
new AttributeRef(mockAgent.getId(), "INVALID CONFIG").toArrayValue()
)
),
- new AssetAttribute("plainAttribute", AttributeType.STRING, Values.create("demo"))
+ new AssetAttribute("plainAttribute", AttributeValueType.STRING, Values.create("demo"))
.setMeta(
new MetaItem(
AssetMeta.DESCRIPTION,
@@ -293,7 +293,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
),
new MetaItem(AssetMeta.READ_ONLY, Values.create(true))
),
- new AssetAttribute("filterRegex", AttributeType.NUMBER)
+ new AssetAttribute("filterRegex", AttributeValueType.NUMBER)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -305,7 +305,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
Values.createArray().add(new RegexFilter("\\w(\\d+)", 1, 2).toValue().get())
)
),
- new AssetAttribute("filterSubstring", AttributeType.STRING)
+ new AssetAttribute("filterSubstring", AttributeValueType.STRING)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
@@ -317,7 +317,7 @@ class BasicProtocolTest extends Specification implements ManagerContainerTrait,
Values.createArray().add(new SubStringFilter(10, 12).toValue().get())
)
),
- new AssetAttribute("filterRegexSubstring", AttributeType.NUMBER)
+ new AssetAttribute("filterRegexSubstring", AttributeValueType.NUMBER)
.setMeta(
new MetaItem("MOCK_ATTRIBUTE_REQUIRED_META", Values.create(true)),
new MetaItem(
diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
index ed87ebc88..4ae9e833c 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
@@ -120,7 +120,7 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {
when: "a thing asset is created that links it's attributes to the knx protocol configuration"
def knxThing = new Asset("Living Room Assset", AssetType.THING, knxAgent)
knxThing.setAttributes(
- new AssetAttribute("light1ToggleOnOff", AttributeType.BOOLEAN)
+ new AssetAttribute("light1ToggleOnOff", AttributeValueType.BOOLEAN)
.setMeta(
new MetaItem(LABEL, Values.create("Light 1 Toggle On/Off")),
new MetaItem(DESCRIPTION, Values.create("Light 1 for living room")),
diff --git a/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy
index e9003d3c7..1bcd0e151 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/TimerProtocolTest.groovy
@@ -14,7 +14,7 @@ import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.AgentLink
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.attribute.AttributeRef
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
import org.openremote.model.value.Values
import org.openremote.test.ManagerContainerTrait
import org.quartz.CronTrigger
@@ -136,7 +136,7 @@ class TimerProtocolTest extends Specification implements ManagerContainerTrait {
when: "an attribute is added that links to a timers cron expression"
apartment1.addAttributes(
- new AssetAttribute("awaySceneCronFRIDAY", AttributeType.STRING)
+ new AssetAttribute("awaySceneCronFRIDAY", AttributeValueType.STRING)
.addMeta(
AgentLink.asAgentLinkMetaItem(new AttributeRef(sceneAgent.id, "awaySceneFRIDAY")),
TimerValue.CRON_EXPRESSION.asMetaItem()
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
index 7f660eef2..a095cc2d2 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
@@ -36,7 +36,7 @@ import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.ConnectionStatus
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.attribute.AttributeRef
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
import org.openremote.model.attribute.MetaItem
import org.openremote.model.value.ObjectValue
import org.openremote.model.value.Value
@@ -462,7 +462,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
def asset = new Asset("Test Asset", AssetType.THING, agent)
asset.setAttributes(
// attribute that sends requests to the server using PUT with dynamic body and custom header to override parent
- new AssetAttribute("putRequestWithHeaders", AttributeType.OBJECT)
+ new AssetAttribute("putRequestWithHeaders", AttributeValueType.OBJECT)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("put_request_with_headers")),
@@ -481,13 +481,13 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
)
),
// attribute that sends requests to the server using GET with dynamic path
- new AssetAttribute("getRequestWithDynamicPath", AttributeType.OBJECT)
+ new AssetAttribute("getRequestWithDynamicPath", AttributeValueType.OBJECT)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create('value/{$value}/set'))
),
// attribute that polls the server using GET and uses regex filter on response
- new AssetAttribute("getPollSlow", AttributeType.NUMBER)
+ new AssetAttribute("getPollSlow", AttributeValueType.NUMBER)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_poll_slow")),
@@ -498,7 +498,7 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
)
),
// attribute that polls the server using GET and uses regex filter on response
- new AssetAttribute("getPollFast", AttributeType.NUMBER)
+ new AssetAttribute("getPollFast", AttributeValueType.NUMBER)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_poll_fast")),
@@ -625,33 +625,33 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTr
when: "attributes are linked to these protocol configurations"
def asset2 = new Asset("Test Asset 2", AssetType.THING, agent)
asset2.addAttributes(
- new AssetAttribute("getSuccess", AttributeType.STRING)
+ new AssetAttribute("getSuccess", AttributeValueType.STRING)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig2").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_success_200"))
),
- new AssetAttribute("getFailure", AttributeType.STRING)
+ new AssetAttribute("getFailure", AttributeValueType.STRING)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig2").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_failure_401"))
),
- new AssetAttribute("pollFailure", AttributeType.STRING)
+ new AssetAttribute("pollFailure", AttributeValueType.STRING)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig3").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_failure_401")),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_POLLING_SECONDS, Values.create(50)), // This is ms in testing
),
- new AssetAttribute("getSuccess2", AttributeType.STRING)
+ new AssetAttribute("getSuccess2", AttributeValueType.STRING)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig4").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_success_200"))
),
- new AssetAttribute("getFailure2", AttributeType.STRING)
+ new AssetAttribute("getFailure2", AttributeValueType.STRING)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig4").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("get_failure_401"))
),
- new AssetAttribute("getRedirect", AttributeType.STRING)
+ new AssetAttribute("getRedirect", AttributeValueType.STRING)
.addMeta(
new MetaItem(AssetMeta.AGENT_LINK, new AttributeRef(agent.id, "protocolConfig4").toArrayValue()),
new MetaItem(HttpClientProtocol.META_ATTRIBUTE_PATH, Values.create("redirect"))
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy
index 76840ee56..0cfef64ee 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy
@@ -19,8 +19,6 @@
*/
package org.openremote.test.protocol.http
-import com.vividsolutions.jts.geom.Coordinate
-import com.vividsolutions.jts.geom.GeometryFactory
import org.jboss.resteasy.spi.ResteasyUriInfo
import org.jboss.resteasy.util.BasicAuthHelper
import org.openremote.agent.protocol.http.*
@@ -30,7 +28,7 @@ import org.openremote.manager.asset.AssetStorageService
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetType
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
import org.openremote.model.attribute.MetaItem
import org.openremote.model.value.ObjectValue
import org.openremote.model.value.Values
@@ -333,7 +331,7 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTr
def testAsset = new Asset("Test Asset", AssetType.THING)
testAsset.setId("12345")
testAsset.setAttributes(
- new AssetAttribute("attribute1", AttributeType.STRING, Values.create("Test"))
+ new AssetAttribute("attribute1", AttributeValueType.STRING, Values.create("Test"))
)
double[] coordinates = [1d, 2d]
testAsset.setCoordinates(coordinates)
@@ -392,7 +390,7 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTr
testAsset = new Asset("Test Asset 2", AssetType.THING)
testAsset.setId("67890")
testAsset.setAttributes(
- new AssetAttribute("attribute2", AttributeType.STRING, Values.create("Test"))
+ new AssetAttribute("attribute2", AttributeValueType.STRING, Values.create("Test"))
)
coordinates = [3d, 4d]
testAsset.setCoordinates(coordinates)
diff --git a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
index eeaf29fa6..a51d8a814 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
@@ -16,7 +16,7 @@ import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.AgentLink
import org.openremote.model.asset.agent.AgentResource
import org.openremote.model.attribute.AttributeRef
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
import org.openremote.model.attribute.MetaItem
import org.openremote.model.file.FileInfo
import org.openremote.model.util.TextUtil
@@ -110,7 +110,7 @@ class VelbusProtocolTest extends Specification implements ManagerContainerTrait
and: "a device asset is created"
def device = new Asset("VELBUS Demo VMBGPOD", AssetType.THING, agent)
device.setAttributes(
- new AssetAttribute("ch1State", AttributeType.STRING)
+ new AssetAttribute("ch1State", AttributeValueType.STRING)
.setMeta(
new MetaItem(
AbstractVelbusProtocol.META_VELBUS_DEVICE_ADDRESS,
diff --git a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
index c5f5442d1..69cc3ecd2 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
@@ -13,7 +13,7 @@ import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetMeta
import org.openremote.model.asset.AssetType
import org.openremote.model.attribute.AttributeEvent
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
import org.openremote.model.attribute.Meta
import org.openremote.model.attribute.MetaItem
import org.openremote.model.rules.AssetRuleset
@@ -213,7 +213,7 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
def asset = new Asset("Kitchen", AssetType.ROOM, apartment2)
asset.setRealmId(keycloakDemoSetup.customerATenant.getId())
def attributes = [
- new AssetAttribute("testString", AttributeType.STRING, Values.create("test"))
+ new AssetAttribute("testString", AttributeValueType.STRING, Values.create("test"))
.setMeta(
new Meta(new MetaItem(AssetMeta.RULE_STATE, Values.create(true))
)
@@ -244,11 +244,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "the Kitchen room asset is modified to add a new attribute but RULE_STATE = true meta is not changed"
rulesImport.resetRulesFired()
attributes = [
- new AssetAttribute("testString", AttributeType.STRING, Values.create("test"))
+ new AssetAttribute("testString", AttributeValueType.STRING, Values.create("test"))
.setMeta(
new MetaItem(AssetMeta.RULE_STATE, Values.create(true))
),
- new AssetAttribute("testInteger", AttributeType.NUMBER, Values.create(0))
+ new AssetAttribute("testInteger", AttributeValueType.NUMBER, Values.create(0))
]
asset.setAttributes(attributes)
asset = assetStorageService.merge(asset)
@@ -270,11 +270,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "the Kitchen room asset is modified to set the RULE_STATE to false"
rulesImport.resetRulesFired()
attributes = [
- new AssetAttribute("testString", AttributeType.STRING, Values.create("test"))
+ new AssetAttribute("testString", AttributeValueType.STRING, Values.create("test"))
.setMeta(
new MetaItem(AssetMeta.RULE_STATE, Values.create(false))
),
- new AssetAttribute("testInteger", AttributeType.NUMBER, Values.create(0))
+ new AssetAttribute("testInteger", AttributeValueType.NUMBER, Values.create(0))
]
asset.setAttributes(attributes)
asset = assetStorageService.merge(asset)
@@ -299,11 +299,11 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
when: "the Kitchen room asset is modified to set all attributes to RULE_STATE = true"
rulesImport.resetRulesFired()
attributes = [
- new AssetAttribute("testString", AttributeType.STRING, Values.create("test"))
+ new AssetAttribute("testString", AttributeValueType.STRING, Values.create("test"))
.setMeta(
new MetaItem(AssetMeta.RULE_STATE, Values.create(true))
),
- new AssetAttribute("testInteger", AttributeType.NUMBER, Values.create(0))
+ new AssetAttribute("testInteger", AttributeValueType.NUMBER, Values.create(0))
.setMeta(
new MetaItem(AssetMeta.RULE_STATE, Values.create(true))
)
@@ -412,4 +412,6 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainer
cleanup: "the server should be stopped"
stopContainer(container)
}
+
+ //TODO add test for location Predicates in AssetQueryPredicate
}
diff --git a/test/src/test/groovy/org/openremote/test/rules/geofence/BasicGeofenceProcessingTest.groovy b/test/src/test/groovy/org/openremote/test/rules/geofence/BasicGeofenceProcessingTest.groovy
index e379b5010..99a431046 100644
--- a/test/src/test/groovy/org/openremote/test/rules/geofence/BasicGeofenceProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/geofence/BasicGeofenceProcessingTest.groovy
@@ -12,7 +12,7 @@ import org.openremote.manager.setup.builtin.ManagerDemoSetup
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
import org.openremote.model.asset.AssetMeta
-import org.openremote.model.attribute.AttributeDescriptorImpl
+import org.openremote.model.attribute.AttributeValue
import org.openremote.model.attribute.MetaItem
import org.openremote.model.rules.AssetRuleset
import org.openremote.model.rules.GlobalRuleset
@@ -78,11 +78,11 @@ class BasicGeofenceProcessingTest extends Specification implements ManagerContai
when: "another console asset is added with its location attribute marked as RULE_STATE and it has a CONSOLE_PROVIDER_GEOFENCE attribute"
Asset console2 = new Asset("Demo Android Console 2", CONSOLE)
.addAttributes(
- new AssetAttribute(AttributeDescriptorImpl.LOCATION.getName(),
- AttributeDescriptorImpl.LOCATION.getType())
+ new AssetAttribute(AttributeValue.LOCATION.getName(),
+ AttributeValue.LOCATION.getType())
.setMeta(new MetaItem(RULE_STATE)),
- new AssetAttribute(AttributeDescriptorImpl.CONSOLE_PROVIDER_GEOFENCE.getName(),
- AttributeDescriptorImpl.CONSOLE_PROVIDER_GEOFENCE.getType())
+ new AssetAttribute(AttributeValue.CONSOLE_PROVIDER_GEOFENCE.getName(),
+ AttributeValue.CONSOLE_PROVIDER_GEOFENCE.getType())
.setMeta(
new MetaItem(GEOFENCE_ADAPTER, Values.create("ORConsole")),
new MetaItem(ACCESS_PUBLIC_READ)
@@ -186,7 +186,7 @@ class BasicGeofenceProcessingTest extends Specification implements ManagerContai
}
when: "the RULE_STATE meta is removed from the second console asset's location attribute"
- console2.getAttribute(AttributeDescriptorImpl.LOCATION.getName()).get().getMeta().removeIf({it.name.orElse(null) == AssetMeta.RULE_STATE.urn})
+ console2.getAttribute(AttributeValue.LOCATION.getName()).get().getMeta().removeIf({it.name.orElse(null) == AssetMeta.RULE_STATE.urn})
console2 = assetStorageService.merge(console2)
then: "the geofence adapter should be notified that the console asset no longer has any rules with location predicates"
diff --git a/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy b/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy
index f235b3159..08456825c 100644
--- a/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy
+++ b/test/src/test/resources/org/openremote/test/rules/BasicSmartHomeMatchAllAssetStates.groovy
@@ -3,7 +3,7 @@ package org.openremote.test.rules
import org.openremote.manager.rules.RulesBuilder
import org.openremote.model.asset.AssetQuery
import org.openremote.model.asset.AssetType
-import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.AttributeValueType
RulesBuilder rules = binding.rules
@@ -37,7 +37,7 @@ rules.add()
{ facts ->
!facts.matchFirst("Kitchen Number Attributes").isPresent() &&
facts.matchAssetState(new AssetQuery().name("Kitchen"))
- .filter({ assetState -> assetState.attributeType == AttributeType.NUMBER })
+ .filter({ assetState -> assetState.attributeValueType == AttributeValueType.NUMBER })
.findFirst().isPresent()
})
.then(
@@ -51,7 +51,7 @@ rules.add()
{ facts ->
!facts.matchFirst("Boolean attributes").isPresent() &&
facts.matchAssetState(new AssetQuery())
- .filter({ assetState -> assetState.attributeType == AttributeType.BOOLEAN })
+ .filter({ assetState -> assetState.attributeValueType == AttributeValueType.BOOLEAN })
.findFirst().isPresent()
})
.then(
@@ -65,7 +65,7 @@ rules.add()
{ facts ->
!facts.matchFirst("String Attributes").isPresent() &&
facts.matchAssetState(new AssetQuery())
- .filter({ assetState -> assetState.attributeType == AttributeType.STRING })
+ .filter({ assetState -> assetState.attributeValueType == AttributeValueType.STRING })
.findFirst().isPresent()
})
.then(