Skip to content

armgit / core

Public Imported from GitHub
0

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

It's now possible to only get attributes supplied by the AssetQuery attributes filter

Michael Rademaker0cdc034b06e5
diff --git a/model/src/main/java/org/openremote/model/query/AssetQuery.java b/model/src/main/java/org/openremote/model/query/AssetQuery.java
index 858265a6a..4b552cb72 100644
--- a/model/src/main/java/org/openremote/model/query/AssetQuery.java
+++ b/model/src/main/java/org/openremote/model/query/AssetQuery.java
@@ -24,6 +24,7 @@ import org.openremote.model.attribute.MetaItemDescriptor;
import org.openremote.model.query.filter.*;
import java.util.Arrays;
+import java.util.stream.Collectors;
/**
* Encapsulate asset query restriction, projection, and ordering of results.
@@ -45,30 +46,30 @@ public class AssetQuery {
public static Select selectExcludePathAndParentInfo() {
return new Select()
- .excludeAttributes(false)
- .excludeAttributeMeta(false)
- .excludeAttributeType(false)
- .excludeAttributeTimestamp(false)
- .excludeAttributeValue(false)
- .excludePath(true)
- .excludeParentInfo(true);
+ .excludeAttributes(false)
+ .excludeAttributeMeta(false)
+ .excludeAttributeType(false)
+ .excludeAttributeTimestamp(false)
+ .excludeAttributeValue(false)
+ .excludePath(true)
+ .excludeParentInfo(true);
}
public static Select selectExcludePathAndAttributes() {
return new Select()
- .excludePath(true)
- .excludeAttributes(true);
+ .excludePath(true)
+ .excludeAttributes(true);
}
public static Select selectExcludeAll() {
return new Select()
- .excludeAttributes(true)
- .excludeAttributeMeta(true)
- .excludeAttributeType(true)
- .excludeAttributeValue(true)
- .excludeAttributeTimestamp(true)
- .excludePath(true)
- .excludeParentInfo(true);
+ .excludeAttributes(true)
+ .excludeAttributeMeta(true)
+ .excludeAttributeType(true)
+ .excludeAttributeValue(true)
+ .excludeAttributeTimestamp(true)
+ .excludePath(true)
+ .excludeParentInfo(true);
}
public Select attributes(String... attributeNames) {
@@ -128,15 +129,15 @@ public class AssetQuery {
@Override
public String toString() {
return getClass().getSimpleName() + "{" +
- "excludeAttributes=" + excludeAttributes +
- ", excludeAttributeMeta=" + excludeAttributeMeta +
- ", excludeAttributeValue=" + excludeAttributeValue +
- ", excludeAttributeTimestamp=" + excludeAttributeTimestamp +
- ", excludeAttributeType=" + excludeAttributeType +
- ", excludePath=" + excludePath +
- ", excludeParentInfo=" + excludeParentInfo +
- ", attributeNames=" + Arrays.toString(attributes) +
- '}';
+ "excludeAttributes=" + excludeAttributes +
+ ", excludeAttributeMeta=" + excludeAttributeMeta +
+ ", excludeAttributeValue=" + excludeAttributeValue +
+ ", excludeAttributeTimestamp=" + excludeAttributeTimestamp +
+ ", excludeAttributeType=" + excludeAttributeType +
+ ", excludePath=" + excludePath +
+ ", excludeParentInfo=" + excludeParentInfo +
+ ", attributeNames=" + Arrays.toString(attributes) +
+ '}';
}
}
@@ -178,9 +179,9 @@ public class AssetQuery {
@Override
public String toString() {
return getClass().getSimpleName() + "{" +
- "property=" + property +
- ", descending=" + descending +
- '}';
+ "property=" + property +
+ ", descending=" + descending +
+ '}';
}
}
@@ -368,6 +369,12 @@ public class AssetQuery {
return this;
}
+ public AssetQuery attributeNames(String... attributeNames) {
+ LogicGroup<AttributePredicate> predicateLogicGroup = new LogicGroup<>(Arrays.stream(attributeNames).map(AttributePredicate::new).collect(Collectors.toList()));
+ predicateLogicGroup.operator = LogicGroup.Operator.OR;
+ return attributes(predicateLogicGroup);
+ }
+
public AssetQuery attributeName(String attributeName) {
return attributes(new AttributePredicate(attributeName));
}
@@ -417,18 +424,18 @@ public class AssetQuery {
@Override
public String toString() {
return getClass().getSimpleName() + "{" +
- "select=" + select +
- ", id='" + ids + '\'' +
- ", name=" + names +
- ", parent=" + parents +
- ", path=" + paths +
- ", tenant=" + tenant +
- ", userId='" + userIds + '\'' +
- ", type=" + types +
- ", attribute=" + (attributes != null ? attributes.toString() : "null" ) +
- ", attributeMeta=" + Arrays.toString(attributeMeta) +
- ", orderBy=" + orderBy +
- ", recursive=" + recursive +
- '}';
+ "select=" + select +
+ ", id='" + ids + '\'' +
+ ", name=" + names +
+ ", parent=" + parents +
+ ", path=" + paths +
+ ", tenant=" + tenant +
+ ", userId='" + userIds + '\'' +
+ ", type=" + types +
+ ", attribute=" + (attributes != null ? attributes.toString() : "null") +
+ ", attributeMeta=" + Arrays.toString(attributeMeta) +
+ ", orderBy=" + orderBy +
+ ", recursive=" + recursive +
+ '}';
}
}