Skip to content

Commit

Permalink
Moved MetaItemType to attribute package and updated AttributeDescript…
Browse files Browse the repository at this point in the history
…or (renamed getName getAttributeName)
  • Loading branch information
richturner committed Apr 15, 2019
1 parent 6a8bafa commit ea31e05
Show file tree
Hide file tree
Showing 63 changed files with 187 additions and 148 deletions.
Expand Up @@ -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;
Expand Down
Expand Up @@ -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.*;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
});
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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("")
Expand All @@ -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 -> {
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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()
);

Expand All @@ -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)
));
});

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -186,10 +186,10 @@ public Notification.Targets mapTarget(Notification.Source source, String sourceI
.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()) {
Expand Down
Expand Up @@ -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)
Expand Down Expand Up @@ -187,7 +187,7 @@ public Notification.Targets mapTarget(Notification.Source source, String sourceI
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);
}
Expand All @@ -201,7 +201,7 @@ public Notification.Targets mapTarget(Notification.Source source, String sourceI
.select(select)
.tenant(new TenantPredicate(targetId))
.type(AssetType.CONSOLE)
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate(PushNotificationMessage.TYPE))
);

Expand Down Expand Up @@ -231,7 +231,7 @@ public Notification.Targets mapTarget(Notification.Source source, String sourceI
.select(select)
.ids(ids)
.type(AssetType.CONSOLE)
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate(PushNotificationMessage.TYPE))
);

Expand All @@ -256,7 +256,7 @@ public Notification.Targets mapTarget(Notification.Source source, String sourceI
.select(select)
.path(new PathPredicate(targetId))
.type(AssetType.CONSOLE)
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getName(),
.attributeValue(AttributeType.CONSOLE_PROVIDERS.getAttributeName(),
new ObjectValueKeyPredicate(PushNotificationMessage.TYPE))
);

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down
Expand Up @@ -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<>()));
}
Expand Down
Expand Up @@ -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;
Expand Down

0 comments on commit ea31e05

Please sign in to comment.