Skip to content
Permalink
Browse files

Moved MetaItemType to attribute package and updated AttributeDescript…

…or (renamed getName getAttributeName)
  • Loading branch information...
richturner committed Apr 14, 2019
1 parent 6a8bafa commit ea31e058e1172114569832f6da6080fffc6c839f
Showing with 187 additions and 148 deletions.
  1. +1 −1 agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java
  2. +1 −1 agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
  3. +1 −1 agent/src/main/java/org/openremote/agent/protocol/knx/KNXProtocol.java
  4. +2 −2 agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java
  5. +1 −1 agent/src/main/java/org/openremote/agent/protocol/timer/TimerProtocol.java
  6. +1 −1 agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java
  7. +1 −1 client/src/main/java/org/openremote/app/client/assets/asset/AbstractAssetActivity.java
  8. +7 −7 client/src/main/java/org/openremote/app/client/assets/attributes/MetaEditor.java
  9. +1 −1 client/src/main/java/org/openremote/app/client/widget/AttributeLinkEditor.java
  10. +1 −1 manager/src/main/java/org/openremote/manager/agent/AgentService.java
  11. +1 −1 manager/src/main/java/org/openremote/manager/asset/AssetAttributeLinkingService.java
  12. +1 −0 manager/src/main/java/org/openremote/manager/asset/AssetProcessingService.java
  13. +2 −2 manager/src/main/java/org/openremote/manager/asset/AssetResourceImpl.java
  14. +3 −2 manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
  15. +1 −1 manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointService.java
  16. +2 −2 manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java
  17. +6 −6 manager/src/main/java/org/openremote/manager/notification/PushNotificationHandler.java
  18. +4 −4 manager/src/main/java/org/openremote/manager/rules/RulesEngine.java
  19. +1 −1 manager/src/main/java/org/openremote/manager/rules/RulesFacts.java
  20. +1 −1 manager/src/main/java/org/openremote/manager/rules/RulesService.java
  21. +3 −4 manager/src/main/java/org/openremote/manager/rules/geofence/ORConsoleGeofenceAssetAdapter.java
  22. +1 −1 manager/src/main/java/org/openremote/manager/setup/AbstractManagerSetup.java
  23. +2 −2 manager/src/main/java/org/openremote/manager/setup/builtin/ManagerDemoSetup.java
  24. +1 −1 manager/src/main/resources/demo/rules/DemoConsoleLocation.groovy
  25. +4 −4 model/src/main/java/org/openremote/model/asset/Asset.java
  26. +4 −4 model/src/main/java/org/openremote/model/asset/AssetAttribute.java
  27. +1 −0 model/src/main/java/org/openremote/model/asset/AssetResource.java
  28. +1 −0 model/src/main/java/org/openremote/model/asset/UserAsset.java
  29. +2 −2 model/src/main/java/org/openremote/model/asset/agent/AgentLink.java
  30. +1 −1 model/src/main/java/org/openremote/model/asset/agent/ConnectionStatus.java
  31. +2 −2 model/src/main/java/org/openremote/model/asset/agent/ProtocolConfiguration.java
  32. +2 −0 model/src/main/java/org/openremote/model/attribute/AttributeDescriptor.java
  33. +32 −21 model/src/main/java/org/openremote/model/attribute/AttributeType.java
  34. +2 −0 model/src/main/java/org/openremote/model/attribute/AttributeValueDescriptor.java
  35. +1 −1 model/src/main/java/org/openremote/model/attribute/AttributeValueType.java
  36. +1 −1 model/src/main/java/org/openremote/model/attribute/MetaItemDescriptor.java
  37. +2 −2 model/src/main/java/org/openremote/model/attribute/MetaItemDescriptorImpl.java
  38. +9 −2 model/src/main/java/org/openremote/model/{asset → attribute}/MetaItemType.java
  39. +7 −7 model/src/main/java/org/openremote/model/console/ConsoleConfiguration.java
  40. +2 −2 model/src/main/java/org/openremote/model/query/filter/LocationAttributePredicate.java
  41. +2 −2 model/src/main/java/org/openremote/model/util/AssetModelUtil.java
  42. +2 −0 model/src/main/java/org/openremote/model/value/Value.java
  43. +3 −0 model/src/main/java/org/openremote/model/value/impl/ArrayValueImpl.java
  44. +3 −0 model/src/main/java/org/openremote/model/value/impl/BooleanValueImpl.java
  45. +3 −0 model/src/main/java/org/openremote/model/value/impl/NumberValueImpl.java
  46. +3 −0 model/src/main/java/org/openremote/model/value/impl/ObjectValueImpl.java
  47. +3 −0 model/src/main/java/org/openremote/model/value/impl/StringValueImpl.java
  48. +0 −1 test/src/test/groovy/org/openremote/test/assets/AssetAttributeLinkingTest.groovy
  49. +11 −11 test/src/test/groovy/org/openremote/test/assets/AssetModelResourceTest.groovy
  50. +1 −1 test/src/test/groovy/org/openremote/test/assets/AssetPermissionsTest.groovy
  51. +0 −1 test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy
  52. +2 −2 test/src/test/groovy/org/openremote/test/assets/AssetPublicQueryTest.groovy
  53. +1 −0 test/src/test/groovy/org/openremote/test/assets/AssetQueryTest.groovy
  54. +20 −20 test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
  55. +1 −1 test/src/test/groovy/org/openremote/test/event/ClientEventTest.groovy
  56. +1 −1 test/src/test/groovy/org/openremote/test/model/SerialisationTest.groovy
  57. +0 −1 test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy
  58. +2 −3 test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
  59. +1 −1 test/src/test/groovy/org/openremote/test/protocol/controller/ControllerProtocolTest.groovy
  60. +1 −1 test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy
  61. +1 −1 test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
  62. +1 −1 test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy
  63. +6 −6 test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
