Showing
18 changed files
with
102 additions
and
38 deletions
... | ... | @@ -44,6 +44,7 @@ import org.thingsboard.server.common.data.query.EntityDataSortOrder; |
44 | 44 | import org.thingsboard.server.common.data.query.EntityKey; |
45 | 45 | import org.thingsboard.server.common.data.query.EntityKeyType; |
46 | 46 | import org.thingsboard.server.common.data.query.EntityListFilter; |
47 | +import org.thingsboard.server.common.data.query.EntityTypeFilter; | |
47 | 48 | import org.thingsboard.server.common.data.query.FilterPredicateValue; |
48 | 49 | import org.thingsboard.server.common.data.query.KeyFilter; |
49 | 50 | import org.thingsboard.server.common.data.query.NumericFilterPredicate; |
... | ... | @@ -132,6 +133,14 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe |
132 | 133 | |
133 | 134 | count = doPostWithResponse("/api/entitiesQuery/count", countQuery, Long.class); |
134 | 135 | Assert.assertEquals(97, count.longValue()); |
136 | + | |
137 | + EntityTypeFilter filter2 = new EntityTypeFilter(); | |
138 | + filter2.setEntityType(EntityType.DEVICE); | |
139 | + | |
140 | + EntityCountQuery countQuery2 = new EntityCountQuery(filter2); | |
141 | + | |
142 | + Long count2 = doPostWithResponse("/api/entitiesQuery/count", countQuery2, Long.class); | |
143 | + Assert.assertEquals(97, count2.longValue()); | |
135 | 144 | } |
136 | 145 | |
137 | 146 | @Test |
... | ... | @@ -198,11 +207,31 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe |
198 | 207 | Assert.assertEquals(11, data.getTotalElements()); |
199 | 208 | Assert.assertEquals("Device19", data.getData().get(0).getLatest().get(EntityKeyType.ENTITY_FIELD).get("name").getValue()); |
200 | 209 | |
210 | + | |
211 | + EntityTypeFilter filter2 = new EntityTypeFilter(); | |
212 | + filter2.setEntityType(EntityType.DEVICE); | |
213 | + | |
214 | + EntityDataSortOrder sortOrder2 = new EntityDataSortOrder( | |
215 | + new EntityKey(EntityKeyType.ENTITY_FIELD, "createdTime"), EntityDataSortOrder.Direction.ASC | |
216 | + ); | |
217 | + EntityDataPageLink pageLink2 = new EntityDataPageLink(10, 0, null, sortOrder2); | |
218 | + List<EntityKey> entityFields2 = Collections.singletonList(new EntityKey(EntityKeyType.ENTITY_FIELD, "name")); | |
219 | + | |
220 | + EntityDataQuery query2 = new EntityDataQuery(filter2, pageLink2, entityFields2, null, null); | |
221 | + | |
222 | + PageData<EntityData> data2 = | |
223 | + doPostWithTypedResponse("/api/entitiesQuery/find", query2, new TypeReference<PageData<EntityData>>() { | |
224 | + }); | |
225 | + | |
226 | + Assert.assertEquals(97, data2.getTotalElements()); | |
227 | + Assert.assertEquals(10, data2.getTotalPages()); | |
228 | + Assert.assertTrue(data2.hasNext()); | |
229 | + Assert.assertEquals(10, data2.getData().size()); | |
230 | + | |
201 | 231 | } |
202 | 232 | |
203 | 233 | @Test |
204 | 234 | public void testFindEntityDataByQueryWithAttributes() throws Exception { |
205 | - | |
206 | 235 | List<Device> devices = new ArrayList<>(); |
207 | 236 | List<Long> temperatures = new ArrayList<>(); |
208 | 237 | List<Long> highTemperatures = new ArrayList<>(); | ... | ... |
... | ... | @@ -26,9 +26,9 @@ import java.util.Arrays; |
26 | 26 | |
27 | 27 | @RunWith(ClasspathSuite.class) |
28 | 28 | @ClasspathSuite.ClassnameFilters({ |
29 | - "org.thingsboard.server.controller.sql.WebsocketApiSqlTest", | |
30 | -// "org.thingsboard.server.controller.sql.TenantProfileControllerSqlTest", | |
31 | -// "org.thingsboard.server.controller.sql.*Test", | |
29 | +// "org.thingsboard.server.controller.sql.WebsocketApiSqlTest", | |
30 | +// "org.thingsboard.server.controller.sql.EntityQueryControllerSqlTest", | |
31 | + "org.thingsboard.server.controller.sql.*Test", | |
32 | 32 | }) |
33 | 33 | public class ControllerSqlTestSuite { |
34 | 34 | ... | ... |
... | ... | @@ -19,7 +19,7 @@ import lombok.Data; |
19 | 19 | import org.thingsboard.server.common.data.EntityType; |
20 | 20 | import org.thingsboard.server.common.data.relation.EntityRelation; |
21 | 21 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
22 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
22 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
23 | 23 | import org.thingsboard.server.common.data.relation.RelationsSearchParameters; |
24 | 24 | |
25 | 25 | import java.util.Collections; |
... | ... | @@ -39,7 +39,7 @@ public class AssetSearchQuery { |
39 | 39 | EntityRelationsQuery query = new EntityRelationsQuery(); |
40 | 40 | query.setParameters(parameters); |
41 | 41 | query.setFilters( |
42 | - Collections.singletonList(new EntityTypeFilter(relationType == null ? EntityRelation.CONTAINS_TYPE : relationType, | |
42 | + Collections.singletonList(new RelationEntityTypeFilter(relationType == null ? EntityRelation.CONTAINS_TYPE : relationType, | |
43 | 43 | Collections.singletonList(EntityType.ASSET)))); |
44 | 44 | return query; |
45 | 45 | } | ... | ... |
... | ... | @@ -19,7 +19,7 @@ import lombok.Data; |
19 | 19 | import org.thingsboard.server.common.data.EntityType; |
20 | 20 | import org.thingsboard.server.common.data.relation.EntityRelation; |
21 | 21 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
22 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
22 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
23 | 23 | import org.thingsboard.server.common.data.relation.RelationsSearchParameters; |
24 | 24 | |
25 | 25 | import java.util.Collections; |
... | ... | @@ -36,7 +36,7 @@ public class DeviceSearchQuery { |
36 | 36 | EntityRelationsQuery query = new EntityRelationsQuery(); |
37 | 37 | query.setParameters(parameters); |
38 | 38 | query.setFilters( |
39 | - Collections.singletonList(new EntityTypeFilter(relationType == null ? EntityRelation.CONTAINS_TYPE : relationType, | |
39 | + Collections.singletonList(new RelationEntityTypeFilter(relationType == null ? EntityRelation.CONTAINS_TYPE : relationType, | |
40 | 40 | Collections.singletonList(EntityType.DEVICE)))); |
41 | 41 | return query; |
42 | 42 | } | ... | ... |
... | ... | @@ -19,7 +19,7 @@ import lombok.Data; |
19 | 19 | import org.thingsboard.server.common.data.EntityType; |
20 | 20 | import org.thingsboard.server.common.data.relation.EntityRelation; |
21 | 21 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
22 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
22 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
23 | 23 | import org.thingsboard.server.common.data.relation.RelationsSearchParameters; |
24 | 24 | |
25 | 25 | import java.util.Collections; |
... | ... | @@ -36,7 +36,7 @@ public class EntityViewSearchQuery { |
36 | 36 | EntityRelationsQuery query = new EntityRelationsQuery(); |
37 | 37 | query.setParameters(parameters); |
38 | 38 | query.setFilters( |
39 | - Collections.singletonList(new EntityTypeFilter(relationType == null ? EntityRelation.CONTAINS_TYPE : relationType, | |
39 | + Collections.singletonList(new RelationEntityTypeFilter(relationType == null ? EntityRelation.CONTAINS_TYPE : relationType, | |
40 | 40 | Collections.singletonList(EntityType.ENTITY_VIEW)))); |
41 | 41 | return query; |
42 | 42 | } | ... | ... |
... | ... | @@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; |
29 | 29 | @JsonSubTypes.Type(value = SingleEntityFilter.class, name = "singleEntity"), |
30 | 30 | @JsonSubTypes.Type(value = EntityListFilter.class, name = "entityList"), |
31 | 31 | @JsonSubTypes.Type(value = EntityNameFilter.class, name = "entityName"), |
32 | + @JsonSubTypes.Type(value = EntityTypeFilter.class, name = "entityType"), | |
32 | 33 | @JsonSubTypes.Type(value = AssetTypeFilter.class, name = "assetType"), |
33 | 34 | @JsonSubTypes.Type(value = DeviceTypeFilter.class, name = "deviceType"), |
34 | 35 | @JsonSubTypes.Type(value = EntityViewTypeFilter.class, name = "entityViewType"), | ... | ... |
... | ... | @@ -19,6 +19,7 @@ public enum EntityFilterType { |
19 | 19 | SINGLE_ENTITY("singleEntity"), |
20 | 20 | ENTITY_LIST("entityList"), |
21 | 21 | ENTITY_NAME("entityName"), |
22 | + ENTITY_TYPE("entityType"), | |
22 | 23 | ASSET_TYPE("assetType"), |
23 | 24 | DEVICE_TYPE("deviceType"), |
24 | 25 | ENTITY_VIEW_TYPE("entityViewType"), | ... | ... |
1 | +/** | |
2 | + * Copyright © 2016-2021 The Thingsboard Authors | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | +package org.thingsboard.server.common.data.query; | |
17 | + | |
18 | +import lombok.Data; | |
19 | +import org.thingsboard.server.common.data.EntityType; | |
20 | + | |
21 | +@Data | |
22 | +public class EntityTypeFilter implements EntityFilter { | |
23 | + @Override | |
24 | + public EntityFilterType getType() { | |
25 | + return EntityFilterType.ENTITY_TYPE; | |
26 | + } | |
27 | + | |
28 | + private EntityType entityType; | |
29 | + | |
30 | +} | ... | ... |
... | ... | @@ -18,8 +18,7 @@ package org.thingsboard.server.common.data.query; |
18 | 18 | import lombok.Data; |
19 | 19 | import org.thingsboard.server.common.data.id.EntityId; |
20 | 20 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
21 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
22 | -import org.thingsboard.server.common.data.relation.RelationTypeGroup; | |
21 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
23 | 22 | |
24 | 23 | import java.util.List; |
25 | 24 | |
... | ... | @@ -33,7 +32,7 @@ public class RelationsQueryFilter implements EntityFilter { |
33 | 32 | |
34 | 33 | private EntityId rootEntity; |
35 | 34 | private EntitySearchDirection direction; |
36 | - private List<EntityTypeFilter> filters; | |
35 | + private List<RelationEntityTypeFilter> filters; | |
37 | 36 | private int maxLevel; |
38 | 37 | private boolean fetchLastLevelOnly; |
39 | 38 | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/relation/RelationEntityTypeFilter.java
renamed from
common/data/src/main/java/org/thingsboard/server/common/data/relation/EntityTypeFilter.java
... | ... | @@ -35,7 +35,7 @@ import org.thingsboard.server.common.data.relation.EntityRelation; |
35 | 35 | import org.thingsboard.server.common.data.relation.EntityRelationInfo; |
36 | 36 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
37 | 37 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
38 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
38 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
39 | 39 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
40 | 40 | import org.thingsboard.server.common.data.relation.RelationsSearchParameters; |
41 | 41 | import org.thingsboard.server.dao.entity.EntityService; |
... | ... | @@ -457,7 +457,7 @@ public class BaseRelationService implements RelationService { |
457 | 457 | //boolean fetchLastLevelOnly = true; |
458 | 458 | log.trace("Executing findByQuery [{}]", query); |
459 | 459 | RelationsSearchParameters params = query.getParameters(); |
460 | - final List<EntityTypeFilter> filters = query.getFilters(); | |
460 | + final List<RelationEntityTypeFilter> filters = query.getFilters(); | |
461 | 461 | if (filters == null || filters.isEmpty()) { |
462 | 462 | log.debug("Filters are not set [{}]", query); |
463 | 463 | } |
... | ... | @@ -575,8 +575,8 @@ public class BaseRelationService implements RelationService { |
575 | 575 | }; |
576 | 576 | } |
577 | 577 | |
578 | - private boolean matchFilters(List<EntityTypeFilter> filters, EntityRelation relation, EntitySearchDirection direction) { | |
579 | - for (EntityTypeFilter filter : filters) { | |
578 | + private boolean matchFilters(List<RelationEntityTypeFilter> filters, EntityRelation relation, EntitySearchDirection direction) { | |
579 | + for (RelationEntityTypeFilter filter : filters) { | |
580 | 580 | if (match(filter, relation, direction)) { |
581 | 581 | return true; |
582 | 582 | } |
... | ... | @@ -584,7 +584,7 @@ public class BaseRelationService implements RelationService { |
584 | 584 | return false; |
585 | 585 | } |
586 | 586 | |
587 | - private boolean match(EntityTypeFilter filter, EntityRelation relation, EntitySearchDirection direction) { | |
587 | + private boolean match(RelationEntityTypeFilter filter, EntityRelation relation, EntitySearchDirection direction) { | |
588 | 588 | if (StringUtils.isEmpty(filter.getRelationType()) || filter.getRelationType().equals(relation.getType())) { |
589 | 589 | if (filter.getEntityTypes() == null || filter.getEntityTypes().isEmpty()) { |
590 | 590 | return true; | ... | ... |
... | ... | @@ -40,12 +40,13 @@ import org.thingsboard.server.common.data.query.EntityKeyType; |
40 | 40 | import org.thingsboard.server.common.data.query.EntityListFilter; |
41 | 41 | import org.thingsboard.server.common.data.query.EntityNameFilter; |
42 | 42 | import org.thingsboard.server.common.data.query.EntitySearchQueryFilter; |
43 | +import org.thingsboard.server.common.data.query.EntityTypeFilter; | |
43 | 44 | import org.thingsboard.server.common.data.query.EntityViewSearchQueryFilter; |
44 | 45 | import org.thingsboard.server.common.data.query.EntityViewTypeFilter; |
45 | 46 | import org.thingsboard.server.common.data.query.RelationsQueryFilter; |
46 | 47 | import org.thingsboard.server.common.data.query.SingleEntityFilter; |
47 | 48 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
48 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
49 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
49 | 50 | |
50 | 51 | import java.util.Arrays; |
51 | 52 | import java.util.Collections; |
... | ... | @@ -488,6 +489,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { |
488 | 489 | case ASSET_SEARCH_QUERY: |
489 | 490 | case ENTITY_VIEW_SEARCH_QUERY: |
490 | 491 | case API_USAGE_STATE: |
492 | + case ENTITY_TYPE: | |
491 | 493 | return ""; |
492 | 494 | default: |
493 | 495 | throw new RuntimeException("Not implemented!"); |
... | ... | @@ -573,7 +575,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { |
573 | 575 | boolean single = entityFilter.getFilters() != null && entityFilter.getFilters().size() == 1; |
574 | 576 | if (entityFilter.getFilters() != null && !entityFilter.getFilters().isEmpty()) { |
575 | 577 | int entityTypeFilterIdx = 0; |
576 | - for (EntityTypeFilter etf : entityFilter.getFilters()) { | |
578 | + for (RelationEntityTypeFilter etf : entityFilter.getFilters()) { | |
577 | 579 | String etfCondition = buildEtfCondition(ctx, etf, entityFilter.getDirection(), entityTypeFilterIdx++); |
578 | 580 | if (!etfCondition.isEmpty()) { |
579 | 581 | if (noConditions) { |
... | ... | @@ -622,7 +624,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { |
622 | 624 | return "( " + selectFields + from + ")"; |
623 | 625 | } |
624 | 626 | |
625 | - private String buildEtfCondition(QueryContext ctx, EntityTypeFilter etf, EntitySearchDirection direction, int entityTypeFilterIdx) { | |
627 | + private String buildEtfCondition(QueryContext ctx, RelationEntityTypeFilter etf, EntitySearchDirection direction, int entityTypeFilterIdx) { | |
626 | 628 | StringBuilder whereFilter = new StringBuilder(); |
627 | 629 | String relationType = etf.getRelationType(); |
628 | 630 | List<EntityType> entityTypes = etf.getEntityTypes(); |
... | ... | @@ -728,6 +730,8 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { |
728 | 730 | return ((EntityListFilter) entityFilter).getEntityType(); |
729 | 731 | case ENTITY_NAME: |
730 | 732 | return ((EntityNameFilter) entityFilter).getEntityType(); |
733 | + case ENTITY_TYPE: | |
734 | + return ((EntityTypeFilter) entityFilter).getEntityType(); | |
731 | 735 | case ASSET_TYPE: |
732 | 736 | case ASSET_SEARCH_QUERY: |
733 | 737 | return EntityType.ASSET; | ... | ... |
... | ... | @@ -58,7 +58,7 @@ import org.thingsboard.server.common.data.query.RelationsQueryFilter; |
58 | 58 | import org.thingsboard.server.common.data.query.StringFilterPredicate; |
59 | 59 | import org.thingsboard.server.common.data.relation.EntityRelation; |
60 | 60 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
61 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
61 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
62 | 62 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
63 | 63 | import org.thingsboard.server.dao.attributes.AttributesService; |
64 | 64 | import org.thingsboard.server.dao.model.sqlts.ts.TsKvEntity; |
... | ... | @@ -160,13 +160,13 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { |
160 | 160 | long count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); |
161 | 161 | Assert.assertEquals(30, count); |
162 | 162 | |
163 | - filter.setFilters(Collections.singletonList(new EntityTypeFilter("Contains", Collections.singletonList(EntityType.DEVICE)))); | |
163 | + filter.setFilters(Collections.singletonList(new RelationEntityTypeFilter("Contains", Collections.singletonList(EntityType.DEVICE)))); | |
164 | 164 | count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); |
165 | 165 | Assert.assertEquals(25, count); |
166 | 166 | |
167 | 167 | filter.setRootEntity(devices.get(0).getId()); |
168 | 168 | filter.setDirection(EntitySearchDirection.TO); |
169 | - filter.setFilters(Collections.singletonList(new EntityTypeFilter("Manages", Collections.singletonList(EntityType.TENANT)))); | |
169 | + filter.setFilters(Collections.singletonList(new RelationEntityTypeFilter("Manages", Collections.singletonList(EntityType.TENANT)))); | |
170 | 170 | count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); |
171 | 171 | Assert.assertEquals(1, count); |
172 | 172 | |
... | ... | @@ -228,7 +228,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { |
228 | 228 | RelationsQueryFilter filter = new RelationsQueryFilter(); |
229 | 229 | filter.setRootEntity(tenantId); |
230 | 230 | filter.setDirection(EntitySearchDirection.FROM); |
231 | - filter.setFilters(Collections.singletonList(new EntityTypeFilter("Contains", Collections.singletonList(EntityType.DEVICE)))); | |
231 | + filter.setFilters(Collections.singletonList(new RelationEntityTypeFilter("Contains", Collections.singletonList(EntityType.DEVICE)))); | |
232 | 232 | |
233 | 233 | EntityDataSortOrder sortOrder = new EntityDataSortOrder( |
234 | 234 | new EntityKey(EntityKeyType.ENTITY_FIELD, "createdTime"), EntityDataSortOrder.Direction.ASC | ... | ... |
... | ... | @@ -26,7 +26,7 @@ import org.thingsboard.server.common.data.id.DeviceId; |
26 | 26 | import org.thingsboard.server.common.data.relation.EntityRelation; |
27 | 27 | import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
28 | 28 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
29 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
29 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
30 | 30 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
31 | 31 | import org.thingsboard.server.common.data.relation.RelationsSearchParameters; |
32 | 32 | import org.thingsboard.server.dao.exception.DataValidationException; |
... | ... | @@ -221,7 +221,7 @@ public abstract class BaseRelationServiceTest extends AbstractServiceTest { |
221 | 221 | |
222 | 222 | EntityRelationsQuery query = new EntityRelationsQuery(); |
223 | 223 | query.setParameters(new RelationsSearchParameters(assetA, EntitySearchDirection.FROM, -1, false)); |
224 | - query.setFilters(Collections.singletonList(new EntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.singletonList(EntityType.ASSET)))); | |
224 | + query.setFilters(Collections.singletonList(new RelationEntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.singletonList(EntityType.ASSET)))); | |
225 | 225 | List<EntityRelation> relations = relationService.findByQuery(SYSTEM_TENANT_ID, query).get(); |
226 | 226 | Assert.assertEquals(3, relations.size()); |
227 | 227 | Assert.assertTrue(relations.contains(relationA)); |
... | ... | @@ -255,7 +255,7 @@ public abstract class BaseRelationServiceTest extends AbstractServiceTest { |
255 | 255 | |
256 | 256 | EntityRelationsQuery query = new EntityRelationsQuery(); |
257 | 257 | query.setParameters(new RelationsSearchParameters(assetA, EntitySearchDirection.FROM, -1, false)); |
258 | - query.setFilters(Collections.singletonList(new EntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.singletonList(EntityType.ASSET)))); | |
258 | + query.setFilters(Collections.singletonList(new RelationEntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.singletonList(EntityType.ASSET)))); | |
259 | 259 | List<EntityRelation> relations = relationService.findByQuery(SYSTEM_TENANT_ID, query).get(); |
260 | 260 | Assert.assertEquals(2, relations.size()); |
261 | 261 | Assert.assertTrue(relations.contains(relationAB)); | ... | ... |
... | ... | @@ -17,7 +17,7 @@ package org.thingsboard.rule.engine.data; |
17 | 17 | |
18 | 18 | import lombok.Data; |
19 | 19 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
20 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
20 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
21 | 21 | |
22 | 22 | import java.util.List; |
23 | 23 | |
... | ... | @@ -26,6 +26,6 @@ public class RelationsQuery { |
26 | 26 | |
27 | 27 | private EntitySearchDirection direction; |
28 | 28 | private int maxLevel = 1; |
29 | - private List<EntityTypeFilter> filters; | |
29 | + private List<RelationEntityTypeFilter> filters; | |
30 | 30 | private boolean fetchLastLevelOnly = false; |
31 | 31 | } | ... | ... |
... | ... | @@ -19,7 +19,7 @@ import lombok.Data; |
19 | 19 | import org.thingsboard.rule.engine.data.RelationsQuery; |
20 | 20 | import org.thingsboard.server.common.data.relation.EntityRelation; |
21 | 21 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
22 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
22 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
23 | 23 | |
24 | 24 | import java.util.Collections; |
25 | 25 | import java.util.HashMap; |
... | ... | @@ -41,8 +41,8 @@ public class TbGetRelatedAttrNodeConfiguration extends TbGetEntityAttrNodeConfig |
41 | 41 | RelationsQuery relationsQuery = new RelationsQuery(); |
42 | 42 | relationsQuery.setDirection(EntitySearchDirection.FROM); |
43 | 43 | relationsQuery.setMaxLevel(1); |
44 | - EntityTypeFilter entityTypeFilter = new EntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.emptyList()); | |
45 | - relationsQuery.setFilters(Collections.singletonList(entityTypeFilter)); | |
44 | + RelationEntityTypeFilter relationEntityTypeFilter = new RelationEntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.emptyList()); | |
45 | + relationsQuery.setFilters(Collections.singletonList(relationEntityTypeFilter)); | |
46 | 46 | configuration.setRelationsQuery(relationsQuery); |
47 | 47 | |
48 | 48 | return configuration; | ... | ... |
... | ... | @@ -20,7 +20,7 @@ import org.thingsboard.rule.engine.api.NodeConfiguration; |
20 | 20 | import org.thingsboard.rule.engine.data.RelationsQuery; |
21 | 21 | import org.thingsboard.server.common.data.relation.EntityRelation; |
22 | 22 | import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
23 | -import org.thingsboard.server.common.data.relation.EntityTypeFilter; | |
23 | +import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; | |
24 | 24 | |
25 | 25 | import java.util.Collections; |
26 | 26 | |
... | ... | @@ -39,8 +39,8 @@ public class TbChangeOriginatorNodeConfiguration extends TbTransformNodeConfigur |
39 | 39 | RelationsQuery relationsQuery = new RelationsQuery(); |
40 | 40 | relationsQuery.setDirection(EntitySearchDirection.FROM); |
41 | 41 | relationsQuery.setMaxLevel(1); |
42 | - EntityTypeFilter entityTypeFilter = new EntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.emptyList()); | |
43 | - relationsQuery.setFilters(Collections.singletonList(entityTypeFilter)); | |
42 | + RelationEntityTypeFilter relationEntityTypeFilter = new RelationEntityTypeFilter(EntityRelation.CONTAINS_TYPE, Collections.emptyList()); | |
43 | + relationsQuery.setFilters(Collections.singletonList(relationEntityTypeFilter)); | |
44 | 44 | configuration.setRelationsQuery(relationsQuery); |
45 | 45 | |
46 | 46 | return configuration; | ... | ... |