Skip to content

armgit / core

Public Imported from GitHub
0

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

Moved MetaItemType to attribute package and updated AttributeDescriptor (renamed getName getAttributeName)

Rich Turnerea31e058e117
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 1655b4a35..36fc32630 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
@@ -32,7 +32,7 @@ import org.openremote.container.timer.TimerService;
import org.openremote.model.ValidationFailure;
import org.openremote.model.ValueHolder;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.agent.AgentLink;
import org.openremote.model.asset.agent.ConnectionStatus;
import org.openremote.model.asset.agent.ProtocolConfiguration;
diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
index de0140ba3..eca86761e 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
@@ -30,7 +30,7 @@ import org.openremote.model.AbstractValueHolder;
import org.openremote.model.ValidationFailure;
import org.openremote.model.ValueHolder;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.agent.ConnectionStatus;
import org.openremote.model.asset.agent.ProtocolConfiguration;
import org.openremote.model.attribute.*;
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 680ffb6fb..3071be43a 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
@@ -7,7 +7,7 @@ import org.openremote.model.AbstractValueHolder;
import org.openremote.model.ValidationFailure;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.AssetType;
import org.openremote.model.asset.agent.AgentLink;
import org.openremote.model.asset.agent.ConnectionStatus;
diff --git a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
index 8f483cbf8..bf63aef2a 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
@@ -41,8 +41,8 @@ import java.util.stream.Collectors;
import static org.openremote.container.concurrent.GlobalLock.withLock;
import static org.openremote.container.concurrent.GlobalLock.withLockReturning;
import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;
-import static org.openremote.model.asset.MetaItemType.RANGE_MAX;
-import static org.openremote.model.asset.MetaItemType.RANGE_MIN;
+import static org.openremote.model.attribute.MetaItemType.RANGE_MAX;
+import static org.openremote.model.attribute.MetaItemType.RANGE_MIN;
import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_INTEGER_POSITIVE;
public class SimulatorProtocol extends AbstractProtocol {
diff --git a/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java
index 2cd4b9b42..72c5402cd 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java
@@ -21,7 +21,7 @@ package org.openremote.agent.protocol.timer;
import org.openremote.agent.protocol.AbstractProtocol;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.agent.ConnectionStatus;
import org.openremote.model.attribute.*;
import org.openremote.model.util.TextUtil;
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 769f210a8..dbfc02f24 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
@@ -26,7 +26,7 @@ import org.openremote.agent.protocol.velbus.device.VelbusDeviceType;
import org.openremote.container.util.CodecUtil;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.AssetType;
import org.openremote.model.asset.agent.AgentLink;
import org.openremote.model.asset.agent.ConnectionStatus;
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 1f198eb9a..6e9c4fa89 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
@@ -45,7 +45,7 @@ import org.openremote.model.ValidationFailure;
import org.openremote.model.ValueHolder;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.agent.ProtocolConfiguration;
import org.openremote.model.attribute.*;
import org.openremote.model.event.bus.EventBus;
diff --git a/client/src/main/java/org/openremote/app/client/assets/attributes/MetaEditor.java b/client/src/main/java/org/openremote/app/client/assets/attributes/MetaEditor.java
index 64c7e596e..4ba50a41f 100644
--- a/client/src/main/java/org/openremote/app/client/assets/attributes/MetaEditor.java
+++ b/client/src/main/java/org/openremote/app/client/assets/attributes/MetaEditor.java
@@ -25,7 +25,7 @@ import org.openremote.app.client.widget.*;
import org.openremote.app.client.Environment;
import org.openremote.model.ValidationFailure;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.agent.AgentLink;
import org.openremote.model.asset.agent.ProtocolDescriptor;
import org.openremote.model.attribute.AttributeValidationResult;
@@ -144,7 +144,7 @@ public class MetaEditor extends AbstractAttributeViewExtension {
Arrays.stream(metaItemDescriptors)
.forEach(metaItemDescriptor -> {
- String name = getMetaItemDisplayName(environment, metaItemDescriptor.name());
+ String name = getMetaItemDisplayName(environment, metaItemDescriptor.getName());
nameList.addItem(name, metaItemDescriptor.getUrn());
});
}
@@ -204,7 +204,7 @@ public class MetaEditor extends AbstractAttributeViewExtension {
}
}
- nameLabel.setText(currentMetaItemDescriptor.map(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.name())).orElse(urn));
+ nameLabel.setText(currentMetaItemDescriptor.map(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.getName())).orElse(urn));
nameInput.setVisible(!currentMetaItemDescriptor.isPresent());
typeList.setVisible(!currentMetaItemDescriptor.isPresent());
typeList.selectItem(typeListValue);
@@ -325,7 +325,7 @@ public class MetaEditor extends AbstractAttributeViewExtension {
return metaItemDescriptor != MetaItemType.PROTOCOL_CONFIGURATION &&
(!isProtocolConfiguration || metaItemDescriptor != MetaItemType.AGENT_LINK);
})
- .sorted(Comparator.comparing(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.name())))
+ .sorted(Comparator.comparing(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.getName())))
.toArray(MetaItemDescriptor[]::new);
// Refresh the new item meta item editor
@@ -460,7 +460,7 @@ public class MetaEditor extends AbstractAttributeViewExtension {
.orElse(true);
if (!canAdd) {
- showValidationError(attribute.getName().orElse(""), null, new ValidationFailure(MetaItem.MetaItemFailureReason.META_ITEM_DUPLICATION, getMetaItemDisplayName(environment, descriptor[0].name())));
+ showValidationError(attribute.getName().orElse(""), null, new ValidationFailure(MetaItem.MetaItemFailureReason.META_ITEM_DUPLICATION, getMetaItemDisplayName(environment, descriptor[0].getName())));
return false;
}
@@ -536,7 +536,7 @@ public class MetaEditor extends AbstractAttributeViewExtension {
.map(parameter ->
// Parameter should be meta item name URN
getMetaItemDescriptor(parameter)
- .map(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.name()))
+ .map(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.getName()))
.orElse(parameter)
)
.orElse("")
@@ -560,7 +560,7 @@ public class MetaEditor extends AbstractAttributeViewExtension {
if (failures != null) {
Optional<MetaItemDescriptor> optionalMetaItemDescriptor = metaItemEditor.getCurrentDescriptor();
String displayName = optionalMetaItemDescriptor
- .map(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.name()))
+ .map(metaItemDescriptor -> getMetaItemDisplayName(environment, metaItemDescriptor.getName()))
.orElse(metaItemEditor.getItem().getName().orElse(""));
failures.forEach(failure -> {
diff --git a/client/src/main/java/org/openremote/app/client/widget/AttributeLinkEditor.java b/client/src/main/java/org/openremote/app/client/widget/AttributeLinkEditor.java
index 67272495c..75ec39d63 100644
--- a/client/src/main/java/org/openremote/app/client/widget/AttributeLinkEditor.java
+++ b/client/src/main/java/org/openremote/app/client/widget/AttributeLinkEditor.java
@@ -27,7 +27,7 @@ import org.openremote.app.client.assets.attributes.AttributeView;
import org.openremote.app.client.assets.attributes.MetaEditor;
import org.openremote.model.ValidationFailure;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.attribute.*;
import org.openremote.model.interop.Consumer;
import org.openremote.model.util.EnumUtil;
diff --git a/manager/src/main/java/org/openremote/manager/agent/AgentService.java b/manager/src/main/java/org/openremote/manager/agent/AgentService.java
index ba3f3ef3c..dbafd5c41 100644
--- a/manager/src/main/java/org/openremote/manager/agent/AgentService.java
+++ b/manager/src/main/java/org/openremote/manager/agent/AgentService.java
@@ -37,7 +37,7 @@ import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.manager.web.ManagerWebService;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.AssetType;
import org.openremote.model.asset.agent.*;
import org.openremote.model.attribute.AttributeEvent;
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java b/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java
index 0fb3f5ed5..97af7da88 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java
@@ -24,7 +24,7 @@ import org.openremote.container.ContainerService;
import org.openremote.manager.asset.AssetProcessingException.Reason;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.query.AssetQuery;
import org.openremote.model.attribute.*;
import org.openremote.model.attribute.AttributeEvent.Source;
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java
index 4c8516fef..96dd17d07 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java
@@ -41,6 +41,7 @@ import org.openremote.model.asset.*;
import org.openremote.model.attribute.AttributeEvent;
import org.openremote.model.attribute.AttributeEvent.Source;
import org.openremote.model.attribute.AttributeExecuteStatus;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.security.ClientRole;
import org.openremote.model.util.AssetModelUtil;
import org.openremote.model.value.Value;
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 e6b37b475..d7f67472a 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
@@ -468,7 +468,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
Optional<AttributeDescriptor> attributeDescriptor = assetDescriptor.getAttributeDescriptors()
.flatMap(attributeDescriptors ->
Arrays.stream(attributeDescriptors)
- .filter(attrDescriptor -> attrDescriptor.getName().equals(assetAttribute.getNameOrThrow()))
+ .filter(attrDescriptor -> attrDescriptor.getAttributeName().equals(assetAttribute.getNameOrThrow()))
.findFirst()
);
@@ -484,7 +484,7 @@ public class AssetResourceImpl extends ManagerWebResource implements AssetResour
assetDescriptor.getAttributeDescriptors().ifPresent(attributeDescriptors ->
newAsset.addAttributes(
Arrays.stream(attributeDescriptors).filter(attributeDescriptor ->
- !newAsset.hasAttribute(attributeDescriptor.getName())).map(AssetAttribute::new).toArray(AssetAttribute[]::new)
+ !newAsset.hasAttribute(attributeDescriptor.getAttributeName())).map(AssetAttribute::new).toArray(AssetAttribute[]::new)
));
});
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 991e0e56e..42579aec2 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
@@ -48,6 +48,7 @@ import org.openremote.model.asset.*;
import org.openremote.model.attribute.AttributeEvent;
import org.openremote.model.attribute.AttributeType;
import org.openremote.model.attribute.MetaItemDescriptor;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.calendar.CalendarEvent;
import org.openremote.model.calendar.RecurrenceRule;
import org.openremote.model.event.TriggeredEventSubscription;
@@ -1391,9 +1392,9 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic
"attributes"), asset.getId());
Optional<AssetAttribute> oldLocation = oldAttributes.filter(assetAttribute -> assetAttribute.name.equals(
- AttributeType.LOCATION.getName())).findFirst();
+ AttributeType.LOCATION.getAttributeName())).findFirst();
Optional<AssetAttribute> currentLocation = currentAttributes.filter(assetAttribute -> assetAttribute.name.equals(
- AttributeType.LOCATION.getName())).findFirst();
+ AttributeType.LOCATION.getAttributeName())).findFirst();
if (!(!oldLocation.isPresent() && !currentLocation.isPresent())) {
if (!oldLocation.isPresent() || !currentLocation.isPresent() || !oldLocation.get().equals(
diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java
index 6f8c439d2..e4df5b9a8 100644
--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java
+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java
@@ -14,7 +14,7 @@ import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.manager.web.ManagerWebService;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.attribute.AttributeEvent.Source;
import org.openremote.model.attribute.AttributeRef;
import org.openremote.model.datapoint.AssetDatapoint;
diff --git a/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java b/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java
index e2f4bfb44..d946226e4 100644
--- a/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java
+++ b/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java
@@ -186,10 +186,10 @@ public class EmailNotificationHandler implements NotificationHandler {
.select(new BaseAssetQuery.Select(
ONLY_ID_AND_NAME_AND_ATTRIBUTES,
false,
- AttributeType.EMAIL.getName()))
+ AttributeType.EMAIL.getAttributeName()))
.path(new PathPredicate(targetId))
.attributes(new AttributePredicate(
- new StringPredicate(AttributeType.EMAIL.getName()),
+ new StringPredicate(AttributeType.EMAIL.getAttributeName()),
new ValueNotEmptyPredicate())));
if (assets.isEmpty()) {
diff --git a/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java b/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java
index 48781c4ad..61177ded8 100644
--- a/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java
+++ b/manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java
@@ -126,9 +126,9 @@ public class PushNotificationHandler extends RouteBuilder implements Notificatio
new AssetQuery()
.select(new BaseAssetQuery.Select(BaseAssetQuery.Include.ALL_EXCEPT_PATH,
false,
- AttributeType.CONSOLE_PROVIDERS.getName()))
+ AttributeType.CONSOLE_PROVIDERS.getAttributeName()))
.type(CONSOLE)
- .attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
+ .attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate("push")))
.stream()
.filter(PushNotificationHandler::isLinkedToFcmProvider)
@@ -187,7 +187,7 @@ public class PushNotificationHandler extends RouteBuilder implements Notificatio
List<Asset> mappedConsoles;
if (forTopic) {
- select = new BaseAssetQuery.Select(ONLY_ID_AND_NAME_AND_ATTRIBUTES, false, AttributeType.CONSOLE_PROVIDERS.getName());
+ select = new BaseAssetQuery.Select(ONLY_ID_AND_NAME_AND_ATTRIBUTES, false, AttributeType.CONSOLE_PROVIDERS.getAttributeName());
} else {
select = new BaseAssetQuery.Select(ONLY_ID_AND_NAME);
}
@@ -201,7 +201,7 @@ public class PushNotificationHandler extends RouteBuilder implements Notificatio
.select(select)
.tenant(new TenantPredicate(targetId))
.type(AssetType.CONSOLE)
- .attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
+ .attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate(PushNotificationMessage.TYPE))
);
@@ -231,7 +231,7 @@ public class PushNotificationHandler extends RouteBuilder implements Notificatio
.select(select)
.ids(ids)
.type(AssetType.CONSOLE)
- .attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
+ .attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate(PushNotificationMessage.TYPE))
);
@@ -256,7 +256,7 @@ public class PushNotificationHandler extends RouteBuilder implements Notificatio
.select(select)
.path(new PathPredicate(targetId))
.type(AssetType.CONSOLE)
- .attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
+ .attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate(PushNotificationMessage.TYPE))
);
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java
index f99eb9ca5..3488b75a2 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesEngine.java
@@ -32,7 +32,7 @@ import org.openremote.manager.rules.facade.NotificationsFacade;
import org.openremote.manager.rules.facade.UsersFacade;
import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.model.asset.Asset;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.attribute.AttributeType;
import org.openremote.model.query.filter.GeofencePredicate;
import org.openremote.model.query.filter.LocationAttributePredicate;
@@ -457,7 +457,7 @@ public class RulesEngine<T extends Ruleset> {
public void updateFact(AssetState assetState, boolean fireImmediately) {
facts.putAssetState(assetState);
- trackLocationPredicates = trackLocationPredicates || assetState.getAttributeName().equals(AttributeType.LOCATION.getName());
+ trackLocationPredicates = trackLocationPredicates || assetState.getAttributeName().equals(AttributeType.LOCATION.getAttributeName());
if (fireImmediately) {
fire();
}
@@ -465,13 +465,13 @@ public class RulesEngine<T extends Ruleset> {
public void removeFact(AssetState assetState) {
facts.removeAssetState(assetState);
- trackLocationPredicates = trackLocationPredicates || assetState.getAttributeName().equals(AttributeType.LOCATION.getName());
+ trackLocationPredicates = trackLocationPredicates || assetState.getAttributeName().equals(AttributeType.LOCATION.getAttributeName());
fire();
}
public void insertFact(String expires, AssetState assetState) {
facts.insertAssetEvent(expires, assetState);
- trackLocationPredicates = trackLocationPredicates || assetState.getAttributeName().equals(AttributeType.LOCATION.getName());
+ trackLocationPredicates = trackLocationPredicates || assetState.getAttributeName().equals(AttributeType.LOCATION.getAttributeName());
fire();
}
diff --git a/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java b/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java
index 174dc1cf4..bfa6620b5 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesFacts.java
@@ -665,7 +665,7 @@ public class RulesFacts extends Facts implements RuleListener {
// Collect asset states only where the attribute is location (location predicates only make sense when the location
// attribute is exposed to rules - we don't support RULE_EVENT facts just RULE_STATE
if (assetStateLocationPredicateMap == null) {
- Collection<AssetState> locationAssetStates = getAssetStates().stream().filter(assetState -> assetState.getAttributeName().equalsIgnoreCase(LOCATION.getName())).collect(Collectors.toSet());
+ Collection<AssetState> locationAssetStates = getAssetStates().stream().filter(assetState -> assetState.getAttributeName().equalsIgnoreCase(LOCATION.getAttributeName())).collect(Collectors.toSet());
assetStateLocationPredicateMap = new HashMap<>(locationAssetStates.size());
locationAssetStates.forEach(assetState -> assetStateLocationPredicateMap.put(assetState.getId(), new HashSet<>()));
}
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 f6c30e7d6..ca05e706e 100644
--- a/manager/src/main/java/org/openremote/manager/rules/RulesService.java
+++ b/manager/src/main/java/org/openremote/manager/rules/RulesService.java
@@ -38,7 +38,7 @@ import org.openremote.manager.security.ManagerIdentityService;
import org.openremote.model.Constants;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.attribute.AttributeEvent.Source;
import org.openremote.model.query.AssetQuery;
import org.openremote.model.query.filter.AttributeMetaPredicate;
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 6c6a4fe5d..e60a2e8a1 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
@@ -42,7 +42,6 @@ import org.openremote.model.query.filter.ObjectValueKeyPredicate;
import org.openremote.model.query.filter.RadialGeofencePredicate;
import org.openremote.model.rules.geofence.GeofenceDefinition;
import org.openremote.model.syslog.SyslogCategory;
-import org.openremote.model.util.TextUtil;
import org.openremote.model.value.ObjectValue;
import org.openremote.model.value.Values;
@@ -106,9 +105,9 @@ public class ORConsoleGeofenceAssetAdapter extends RouteBuilder implements Geofe
new AssetQuery()
.select(new BaseAssetQuery.Select(BaseAssetQuery.Include.ALL_EXCEPT_PATH,
false,
- AttributeType.CONSOLE_PROVIDERS.getName()))
+ AttributeType.CONSOLE_PROVIDERS.getAttributeName()))
.type(CONSOLE)
- .attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
+ .attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate("geofence")))
.stream()
.filter(ORConsoleGeofenceAssetAdapter::isLinkedToORConsoleGeofenceAdapter)
@@ -243,7 +242,7 @@ public class ORConsoleGeofenceAssetAdapter extends RouteBuilder implements Geofe
protected GeofenceDefinition locationPredicateToGeofenceDefinition(String assetId, GeofencePredicate geofencePredicate) {
RadialGeofencePredicate radialLocationPredicate = (RadialGeofencePredicate) geofencePredicate;
String id = assetId + "_" + Integer.toString(radialLocationPredicate.hashCode());
- String url = getWriteAttributeUrl(new AttributeRef(assetId, AttributeType.LOCATION.getName()));
+ String url = getWriteAttributeUrl(new AttributeRef(assetId, AttributeType.LOCATION.getAttributeName()));
return new GeofenceDefinition(id,
radialLocationPredicate.getLat(),
radialLocationPredicate.getLng(),
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 3c86dc866..dc7ed4578 100644
--- a/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
+++ b/manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
@@ -45,7 +45,7 @@ import java.util.function.Supplier;
import static org.openremote.agent.protocol.macro.MacroProtocol.META_MACRO_ACTION_INDEX;
import static org.openremote.agent.protocol.timer.TimerConfiguration.initTimerConfiguration;
import static org.openremote.agent.protocol.timer.TimerProtocol.META_TIMER_VALUE_LINK;
-import static org.openremote.model.asset.MetaItemType.*;
+import static org.openremote.model.attribute.MetaItemType.*;
import static org.openremote.model.asset.AssetType.*;
import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
import static org.openremote.model.attribute.AttributeValueType.*;
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 c68d640d3..3c45bbcb0 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
@@ -26,7 +26,7 @@ import org.openremote.manager.security.UserConfiguration;
import org.openremote.manager.setup.AbstractManagerSetup;
import org.openremote.model.asset.Asset;
import org.openremote.model.asset.AssetAttribute;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.asset.UserAsset;
import org.openremote.model.attribute.*;
import org.openremote.model.geo.GeoJSONPoint;
@@ -44,7 +44,7 @@ import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.List;
-import static org.openremote.model.asset.MetaItemType.*;
+import static org.openremote.model.attribute.MetaItemType.*;
import static org.openremote.model.asset.AssetType.*;
import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
import static org.openremote.model.attribute.AttributeValueType.*;
diff --git a/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy b/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy
index b4d0e9899..a96003e2f 100644
--- a/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy
+++ b/manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy
@@ -64,7 +64,7 @@ rules.add()
def consoleIds = facts.matchAssetState(new AssetQuery()
.type(AssetType.CONSOLE)
- .attributeValue(AttributeType.LOCATION.name, new ValueEmptyPredicate()))
+ .attributeValue(AttributeType.LOCATION.attributeName, new ValueEmptyPredicate()))
.filter({ facts.getOptional("welcomeHome" + "_${it.id}").isPresent() })
.map({ it.id })
.collect()
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 7b99ffb22..a17292901 100644
--- a/model/src/main/java/org/openremote/model/asset/Asset.java
+++ b/model/src/main/java/org/openremote/model/asset/Asset.java
@@ -367,7 +367,7 @@ public class Asset implements IdentifiableEntity {
}
public Asset removeAttribute(AttributeDescriptor attributeDescriptor) {
- return removeAttribute(attributeDescriptor.getName());
+ return removeAttribute(attributeDescriptor.getAttributeName());
}
public String getId() {
@@ -539,7 +539,7 @@ public class Asset implements IdentifiableEntity {
}
public Optional<AssetAttribute> getAttribute(AttributeDescriptor descriptor) {
- return getAttribute(descriptor.getName());
+ return getAttribute(descriptor.getAttributeName());
}
public Optional<AssetAttribute> getAttribute(String name) {
@@ -598,7 +598,7 @@ public class Asset implements IdentifiableEntity {
*/
public GeoJSONPoint getCoordinates() {
return getAttributesStream()
- .filter(attribute -> attribute.getNameOrThrow().equals(LOCATION.getName()))
+ .filter(attribute -> attribute.getNameOrThrow().equals(LOCATION.getAttributeName()))
.findFirst()
.flatMap(AbstractValueHolder::getValue)
.flatMap(GeoJSONPoint::fromValue)
@@ -610,7 +610,7 @@ public class Asset implements IdentifiableEntity {
*/
public void setCoordinates(GeoJSONPoint coordinates) {
AssetAttribute locationAttribute = getAttributesStream()
- .filter(attribute -> attribute.getNameOrThrow().equals(LOCATION.getName()))
+ .filter(attribute -> attribute.getNameOrThrow().equals(LOCATION.getAttributeName()))
.findFirst().orElse(new AssetAttribute(LOCATION));
locationAttribute.setValue(coordinates == null ? null : coordinates.toValue());
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 cd1d2e4b8..7f40f58bf 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetAttribute.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetAttribute.java
@@ -32,7 +32,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static org.openremote.model.asset.MetaItemType.*;
+import static org.openremote.model.attribute.MetaItemType.*;
import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo;
import static org.openremote.model.attribute.MetaItem.replaceMetaByName;
import static org.openremote.model.util.TextUtil.isNullOrEmpty;
@@ -59,7 +59,7 @@ public class AssetAttribute extends Attribute {
}
public AssetAttribute(AttributeDescriptor attributeDescriptor) {
- this(attributeDescriptor.getName(), attributeDescriptor);
+ this(attributeDescriptor.getAttributeName(), attributeDescriptor);
}
public AssetAttribute(String name, AttributeDescriptor attributeDescriptor) {
@@ -67,7 +67,7 @@ public class AssetAttribute extends Attribute {
}
public AssetAttribute(AttributeDescriptor attributeDescriptor, Value value) {
- this(attributeDescriptor.getName(), attributeDescriptor, value);
+ this(attributeDescriptor.getAttributeName(), attributeDescriptor, value);
}
public AssetAttribute(String name, AttributeDescriptor attributeDescriptor, Value value) {
@@ -75,7 +75,7 @@ public class AssetAttribute extends Attribute {
}
public AssetAttribute(AttributeDescriptor attributeDescriptor, Value value, long timestamp) {
- this(attributeDescriptor.getName(), attributeDescriptor, value, timestamp);
+ this(attributeDescriptor.getAttributeName(), attributeDescriptor, value, timestamp);
}
public AssetAttribute(String name, AttributeDescriptor attributeDescriptor, Value value, long timestamp) {
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 071134905..87a82ea04 100644
--- a/model/src/main/java/org/openremote/model/asset/AssetResource.java
+++ b/model/src/main/java/org/openremote/model/asset/AssetResource.java
@@ -21,6 +21,7 @@ package org.openremote.model.asset;
import jsinterop.annotations.JsType;
import org.openremote.model.attribute.AttributeRef;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.http.RequestParams;
import org.openremote.model.http.SuccessStatusCode;
import org.openremote.model.query.AssetQuery;
diff --git a/model/src/main/java/org/openremote/model/asset/UserAsset.java b/model/src/main/java/org/openremote/model/asset/UserAsset.java
index 851565cca..b2bf1847e 100644
--- a/model/src/main/java/org/openremote/model/asset/UserAsset.java
+++ b/model/src/main/java/org/openremote/model/asset/UserAsset.java
@@ -21,6 +21,7 @@ package org.openremote.model.asset;
import org.hibernate.annotations.Formula;
import org.openremote.model.attribute.MetaItemDescriptor;
+import org.openremote.model.attribute.MetaItemType;
import javax.persistence.*;
import java.io.Serializable;
diff --git a/model/src/main/java/org/openremote/model/asset/agent/AgentLink.java b/model/src/main/java/org/openremote/model/asset/agent/AgentLink.java
index f985c6292..2c425ed21 100644
--- a/model/src/main/java/org/openremote/model/asset/agent/AgentLink.java
+++ b/model/src/main/java/org/openremote/model/asset/agent/AgentLink.java
@@ -23,13 +23,13 @@ import org.openremote.model.AbstractValueHolder;
import org.openremote.model.attribute.Attribute;
import org.openremote.model.attribute.AttributeRef;
import org.openremote.model.attribute.MetaItem;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import java.util.Optional;
import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo;
import static org.openremote.model.attribute.MetaItem.replaceMetaByName;
-import static org.openremote.model.asset.MetaItemType.AGENT_LINK;
+import static org.openremote.model.attribute.MetaItemType.AGENT_LINK;
/**
* An asset attribute can be linked to an agent's {@link ProtocolConfiguration},
diff --git a/model/src/main/java/org/openremote/model/asset/agent/ConnectionStatus.java b/model/src/main/java/org/openremote/model/asset/agent/ConnectionStatus.java
index c3ef315d5..00def302b 100644
--- a/model/src/main/java/org/openremote/model/asset/agent/ConnectionStatus.java
+++ b/model/src/main/java/org/openremote/model/asset/agent/ConnectionStatus.java
@@ -19,7 +19,7 @@
*/
package org.openremote.model.asset.agent;
-import org.openremote.model.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.attribute.MetaItem;
/**
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 bd0fcc3fa..e63a387f7 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.asset.MetaItemType;
+import org.openremote.model.attribute.MetaItemType;
import org.openremote.model.attribute.AttributeValueType;
import org.openremote.model.attribute.MetaItem;
import org.openremote.model.util.TextUtil;
@@ -30,7 +30,7 @@ import org.openremote.model.value.Values;
import java.util.Optional;
import java.util.function.UnaryOperator;
-import static org.openremote.model.asset.MetaItemType.PROTOCOL_CONFIGURATION;
+import static org.openremote.model.attribute.MetaItemType.PROTOCOL_CONFIGURATION;
import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo;
/**
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 904613e50..ca1ed256c 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java
@@ -29,6 +29,8 @@ public interface AttributeDescriptor {
String getName();
+ String getAttributeName();
+
AttributeValueDescriptor getValueDescriptor();
Optional<MetaItemDescriptor[]> getMetaItemDescriptors();
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeType.java b/model/src/main/java/org/openremote/model/attribute/AttributeType.java
index 7c691c570..df602e70a 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeType.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeType.java
@@ -25,38 +25,37 @@ import org.openremote.model.value.Values;
import java.util.Optional;
-import static org.openremote.model.asset.MetaItemType.*;
-import static org.openremote.model.attribute.AttributeValueType.OBJECT;
+import static org.openremote.model.attribute.MetaItemType.*;
public enum AttributeType implements AttributeDescriptor {
- STRING("string", org.openremote.model.attribute.AttributeValueType.STRING),
+ STRING("string", AttributeValueType.STRING),
- NUMBER("number", org.openremote.model.attribute.AttributeValueType.NUMBER),
+ NUMBER("number", AttributeValueType.NUMBER),
- CONSOLE_NAME("consoleName", org.openremote.model.attribute.AttributeValueType.STRING),
+ CONSOLE_NAME("consoleName", AttributeValueType.STRING),
- CONSOLE_VERSION("consoleVersion", org.openremote.model.attribute.AttributeValueType.STRING),
+ CONSOLE_VERSION("consoleVersion", AttributeValueType.STRING),
- CONSOLE_PLATFORM("consolePlatform", org.openremote.model.attribute.AttributeValueType.STRING),
+ CONSOLE_PLATFORM("consolePlatform", AttributeValueType.STRING),
- CONSOLE_PROVIDERS("consoleProviders", OBJECT),
+ CONSOLE_PROVIDERS("consoleProviders", AttributeValueType.OBJECT),
EMAIL("email", AttributeValueType.EMAIL, LABEL.withInitialValue(Values.create("Email"))),
- GEO_CITY("city", org.openremote.model.attribute.AttributeValueType.STRING,
+ GEO_CITY("city", AttributeValueType.STRING,
LABEL.withInitialValue(Values.create("City")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoCity"))),
- GEO_COUNTRY("country", org.openremote.model.attribute.AttributeValueType.STRING,
+ GEO_COUNTRY("country", AttributeValueType.STRING,
LABEL.withInitialValue(Values.create("Country")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoCountry"))),
- GEO_POSTAL_CODE("postalCode", org.openremote.model.attribute.AttributeValueType.NUMBER,
+ GEO_POSTAL_CODE("postalCode", AttributeValueType.NUMBER,
LABEL.withInitialValue(Values.create("Postal Code")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoPostalCode"))),
- GEO_STREET("street", org.openremote.model.attribute.AttributeValueType.STRING,
+ GEO_STREET("street", AttributeValueType.STRING,
LABEL.withInitialValue(Values.create("Street")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoStreet"))),
@@ -64,22 +63,23 @@ public enum AttributeType implements AttributeDescriptor {
SURFACE_AREA(
"surfaceArea",
- org.openremote.model.attribute.AttributeValueType.NUMBER,
+ AttributeValueType.NUMBER,
LABEL.withInitialValue(Values.create("Surface Area")),
DESCRIPTION.withInitialValue(Values.create("Floor area of building measured in m²")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/area")));
- final protected String name;
+
+ final protected String attributeName;
final protected AttributeValueDescriptor attributeValueDescriptor;
final protected Value initialValue;
final protected MetaItemDescriptor[] metaItemDescriptors;
- AttributeType(String name, AttributeValueDescriptor attributeValueDescriptor, MetaItemDescriptor... metaItemDescriptors) {
- this(name, attributeValueDescriptor, null, metaItemDescriptors);
+ AttributeType(String attributeName, AttributeValueDescriptor attributeValueDescriptor, MetaItemDescriptor... metaItemDescriptors) {
+ this(attributeName, attributeValueDescriptor, null, metaItemDescriptors);
}
- AttributeType(String name, AttributeValueDescriptor attributeValueDescriptor, Value initialValue, MetaItemDescriptor... metaItemDescriptors) {
- this.name = name;
+ AttributeType(String attributeName, AttributeValueDescriptor attributeValueDescriptor, Value initialValue, MetaItemDescriptor... metaItemDescriptors) {
+ this.attributeName = attributeName;
this.attributeValueDescriptor = attributeValueDescriptor;
this.metaItemDescriptors = metaItemDescriptors;
this.initialValue = initialValue;
@@ -90,15 +90,21 @@ public enum AttributeType implements AttributeDescriptor {
return Optional.empty();
for (AttributeDescriptor descriptor : values()) {
- if (name.equals(descriptor.getName()))
+ if (name.equals(descriptor.getAttributeName()))
return Optional.of(descriptor);
}
return Optional.empty();
}
+
@Override
public String getName() {
- return name;
+ return name();
+ }
+
+ @Override
+ public String getAttributeName() {
+ return attributeName;
}
@Override
@@ -124,8 +130,13 @@ public enum AttributeType implements AttributeDescriptor {
return new AttributeDescriptor() {
@Override
- @JsonProperty
public String getName() {
+ return name();
+ }
+
+ @Override
+ @JsonProperty
+ public String getAttributeName() {
return name;
}
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java b/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java
index 0b36c13a2..8e3c7917a 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java
@@ -20,6 +20,7 @@
package org.openremote.model.attribute;
import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.openremote.model.ValidationFailure;
import org.openremote.model.value.Value;
@@ -40,5 +41,6 @@ public interface AttributeValueDescriptor {
Optional<MetaItemDescriptor[]> getMetaItemDescriptors();
+ @JsonIgnore
Optional<Function<Value, Optional<ValidationFailure>>> getValidator();
}
diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java b/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
index 885302070..b03bdbd2f 100644
--- a/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
+++ b/model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
@@ -29,7 +29,7 @@ import org.openremote.model.value.Values;
import java.util.Optional;
import java.util.function.Function;
-import static org.openremote.model.asset.MetaItemType.*;
+import static org.openremote.model.attribute.MetaItemType.*;
import static org.openremote.model.attribute.AttributeValueType.AttributeValueTypeFailureReason.ATTRIBUTE_TYPE_VALUE_DOES_NOT_MATCH;
/**
diff --git a/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java b/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java
index 9e8c9af80..2d778141a 100644
--- a/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java
+++ b/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java
@@ -108,7 +108,7 @@ public interface MetaItemDescriptor extends HasUniqueResourceName {
}
@JsonProperty
- String name();
+ String getName();
String getUrn();
diff --git a/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptorImpl.java b/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptorImpl.java
index 7c3a2795b..8da83e0c4 100644
--- a/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptorImpl.java
+++ b/model/src/main/java/org/openremote/model/attribute/MetaItemDescriptorImpl.java
@@ -47,7 +47,7 @@ public class MetaItemDescriptorImpl implements MetaItemDescriptor {
}
public MetaItemDescriptorImpl(MetaItemDescriptor metaItemDescriptor, Value initialValue) {
- this(metaItemDescriptor.name(),
+ this(metaItemDescriptor.getName(),
metaItemDescriptor.getUrn(),
metaItemDescriptor.getValueType(),
metaItemDescriptor.isRequired(),
@@ -94,7 +94,7 @@ public class MetaItemDescriptorImpl implements MetaItemDescriptor {
}
@Override
- public String name() {
+ public String getName() {
return name;
}
diff --git a/model/src/main/java/org/openremote/model/asset/MetaItemType.java b/model/src/main/java/org/openremote/model/attribute/MetaItemType.java
similarity index 98%
rename from model/src/main/java/org/openremote/model/asset/MetaItemType.java
rename to model/src/main/java/org/openremote/model/attribute/MetaItemType.java
index 0fae0c1f4..ed60de587 100644
--- a/model/src/main/java/org/openremote/model/asset/MetaItemType.java
+++ b/model/src/main/java/org/openremote/model/attribute/MetaItemType.java
@@ -17,10 +17,11 @@
* 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.asset;
+package org.openremote.model.attribute;
import org.openremote.model.ValidationFailure;
-import org.openremote.model.attribute.*;
+import org.openremote.model.asset.AssetModelProvider;
+import org.openremote.model.asset.UserAsset;
import org.openremote.model.rules.AssetState;
import org.openremote.model.rules.TemporaryFact;
import org.openremote.model.value.Value;
@@ -409,6 +410,12 @@ public enum MetaItemType implements MetaItemDescriptor {
this.patternFailureMessage = patternFailureMessage;
}
+
+ @Override
+ public String getName() {
+ return this.name();
+ }
+
@Override
public String getUrn() {
return urn;
diff --git a/model/src/main/java/org/openremote/model/console/ConsoleConfiguration.java b/model/src/main/java/org/openremote/model/console/ConsoleConfiguration.java
index 756eaceea..4c2b3e7b9 100644
--- a/model/src/main/java/org/openremote/model/console/ConsoleConfiguration.java
+++ b/model/src/main/java/org/openremote/model/console/ConsoleConfiguration.java
@@ -40,9 +40,9 @@ import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
-import static org.openremote.model.asset.MetaItemType.ACCESS_PUBLIC_WRITE;
-import static org.openremote.model.asset.MetaItemType.ACCESS_RESTRICTED_WRITE;
-import static org.openremote.model.asset.MetaItemType.RULE_STATE;
+import static org.openremote.model.attribute.MetaItemType.ACCESS_PUBLIC_WRITE;
+import static org.openremote.model.attribute.MetaItemType.ACCESS_RESTRICTED_WRITE;
+import static org.openremote.model.attribute.MetaItemType.RULE_STATE;
public final class ConsoleConfiguration {
@@ -120,7 +120,7 @@ public final class ConsoleConfiguration {
valid = false;
}
- Value providerValue = asset.getAttribute(AttributeType.CONSOLE_PROVIDERS.getName()).flatMap(AbstractValueHolder::getValue).orElse(null);
+ Value providerValue = asset.getAttribute(AttributeType.CONSOLE_PROVIDERS.getAttributeName()).flatMap(AbstractValueHolder::getValue).orElse(null);
if (providerValue != null && !getConsoleProviders(asset).isPresent()) {
if (validationFailures != null) {
@@ -217,7 +217,7 @@ public final class ConsoleConfiguration {
public static Asset setConsolProviders(Asset asset, Map<String, ConsoleProvider> consoleProviderMap) {
Objects.requireNonNull(asset);
if (consoleProviderMap == null || consoleProviderMap.isEmpty()) {
- asset.removeAttribute(AttributeType.CONSOLE_PROVIDERS.getName());
+ asset.removeAttribute(AttributeType.CONSOLE_PROVIDERS.getAttributeName());
return asset;
}
@@ -245,7 +245,7 @@ public final class ConsoleConfiguration {
if (consoleProvider == null) {
providerObj.remove(name);
if (!providerObj.hasKeys()) {
- asset.removeAttribute(AttributeType.CONSOLE_PROVIDERS.getName());
+ asset.removeAttribute(AttributeType.CONSOLE_PROVIDERS.getAttributeName());
}
} else {
providerObj.put(name, consoleProvider.toValue());
@@ -253,7 +253,7 @@ public final class ConsoleConfiguration {
}
public static Optional<Map<String, ConsoleProvider>> getConsoleProviders(AssetAttribute attribute) {
- if (attribute == null || !AttributeType.CONSOLE_PROVIDERS.getName().equals(attribute.getName().orElse(null))) {
+ if (attribute == null || !AttributeType.CONSOLE_PROVIDERS.getAttributeName().equals(attribute.getName().orElse(null))) {
return Optional.empty();
}
diff --git a/model/src/main/java/org/openremote/model/query/filter/LocationAttributePredicate.java b/model/src/main/java/org/openremote/model/query/filter/LocationAttributePredicate.java
index 8e3068ee4..4233c2ecf 100644
--- a/model/src/main/java/org/openremote/model/query/filter/LocationAttributePredicate.java
+++ b/model/src/main/java/org/openremote/model/query/filter/LocationAttributePredicate.java
@@ -30,14 +30,14 @@ import static org.openremote.model.attribute.AttributeType.LOCATION;
public class LocationAttributePredicate extends AttributePredicate {
public LocationAttributePredicate(GeofencePredicate geofencePredicate) {
- super(new StringPredicate(AttributeType.LOCATION.getName()), geofencePredicate);
+ super(new StringPredicate(AttributeType.LOCATION.getAttributeName()), geofencePredicate);
}
public static List<GeofencePredicate> getLocationPredicates(List<AttributePredicate> attributePredicates) {
return attributePredicates.stream()
.filter(attributePredicate -> attributePredicate.name != null
&& attributePredicate.name.match == BaseAssetQuery.Match.EXACT
- && LOCATION.getName().equals(attributePredicate.name.value)
+ && LOCATION.getAttributeName().equals(attributePredicate.name.value)
&& attributePredicate.value instanceof GeofencePredicate)
.map(attributePredicate -> (GeofencePredicate) attributePredicate.value)
.collect(Collectors.toList());
diff --git a/model/src/main/java/org/openremote/model/util/AssetModelUtil.java b/model/src/main/java/org/openremote/model/util/AssetModelUtil.java
index fe4179602..872889a69 100644
--- a/model/src/main/java/org/openremote/model/util/AssetModelUtil.java
+++ b/model/src/main/java/org/openremote/model/util/AssetModelUtil.java
@@ -117,7 +117,7 @@ public class AssetModelUtil {
return Optional.empty();
for (AttributeDescriptor attributeDescriptor : attributeDescriptors) {
- if (name.equals(attributeDescriptor.getName()))
+ if (name.equals(attributeDescriptor.getAttributeName()))
return Optional.of(attributeDescriptor);
}
return Optional.empty();
@@ -155,7 +155,7 @@ public class AssetModelUtil {
// public static AssetDescriptor[] getAssetTypesSorted() {
// List<AssetDescriptor> list = new ArrayList<>(Arrays.asList(assetDescriptors));
//
-// list.sort(Comparator.comparing(AssetDescriptor::getName));
+// list.sort(Comparator.comparing(AssetDescriptor::getAttributeName));
// if (list.contains(CUSTOM)) {
// // CUSTOM should be first
// list.remove(CUSTOM);
diff --git a/model/src/main/java/org/openremote/model/value/Value.java b/model/src/main/java/org/openremote/model/value/Value.java
index eecc45434..3b1a505d0 100644
--- a/model/src/main/java/org/openremote/model/value/Value.java
+++ b/model/src/main/java/org/openremote/model/value/Value.java
@@ -15,7 +15,9 @@
*/
package org.openremote.model.value;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import jsinterop.base.Any;
+import org.openremote.model.ModelModule;
/**
* Base interface for all values. This is a Java API for a JSON model and instances
diff --git a/model/src/main/java/org/openremote/model/value/impl/ArrayValueImpl.java b/model/src/main/java/org/openremote/model/value/impl/ArrayValueImpl.java
index dda86f83a..99ea708b0 100644
--- a/model/src/main/java/org/openremote/model/value/impl/ArrayValueImpl.java
+++ b/model/src/main/java/org/openremote/model/value/impl/ArrayValueImpl.java
@@ -15,12 +15,15 @@
*/
package org.openremote.model.value.impl;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.openremote.model.ModelModule;
import org.openremote.model.value.*;
import java.util.ArrayList;
import java.util.Optional;
import java.util.stream.Stream;
+@JsonSerialize(using = ModelModule.ValueJsonSerializer.class)
public class ArrayValueImpl extends ValueImpl implements ArrayValue {
final private transient ValueFactory factory;
diff --git a/model/src/main/java/org/openremote/model/value/impl/BooleanValueImpl.java b/model/src/main/java/org/openremote/model/value/impl/BooleanValueImpl.java
index f35088545..1268eda78 100644
--- a/model/src/main/java/org/openremote/model/value/impl/BooleanValueImpl.java
+++ b/model/src/main/java/org/openremote/model/value/impl/BooleanValueImpl.java
@@ -15,9 +15,12 @@
*/
package org.openremote.model.value.impl;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.openremote.model.ModelModule;
import org.openremote.model.value.BooleanValue;
import org.openremote.model.value.ValueType;
+@JsonSerialize(using = ModelModule.ValueJsonSerializer.class)
public class BooleanValueImpl extends ValueImpl implements BooleanValue {
private static final BooleanValueImpl FALSE = new BooleanValueImpl(false);
diff --git a/model/src/main/java/org/openremote/model/value/impl/NumberValueImpl.java b/model/src/main/java/org/openremote/model/value/impl/NumberValueImpl.java
index 3f762f051..de165253a 100644
--- a/model/src/main/java/org/openremote/model/value/impl/NumberValueImpl.java
+++ b/model/src/main/java/org/openremote/model/value/impl/NumberValueImpl.java
@@ -15,9 +15,12 @@
*/
package org.openremote.model.value.impl;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.openremote.model.ModelModule;
import org.openremote.model.value.NumberValue;
import org.openremote.model.value.ValueType;
+@JsonSerialize(using = ModelModule.ValueJsonSerializer.class)
public class NumberValueImpl extends ValueImpl implements NumberValue {
private transient double number;
diff --git a/model/src/main/java/org/openremote/model/value/impl/ObjectValueImpl.java b/model/src/main/java/org/openremote/model/value/impl/ObjectValueImpl.java
index 4511ea176..c9df9a186 100644
--- a/model/src/main/java/org/openremote/model/value/impl/ObjectValueImpl.java
+++ b/model/src/main/java/org/openremote/model/value/impl/ObjectValueImpl.java
@@ -15,6 +15,8 @@
*/
package org.openremote.model.value.impl;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.openremote.model.ModelModule;
import org.openremote.model.util.Pair;
import org.openremote.model.value.*;
@@ -23,6 +25,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+@JsonSerialize(using = ModelModule.ValueJsonSerializer.class)
public class ObjectValueImpl extends ValueImpl implements ObjectValue {
private static List<String> stringifyOrder(String[] keys) {
diff --git a/model/src/main/java/org/openremote/model/value/impl/StringValueImpl.java b/model/src/main/java/org/openremote/model/value/impl/StringValueImpl.java
index 8182c352f..6d6ba406f 100644
--- a/model/src/main/java/org/openremote/model/value/impl/StringValueImpl.java
+++ b/model/src/main/java/org/openremote/model/value/impl/StringValueImpl.java
@@ -15,12 +15,15 @@
*/
package org.openremote.model.value.impl;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.openremote.model.ModelModule;
import org.openremote.model.value.StringValue;
import org.openremote.model.value.ValueException;
import org.openremote.model.value.ValueType;
import java.util.Objects;
+@JsonSerialize(using = ModelModule.ValueJsonSerializer.class)
public class StringValueImpl extends ValueImpl implements StringValue {
private transient String string;
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 fdf9342e9..7f573bbc7 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy
@@ -6,7 +6,6 @@ import org.openremote.manager.asset.AssetStorageService
import org.openremote.model.Constants
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
-import org.openremote.model.asset.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.attribute.*
import org.openremote.model.value.Values
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetModelResourceTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetModelResourceTest.groovy
index 202f48168..19edda952 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetModelResourceTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetModelResourceTest.groovy
@@ -80,17 +80,17 @@ class AssetModelResourceTest extends Specification implements ManagerContainerTr
then: "the eleven default types should be present"
attributeTypeDescriptors.size() == 11
- attributeTypeDescriptors[0].name == "consoleName"
- attributeTypeDescriptors[1].name == "consoleVersion"
- attributeTypeDescriptors[2].name == "consolePlatform"
- attributeTypeDescriptors[3].name == "consoleProviders"
- attributeTypeDescriptors[4].name == "email"
- attributeTypeDescriptors[5].name == "city"
- attributeTypeDescriptors[6].name == "country"
- attributeTypeDescriptors[7].name == "postalCode"
- attributeTypeDescriptors[8].name == "street"
- attributeTypeDescriptors[9].name == "location"
- attributeTypeDescriptors[10].name == "surfaceArea"
+ attributeTypeDescriptors[0].attributeName == "consoleName"
+ attributeTypeDescriptors[1].attributeName == "consoleVersion"
+ attributeTypeDescriptors[2].attributeName == "consolePlatform"
+ attributeTypeDescriptors[3].attributeName == "consoleProviders"
+ attributeTypeDescriptors[4].attributeName == "email"
+ attributeTypeDescriptors[5].attributeName == "city"
+ attributeTypeDescriptors[6].attributeName == "country"
+ attributeTypeDescriptors[7].attributeName == "postalCode"
+ attributeTypeDescriptors[8].attributeName == "street"
+ attributeTypeDescriptors[9].attributeName == "location"
+ attributeTypeDescriptors[10].attributeName == "surfaceArea"
when: "a request for Attribute value types is made"
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 1e2eef6b9..f1c9715e6 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
@@ -24,7 +24,7 @@ import static org.openremote.container.util.MapAccess.getString
import static org.openremote.manager.setup.AbstractKeycloakSetup.SETUP_ADMIN_PASSWORD
import static org.openremote.manager.setup.AbstractKeycloakSetup.SETUP_ADMIN_PASSWORD_DEFAULT
import static org.openremote.model.Constants.*
-import static org.openremote.model.asset.MetaItemType.*
+import static org.openremote.model.attribute.MetaItemType.*
import static org.openremote.model.attribute.AttributeValueType.BOOLEAN
import static org.openremote.model.attribute.AttributeValueType.NUMBER
import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo
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 d8557e21f..4b8237682 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
@@ -7,7 +7,6 @@ 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.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.ProtocolConfiguration
import org.openremote.model.attribute.*
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 6eeb49895..006aca2f0 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
@@ -17,8 +17,8 @@ import spock.lang.Shared
import spock.lang.Specification
import static org.openremote.model.Constants.MASTER_REALM
-import static org.openremote.model.asset.MetaItemType.ACCESS_PUBLIC_READ
-import static org.openremote.model.asset.MetaItemType.LABEL
+import static org.openremote.model.attribute.MetaItemType.ACCESS_PUBLIC_READ
+import static org.openremote.model.attribute.MetaItemType.LABEL
import static org.openremote.model.asset.AssetType.THING
import static org.openremote.model.attribute.AttributeValueType.NUMBER
import static org.openremote.model.query.BaseAssetQuery.Include
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 ee78b634d..5e952b6e6 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
@@ -8,6 +8,7 @@ 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.*
+import org.openremote.model.attribute.MetaItemType
import org.openremote.model.calendar.CalendarEvent
import org.openremote.model.calendar.RecurrenceRule
import org.openremote.model.geo.GeoJSONPoint
diff --git a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
index 725d84962..23a45cf89 100644
--- a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
@@ -41,7 +41,7 @@ import java.util.stream.IntStream
import static org.openremote.manager.setup.builtin.ManagerDemoSetup.DEMO_RULE_STATES_CUSTOMER_A
import static org.openremote.manager.setup.builtin.ManagerDemoSetup.SMART_BUILDING_LOCATION
import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID
-import static org.openremote.model.asset.MetaItemType.RULE_STATE
+import static org.openremote.model.attribute.MetaItemType.RULE_STATE
import static org.openremote.model.asset.AssetResource.Util.WRITE_ATTRIBUTE_HTTP_METHOD
import static org.openremote.model.asset.AssetResource.Util.getWriteAttributeUrl
import static org.openremote.model.attribute.AttributeType.LOCATION
@@ -356,13 +356,13 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
messages.clear()
and: "an authenticated user updates the location of a linked console"
- authenticatedAssetResource.writeAttributeValue(null, testUser3Console1.id, LOCATION.name, new GeoJSONPoint(0d, 0d, 0d).toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, testUser3Console1.id, LOCATION.attributeName, new GeoJSONPoint(0d, 0d, 0d).toValue().toJson())
then: "the consoles location should have been updated"
conditions.eventually {
testUser3Console1 = assetStorageService.find(testUser3Console1.id, true)
assert testUser3Console1 != null
- def assetLocation = testUser3Console1.getAttribute(LOCATION.name).flatMap { it.value }.flatMap {
+ def assetLocation = testUser3Console1.getAttribute(LOCATION.attributeName).flatMap { it.value }.flatMap {
GeoJSONPoint.fromValue(it)
}.orElse(null)
assert assetLocation != null
@@ -379,7 +379,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
// ex.response.status == 403
when: "a console's location is updated to be at the Smart Building"
- authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.name, SMART_BUILDING_LOCATION.toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.attributeName, SMART_BUILDING_LOCATION.toValue().toJson())
long timestamp = Long.MAX_VALUE
then: "a welcome home alert should be sent to the console"
@@ -387,29 +387,29 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert notificationIds.size() == 1
def asset = assetStorageService.find(testUser3Console2.id, true)
assert asset != null
- timestamp = asset.getAttribute(LOCATION.name).flatMap { it.valueTimestamp }.orElse(Long.MAX_VALUE)
+ timestamp = asset.getAttribute(LOCATION.attributeName).flatMap { it.valueTimestamp }.orElse(Long.MAX_VALUE)
}
when: "a console's location is updated to be at the Smart Building again"
- authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.name, SMART_BUILDING_LOCATION.toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.attributeName, SMART_BUILDING_LOCATION.toValue().toJson())
then: "no more alerts should have been sent"
conditions.eventually {
def asset = assetStorageService.find(testUser3Console2.id, true)
assert asset != null
- assert asset.getAttribute(LOCATION.name).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE) > timestamp
- timestamp = asset.getAttribute(LOCATION.name).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE)
+ assert asset.getAttribute(LOCATION.attributeName).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE) > timestamp
+ timestamp = asset.getAttribute(LOCATION.attributeName).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE)
assert notificationIds.size() == 1
}
when: "a console's location is updated to be null"
- authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.name, "null")
+ authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.attributeName, "null")
then: "no more alerts should have been sent and the welcome reset rule should have fired on the tenant rule engine"
conditions.eventually {
def asset = assetStorageService.find(testUser3Console2.id, true)
assert asset != null
- assert asset.getAttribute(LOCATION.name).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE) > timestamp
+ assert asset.getAttribute(LOCATION.attributeName).flatMap { it.valueTimestamp }.orElse(Long.MIN_VALUE) > timestamp
assert notificationIds.size() == 1
def tenantAEngine = rulesService.tenantEngines.get(keycloakDemoSetup.tenantA.realm)
assert tenantAEngine != null
@@ -418,7 +418,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
}
when: "a console's location is updated to be at the Smart Building again"
- authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.name, SMART_BUILDING_LOCATION.toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, testUser3Console2.id, LOCATION.attributeName, SMART_BUILDING_LOCATION.toValue().toJson())
then: "another alert should have been sent"
conditions.eventually {
@@ -443,7 +443,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofences[0].lng == expectedLocationPredicate.lng
assert geofences[0].radius == expectedLocationPredicate.radius
assert geofences[0].httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getName()))
+ assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getAttributeName()))
// TODO: Update once console permissions model finalised
// when: "an anonymous user tries to retrieve the geofences of a console linked to users"
@@ -463,7 +463,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofences[0].lng == expectedLocationPredicate.lng
assert geofences[0].radius == expectedLocationPredicate.radius
assert geofences[0].httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(testUser3Console2.id, LOCATION.getName()))
+ assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(testUser3Console2.id, LOCATION.getAttributeName()))
when: "the geofences of anonymousConsole1 are retrieved"
geofences = anonymousRulesResource.getAssetGeofences(null, anonymousConsole1.id)
@@ -475,7 +475,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofences[0].lng == expectedLocationPredicate.lng
assert geofences[0].radius == expectedLocationPredicate.radius
assert geofences[0].httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(anonymousConsole1.id, LOCATION.getName()))
+ assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(anonymousConsole1.id, LOCATION.getAttributeName()))
when: "the geofences of a non-existent console are retrieved"
geofences = anonymousRulesResource.getAssetGeofences(null, UniqueIdentifierGenerator.generateId("nonExistentConsole"))
@@ -541,12 +541,12 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofence1.lng == expectedLocationPredicate.lng
assert geofence1.radius == expectedLocationPredicate.radius
assert geofence1.httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofence1.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getName()))
+ assert geofence1.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getAttributeName()))
assert geofence2.lat == newLocationPredicate.lat
assert geofence2.lng == newLocationPredicate.lng
assert geofence2.radius == newLocationPredicate.radius
assert geofence2.httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofence2.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getName()))
+ assert geofence2.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getAttributeName()))
}
when: "an existing ruleset containing a radial location predicate is updated"
@@ -578,12 +578,12 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofence1.lng == expectedLocationPredicate.lng
assert geofence1.radius == expectedLocationPredicate.radius
assert geofence1.httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofence1.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getName()))
+ assert geofence1.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getAttributeName()))
assert geofence2.lat == newLocationPredicate.lat
assert geofence2.lng == newLocationPredicate.lng
assert geofence2.radius == newLocationPredicate.radius
assert geofence2.httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofence2.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getName()))
+ assert geofence2.url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getAttributeName()))
}
when: "a location predicate ruleset is removed"
@@ -603,7 +603,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
assert geofences[0].lng == expectedLocationPredicate.lng
assert geofences[0].radius == expectedLocationPredicate.radius
assert geofences[0].httpMethod == WRITE_ATTRIBUTE_HTTP_METHOD
- assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getName()))
+ assert geofences[0].url == getWriteAttributeUrl(new AttributeRef(testUser3Console1.id, LOCATION.getAttributeName()))
}
and: "the consoles should have been notified to refresh their geofences"
@@ -660,7 +660,7 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
when: "the RULE_STATE meta is removed from a console's location attribute"
testUser3Console1 = assetStorageService.find(testUser3Console1.id, true)
- testUser3Console1.getAttribute(LOCATION.getName()).get().getMeta().removeIf({
+ testUser3Console1.getAttribute(LOCATION.getAttributeName()).get().getMeta().removeIf({
it.name.orElse(null) == RULE_STATE.urn
})
testUser3Console1 = assetStorageService.merge(testUser3Console1)
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 6b9ddd990..7bb5f298f 100644
--- a/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy
@@ -24,7 +24,7 @@ import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.setup.SetupService
import org.openremote.manager.setup.builtin.ManagerDemoSetup
-import org.openremote.model.asset.MetaItemType
+import org.openremote.model.attribute.MetaItemType
import org.openremote.model.asset.LocationEvent
import org.openremote.model.asset.agent.AgentStatusEvent
import org.openremote.model.asset.agent.ConnectionStatus
diff --git a/test/src/test/groovy/org/openremote/test/model/SerialisationTest.groovy b/test/src/test/groovy/org/openremote/test/model/SerialisationTest.groovy
index 18447b6ed..b2a8b6af7 100644
--- a/test/src/test/groovy/org/openremote/test/model/SerialisationTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/model/SerialisationTest.groovy
@@ -24,7 +24,7 @@ import org.openremote.container.Container
import org.openremote.model.ValidationFailure
import org.openremote.model.ValueHolder
import org.openremote.model.asset.AssetAttribute
-import org.openremote.model.asset.MetaItemType
+import org.openremote.model.attribute.MetaItemType
import org.openremote.model.asset.agent.ProtocolConfiguration
import org.openremote.model.attribute.AttributeValidationResult
import org.openremote.model.attribute.MetaItem
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 5771da440..6b3e2e377 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
@@ -28,7 +28,6 @@ import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
-import org.openremote.model.asset.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.ConnectionStatus
import org.openremote.model.asset.agent.ProtocolConfiguration
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 7143e6e0b..99afb2e58 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
@@ -23,8 +23,8 @@ import org.apache.commons.lang3.SystemUtils
import org.openremote.model.asset.Asset
import tuwien.auto.calimero.server.knxnetip.DefaultServiceContainer
-import static org.openremote.model.asset.MetaItemType.DESCRIPTION
-import static org.openremote.model.asset.MetaItemType.LABEL
+import static org.openremote.model.attribute.MetaItemType.DESCRIPTION
+import static org.openremote.model.attribute.MetaItemType.LABEL
import org.openremote.agent.protocol.knx.KNXProtocol
import org.openremote.model.asset.agent.ConnectionStatus
@@ -34,7 +34,6 @@ import org.openremote.manager.asset.AssetStorageService
import org.openremote.model.Constants
import org.openremote.model.asset.AssetAttribute
-import org.openremote.model.asset.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.ProtocolConfiguration
import org.openremote.model.attribute.*
diff --git a/test/src/test/groovy/org/openremote/test/protocol/controller/ControllerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/controller/ControllerProtocolTest.groovy
index 2f023af1a..f961fa38c 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/controller/ControllerProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/controller/ControllerProtocolTest.groovy
@@ -29,7 +29,7 @@ import org.openremote.manager.asset.AssetStorageService
import org.openremote.model.Constants
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
-import org.openremote.model.asset.MetaItemType
+import org.openremote.model.attribute.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.ConnectionStatus
import org.openremote.model.asset.agent.ProtocolConfiguration
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 18a6aada5..c31222ea4 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
@@ -31,7 +31,7 @@ import org.openremote.manager.asset.AssetStorageService
import org.openremote.model.Constants
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
-import org.openremote.model.asset.MetaItemType
+import org.openremote.model.attribute.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.ConnectionStatus
import org.openremote.model.attribute.AttributeEvent
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 d1ae993a0..8ac7398e4 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
@@ -11,7 +11,7 @@ import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.model.asset.Asset
import org.openremote.model.asset.AssetAttribute
-import org.openremote.model.asset.MetaItemType
+import org.openremote.model.attribute.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.asset.agent.AgentLink
import org.openremote.model.asset.agent.AgentResource
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 fd0364aeb..0c6bd5648 100644
--- a/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
@@ -10,7 +10,7 @@ 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.MetaItemType
+import org.openremote.model.attribute.MetaItemType
import org.openremote.model.asset.AssetType
import org.openremote.model.attribute.AttributeEvent
import org.openremote.model.attribute.AttributeValueType
diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
index 3882537a3..af26d5591 100644
--- a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
@@ -144,7 +144,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
assert consoleRegistration.id != null
when: "the console location is set to the apartment"
- authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.name, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.attributeName, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue().toJson())
then: "the consoles location should have been updated"
conditions.eventually {
@@ -169,7 +169,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
}
when: "the console device moves outside the home geofence (as defined in the rule)"
- authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.name, new GeoJSONPoint(0d,0d).toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.attributeName, new GeoJSONPoint(0d,0d).toValue().toJson())
then: "the apartment lights should be switched off"
conditions.eventually {
@@ -198,7 +198,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
}
when: "the console device moves back inside the home geofence (as defined in the rule)"
- authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.name, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.attributeName, ManagerDemoSetup.SMART_BUILDING_LOCATION.toValue().toJson())
then: "the rule reset fact should be removed"
conditions.eventually {
@@ -206,7 +206,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
}
when: "the console device moves outside the home geofence again (as defined in the rule)"
- authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.name, new GeoJSONPoint(0d,0d).toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.attributeName, new GeoJSONPoint(0d,0d).toValue().toJson())
then: "another notification should have been sent to the console"
conditions.eventually {
@@ -216,7 +216,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
when: "the console sends a location update with the same location but a newer timestamp"
advancePseudoClock(35, MINUTES, container)
- authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.name, new GeoJSONPoint(0d,0d).toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.attributeName, new GeoJSONPoint(0d,0d).toValue().toJson())
then: "another notification should have been sent to the console (because the reset condition includes reset on attributeTimestampChange)"
conditions.eventually {
@@ -225,7 +225,7 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
}
when: "the console sends a location update with a new location but still outside the geofence"
- authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.name, new GeoJSONPoint(10d,10d).toValue().toJson())
+ authenticatedAssetResource.writeAttributeValue(null, consoleRegistration.id, LOCATION.attributeName, new GeoJSONPoint(10d,10d).toValue().toJson())
then: "another notification should have been sent to the console (because the reset condition includes reset on attributeValueChange)"
conditions.eventually {