@@ -32,7 +32,7 @@
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;
@@ -30,7 +30,7 @@
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.*;
@@ -7,7 +7,7 @@
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;
@@ -41,8 +41,8 @@
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 {
@@ -21,7 +21,7 @@

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;
@@ -26,7 +26,7 @@
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;
@@ -45,7 +45,7 @@
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;
@@ -25,7 +25,7 @@
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 @@ protected void updateNameList() {

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 @@ protected void onNameChanged(boolean updateItem) {
}
}

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 @@ protected void refreshMetaItemDescriptors() {
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 @@ protected boolean addItem(MetaItem item, boolean viewOnly) {
.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 void onValidationStateChange(AttributeValidationResult validationResult)
.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 @@ protected void showMetaItemFailure(MetaItemEditor metaItemEditor, List<Validatio
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 -> {
@@ -27,7 +27,7 @@
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;
@@ -37,7 +37,7 @@
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;
@@ -24,7 +24,7 @@
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;
@@ -41,6 +41,7 @@
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;
@@ -468,7 +468,7 @@ public Asset create(RequestParams requestParams, Asset asset) {
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 Asset create(RequestParams requestParams, Asset asset) {
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)
));
});

@@ -48,6 +48,7 @@
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 @@ protected void publishModificationEvents(PersistenceEvent<Asset> persistenceEven
"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(
@@ -14,7 +14,7 @@
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;
@@ -186,10 +186,10 @@ public boolean isMessageValid(AbstractNotificationMessage message) {
.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()) {
@@ -126,9 +126,9 @@ public void start(Container container) throws Exception {
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 boolean isMessageValid(AbstractNotificationMessage message) {
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 boolean isMessageValid(AbstractNotificationMessage message) {
.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 boolean isMessageValid(AbstractNotificationMessage message) {
.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 boolean isMessageValid(AbstractNotificationMessage message) {
.select(select)
.path(new PathPredicate(targetId))
.type(AssetType.CONSOLE)
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate(PushNotificationMessage.TYPE))
);

@@ -32,7 +32,7 @@
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,21 +457,21 @@ public void stop(boolean systemShutdownInProgress) {

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();
}
}

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();
}

@@ -665,7 +665,7 @@ protected void storeLocationPredicates(List<GeofencePredicate> foundLocationPred
// 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<>()));
}
@@ -38,7 +38,7 @@
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;
Oops, something went wrong.

0 comments on commit ea31e05

Please sign in to comment.
You can’t perform that action at this time.