From d534fb31e19105428522f10663d55e7fbe1edf1a Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Wed, 1 Feb 2023 17:21:04 +0200 Subject: [PATCH 01/16] Updated filter types - add possibility to select multiple subtypes --- .../install/ThingsboardInstallService.java | 1 + .../update/DefaultDataUpdateService.java | 100 ++++++++++++++++++ .../BaseEntityQueryControllerTest.java | 15 +-- .../BaseEntityViewControllerTest.java | 4 +- .../controller/BaseWebsocketApiTest.java | 8 +- ...AbstractMqttAttributesIntegrationTest.java | 2 +- .../common/data/query/AssetTypeFilter.java | 4 +- .../common/data/query/DeviceTypeFilter.java | 4 +- .../common/data/query/EdgeTypeFilter.java | 4 +- .../data/query/EntityViewTypeFilter.java | 4 +- .../query/DefaultEntityQueryRepository.java | 14 +-- .../dao/service/BaseEntityServiceTest.java | 28 ++--- .../entity/entity-filter-view.component.ts | 40 ++++--- .../entity/entity-filter.component.html | 32 +++--- .../entity/entity-filter.component.ts | 8 +- ui-ngx/src/app/shared/models/alias.models.ts | 8 +- .../assets/locale/locale.constant-ca_ES.json | 16 +-- .../assets/locale/locale.constant-cs_CZ.json | 16 +-- .../assets/locale/locale.constant-de_DE.json | 14 +-- .../assets/locale/locale.constant-el_GR.json | 12 +-- .../assets/locale/locale.constant-en_US.json | 16 +-- .../assets/locale/locale.constant-es_ES.json | 16 +-- .../assets/locale/locale.constant-fa_IR.json | 12 +-- .../assets/locale/locale.constant-fr_FR.json | 16 +-- .../assets/locale/locale.constant-it_IT.json | 10 +- .../assets/locale/locale.constant-ja_JP.json | 8 +- .../assets/locale/locale.constant-ka_GE.json | 12 +-- .../assets/locale/locale.constant-ko_KR.json | 12 +-- .../assets/locale/locale.constant-lv_LV.json | 12 +-- .../assets/locale/locale.constant-pt_BR.json | 12 +-- .../assets/locale/locale.constant-ro_RO.json | 12 +-- .../assets/locale/locale.constant-ru_RU.json | 12 +-- .../assets/locale/locale.constant-sl_SI.json | 12 +-- .../assets/locale/locale.constant-tr_TR.json | 16 +-- .../assets/locale/locale.constant-uk_UA.json | 12 +-- .../assets/locale/locale.constant-zh_CN.json | 16 +-- .../assets/locale/locale.constant-zh_TW.json | 16 +-- 37 files changed, 341 insertions(+), 215 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java index d756541902..6d82479b9b 100644 --- a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java +++ b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java @@ -236,6 +236,7 @@ public class ThingsboardInstallService { case "3.4.3": log.info("Upgrading ThingsBoard from version 3.4.3 to 3.5.0 ..."); databaseEntitiesUpgradeService.upgradeDatabase("3.4.3"); + dataUpdateService.updateData("3.4.3"); log.info("Updating system data..."); systemDataLoaderService.updateSystemWidgets(); break; diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index 13f8672d67..e6c37d0c08 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -16,6 +16,7 @@ package org.thingsboard.server.service.install.update; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -30,6 +31,7 @@ import org.thingsboard.rule.engine.flow.TbRuleChainInputNode; import org.thingsboard.rule.engine.flow.TbRuleChainInputNodeConfiguration; import org.thingsboard.rule.engine.profile.TbDeviceProfileNode; import org.thingsboard.rule.engine.profile.TbDeviceProfileNodeConfiguration; +import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.DataConstants; import org.thingsboard.server.common.data.EntityView; import org.thingsboard.server.common.data.Tenant; @@ -38,6 +40,7 @@ import org.thingsboard.server.common.data.alarm.Alarm; import org.thingsboard.server.common.data.alarm.AlarmInfo; import org.thingsboard.server.common.data.alarm.AlarmQuery; import org.thingsboard.server.common.data.alarm.AlarmSeverity; +import org.thingsboard.server.common.data.id.DashboardId; import org.thingsboard.server.common.data.id.EntityViewId; import org.thingsboard.server.common.data.id.RuleChainId; import org.thingsboard.server.common.data.id.RuleNodeId; @@ -65,6 +68,7 @@ import org.thingsboard.server.common.data.tenant.profile.TenantProfileQueueConfi import org.thingsboard.server.dao.DaoUtil; import org.thingsboard.server.dao.alarm.AlarmDao; import org.thingsboard.server.dao.audit.AuditLogDao; +import org.thingsboard.server.dao.dashboard.DashboardService; import org.thingsboard.server.dao.edge.EdgeEventDao; import org.thingsboard.server.dao.entity.EntityService; import org.thingsboard.server.dao.entityview.EntityViewService; @@ -110,6 +114,9 @@ public class DefaultDataUpdateService implements DataUpdateService { @Autowired private EntityViewService entityViewService; + @Autowired + private DashboardService dashboardService; + @Autowired private TimeseriesService tsService; @@ -203,6 +210,10 @@ public class DefaultDataUpdateService implements DataUpdateService { log.info("Skipping edge events migration"); } break; + case "3.4.3": + log.info("Updating data from version 3.4.3 to 3.5.0 ..."); + tenantsDashboardsFiltersUpdater.updateEntities(); + break; default: throw new RuntimeException("Unable to update data, unsupported fromVersion: " + fromVersion); } @@ -681,4 +692,93 @@ public class DefaultDataUpdateService implements DataUpdateService { } } + private final PaginatedUpdater tenantsDashboardsFiltersUpdater = + new PaginatedUpdater<>() { + + @Override + protected String getName() { + return "Tenants dashboards filters updater"; + } + + @Override + protected boolean forceReportTotal() { + return true; + } + + @Override + protected PageData findEntities(String region, PageLink pageLink) { + return tenantService.findTenants(pageLink); + } + + @Override + protected void updateEntity(Tenant tenant) { + updateTenantDashboardsFilters(tenant.getId()); + } + }; + + private void updateTenantDashboardsFilters(TenantId tenantId) { + PageLink pageLink = new PageLink(100); + PageData pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink); + boolean hasNext = true; + while (hasNext) { + List>> updateFutures = new ArrayList<>(); + for (DashboardInfo dashboardInfo : pageData.getData()) { + updateFutures.add(updateDashboardFilters(tenantId, dashboardInfo)); + } + + try { + Futures.allAsList(updateFutures).get(); + } catch (InterruptedException | ExecutionException e) { + log.error("Failed to update dashboards filters", e); + } + + if (pageData.hasNext()) { + pageLink = pageLink.nextPageLink(); + pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink); + } else { + hasNext = false; + } + } + } + + private ListenableFuture> updateDashboardFilters(TenantId tenantId, DashboardInfo dashboardInfo) { + DashboardId dashboardId = dashboardInfo.getId(); + return Futures.transform(dashboardService.findDashboardByIdAsync(tenantId, dashboardId), dashboard -> { + if (dashboard == null || dashboard.getConfiguration() == null) { + return null; + } + try { + JsonNode configuration = dashboard.getConfiguration(); + JsonNode entityAliases = configuration.get("entityAliases"); + if (entityAliases == null) { + return null; + } + for (JsonNode entityAlias : entityAliases) { + JsonNode filter = entityAlias.get("filter"); + updateFilterIfRequired(filter, "assetType", "assetType", "assetTypes"); + updateFilterIfRequired(filter, "deviceType", "deviceType", "deviceTypes"); + updateFilterIfRequired(filter, "entityViewType", "entityViewType", "entityViewTypes"); + updateFilterIfRequired(filter, "edgeType", "edgeType", "edgeTypes"); + } + dashboardService.saveDashboard(dashboard); + } catch (Exception e) { + log.warn("Failed to update dashboard filters. Dashboard {} ", dashboard, e); + } + return null; + }, MoreExecutors.directExecutor()); + } + + private static void updateFilterIfRequired(JsonNode filter, String filterType, String oldParameterName, String newParameterName) { + if (filter == null || filter.get("type") == null) { + return; + } + if (filterType.equals(filter.get("type").asText())) { + if (filter.get(oldParameterName) != null) { + ArrayNode arrayNode = JacksonUtil.OBJECT_MAPPER.createArrayNode(); + arrayNode.add(filter.get(oldParameterName).asText()); + ((ObjectNode) filter).set(newParameterName, arrayNode); + ((ObjectNode) filter).remove(oldParameterName); + } + } + } } diff --git a/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java index aeebc7bfee..eadccc610f 100644 --- a/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java @@ -51,6 +51,7 @@ import org.thingsboard.server.common.data.query.TsValue; import org.thingsboard.server.common.data.security.Authority; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; @@ -103,7 +104,7 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe Thread.sleep(1); } DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityCountQuery countQuery = new EntityCountQuery(filter); @@ -111,11 +112,11 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe Long count = doPostWithResponse("/api/entitiesQuery/count", countQuery, Long.class); Assert.assertEquals(97, count.longValue()); - filter.setDeviceType("unknown"); + filter.setDeviceTypes(List.of("unknown")); count = doPostWithResponse("/api/entitiesQuery/count", countQuery, Long.class); Assert.assertEquals(0, count.longValue()); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter("Device1"); count = doPostWithResponse("/api/entitiesQuery/count", countQuery, Long.class); @@ -152,7 +153,7 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe } DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -253,7 +254,7 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe Thread.sleep(1000); DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -332,7 +333,7 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); KeyFilter highTemperatureFilter = new KeyFilter(); @@ -387,7 +388,7 @@ public abstract class BaseEntityQueryControllerTest extends AbstractControllerTe @Test public void givenInvalidEntityDataPageLink_thenReturnError() throws Exception { DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); String invalidSortProperty = "created(Time)"; diff --git a/application/src/test/java/org/thingsboard/server/controller/BaseEntityViewControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/BaseEntityViewControllerTest.java index 7a9d8f69a4..5aa666106f 100644 --- a/application/src/test/java/org/thingsboard/server/controller/BaseEntityViewControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/BaseEntityViewControllerTest.java @@ -584,7 +584,7 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes @Test public void testGetTelemetryWhenEntityViewTimeRangeInsideTimestampRange() throws Exception { - DeviceTypeFilter dtf = new DeviceTypeFilter(testDevice.getType(), testDevice.getName()); + DeviceTypeFilter dtf = new DeviceTypeFilter(List.of(testDevice.getType()), testDevice.getName()); List tsKeys = List.of("tsKey1", "tsKey2", "tsKey3"); DeviceCredentials deviceCredentials = doGet("/api/device/" + testDevice.getId().getId() + "/credentials", DeviceCredentials.class); @@ -683,7 +683,7 @@ public abstract class BaseEntityViewControllerTest extends AbstractControllerTes } private Set putAttributesAndWait(String stringKV, Set expectedKeySet) throws Exception { - DeviceTypeFilter dtf = new DeviceTypeFilter(testDevice.getType(), testDevice.getName()); + DeviceTypeFilter dtf = new DeviceTypeFilter(List.of(testDevice.getType()), testDevice.getName()); List keysToSubscribe = expectedKeySet.stream() .map(key -> new EntityKey(EntityKeyType.CLIENT_ATTRIBUTE, key)) .collect(Collectors.toList()); diff --git a/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java b/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java index 09fb5c505d..4cfae948fa 100644 --- a/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/BaseWebsocketApiTest.java @@ -82,7 +82,7 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest { device.setType("default"); device.setLabel("testLabel" + (int) (Math.random() * 1000)); device = doPost("/api/device", device, Device.class); - dtf = new DeviceTypeFilter(device.getType(), device.getName()); + dtf = new DeviceTypeFilter(List.of(device.getType()), device.getName()); } @After @@ -190,7 +190,7 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest { Assert.assertEquals(1, update1.getCmdId()); Assert.assertEquals(1, update1.getCount()); - DeviceTypeFilter dtf2 = new DeviceTypeFilter("non-existing-device-type", "D"); + DeviceTypeFilter dtf2 = new DeviceTypeFilter(List.of("non-existing-device-type"), "D"); EntityCountQuery edq2 = new EntityCountQuery(dtf2, Collections.emptyList()); EntityCountCmd cmd2 = new EntityCountCmd(2, edq2); @@ -209,7 +209,7 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest { highTemperatureFilter.setPredicate(predicate); highTemperatureFilter.setValueType(EntityKeyValueType.NUMERIC); - DeviceTypeFilter dtf3 = new DeviceTypeFilter("default", "D"); + DeviceTypeFilter dtf3 = new DeviceTypeFilter(List.of("default"), "D"); EntityCountQuery edq3 = new EntityCountQuery(dtf3, Collections.singletonList(highTemperatureFilter)); EntityCountCmd cmd3 = new EntityCountCmd(3, edq3); getWsClient().send(cmd3); @@ -226,7 +226,7 @@ public abstract class BaseWebsocketApiTest extends AbstractControllerTest { highTemperatureFilter2.setPredicate(predicate2); highTemperatureFilter2.setValueType(EntityKeyValueType.NUMERIC); - DeviceTypeFilter dtf4 = new DeviceTypeFilter("default", "D"); + DeviceTypeFilter dtf4 = new DeviceTypeFilter(List.of("default"), "D"); EntityCountQuery edq4 = new EntityCountQuery(dtf4, Collections.singletonList(highTemperatureFilter2)); EntityCountCmd cmd4 = new EntityCountCmd(4, edq4); diff --git a/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/attributes/AbstractMqttAttributesIntegrationTest.java b/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/attributes/AbstractMqttAttributesIntegrationTest.java index 2c0278f689..60af3b66f7 100644 --- a/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/attributes/AbstractMqttAttributesIntegrationTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/mqtt/mqttv3/attributes/AbstractMqttAttributesIntegrationTest.java @@ -351,7 +351,7 @@ public abstract class AbstractMqttAttributesIntegrationTest extends AbstractMqtt protected void processProtoTestRequestAttributesValuesFromTheServer(String attrPubTopic, String attrSubTopic, String attrReqTopicPrefix) throws Exception { MqttTestClient client = new MqttTestClient(); client.connectAndWait(accessToken); - DeviceTypeFilter dtf = new DeviceTypeFilter(savedDevice.getType(), savedDevice.getName()); + DeviceTypeFilter dtf = new DeviceTypeFilter(List.of(savedDevice.getType()), savedDevice.getName()); String clientKeysStr = "clientStr,clientBool,clientDbl,clientLong,clientJson"; String sharedKeysStr = "sharedStr,sharedBool,sharedDbl,sharedLong,sharedJson"; List clientKeysList = List.of(clientKeysStr.split(",")); diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java index 9b875cf42c..7bb7da2f6e 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java @@ -17,6 +17,8 @@ package org.thingsboard.server.common.data.query; import lombok.Data; +import java.util.List; + @Data public class AssetTypeFilter implements EntityFilter { @@ -25,7 +27,7 @@ public class AssetTypeFilter implements EntityFilter { return EntityFilterType.ASSET_TYPE; } - private String assetType; + private List assetTypes; private String assetNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index 0c502dff8b..a1efe0ccb2 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -19,6 +19,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor @Data @@ -29,7 +31,7 @@ public class DeviceTypeFilter implements EntityFilter { return EntityFilterType.DEVICE_TYPE; } - private String deviceType; + private List deviceTypes; private String deviceNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index 8a1f325354..38294e14ca 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -17,6 +17,8 @@ package org.thingsboard.server.common.data.query; import lombok.Data; +import java.util.List; + @Data public class EdgeTypeFilter implements EntityFilter { @@ -25,7 +27,7 @@ public class EdgeTypeFilter implements EntityFilter { return EntityFilterType.EDGE_TYPE; } - private String edgeType; + private List edgeTypes; private String edgeNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index b9c5e00767..e52ac2f002 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -17,6 +17,8 @@ package org.thingsboard.server.common.data.query; import lombok.Data; +import java.util.List; + @Data public class EntityViewTypeFilter implements EntityFilter { @@ -25,7 +27,7 @@ public class EntityViewTypeFilter implements EntityFilter { return EntityFilterType.ENTITY_VIEW_TYPE; } - private String entityViewType; + private List entityViewTypes; private String entityViewNameFilter; diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java index 681efe4829..a8c4ab6912 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java @@ -809,31 +809,31 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { } private String typeQuery(QueryContext ctx, EntityFilter filter) { - String type; + List types; String name; switch (filter.getType()) { case ASSET_TYPE: - type = ((AssetTypeFilter) filter).getAssetType(); + types = ((AssetTypeFilter) filter).getAssetTypes(); name = ((AssetTypeFilter) filter).getAssetNameFilter(); break; case DEVICE_TYPE: - type = ((DeviceTypeFilter) filter).getDeviceType(); + types = ((DeviceTypeFilter) filter).getDeviceTypes(); name = ((DeviceTypeFilter) filter).getDeviceNameFilter(); break; case ENTITY_VIEW_TYPE: - type = ((EntityViewTypeFilter) filter).getEntityViewType(); + types = ((EntityViewTypeFilter) filter).getEntityViewTypes(); name = ((EntityViewTypeFilter) filter).getEntityViewNameFilter(); break; case EDGE_TYPE: - type = ((EdgeTypeFilter) filter).getEdgeType(); + types = ((EdgeTypeFilter) filter).getEdgeTypes(); name = ((EdgeTypeFilter) filter).getEdgeNameFilter(); break; default: throw new RuntimeException("Not supported!"); } - ctx.addStringParameter("entity_filter_type_query_type", type); + ctx.addStringListParameter("entity_filter_type_query_types", types); ctx.addStringParameter("entity_filter_type_query_name", name); - return "e.type = :entity_filter_type_query_type and lower(e.search_text) like lower(concat(:entity_filter_type_query_name, '%%'))"; + return "e.type in (:entity_filter_type_query_types) and lower(e.search_text) like lower(concat(:entity_filter_type_query_name, '%%'))"; } public static EntityType resolveEntityType(EntityFilter entityFilter) { diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceTest.java index e2003ed7b2..2054945285 100644 --- a/dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceTest.java +++ b/dao/src/test/java/org/thingsboard/server/dao/service/BaseEntityServiceTest.java @@ -140,7 +140,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { } DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityCountQuery countQuery = new EntityCountQuery(filter); @@ -148,11 +148,11 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { long count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); Assert.assertEquals(97, count); - filter.setDeviceType("unknown"); + filter.setDeviceTypes(List.of("unknown")); count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); Assert.assertEquals(0, count); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter("Device1"); count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); Assert.assertEquals(11, count); @@ -244,7 +244,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { } EdgeTypeFilter filter = new EdgeTypeFilter(); - filter.setEdgeType("default"); + filter.setEdgeTypes(List.of("default")); filter.setEdgeNameFilter(""); EntityCountQuery countQuery = new EntityCountQuery(filter); @@ -252,11 +252,11 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { long count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); Assert.assertEquals(97, count); - filter.setEdgeType("unknown"); + filter.setEdgeTypes(List.of("unknown")); count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); Assert.assertEquals(0, count); - filter.setEdgeType("default"); + filter.setEdgeTypes(List.of("default")); filter.setEdgeNameFilter("Edge1"); count = entityService.countEntitiesByQuery(tenantId, new CustomerId(CustomerId.NULL_UUID), countQuery); Assert.assertEquals(11, count); @@ -822,7 +822,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { } DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -992,7 +992,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { private EntityDataQuery createDeviceSearchQuery(String deviceField, StringOperation operation, String searchQuery) { DeviceTypeFilter deviceTypeFilter = new DeviceTypeFilter(); - deviceTypeFilter.setDeviceType("default"); + deviceTypeFilter.setDeviceTypes(List.of("default")); deviceTypeFilter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -1057,7 +1057,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { Futures.allAsList(attributeFutures).get(); DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -1157,7 +1157,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { Futures.allAsList(attributeFutures).get(); DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -1303,7 +1303,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { Futures.allAsList(timeseriesFutures).get(); DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -1435,7 +1435,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { Futures.allAsList(attributeFutures).get(); DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -1567,7 +1567,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { } DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder( @@ -1684,7 +1684,7 @@ public abstract class BaseEntityServiceTest extends AbstractServiceTest { } DeviceTypeFilter filter = new DeviceTypeFilter(); - filter.setDeviceType("default"); + filter.setDeviceTypes(List.of("default")); filter.setDeviceNameFilter(""); EntityDataSortOrder sortOrder = new EntityDataSortOrder(new EntityKey(EntityKeyType.ENTITY_FIELD, "name"), EntityDataSortOrder.Direction.DESC); diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-filter-view.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity-filter-view.component.ts index 7ed0a8b3c9..9f4927402e 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-filter-view.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity-filter-view.component.ts @@ -84,47 +84,63 @@ export class EntityFilterViewComponent implements ControlValueAccessor { this.filterDisplayValue = this.translate.instant('alias.filter-type-state-entity-description'); break; case AliasFilterType.assetType: - const assetType = this.filter.assetType; + const assetTypesQuoted = []; + this.filter.assetTypes.forEach((filterAssetType) => { + assetTypesQuoted.push(`'${filterAssetType}'`); + }); + const assetTypes = assetTypesQuoted.join(', '); prefix = this.filter.assetNameFilter; if (prefix && prefix.length) { this.filterDisplayValue = this.translate.instant('alias.filter-type-asset-type-and-name-description', - {assetType, prefix}); + {assetTypes, prefix}); } else { this.filterDisplayValue = this.translate.instant('alias.filter-type-asset-type-description', - {assetType}); + {assetTypes}); } break; case AliasFilterType.deviceType: - const deviceType = this.filter.deviceType; + const deviceTypesQuoted = []; + this.filter.deviceTypes.forEach((filterDeviceType) => { + deviceTypesQuoted.push(`'${filterDeviceType}'`); + }); + const deviceTypes = deviceTypesQuoted.join(', '); prefix = this.filter.deviceNameFilter; if (prefix && prefix.length) { this.filterDisplayValue = this.translate.instant('alias.filter-type-device-type-and-name-description', - {deviceType, prefix}); + {deviceTypes, prefix}); } else { this.filterDisplayValue = this.translate.instant('alias.filter-type-device-type-description', - {deviceType}); + {deviceTypes}); } break; case AliasFilterType.edgeType: - const edgeType = this.filter.edgeType; + const edgeTypesQuoted = []; + this.filter.edgeTypes.forEach((filterEdgeType) => { + edgeTypesQuoted.push(`'${filterEdgeType}'`); + }); + const edgeTypes = edgeTypesQuoted.join(', '); prefix = this.filter.edgeNameFilter; if (prefix && prefix.length) { this.filterDisplayValue = this.translate.instant('alias.filter-type-edge-type-and-name-description', - {edgeType, prefix}); + {edgeTypes, prefix}); } else { this.filterDisplayValue = this.translate.instant('alias.filter-type-edge-type-description', - {edgeType}); + {edgeTypes}); } break; case AliasFilterType.entityViewType: - const entityView = this.filter.entityViewType; + const entityViewTypesQuoted = []; + this.filter.entityViewTypes.forEach((entityViewType) => { + entityViewTypesQuoted.push(`'${entityViewType}'`); + }); + const entityViewTypes = entityViewTypesQuoted.join(', '); prefix = this.filter.entityViewNameFilter; if (prefix && prefix.length) { this.filterDisplayValue = this.translate.instant('alias.filter-type-entity-view-type-and-name-description', - {entityView, prefix}); + {entityViewTypes, prefix}); } else { this.filterDisplayValue = this.translate.instant('alias.filter-type-entity-view-type-description', - {entityView}); + {entityViewTypes}); } break; case AliasFilterType.relationsQuery: diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html index 7886aefe1e..40b860033d 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html +++ b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html @@ -83,10 +83,10 @@ - - + + asset.name-starts-with - - + + device.name-starts-with - - + + entity-view.name-starts-with - - + + edge.name-starts-with diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts index 2fcb4ecaa7..1f59e622d2 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts @@ -136,25 +136,25 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit { break; case AliasFilterType.assetType: this.filterFormGroup = this.fb.group({ - assetType: [filter ? filter.assetType : null, [Validators.required]], + assetTypes: [filter ? filter.assetTypes : null, [Validators.required]], assetNameFilter: [filter ? filter.assetNameFilter : '', []], }); break; case AliasFilterType.deviceType: this.filterFormGroup = this.fb.group({ - deviceType: [filter ? filter.deviceType : null, [Validators.required]], + deviceTypes: [filter ? filter.deviceTypes : null, [Validators.required]], deviceNameFilter: [filter ? filter.deviceNameFilter : '', []], }); break; case AliasFilterType.edgeType: this.filterFormGroup = this.fb.group({ - edgeType: [filter ? filter.edgeType : null, [Validators.required]], + edgeTypes: [filter ? filter.edgeTypes : null, [Validators.required]], edgeNameFilter: [filter ? filter.edgeNameFilter : '', []], }); break; case AliasFilterType.entityViewType: this.filterFormGroup = this.fb.group({ - entityViewType: [filter ? filter.entityViewType : null, [Validators.required]], + entityViewTypes: [filter ? filter.entityViewTypes : null, [Validators.required]], entityViewNameFilter: [filter ? filter.entityViewNameFilter : '', []], }); break; diff --git a/ui-ngx/src/app/shared/models/alias.models.ts b/ui-ngx/src/app/shared/models/alias.models.ts index 418e549244..4790a24b7b 100644 --- a/ui-ngx/src/app/shared/models/alias.models.ts +++ b/ui-ngx/src/app/shared/models/alias.models.ts @@ -86,22 +86,22 @@ export interface StateEntityFilter { } export interface AssetTypeFilter { - assetType?: string; + assetTypes?: string[]; assetNameFilter?: string; } export interface DeviceTypeFilter { - deviceType?: string; + deviceTypes?: string[]; deviceNameFilter?: string; } export interface EdgeTypeFilter { - edgeType?: string; + edgeTypes?: string[]; edgeNameFilter?: string; } export interface EntityViewFilter { - entityViewType?: string; + entityViewTypes?: string[]; entityViewNameFilter?: string; } diff --git a/ui-ngx/src/assets/locale/locale.constant-ca_ES.json b/ui-ngx/src/assets/locale/locale.constant-ca_ES.json index 3d6f2c163c..4e74897623 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ca_ES.json +++ b/ui-ngx/src/assets/locale/locale.constant-ca_ES.json @@ -497,17 +497,17 @@ "filter-type-state-entity-owner": "Propietari de l'entitat des de l'estat del tauler", "filter-type-state-entity-owner-description": "Propietari de l'entitat presa dels paràmetres d'estat del tauler de control", "filter-type-asset-type": "Tipus d'actiu", - "filter-type-asset-type-description": "Actius del tipus '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Actius del tipus '{{assetType}}' i el nom del qual comenci per '{{prefix}}'", + "filter-type-asset-type-description": "Actius del tipus '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Actius del tipus '{{assetTypes}}' i el nom del qual comenci per '{{prefix}}'", "filter-type-device-type": "Tipus de dispositiu", - "filter-type-device-type-description": "Dispositius de tipus '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Dispositius de tipus '{{deviceType}}' i el nom del qual comenci per '{{prefix}}'", + "filter-type-device-type-description": "Dispositius de tipus '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Dispositius de tipus '{{deviceTypes}}' i el nom del qual comenci per '{{prefix}}'", "filter-type-entity-view-type": "Tipus de vista d'entitat", - "filter-type-entity-view-type-description": "Vistes d'entitat del tipus '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Vistes d'entitat del tipus '{{entityView}}' i el nom del qual comenci per '{{prefix}}'", + "filter-type-entity-view-type-description": "Vistes d'entitat del tipus '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Vistes d'entitat del tipus '{{entityViewTypes}}' i el nom del qual comenci per '{{prefix}}'", "filter-type-edge-type": "Tipus de vora", - "filter-type-edge-type-description": "Vores del tipus '{{edgeType}}'", - "filter-type-edge-type-and-name-description": "Vores del tipus '{{edgeType}}' i el nom del qual comenci per '{{prefix}}'", + "filter-type-edge-type-description": "Vores del tipus '{{edgeTypes}}'", + "filter-type-edge-type-and-name-description": "Vores del tipus '{{edgeTypes}}' i el nom del qual comenci per '{{prefix}}'", "filter-type-relations-query": "Consulta de relacions", "filter-type-relations-query-description": "{{entities}} que tenen {{relationType}} relació {{direction}} {{rootEntity}}", "filter-type-edge-search-query": "Consultar cerca de vora", diff --git a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json index a194bf3a7b..6fde89043d 100644 --- a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json +++ b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json @@ -324,17 +324,17 @@ "filter-type-state-entity": "Entita ze stavu dashboardu", "filter-type-state-entity-description": "Entita převzata z parametrů stavu dashboardu", "filter-type-asset-type": "Typ aktiva", - "filter-type-asset-type-description": "Aktiva typu '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Aktiva typu '{{assetType}}' s názvem začínajícím '{{prefix}}'", + "filter-type-asset-type-description": "Aktiva typu '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Aktiva typu '{{assetTypes}}' s názvem začínajícím '{{prefix}}'", "filter-type-device-type": "Typ zařízení", - "filter-type-device-type-description": "Zařízení typu '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Zařízení typu '{{deviceType}}' s názvem začínajícím '{{prefix}}'", + "filter-type-device-type-description": "Zařízení typu '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Zařízení typu '{{deviceTypes}}' s názvem začínajícím '{{prefix}}'", "filter-type-entity-view-type": "Typ entitního pohledu", - "filter-type-entity-view-type-description": "Entitní pohledy typu '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Entitní pohledy typu '{{entityView}}' s názvem začínajícím '{{prefix}}'", + "filter-type-entity-view-type-description": "Entitní pohledy typu '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Entitní pohledy typu '{{entityViewTypes}}' s názvem začínajícím '{{prefix}}'", "filter-type-edge-type": "Typ edge", - "filter-type-edge-type-description": "Edge typu '{{edgeType}}'", - "filter-type-edge-type-and-name-description": "Edge typu '{{edgeType}}' s názvem začínajícím '{{prefix}}'", + "filter-type-edge-type-description": "Edge typu '{{edgeTypes}}'", + "filter-type-edge-type-and-name-description": "Edge typu '{{edgeTypes}}' s názvem začínajícím '{{prefix}}'", "filter-type-relations-query": "Dotaz na vztahy", "filter-type-relations-query-description": "{{entities}} se {{relationType}} vztahem {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Dotaz na vyhledání aktiva", diff --git a/ui-ngx/src/assets/locale/locale.constant-de_DE.json b/ui-ngx/src/assets/locale/locale.constant-de_DE.json index d60ed055ad..68dde0b498 100644 --- a/ui-ngx/src/assets/locale/locale.constant-de_DE.json +++ b/ui-ngx/src/assets/locale/locale.constant-de_DE.json @@ -212,16 +212,16 @@ "filter-type-state-entity": "Entität aus dem Dashboard Status", "filter-type-state-entity-description": "Entität aus den Dashboard Status Parametern", "filter-type-asset-type": "Objekttyp", - "filter-type-asset-type-description": "Objekte vom Typ '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Objekte vom Typ '{{assetType}}' und Name beginnend mit '{{prefix}}'", + "filter-type-asset-type-description": "Objekte vom Typ '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Objekte vom Typ '{{assetTypes}}' und Name beginnend mit '{{prefix}}'", "filter-type-device-type": "Gerätetyp", - "filter-type-device-type-description": "Geräte vom Typ '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Geräte vom Typ '{{deviceType}}' und Name beginnend mit '{{prefix}}'", + "filter-type-device-type-description": "Geräte vom Typ '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Geräte vom Typ '{{deviceTypes}}' und Name beginnend mit '{{prefix}}'", "filter-type-entity-view-type": "Entitätsansichtstyp", - "filter-type-entity-view-type-description": "Entitätsansichten vom Typ '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Entitätsansichten vom Typ '{{entityView}}' und Name beginnend mit '{{prefix}}'", + "filter-type-entity-view-type-description": "Entitätsansichten vom Typ '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Entitätsansichten vom Typ '{{entityViewTypes}}' und Name beginnend mit '{{prefix}}'", "filter-type-edge-type": "Randtyp", - "filter-type-edge-type-description": "Rand vom Typ '{{edgeType}}'", + "filter-type-edge-type-description": "Rand vom Typ '{{edgeTypes}}'", "filter-type-relations-query": "Beziehungsabfrage", "filter-type-relations-query-description": "{{entities}} mit {{relationType}} Beziehung {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Objektabfrage", diff --git a/ui-ngx/src/assets/locale/locale.constant-el_GR.json b/ui-ngx/src/assets/locale/locale.constant-el_GR.json index b66e02ba26..e6191b90ea 100644 --- a/ui-ngx/src/assets/locale/locale.constant-el_GR.json +++ b/ui-ngx/src/assets/locale/locale.constant-el_GR.json @@ -179,14 +179,14 @@ "filter-type-state-entity": "Οντότητα από την κατάσταση του dashboard", "filter-type-state-entity-description": "Οντότητα που λαμβάνεται από τις παραμέτρους κατάστασης του dashboard", "filter-type-asset-type": "Τύπος Asset", - "filter-type-asset-type-description": "Assets του τύπου '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Assets του τύπου '{{assetType}}' με όνομα που αρχίζει από '{{prefix}}'", + "filter-type-asset-type-description": "Assets του τύπου '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Assets του τύπου '{{assetTypes}}' με όνομα που αρχίζει από '{{prefix}}'", "filter-type-device-type": "Τύπος Συσκευής", - "filter-type-device-type-description": "Συσκευές του τύπου '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Συσκευές του τύπου '{{deviceType}}' με όνομα που αρχίζει από '{{prefix}}'", + "filter-type-device-type-description": "Συσκευές του τύπου '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Συσκευές του τύπου '{{deviceTypes}}' με όνομα που αρχίζει από '{{prefix}}'", "filter-type-entity-view-type": "Τύπος προβολής Οντοτήτων", - "filter-type-entity-view-type-description": "Τύπος προβολής Οντοτήτων '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Τύπος προβολής Οντοτήτων '{{entityView}}' με όνομα που αρχίζει από '{{prefix}}'", + "filter-type-entity-view-type-description": "Τύπος προβολής Οντοτήτων '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Τύπος προβολής Οντοτήτων '{{entityViewTypes}}' με όνομα που αρχίζει από '{{prefix}}'", "filter-type-relations-query": "Ερώτημα Σχέσεων", "filter-type-relations-query-description": "{{entities}} που έχουν σχέση {{relationType}} {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Ερώτημα αναζήτησης Asset", diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 949ebd4d23..24e20d7404 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -489,17 +489,17 @@ "filter-type-state-entity": "Entity from dashboard state", "filter-type-state-entity-description": "Entity taken from dashboard state parameters", "filter-type-asset-type": "Asset type", - "filter-type-asset-type-description": "Assets of type '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Assets of type '{{assetType}}' and with name starting with '{{prefix}}'", + "filter-type-asset-type-description": "Assets of type '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Assets of type '{{assetTypes}}' and with name starting with '{{prefix}}'", "filter-type-device-type": "Device type", - "filter-type-device-type-description": "Devices of type '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Devices of type '{{deviceType}}' and with name starting with '{{prefix}}'", + "filter-type-device-type-description": "Devices of type '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Devices of types '{{deviceTypes}}' and with name starting with '{{prefix}}'", "filter-type-entity-view-type": "Entity View type", - "filter-type-entity-view-type-description": "Entity Views of type '{{entityViewType}}'", - "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityViewType}}' and with name starting with '{{prefix}}'", + "filter-type-entity-view-type-description": "Entity Views of type '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityViewTypes}}' and with name starting with '{{prefix}}'", "filter-type-edge-type": "Edge type", - "filter-type-edge-type-description": "Edges of type '{{edgeType}}'", - "filter-type-edge-type-and-name-description": "Edges of type '{{edgeType}}' and with name starting with '{{prefix}}'", + "filter-type-edge-type-description": "Edges of type '{{edgeTypes}}'", + "filter-type-edge-type-and-name-description": "Edges of type '{{edgeTypes}}' and with name starting with '{{prefix}}'", "filter-type-relations-query": "Relations query", "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Asset search query", diff --git a/ui-ngx/src/assets/locale/locale.constant-es_ES.json b/ui-ngx/src/assets/locale/locale.constant-es_ES.json index 68305d1352..7e5dd181fa 100644 --- a/ui-ngx/src/assets/locale/locale.constant-es_ES.json +++ b/ui-ngx/src/assets/locale/locale.constant-es_ES.json @@ -465,17 +465,17 @@ "filter-type-state-entity": "Entidad desde estado de panel", "filter-type-state-entity-description": "Entidad tomada de los parámetros de panel", "filter-type-asset-type": "Tipo de activo", - "filter-type-asset-type-description": "Activos del tipo '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Activos del tipo '{{assetType}}' y cuyo nombre comience por '{{prefix}}'", + "filter-type-asset-type-description": "Activos del tipo '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Activos del tipo '{{assetTypes}}' y cuyo nombre comience por '{{prefix}}'", "filter-type-device-type": "Tipo de dispositivo", - "filter-type-device-type-description": "Dispositivos de tipo '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Dispositivos de tipo '{{deviceType}}' y cuyo nombre comience por '{{prefix}}'", + "filter-type-device-type-description": "Dispositivos de tipo '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Dispositivos de tipo '{{deviceTypes}}' y cuyo nombre comience por '{{prefix}}'", "filter-type-entity-view-type": "Tipo de vista de entidad", - "filter-type-entity-view-type-description": "Vistas de entidad del tipo '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Vistas de entidad del tipo '{{entityView}}' y cuyo nombre comience por '{{prefix}}'", + "filter-type-entity-view-type-description": "Vistas de entidad del tipo '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Vistas de entidad del tipo '{{entityViewTypes}}' y cuyo nombre comience por '{{prefix}}'", "filter-type-edge-type": "Tipo de borde", - "filter-type-edge-type-description": "Bordes del tipo '{{edgeType}}'", - "filter-type-edge-type-and-name-description": "Vistas de entidad del tipo '{{entityViewType}}' y cuyo nombre comience por '{{prefix}}'", + "filter-type-edge-type-description": "Bordes del tipo '{{edgeTypes}}'", + "filter-type-edge-type-and-name-description": "Vistas de entidad del tipo '{{edgeTypes}}' y cuyo nombre comience por '{{prefix}}'", "filter-type-relations-query": "Consulta de relaciones", "filter-type-relations-query-description": "{{entities}} que tienen {{relationType}} relación {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Búsqueda de activos", diff --git a/ui-ngx/src/assets/locale/locale.constant-fa_IR.json b/ui-ngx/src/assets/locale/locale.constant-fa_IR.json index b0eef3fa2c..78813dddde 100644 --- a/ui-ngx/src/assets/locale/locale.constant-fa_IR.json +++ b/ui-ngx/src/assets/locale/locale.constant-fa_IR.json @@ -154,14 +154,14 @@ "filter-type-state-entity": "موجودي از وضعيت داشبورد", "filter-type-state-entity-description": "پارامترهاي موجودي گرفته شده از وضعيت داشبورد", "filter-type-asset-type": "نوع دارايي", - "filter-type-asset-type-description": "'{{assetType}}' دارايي هاي نوع", - "filter-type-asset-type-and-name-description": ".شروع مي شود '{{prefix}}' که نامشان با '{{assetType}}' دارايي هاي نوع", + "filter-type-asset-type-description": "'{{assetTypes}}' دارايي هاي نوع", + "filter-type-asset-type-and-name-description": ".شروع مي شود '{{prefix}}' که نامشان با '{{assetTypes}}' دارايي هاي نوع", "filter-type-device-type": "نوع دستگاه", - "filter-type-device-type-description": "'{{deviceType}}' دستگاه هاي نوع", - "filter-type-device-type-and-name-description": ".شروع مي شود '{{prefix}}' که نامشان با '{{deviceType}}' دستگاه هاي نوع", + "filter-type-device-type-description": "'{{deviceTypes}}' دستگاه هاي نوع", + "filter-type-device-type-and-name-description": ".شروع مي شود '{{prefix}}' که نامشان با '{{deviceTypes}}' دستگاه هاي نوع", "filter-type-entity-view-type": "نوع نمايش موجودي", - "filter-type-entity-view-type-description": "'{{entityView}}' نمايش هاي موجودي نوع ", - "filter-type-entity-view-type-and-name-description": ".شروع مي شود '{{prefix}}' که نامشان با '{{entityView}}' نمايش هاي موجودي نوع", + "filter-type-entity-view-type-description": "'{{entityViewTypes}}' نمايش هاي موجودي نوع ", + "filter-type-entity-view-type-and-name-description": ".شروع مي شود '{{prefix}}' که نامشان با '{{entityViewTypes}}' نمايش هاي موجودي نوع", "filter-type-relations-query": "پرس و جو درمورد ارتباطات", "filter-type-relations-query-description": ". دارند {{direction}} {{rootEntity}} را {{relationType}} که ارتباط {{entities}}", "filter-type-asset-search-query": "پرس و جو درمورد جستجوي دارايي", diff --git a/ui-ngx/src/assets/locale/locale.constant-fr_FR.json b/ui-ngx/src/assets/locale/locale.constant-fr_FR.json index ce66154f10..b6a32a834f 100644 --- a/ui-ngx/src/assets/locale/locale.constant-fr_FR.json +++ b/ui-ngx/src/assets/locale/locale.constant-fr_FR.json @@ -324,13 +324,13 @@ "filter-type-asset-search-query": "Requête de recherche d'actifs", "filter-type-asset-search-query-description": "Actifs de types {{assetTypes}} ayant {{relationType}} relation {{direction}} {{rootEntity}}", "filter-type-asset-type": "type d'actif", - "filter-type-asset-type-and-name-description": "Actifs de type '{{assetType}}' et dont le nom commence par '{{prefix}}'", - "filter-type-asset-type-description": "Actifs de type '{{assetType}}'", + "filter-type-asset-type-and-name-description": "Actifs de type '{{assetTypes}}' et dont le nom commence par '{{prefix}}'", + "filter-type-asset-type-description": "Actifs de type '{{assetTypes}}'", "filter-type-device-search-query": "Requête de recherche de dispositif", "filter-type-device-search-query-description": "Dispositifs de types {{deviceTypes}} ayant {{relationType}} relation {{direction}} {{rootEntity}}", "filter-type-device-type": "Type de dispositif", - "filter-type-device-type-and-name-description": "Dispositifs de type '{{deviceType}}' et dont le nom commence par '{{prefix}}'", - "filter-type-device-type-description": "Dispositifs de type '{{deviceType}}'", + "filter-type-device-type-and-name-description": "Dispositifs de type '{{deviceTypes}}' et dont le nom commence par '{{prefix}}'", + "filter-type-device-type-description": "Dispositifs de type '{{deviceTypes}}'", "filter-type-entity-list": "Liste d'entités", "filter-type-entity-name": "Nom d'entité", "filter-type-entity-view-search-query": "Requête de recherche vue d'entité", @@ -338,10 +338,10 @@ "filter-type-edge-search-query": "Requête de recherche de Edge", "filter-type-edge-search-query-description": "Edges avec types {{edgeTypes}} qui ont {{relationType}} relation {{direction}} {{rootEntity}}", "filter-type-entity-view-type": "Type de vue d'entité", - "filter-type-entity-view-type-and-name-description": "Vues d'entité de type '{{entityView}}' et dont le nom commence par '{{prefix}}'", - "filter-type-entity-view-type-description": "Vues d'entité de type '{{entityView}}'", + "filter-type-entity-view-type-and-name-description": "Vues d'entité de type '{{entityViewTypes}}' et dont le nom commence par '{{prefix}}'", + "filter-type-entity-view-type-description": "Vues d'entité de type '{{entityViewTypes}}'", "filter-type-edge-type": "Types de Edge", - "filter-type-edge-type-description": "Edges de type '{{edgeType}}'", + "filter-type-edge-type-description": "Edges de type '{{edgeTypes}}'", "filter-type-relations-query": "Interrogation des relations", "filter-type-relations-query-description": "{{entities}} ayant {{relationType}} relation {{direction}} {{rootEntity}}", "filter-type-required": "Le type de filtre est requis.", @@ -359,7 +359,7 @@ "state-entity-parameter-name": "Nom du paramétre d'entité d'état", "unlimited-level": "Niveau illimité", "filter-type-entity-type": "Type d'entité", - "filter-type-edge-type-and-name-description": "Edges de type '{{edgeType}}' et dont le nom commence par '{{prefix}}'", + "filter-type-edge-type-and-name-description": "Edges de type '{{edgeTypes}}' et dont le nom commence par '{{prefix}}'", "filter-type-apiUsageState": "État d'utilisation de l'API", "last-level-relation": "Récupérer uniquement la relation de dernier niveau" }, diff --git a/ui-ngx/src/assets/locale/locale.constant-it_IT.json b/ui-ngx/src/assets/locale/locale.constant-it_IT.json index 52485e3722..95e23543f9 100644 --- a/ui-ngx/src/assets/locale/locale.constant-it_IT.json +++ b/ui-ngx/src/assets/locale/locale.constant-it_IT.json @@ -177,13 +177,13 @@ "filter-type-state-entity-description": "Entità prelevata dai parametri di stato della dashboard", "filter-type-asset-type": "Tipo di Asset", "filter-type-asset-type-description": "Asset di tipo '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Asset di tipo '{{assetType}}' e con un nome che inizia per '{{prefix}}'", + "filter-type-asset-type-and-name-description": "Asset di tipo '{{assetTypes}}' e con un nome che inizia per '{{prefix}}'", "filter-type-device-type": "Tipo di dispositivo", - "filter-type-device-type-description": "Dispositivi di tipo '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Dispositivi di tipo '{{deviceType}}' e con un nome che inizia per '{{prefix}}'", + "filter-type-device-type-description": "Dispositivi di tipo '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Dispositivi di tipo '{{deviceTypes}}' e con un nome che inizia per '{{prefix}}'", "filter-type-entity-view-type": "Tipo vista entità", - "filter-type-entity-view-type-description": "Viste entità di tipo '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Viste entità di tipo '{{entityView}}' e con un nome che inizia per '{{prefix}}'", + "filter-type-entity-view-type-description": "Viste entità di tipo '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Viste entità di tipo '{{entityViewTypes}}' e con un nome che inizia per '{{prefix}}'", "filter-type-relations-query": "Query relazioni", "filter-type-relations-query-description": "{{entities}} che hanno una relazione {{relationType}} {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Query ricerca asset", diff --git a/ui-ngx/src/assets/locale/locale.constant-ja_JP.json b/ui-ngx/src/assets/locale/locale.constant-ja_JP.json index 6420f4fce5..629453f551 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ja_JP.json +++ b/ui-ngx/src/assets/locale/locale.constant-ja_JP.json @@ -149,11 +149,11 @@ "filter-type-state-entity": "ダッシュボード状態からのエンティティ", "filter-type-state-entity-description": "ダッシュボードの状態パラメータから取得されたエンティティ", "filter-type-asset-type": "資産の種類", - "filter-type-asset-type-description": "'{{assetType}}'", - "filter-type-asset-type-and-name-description": "'{{assetType}}''{{prefix}}'", + "filter-type-asset-type-description": "'{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "'{{assetTypes}}''{{prefix}}'", "filter-type-device-type": "デバイスタイプ", - "filter-type-device-type-description": "'{{deviceType}}'", - "filter-type-device-type-and-name-description": "'{{deviceType}}''{{prefix}}'", + "filter-type-device-type-description": "'{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "'{{deviceTypes}}''{{prefix}}'", "filter-type-relations-query": "関係クエリ", "filter-type-relations-query-description": "{{entities}}{{relationType}}{{direction}}{{rootEntity}}", "filter-type-asset-search-query": "資産検索クエリ", diff --git a/ui-ngx/src/assets/locale/locale.constant-ka_GE.json b/ui-ngx/src/assets/locale/locale.constant-ka_GE.json index c33964e3b9..ad6b23c25d 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ka_GE.json +++ b/ui-ngx/src/assets/locale/locale.constant-ka_GE.json @@ -186,14 +186,14 @@ "filter-type-state-entity": "ფილტრის ტიპის სუბიექტი", "filter-type-state-entity-description": "ფილტრის ტიპის სუბიექტის აღწერა", "filter-type-asset-type": "აქტივის ტიპი", - "filter-type-asset-type-description": "აქტივის ტიპის აღწერა '{{assetType}}'", - "filter-type-asset-type-and-name-description": "ტიპის ასეტები '{{assetType}}' და სახელები რომლები იწყება '{{prefix}}'", + "filter-type-asset-type-description": "აქტივის ტიპის აღწერა '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "ტიპის ასეტები '{{assetTypes}}' და სახელები რომლები იწყება '{{prefix}}'", "filter-type-device-type": "მოწყობილობის ტიპი", - "filter-type-device-type-description": "ტიპის მოწყობილობები '{{deviceType}}'", - "filter-type-device-type-and-name-description": "ტიპის მოწყობილობები '{{deviceType}}' რომლების სახელებიც იწყება '{{prefix}}'", + "filter-type-device-type-description": "ტიპის მოწყობილობები '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "ტიპის მოწყობილობები '{{deviceTypes}}' რომლების სახელებიც იწყება '{{prefix}}'", "filter-type-entity-view-type": "ობიექტის მოწყობილობის ტიპი", - "filter-type-entity-view-type-description": "ობიექტის ტიპის ვარიანტები '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "ობიექტის ტიპის განსაზღვრება '{{entityView}}' და დასახელება რომელიც იწყება '{{prefix}}'", + "filter-type-entity-view-type-description": "ობიექტის ტიპის ვარიანტები '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "ობიექტის ტიპის განსაზღვრება '{{entityViewTypes}}' და დასახელება რომელიც იწყება '{{prefix}}'", "filter-type-relations-query": "მოთხოვნა რელაციის ტიპის მიხედვით", "filter-type-relations-query-description": "{{entities}}, არსებული რელაციის ტიპი {{relationType}} {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "ძიება აქტივების მიხედვით", diff --git a/ui-ngx/src/assets/locale/locale.constant-ko_KR.json b/ui-ngx/src/assets/locale/locale.constant-ko_KR.json index 1d05b49950..279a702d82 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ko_KR.json +++ b/ui-ngx/src/assets/locale/locale.constant-ko_KR.json @@ -302,14 +302,14 @@ "filter-type-state-entity": "대시보드 상태로 부터의 개체", "filter-type-state-entity-description": "개체 taken from dashboard state parameters", "filter-type-asset-type": "자산 유형", - "filter-type-asset-type-description": "'{{assetType}}' 유형의 자산", - "filter-type-asset-type-and-name-description": "이름이 '{{prefix}}'로 시작되는 '{{assetType}}' 유형의 자산", + "filter-type-asset-type-description": "'{{assetTypes}}' 유형의 자산", + "filter-type-asset-type-and-name-description": "이름이 '{{prefix}}'로 시작되는 '{{assetTypes}}' 유형의 자산", "filter-type-device-type": "장치 유형", - "filter-type-device-type-description": "'{{deviceType}}' 유형의 장치", - "filter-type-device-type-and-name-description": "이름이 '{{prefix}}'로 시작되는 '{{assetType}}' 유형의 장치", + "filter-type-device-type-description": "'{{deviceTypes}}' 유형의 장치", + "filter-type-device-type-and-name-description": "이름이 '{{prefix}}'로 시작되는 '{{deviceTypes}}' 유형의 장치", "filter-type-entity-view-type": "Entity View type", - "filter-type-entity-view-type-description": "Entity Views of type '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'", + "filter-type-entity-view-type-description": "Entity Views of type '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityViewTypes}}' and with name starting with '{{prefix}}'", "filter-type-relations-query": "관계 질의", "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "자산 검색 질의", diff --git a/ui-ngx/src/assets/locale/locale.constant-lv_LV.json b/ui-ngx/src/assets/locale/locale.constant-lv_LV.json index 77ca2300b5..ae33ed2f22 100644 --- a/ui-ngx/src/assets/locale/locale.constant-lv_LV.json +++ b/ui-ngx/src/assets/locale/locale.constant-lv_LV.json @@ -155,14 +155,14 @@ "filter-type-state-entity": "Vienība no paneļa stāvokļa", "filter-type-state-entity-description": "Vienība ņemta no paneļa stāvokļa parametriem", "filter-type-asset-type": "Aktīvu tips", - "filter-type-asset-type-description": "Aktīvu tipi '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Aktīvu tips '{{assetType}}' un ar vārdu sākot ar '{{prefix}}'", + "filter-type-asset-type-description": "Aktīvu tipi '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Aktīvu tips '{{assetTypes}}' un ar vārdu sākot ar '{{prefix}}'", "filter-type-device-type": "Iekārtas tips", - "filter-type-device-type-description": "Iekārtas tipi '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Iekārtas tipi '{{deviceType}}' un ar vārdu sākot ar '{{prefix}}'", + "filter-type-device-type-description": "Iekārtas tipi '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Iekārtas tipi '{{deviceTypes}}' un ar vārdu sākot ar '{{prefix}}'", "filter-type-entity-view-type": "Vienības skata tips", - "filter-type-entity-view-type-description": "Vienības skats tipam '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Vienības skats tipam '{{entityView}}' un ar vārdu sākot ar '{{prefix}}'", + "filter-type-entity-view-type-description": "Vienības skats tipam '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Vienības skats tipam '{{entityViewTypes}}' un ar vārdu sākot ar '{{prefix}}'", "filter-type-relations-query": "Attiecību vaicājums", "filter-type-relations-query-description": "{{entities}} kam ir {{relationType}} attiecība {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Aktīvu meklēšanas vaicājums", diff --git a/ui-ngx/src/assets/locale/locale.constant-pt_BR.json b/ui-ngx/src/assets/locale/locale.constant-pt_BR.json index 78a81f4b57..c5a780c988 100644 --- a/ui-ngx/src/assets/locale/locale.constant-pt_BR.json +++ b/ui-ngx/src/assets/locale/locale.constant-pt_BR.json @@ -204,14 +204,14 @@ "filter-type-state-entity": "Entidade do estado do dashboard", "filter-type-state-entity-description": "Entidade obtida dos parâmetros de estado do dashboard", "filter-type-asset-type": "Tipo de ativo", - "filter-type-asset-type-description": "Ativos do tipo '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Ativos do tipo '{{assetType}}' cujo nome começa com '{{prefix}}'", + "filter-type-asset-type-description": "Ativos do tipo '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Ativos do tipo '{{assetTypes}}' cujo nome começa com '{{prefix}}'", "filter-type-device-type": "Tipo de dispositivo", - "filter-type-device-type-description": "Dispositivos do tipo '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Dispositivos do tipo '{{deviceType}}' cujo nome começa com '{{prefix}}'", + "filter-type-device-type-description": "Dispositivos do tipo '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Dispositivos do tipo '{{deviceTypes}}' cujo nome começa com '{{prefix}}'", "filter-type-entity-view-type": "Tipo de exibições de entidades", - "filter-type-entity-view-type-description": "Exibições de entidades do tipo '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Exibições de entidades do tipo '{{entityView}}' cujo nome começa com '{{prefix}}'", + "filter-type-entity-view-type-description": "Exibições de entidades do tipo '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Exibições de entidades do tipo '{{entityViewTypes}}' cujo nome começa com '{{prefix}}'", "filter-type-relations-query": "Consulta de relações", "filter-type-relations-query-description": "{{entities}} que tem relação de {{relationType}} {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Consulta de pesquisa de ativo", diff --git a/ui-ngx/src/assets/locale/locale.constant-ro_RO.json b/ui-ngx/src/assets/locale/locale.constant-ro_RO.json index 01af73ece5..b8edabf826 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ro_RO.json +++ b/ui-ngx/src/assets/locale/locale.constant-ro_RO.json @@ -183,14 +183,14 @@ "filter-type-state-entity": "Entitate din starea panoului", "filter-type-state-entity-description": "Entitate luată din parametrii stării panoului", "filter-type-asset-type": "Tip Proprietate", - "filter-type-asset-type-description": "Proprietăţi de tip: '{{assetType}}'", - "filter-type-asset-type-and-name-description": "proprietăţi de tipul: '{{assetType}}' a căror denumire începe cu: '{{prefix}}'", + "filter-type-asset-type-description": "Proprietăţi de tip: '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "proprietăţi de tipul: '{{assetTypes}}' a căror denumire începe cu: '{{prefix}}'", "filter-type-device-type": "Tip Dispozitiv", - "filter-type-device-type-description": "Dispozitive tip: '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Dispozitive Tip: '{{deviceType}}' a căror denumire începe cu: '{{prefix}}'", + "filter-type-device-type-description": "Dispozitive tip: '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Dispozitive Tip: '{{deviceTypes}}' a căror denumire începe cu: '{{prefix}}'", "filter-type-entity-view-type": "Tip entitate definită", - "filter-type-entity-view-type-description": "Tip entități definite: '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Entități definite de tip: '{{entityView}}' a căror denumire începe cu : '{{prefix}}'", + "filter-type-entity-view-type-description": "Tip entități definite: '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Entități definite de tip: '{{entityViewTypes}}' a căror denumire începe cu : '{{prefix}}'", "filter-type-relations-query": "Relaţii Interogare", "filter-type-relations-query-description": "{{entities}} care au relații tip {{relationType}} în direcția {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Proprietate Asset search query", diff --git a/ui-ngx/src/assets/locale/locale.constant-ru_RU.json b/ui-ngx/src/assets/locale/locale.constant-ru_RU.json index e9d5587d4d..fda2b4e1e8 100644 --- a/ui-ngx/src/assets/locale/locale.constant-ru_RU.json +++ b/ui-ngx/src/assets/locale/locale.constant-ru_RU.json @@ -209,14 +209,14 @@ "filter-type-state-entity": "Объект из состояния дашборда", "filter-type-state-entity-description": "Объект, полученный из параметров состояния дашборда", "filter-type-asset-type": "Тип актива", - "filter-type-asset-type-description": "Активы типа '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Активы типа '{{assetType}}' и названием, начинающимся с '{{prefix}}'", + "filter-type-asset-type-description": "Активы типа '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Активы типа '{{assetTypes}}' и названием, начинающимся с '{{prefix}}'", "filter-type-device-type": "Тип устройства", - "filter-type-device-type-description": "Устройства типа '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Устройства типа '{{deviceType}}' и названием, начинающимся с '{{prefix}}'", + "filter-type-device-type-description": "Устройства типа '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Устройства типа '{{deviceTypes}}' и названием, начинающимся с '{{prefix}}'", "filter-type-entity-view-type": "Тип Представления Объекта", - "filter-type-entity-view-type-description": "Представления Объекта типа '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Представления Объекта типа '{{entityView}}' и названием, начинающимся с '{{prefix}}'", + "filter-type-entity-view-type-description": "Представления Объекта типа '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Представления Объекта типа '{{entityViewTypes}}' и названием, начинающимся с '{{prefix}}'", "filter-type-relations-query": "Запрос по типу отношений", "filter-type-relations-query-description": "{{entities}}, имеющие отношение типа {{relationType}} {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Поисковый запрос по активам", diff --git a/ui-ngx/src/assets/locale/locale.constant-sl_SI.json b/ui-ngx/src/assets/locale/locale.constant-sl_SI.json index 04d7bcd25f..1e38013dec 100644 --- a/ui-ngx/src/assets/locale/locale.constant-sl_SI.json +++ b/ui-ngx/src/assets/locale/locale.constant-sl_SI.json @@ -302,14 +302,14 @@ "filter-type-state-entity": "Subjekt iz stanja nadzorne plošče", "filter-type-state-entity-description": "Entiteta, vzeta iz parametrov stanja nadzorne plošče", "filter-type-asset-type": "Vrsta sredstva", - "filter-type-asset-type-description": "Sredstva vrste '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Sredstva vrste '{{assetType}}' in z imenom, ki se začne z '{{prefix}}'", + "filter-type-asset-type-description": "Sredstva vrste '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Sredstva vrste '{{assetTypes}}' in z imenom, ki se začne z '{{prefix}}'", "filter-type-device-type": "Vrsta naprave", - "filter-type-device-type-description": "Naprave tipa '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Naprave vrste '{{deviceType}}' in z imenom, ki se začne z '{{prefix}}'", + "filter-type-device-type-description": "Naprave tipa '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Naprave vrste '{{deviceTypes}}' in z imenom, ki se začne z '{{prefix}}'", "filter-type-entity-view-type": "Vrsta pogleda entitete", - "filter-type-entity-view-type-description": "Pogledi entitet vrste '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Pogledi entitet vrste '{{entityView}}' in z imenom, ki se začne z '{{prefix}}'", + "filter-type-entity-view-type-description": "Pogledi entitet vrste '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Pogledi entitet vrste '{{entityViewTypes}}' in z imenom, ki se začne z '{{prefix}}'", "filter-type-relations-query": "Poizvedba odnosov", "filter-type-relations-query-description": "{{entities}}, ki imajo {{relationType}} relacijo {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Iskalna poizvedba sredstva", diff --git a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json index 174c648e7a..3bd5486da5 100644 --- a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json +++ b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json @@ -324,17 +324,17 @@ "filter-type-state-entity": "Gösterge panelinden öğe", "filter-type-state-entity-description": "Gösterge paneli durum parametrelerinden alınan öğeler", "filter-type-asset-type": "Varlık türü", - "filter-type-asset-type-description": "'{{assetType}}' türünde varlıklar", - "filter-type-asset-type-and-name-description": "Adı '{{prefix}}' ile başlayan '{{assetType}}' türünde varlıklar", + "filter-type-asset-type-description": "'{{assetTypes}}' türünde varlıklar", + "filter-type-asset-type-and-name-description": "Adı '{{prefix}}' ile başlayan '{{assetTypes}}' türünde varlıklar", "filter-type-device-type": "Cihaz türü", - "filter-type-device-type-description": "'{{deviceType}}' türünde cihazlar", - "filter-type-device-type-and-name-description": "Adı '{{prefix}}' ile başlayan'{{deviceType}}' türünde cihazlar", + "filter-type-device-type-description": "'{{deviceTypes}}' türünde cihazlar", + "filter-type-device-type-and-name-description": "Adı '{{prefix}}' ile başlayan'{{deviceTypes}}' türünde cihazlar", "filter-type-entity-view-type": "Öğe Görünümü türü", - "filter-type-entity-view-type-description": "'{{entityViewType}}' türünde Öğe Görünümleri", - "filter-type-entity-view-type-and-name-description": "'{{entityViewType}}' türünde ve adı '{{prefix}}' ile başlayan Öğe Görünümleri", + "filter-type-entity-view-type-description": "'{{entityViewTypes}}' türünde Öğe Görünümleri", + "filter-type-entity-view-type-and-name-description": "'{{entityViewTypes}}' türünde ve adı '{{prefix}}' ile başlayan Öğe Görünümleri", "filter-type-edge-type": "Uç tipi", - "filter-type-edge-type-description": "'{{edgeType}}' türünün uçları", - "filter-type-edge-type-and-name-description": "'{{edgeType}}' türü ve adı '{{prefix}}' ile başlayan kenarlar", + "filter-type-edge-type-description": "'{{edgeTypes}}' türünün uçları", + "filter-type-edge-type-and-name-description": "'{{edgeTypes}}' türü ve adı '{{prefix}}' ile başlayan kenarlar", "filter-type-relations-query": "İlişkiler sorgusu", "filter-type-relations-query-description": "{{relationType}} türünde ilişkili olan öğeler: {{entities}}. {{direction}}: {{rootEntity}}", "filter-type-asset-search-query": "Varlık arama sorgusu", diff --git a/ui-ngx/src/assets/locale/locale.constant-uk_UA.json b/ui-ngx/src/assets/locale/locale.constant-uk_UA.json index 1522a03731..bcbb87c5eb 100644 --- a/ui-ngx/src/assets/locale/locale.constant-uk_UA.json +++ b/ui-ngx/src/assets/locale/locale.constant-uk_UA.json @@ -228,14 +228,14 @@ "filter-type-state-entity": "Сутність з стану панелі пристроїв", "filter-type-state-entity-description": "Сутність, взята з параметрів стану панелі пристроїв", "filter-type-asset-type": "Тип активу", - "filter-type-asset-type-description": "Тип активів '{{assetType}}'", - "filter-type-asset-type-and-name-description": "Тип активів '{{assetType}}' і ім'я, що починаються з '{{prefix}}'", + "filter-type-asset-type-description": "Тип активів '{{assetTypes}}'", + "filter-type-asset-type-and-name-description": "Тип активів '{{assetTypes}}' і ім'я, що починаються з '{{prefix}}'", "filter-type-device-type": "Тип пристрою", - "filter-type-device-type-description": "Тип пристроїв '{{deviceType}}'", - "filter-type-device-type-and-name-description": "Тип пристроїв '{{deviceType}}' і ім'я, що починаються з '{{prefix}}'", + "filter-type-device-type-description": "Тип пристроїв '{{deviceTypes}}'", + "filter-type-device-type-and-name-description": "Тип пристроїв '{{deviceTypes}}' і ім'я, що починаються з '{{prefix}}'", "filter-type-entity-view-type": "Тип перегляду сутності", - "filter-type-entity-view-type-description": "Перегляд сутності з типом '{{entityView}}'", - "filter-type-entity-view-type-and-name-description": "Перегляд сутності з типом'{{entityView}}' і іменем, що починаються з '{{prefix}}'", + "filter-type-entity-view-type-description": "Перегляд сутності з типом '{{entityViewTypes}}'", + "filter-type-entity-view-type-and-name-description": "Перегляд сутності з типом'{{entityViewTypes}}' і іменем, що починаються з '{{prefix}}'", "filter-type-relations-query": "Запит відносин", "filter-type-relations-query-description": "{{entities}}, які мають {{relationType}} відношення {{direction}} {{rootEntity}}", "filter-type-asset-search-query": "Запит пошуку активу", diff --git a/ui-ngx/src/assets/locale/locale.constant-zh_CN.json b/ui-ngx/src/assets/locale/locale.constant-zh_CN.json index 2f1d4cab96..e3db532666 100644 --- a/ui-ngx/src/assets/locale/locale.constant-zh_CN.json +++ b/ui-ngx/src/assets/locale/locale.constant-zh_CN.json @@ -466,17 +466,17 @@ "filter-type-state-entity": "仪表板状态实体", "filter-type-state-entity-description": "仪表板实体令牌状态参数", "filter-type-asset-type": "资产类型", - "filter-type-asset-type-description": "类型为 '{{assetType}}' 的资产", - "filter-type-asset-type-and-name-description": "类型为 '{{assetType}}' 且以 '{{prefix}}' 开头的资产", + "filter-type-asset-type-description": "类型为 '{{assetTypes}}' 的资产", + "filter-type-asset-type-and-name-description": "类型为 '{{assetTypes}}' 且以 '{{prefix}}' 开头的资产", "filter-type-device-type": "设备类型", - "filter-type-device-type-description": "类型为 '{{deviceType}}' 的设备", - "filter-type-device-type-and-name-description": "类型为 '{{deviceType}}' 且以 '{{prefix}}' 开头的设备", + "filter-type-device-type-description": "类型为 '{{deviceTypes}}' 的设备", + "filter-type-device-type-and-name-description": "类型为 '{{deviceTypes}}' 且以 '{{prefix}}' 开头的设备", "filter-type-entity-view-type": "实体视图类型", - "filter-type-entity-view-type-description": "类型为 '{{entityView}}' 的实体视图", - "filter-type-entity-view-type-and-name-description": "类型为 {{entityView}}' 且以 '{{prefix}}' 开头的实体视图", + "filter-type-entity-view-type-description": "类型为 '{{entityViewTypes}}' 的实体视图", + "filter-type-entity-view-type-and-name-description": "类型为 {{entityViewTypes}}' 且以 '{{prefix}}' 开头的实体视图", "filter-type-edge-type": "边缘类型", - "filter-type-edge-type-description": "类型为 '{{edgeType}}' 的边缘", - "filter-type-edge-type-and-name-description": "类型为 '{{edgeType}}' 且以 '{{prefix}}' 开头的边缘", + "filter-type-edge-type-description": "类型为 '{{edgeTypes}}' 的边缘", + "filter-type-edge-type-and-name-description": "类型为 '{{edgeTypes}}' 且以 '{{prefix}}' 开头的边缘", "filter-type-relations-query": "关联查询", "filter-type-relations-query-description": "具有 {{relationType}} 关联 {{direction}} {{rootEntity}} 的 {{entities}} ", "filter-type-asset-search-query": "资产搜索查询", diff --git a/ui-ngx/src/assets/locale/locale.constant-zh_TW.json b/ui-ngx/src/assets/locale/locale.constant-zh_TW.json index e5a54a6198..3c6e4b69ec 100644 --- a/ui-ngx/src/assets/locale/locale.constant-zh_TW.json +++ b/ui-ngx/src/assets/locale/locale.constant-zh_TW.json @@ -395,17 +395,17 @@ "filter-type-state-entity": "實體(儀表板狀態)", "filter-type-state-entity-description": "實體taken(儀表板狀態參數)", "filter-type-asset-type": "資產類型", - "filter-type-asset-type-description": "類型為 '{{assetType}}' 的資產", - "filter-type-asset-type-and-name-description": "類型為 '{{assetType}}' 且以 '{{prefix}}' 開頭的資產", + "filter-type-asset-type-description": "類型為 '{{assetTypes}}' 的資產", + "filter-type-asset-type-and-name-description": "類型為 '{{assetTypes}}' 且以 '{{prefix}}' 開頭的資產", "filter-type-device-type": "設備類型", - "filter-type-device-type-description": "類型為 '{{deviceType}}' 的設備", - "filter-type-device-type-and-name-description": "類型為 '{{deviceType}}' 且以 '{{prefix}}' 開頭的設備", + "filter-type-device-type-description": "類型為 '{{deviceTypes}}' 的設備", + "filter-type-device-type-and-name-description": "類型為 '{{deviceTypes}}' 且以 '{{prefix}}' 開頭的設備", "filter-type-entity-view-type": "實體視圖類型", - "filter-type-entity-view-type-description": "類型為 '{{entityView}}' 的實體視圖", - "filter-type-entity-view-type-and-name-description": "類型為 {{entityView}}' 且以 '{{prefix}}' 開頭的實體視圖", + "filter-type-entity-view-type-description": "類型為 '{{entityViewTypes}}' 的實體視圖", + "filter-type-entity-view-type-and-name-description": "類型為 {{entityViewTypes}}' 且以 '{{prefix}}' 開頭的實體視圖", "filter-type-edge-type": "邊緣類型", - "filter-type-edge-type-description": " '類型為{{edgeType}}'的邊緣", - "filter-type-edge-type-and-name-description": "類型為 '{{edgeType}}' 且名稱以 '{{prefix}}'開頭的邊緣", + "filter-type-edge-type-description": " '類型為{{edgeTypes}}'的邊緣", + "filter-type-edge-type-and-name-description": "類型為 '{{edgeTypes}}' 且名稱以 '{{prefix}}'開頭的邊緣", "filter-type-relations-query": "關聯查詢", "filter-type-relations-query-description": "具有 {{relationType}} 關聯 {{direction}} {{rootEntity}} 的 {{entities}} ", "filter-type-asset-search-query": "資產搜尋查詢", From aa74965f014e8b99c759b690f33ee8d343858657 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Wed, 1 Feb 2023 17:42:41 +0200 Subject: [PATCH 02/16] Minor refactoring - renaming params --- .../install/update/DefaultDataUpdateService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index e6c37d0c08..7e42403ce3 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -768,16 +768,16 @@ public class DefaultDataUpdateService implements DataUpdateService { }, MoreExecutors.directExecutor()); } - private static void updateFilterIfRequired(JsonNode filter, String filterType, String oldParameterName, String newParameterName) { + private static void updateFilterIfRequired(JsonNode filter, String filterType, String singleTypeParamName, String multipleTypesParamName) { if (filter == null || filter.get("type") == null) { return; } if (filterType.equals(filter.get("type").asText())) { - if (filter.get(oldParameterName) != null) { + if (filter.get(singleTypeParamName) != null) { ArrayNode arrayNode = JacksonUtil.OBJECT_MAPPER.createArrayNode(); - arrayNode.add(filter.get(oldParameterName).asText()); - ((ObjectNode) filter).set(newParameterName, arrayNode); - ((ObjectNode) filter).remove(oldParameterName); + arrayNode.add(filter.get(singleTypeParamName).asText()); + ((ObjectNode) filter).set(multipleTypesParamName, arrayNode); + ((ObjectNode) filter).remove(singleTypeParamName); } } } From cbf4297593d8328be89ca94bffbcf4aefa46973f Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 2 Feb 2023 13:13:49 +0200 Subject: [PATCH 03/16] Add support for dashboard filter backward compatibility --- .../update/DefaultDataUpdateService.java | 25 +++-------------- .../impl/DashboardImportService.java | 4 +++ .../thingsboard/server/utils/MiscUtils.java | 27 +++++++++++++++++++ .../common/data/query/AssetTypeFilter.java | 14 +++++++--- .../common/data/query/DeviceTypeFilter.java | 18 ++++++++++--- .../common/data/query/EdgeTypeFilter.java | 14 +++++++--- .../common/data/query/EntityFilterType.java | 3 +++ .../data/query/EntityViewTypeFilter.java | 14 +++++++--- .../query/DefaultEntityQueryRepository.java | 13 +++++++++ 9 files changed, 95 insertions(+), 37 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index 7e42403ce3..9404cede2c 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -16,7 +16,6 @@ package org.thingsboard.server.service.install.update; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -84,6 +83,7 @@ import org.thingsboard.server.dao.timeseries.TimeseriesService; import org.thingsboard.server.service.install.InstallScripts; import org.thingsboard.server.service.install.SystemDataLoaderService; import org.thingsboard.server.service.install.TbRuleEngineQueueConfigService; +import org.thingsboard.server.utils.MiscUtils; import java.util.ArrayList; import java.util.Collections; @@ -748,17 +748,12 @@ public class DefaultDataUpdateService implements DataUpdateService { return null; } try { - JsonNode configuration = dashboard.getConfiguration(); - JsonNode entityAliases = configuration.get("entityAliases"); + List entityAliases = dashboard.getEntityAliasesConfig(); if (entityAliases == null) { return null; } for (JsonNode entityAlias : entityAliases) { - JsonNode filter = entityAlias.get("filter"); - updateFilterIfRequired(filter, "assetType", "assetType", "assetTypes"); - updateFilterIfRequired(filter, "deviceType", "deviceType", "deviceTypes"); - updateFilterIfRequired(filter, "entityViewType", "entityViewType", "entityViewTypes"); - updateFilterIfRequired(filter, "edgeType", "edgeType", "edgeTypes"); + MiscUtils.updateDashboardFilterIfRequired(entityAlias); } dashboardService.saveDashboard(dashboard); } catch (Exception e) { @@ -768,17 +763,5 @@ public class DefaultDataUpdateService implements DataUpdateService { }, MoreExecutors.directExecutor()); } - private static void updateFilterIfRequired(JsonNode filter, String filterType, String singleTypeParamName, String multipleTypesParamName) { - if (filter == null || filter.get("type") == null) { - return; - } - if (filterType.equals(filter.get("type").asText())) { - if (filter.get(singleTypeParamName) != null) { - ArrayNode arrayNode = JacksonUtil.OBJECT_MAPPER.createArrayNode(); - arrayNode.add(filter.get(singleTypeParamName).asText()); - ((ObjectNode) filter).set(multipleTypesParamName, arrayNode); - ((ObjectNode) filter).remove(singleTypeParamName); - } - } - } + } diff --git a/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java b/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java index 2da996953f..245fee45b1 100644 --- a/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java +++ b/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java @@ -32,6 +32,7 @@ import org.thingsboard.server.common.data.sync.ie.EntityExportData; import org.thingsboard.server.dao.dashboard.DashboardService; import org.thingsboard.server.queue.util.TbCoreComponent; import org.thingsboard.server.service.sync.vc.data.EntitiesImportCtx; +import org.thingsboard.server.utils.MiscUtils; import java.util.Arrays; import java.util.Collections; @@ -73,6 +74,9 @@ public class DashboardImportService extends BaseEntityImportService assetTypes; private String assetNameFilter; + @Override + public EntityFilterType getType() { + return EntityFilterType.ASSET_TYPE; + } + } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index a1efe0ccb2..dfb0771fc5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -26,13 +26,23 @@ import java.util.List; @Data public class DeviceTypeFilter implements EntityFilter { - @Override - public EntityFilterType getType() { - return EntityFilterType.DEVICE_TYPE; - } + /** + * Replaced by {@link DeviceTypeFilter#getDeviceTypes()} instead. + */ + @Deprecated(since = "3.5", forRemoval = true) + private String deviceType; private List deviceTypes; private String deviceNameFilter; + public DeviceTypeFilter(List deviceTypes, String deviceNameFilter) { + this.deviceTypes = deviceTypes; + this.deviceNameFilter = deviceNameFilter; + } + + @Override + public EntityFilterType getType() { + return EntityFilterType.DEVICE_TYPE; + } } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index 38294e14ca..7dbcb8ce34 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -22,13 +22,19 @@ import java.util.List; @Data public class EdgeTypeFilter implements EntityFilter { - @Override - public EntityFilterType getType() { - return EntityFilterType.EDGE_TYPE; - } + /** + * Replaced by {@link EdgeTypeFilter#getEdgeTypes()} instead. + */ + @Deprecated(since = "3.5", forRemoval = true) + private String edgeType; private List edgeTypes; private String edgeNameFilter; + @Override + public EntityFilterType getType() { + return EntityFilterType.EDGE_TYPE; + } + } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java index 2156b5f25e..4105800158 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java @@ -15,6 +15,8 @@ */ package org.thingsboard.server.common.data.query; +import lombok.Getter; + public enum EntityFilterType { SINGLE_ENTITY("singleEntity"), ENTITY_LIST("entityList"), @@ -31,6 +33,7 @@ public enum EntityFilterType { EDGE_SEARCH_QUERY("edgeSearchQuery"), API_USAGE_STATE("apiUsageState"); + @Getter private final String label; EntityFilterType(String label) { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index e52ac2f002..ad3d8af9e5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -22,13 +22,19 @@ import java.util.List; @Data public class EntityViewTypeFilter implements EntityFilter { - @Override - public EntityFilterType getType() { - return EntityFilterType.ENTITY_VIEW_TYPE; - } + /** + * Replaced by {@link EntityViewTypeFilter#getEntityViewTypes()} instead. + */ + @Deprecated(since = "3.5", forRemoval = true) + private String entityViewType; private List entityViewTypes; private String entityViewNameFilter; + @Override + public EntityFilterType getType() { + return EntityFilterType.ENTITY_VIEW_TYPE; + } + } diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java index a8c4ab6912..91c7546b2a 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java @@ -53,6 +53,7 @@ import org.thingsboard.server.common.data.query.SingleEntityFilter; import org.thingsboard.server.common.data.relation.EntitySearchDirection; import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -814,18 +815,22 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { switch (filter.getType()) { case ASSET_TYPE: types = ((AssetTypeFilter) filter).getAssetTypes(); + types = checkTypeListForBackwardCompatibility(types, ((AssetTypeFilter) filter).getAssetType()); name = ((AssetTypeFilter) filter).getAssetNameFilter(); break; case DEVICE_TYPE: types = ((DeviceTypeFilter) filter).getDeviceTypes(); + types = checkTypeListForBackwardCompatibility(types, ((DeviceTypeFilter) filter).getDeviceType()); name = ((DeviceTypeFilter) filter).getDeviceNameFilter(); break; case ENTITY_VIEW_TYPE: types = ((EntityViewTypeFilter) filter).getEntityViewTypes(); + types = checkTypeListForBackwardCompatibility(types, ((EntityViewTypeFilter) filter).getEntityViewType()); name = ((EntityViewTypeFilter) filter).getEntityViewNameFilter(); break; case EDGE_TYPE: types = ((EdgeTypeFilter) filter).getEdgeTypes(); + types = checkTypeListForBackwardCompatibility(types, ((EdgeTypeFilter) filter).getEdgeType()); name = ((EdgeTypeFilter) filter).getEdgeNameFilter(); break; default: @@ -836,6 +841,14 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { return "e.type in (:entity_filter_type_query_types) and lower(e.search_text) like lower(concat(:entity_filter_type_query_name, '%%'))"; } + private List checkTypeListForBackwardCompatibility(List types, String subType) { + if (types == null || types.isEmpty()) { + types = new ArrayList<>(); + types.add(subType); + } + return types; + } + public static EntityType resolveEntityType(EntityFilter entityFilter) { switch (entityFilter.getType()) { case SINGLE_ENTITY: From 133856b35b02f2850bc1482621e6bbd9636b3924 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 2 Feb 2023 13:18:47 +0200 Subject: [PATCH 04/16] Added @JsonIgnore interface for newly added list of subtypes - for backward compatibility --- .../thingsboard/server/common/data/query/AssetTypeFilter.java | 2 ++ .../thingsboard/server/common/data/query/DeviceTypeFilter.java | 2 ++ .../thingsboard/server/common/data/query/EdgeTypeFilter.java | 2 ++ .../server/common/data/query/EntityViewTypeFilter.java | 2 ++ 4 files changed, 8 insertions(+) diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java index 55bbf3b810..6212e80c8a 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.common.data.query; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.util.List; @@ -28,6 +29,7 @@ public class AssetTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String assetType; + @JsonIgnore private List assetTypes; private String assetNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index dfb0771fc5..adc7a2de04 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.common.data.query; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -32,6 +33,7 @@ public class DeviceTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String deviceType; + @JsonIgnore private List deviceTypes; private String deviceNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index 7dbcb8ce34..e31dedecfa 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.common.data.query; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.util.List; @@ -28,6 +29,7 @@ public class EdgeTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String edgeType; + @JsonIgnore private List edgeTypes; private String edgeNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index ad3d8af9e5..509b4660a5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.common.data.query; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.util.List; @@ -28,6 +29,7 @@ public class EntityViewTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String entityViewType; + @JsonIgnore private List entityViewTypes; private String entityViewNameFilter; From 56e2ce9241b1f6c1f0a251cf86d98d741110ffa3 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Wed, 8 Feb 2023 15:34:12 +0200 Subject: [PATCH 05/16] Refactored to be in sync with PE --- .../dao/sql/query/DefaultEntityQueryRepository.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java index 91c7546b2a..f8664331cd 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java @@ -836,9 +836,14 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { default: throw new RuntimeException("Not supported!"); } + String typesFilter = "e.type in (:entity_filter_type_query_types)"; ctx.addStringListParameter("entity_filter_type_query_types", types); - ctx.addStringParameter("entity_filter_type_query_name", name); - return "e.type in (:entity_filter_type_query_types) and lower(e.search_text) like lower(concat(:entity_filter_type_query_name, '%%'))"; + if (!StringUtils.isEmpty(name)) { + ctx.addStringParameter("entity_filter_type_query_name", name); + return typesFilter + " and lower(e.search_text) like lower(concat(:entity_filter_type_query_name, '%%'))"; + } else { + return typesFilter; + } } private List checkTypeListForBackwardCompatibility(List types, String subType) { From 76f11c320bae897cb95e299de578eebc9fa03c27 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 9 Feb 2023 13:06:42 +0200 Subject: [PATCH 06/16] Move update of dashboard alias to dashboard service. Added test for backward compatibility --- .../update/DefaultDataUpdateService.java | 7 ---- .../impl/DashboardImportService.java | 7 ---- .../thingsboard/server/utils/MiscUtils.java | 27 ---------------- .../controller/BaseWebsocketApiTest.java | 30 +++++++++++++++++ .../common/data/query/AssetTypeFilter.java | 1 - .../common/data/query/DeviceTypeFilter.java | 1 - .../common/data/query/EdgeTypeFilter.java | 1 - .../data/query/EntityViewTypeFilter.java | 1 - .../dao/dashboard/DashboardServiceImpl.java | 32 +++++++++++++++++++ 9 files changed, 62 insertions(+), 45 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index 8bba2214d6..a0f13d7ec4 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -748,13 +748,6 @@ public class DefaultDataUpdateService implements DataUpdateService { return null; } try { - List entityAliases = dashboard.getEntityAliasesConfig(); - if (entityAliases == null) { - return null; - } - for (JsonNode entityAlias : entityAliases) { - MiscUtils.updateDashboardFilterIfRequired(entityAlias); - } dashboardService.saveDashboard(dashboard); } catch (Exception e) { log.warn("Failed to update dashboard filters. Dashboard {} ", dashboard, e); diff --git a/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java b/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java index 245fee45b1..611b536808 100644 --- a/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java +++ b/application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/DashboardImportService.java @@ -22,9 +22,6 @@ import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.EntityType; import org.thingsboard.server.common.data.ShortCustomerInfo; -import org.thingsboard.server.common.data.User; -import org.thingsboard.server.common.data.edge.EdgeEventActionType; -import org.thingsboard.server.common.data.exception.ThingsboardException; import org.thingsboard.server.common.data.id.CustomerId; import org.thingsboard.server.common.data.id.DashboardId; import org.thingsboard.server.common.data.id.TenantId; @@ -32,7 +29,6 @@ import org.thingsboard.server.common.data.sync.ie.EntityExportData; import org.thingsboard.server.dao.dashboard.DashboardService; import org.thingsboard.server.queue.util.TbCoreComponent; import org.thingsboard.server.service.sync.vc.data.EntitiesImportCtx; -import org.thingsboard.server.utils.MiscUtils; import java.util.Arrays; import java.util.Collections; @@ -74,9 +70,6 @@ public class DashboardImportService extends BaseEntityImportService tsData) throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); tsService.saveAndNotify(device.getTenantId(), null, device.getId(), tsData, 0, new FutureCallback() { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java index 6212e80c8a..61a4b969a2 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java @@ -29,7 +29,6 @@ public class AssetTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String assetType; - @JsonIgnore private List assetTypes; private String assetNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index adc7a2de04..f6ac85a7f4 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -33,7 +33,6 @@ public class DeviceTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String deviceType; - @JsonIgnore private List deviceTypes; private String deviceNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index e31dedecfa..d51916fcc6 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -29,7 +29,6 @@ public class EdgeTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String edgeType; - @JsonIgnore private List edgeTypes; private String edgeNameFilter; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index 509b4660a5..97c7efce33 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -29,7 +29,6 @@ public class EntityViewTypeFilter implements EntityFilter { @Deprecated(since = "3.5", forRemoval = true) private String entityViewType; - @JsonIgnore private List entityViewTypes; private String entityViewNameFilter; diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java index 96d56148eb..d64f6dd246 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java @@ -15,12 +15,16 @@ */ package org.thingsboard.server.dao.dashboard; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.util.concurrent.ListenableFuture; import lombok.extern.slf4j.Slf4j; import org.hibernate.exception.ConstraintViolationException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.DashboardInfo; @@ -34,6 +38,7 @@ import org.thingsboard.server.common.data.id.HasId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.page.PageData; import org.thingsboard.server.common.data.page.PageLink; +import org.thingsboard.server.common.data.query.EntityFilterType; import org.thingsboard.server.common.data.relation.EntityRelation; import org.thingsboard.server.common.data.relation.RelationTypeGroup; import org.thingsboard.server.dao.customer.CustomerDao; @@ -103,6 +108,9 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb log.trace("Executing saveDashboard [{}]", dashboard); dashboardValidator.validate(dashboard, DashboardInfo::getTenantId); try { + for (JsonNode entityAlias : dashboard.getEntityAliasesConfig()) { + updateDashboardFilterIfRequired(entityAlias); + } return dashboardDao.save(dashboard.getTenantId(), dashboard); } catch (Exception e) { checkConstraintViolation(e, "dashboard_external_id_unq_key", "Dashboard with such external id already exists!"); @@ -110,6 +118,30 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb } } + private static void updateDashboardFilterIfRequired(JsonNode entityAlias) { + JsonNode filter = entityAlias.get("filter"); + if (filter == null || filter.get("type") == null) { + return; + } + updateFilterByTypeIfRequired(filter, EntityFilterType.ASSET_TYPE.getLabel()); + updateFilterByTypeIfRequired(filter, EntityFilterType.DEVICE_TYPE.getLabel()); + updateFilterByTypeIfRequired(filter, EntityFilterType.ENTITY_VIEW_TYPE.getLabel()); + updateFilterByTypeIfRequired(filter, EntityFilterType.EDGE_TYPE.getLabel()); + } + + private static void updateFilterByTypeIfRequired(JsonNode filter, String FILTER_TYPE_SINGULAR_LABEL) { + if (filter.get(FILTER_TYPE_SINGULAR_LABEL) == null) { + return; + } + if (FILTER_TYPE_SINGULAR_LABEL.equals(filter.get("type").asText())) { + ArrayNode filterTypes = JacksonUtil.OBJECT_MAPPER.createArrayNode(); + filterTypes.add(filter.get(FILTER_TYPE_SINGULAR_LABEL).asText()); + final String FILTER_TYPES_PLURAL_LABEL = String.format("%ss", FILTER_TYPE_SINGULAR_LABEL); + ((ObjectNode) filter).set(FILTER_TYPES_PLURAL_LABEL, filterTypes); + ((ObjectNode) filter).remove(FILTER_TYPE_SINGULAR_LABEL); + } + } + @Override public Dashboard assignDashboardToCustomer(TenantId tenantId, DashboardId dashboardId, CustomerId customerId) { Dashboard dashboard = findDashboardById(tenantId, dashboardId); From e45775ce8f036f45a829b05f6440e301bf569ff6 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 9 Feb 2023 13:18:12 +0200 Subject: [PATCH 07/16] Organize imports --- .../server/service/install/update/DefaultDataUpdateService.java | 1 - .../server/controller/BaseEntityQueryControllerTest.java | 1 - .../thingsboard/server/common/data/query/AssetTypeFilter.java | 1 - .../thingsboard/server/common/data/query/DeviceTypeFilter.java | 1 - .../org/thingsboard/server/common/data/query/EdgeTypeFilter.java | 1 - .../server/common/data/query/EntityViewTypeFilter.java | 1 - 6 files changed, 6 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index a0f13d7ec4..be98fe5a5e 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -83,7 +83,6 @@ import org.thingsboard.server.dao.timeseries.TimeseriesService; import org.thingsboard.server.service.install.InstallScripts; import org.thingsboard.server.service.install.SystemDataLoaderService; import org.thingsboard.server.service.install.TbRuleEngineQueueConfigService; -import org.thingsboard.server.utils.MiscUtils; import java.util.ArrayList; import java.util.Collections; diff --git a/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java index eadccc610f..08022b376b 100644 --- a/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/BaseEntityQueryControllerTest.java @@ -51,7 +51,6 @@ import org.thingsboard.server.common.data.query.TsValue; import org.thingsboard.server.common.data.security.Authority; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java index 61a4b969a2..55bbf3b810 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java @@ -15,7 +15,6 @@ */ package org.thingsboard.server.common.data.query; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.util.List; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index f6ac85a7f4..dfb0771fc5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -15,7 +15,6 @@ */ package org.thingsboard.server.common.data.query; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index d51916fcc6..7dbcb8ce34 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -15,7 +15,6 @@ */ package org.thingsboard.server.common.data.query; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.util.List; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index 97c7efce33..ad3d8af9e5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -15,7 +15,6 @@ */ package org.thingsboard.server.common.data.query; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.util.List; From cf3beda316771ae832ee2bcd6630e6acbf29d104 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Tue, 21 Feb 2023 16:08:41 +0200 Subject: [PATCH 08/16] Data Update - update only dashboard which configurationthat contains required filters --- .../update/DefaultDataUpdateService.java | 39 ++++++++++--------- .../dao/dashboard/DashboardService.java | 2 + .../server/common/data/DataConstants.java | 10 +++++ .../dao/dashboard/DashboardInfoDao.java | 2 + .../dao/dashboard/DashboardServiceImpl.java | 28 +++++++------ .../dashboard/DashboardInfoRepository.java | 5 +++ .../sql/dashboard/JpaDashboardInfoDao.java | 10 +++++ 7 files changed, 66 insertions(+), 30 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index be98fe5a5e..fec27bfe2c 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -716,27 +716,30 @@ public class DefaultDataUpdateService implements DataUpdateService { }; private void updateTenantDashboardsFilters(TenantId tenantId) { - PageLink pageLink = new PageLink(100); - PageData pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink); - boolean hasNext = true; - while (hasNext) { - List>> updateFutures = new ArrayList<>(); - for (DashboardInfo dashboardInfo : pageData.getData()) { - updateFutures.add(updateDashboardFilters(tenantId, dashboardInfo)); - } + for (String filterTypeForUpdate : DataConstants.DASHBOARD_FILTER_TYPES_FOR_UPDATE) { + PageLink pageLink = new PageLink(100); + PageData pageData = dashboardService.findDashboardsByTenantIdAndConfigurationText(tenantId, filterTypeForUpdate, pageLink); + boolean hasNext = true; + while (hasNext) { + List>> updateFutures = new ArrayList<>(); + for (DashboardInfo dashboardInfo : pageData.getData()) { + updateFutures.add(updateDashboardFilters(tenantId, dashboardInfo)); + } - try { - Futures.allAsList(updateFutures).get(); - } catch (InterruptedException | ExecutionException e) { - log.error("Failed to update dashboards filters", e); - } + try { + Futures.allAsList(updateFutures).get(); + } catch (InterruptedException | ExecutionException e) { + log.error("Failed to update dashboards filters", e); + } - if (pageData.hasNext()) { - pageLink = pageLink.nextPageLink(); - pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink); - } else { - hasNext = false; + if (pageData.hasNext()) { + pageLink = pageLink.nextPageLink(); + pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink); + } else { + hasNext = false; + } } + } } diff --git a/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java b/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java index 7c47efafc3..110ba9f53f 100644 --- a/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java +++ b/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java @@ -70,4 +70,6 @@ public interface DashboardService extends EntityDaoService { List findTenantDashboardsByTitle(TenantId tenantId, String title); + PageData findDashboardsByTenantIdAndConfigurationText(TenantId tenantId, String searchText, PageLink pageLink); + } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java index 2cc9836864..950c4c9d8f 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java @@ -15,6 +15,11 @@ */ package org.thingsboard.server.common.data; +import org.thingsboard.server.common.data.query.EntityFilterType; + +import java.util.Arrays; +import java.util.List; + /** * @author Andrew Shvayka */ @@ -126,4 +131,9 @@ public class DataConstants { public static final String SQ_QUEUE_NAME = "SequentialByOriginator"; public static final String SQ_QUEUE_TOPIC = "tb_rule_engine.sq"; + public static final List DASHBOARD_FILTER_TYPES_FOR_UPDATE = Arrays.asList( + EntityFilterType.ASSET_TYPE.getLabel(), + EntityFilterType.DEVICE_TYPE.getLabel(), + EntityFilterType.ENTITY_VIEW_TYPE.getLabel(), + EntityFilterType.EDGE_TYPE.getLabel()); } diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java index e0d1777112..4b365e5ed1 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java +++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java @@ -77,4 +77,6 @@ public interface DashboardInfoDao extends Dao { DashboardInfo findFirstByTenantIdAndName(UUID tenantId, String name); + PageData findByTenantIdAndConfigurationText(UUID tenantId, String searchText, PageLink pageLink); + } diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java index d64f6dd246..21dea65229 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java @@ -28,6 +28,7 @@ import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.DashboardInfo; +import org.thingsboard.server.common.data.DataConstants; import org.thingsboard.server.common.data.EntityType; import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.id.CustomerId; @@ -38,7 +39,6 @@ import org.thingsboard.server.common.data.id.HasId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.page.PageData; import org.thingsboard.server.common.data.page.PageLink; -import org.thingsboard.server.common.data.query.EntityFilterType; import org.thingsboard.server.common.data.relation.EntityRelation; import org.thingsboard.server.common.data.relation.RelationTypeGroup; import org.thingsboard.server.dao.customer.CustomerDao; @@ -123,22 +123,21 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb if (filter == null || filter.get("type") == null) { return; } - updateFilterByTypeIfRequired(filter, EntityFilterType.ASSET_TYPE.getLabel()); - updateFilterByTypeIfRequired(filter, EntityFilterType.DEVICE_TYPE.getLabel()); - updateFilterByTypeIfRequired(filter, EntityFilterType.ENTITY_VIEW_TYPE.getLabel()); - updateFilterByTypeIfRequired(filter, EntityFilterType.EDGE_TYPE.getLabel()); + for (String filterTypeForUpdate : DataConstants.DASHBOARD_FILTER_TYPES_FOR_UPDATE) { + updateFilterByTypeIfRequired(filter, filterTypeForUpdate); + } } - private static void updateFilterByTypeIfRequired(JsonNode filter, String FILTER_TYPE_SINGULAR_LABEL) { - if (filter.get(FILTER_TYPE_SINGULAR_LABEL) == null) { + private static void updateFilterByTypeIfRequired(JsonNode filter, String filterTypeSingularLabel) { + if (filter.get(filterTypeSingularLabel) == null) { return; } - if (FILTER_TYPE_SINGULAR_LABEL.equals(filter.get("type").asText())) { + if (filterTypeSingularLabel.equals(filter.get("type").asText())) { ArrayNode filterTypes = JacksonUtil.OBJECT_MAPPER.createArrayNode(); - filterTypes.add(filter.get(FILTER_TYPE_SINGULAR_LABEL).asText()); - final String FILTER_TYPES_PLURAL_LABEL = String.format("%ss", FILTER_TYPE_SINGULAR_LABEL); - ((ObjectNode) filter).set(FILTER_TYPES_PLURAL_LABEL, filterTypes); - ((ObjectNode) filter).remove(FILTER_TYPE_SINGULAR_LABEL); + filterTypes.add(filter.get(filterTypeSingularLabel).asText()); + final String filterTypesPluralLabel = String.format("%ss", filterTypeSingularLabel); + ((ObjectNode) filter).set(filterTypesPluralLabel, filterTypes); + ((ObjectNode) filter).remove(filterTypeSingularLabel); } } @@ -329,6 +328,11 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb return dashboardDao.findByTenantIdAndTitle(tenantId.getId(), title); } + @Override + public PageData findDashboardsByTenantIdAndConfigurationText(TenantId tenantId, String searchText, PageLink pageLink) { + return dashboardInfoDao.findByTenantIdAndConfigurationText(tenantId.getId(), searchText, pageLink); + } + private PaginatedRemover tenantDashboardsRemover = new PaginatedRemover() { diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java index 0ede2325ac..b48020b617 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java @@ -72,4 +72,9 @@ public interface DashboardInfoRepository extends JpaRepository findByTenantIdAndConfigurationText(@Param("tenantId") UUID tenantId, + @Param("searchText") String searchText, + Pageable pageable); } diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java index c12770cf79..4a22008eb7 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java @@ -118,4 +118,14 @@ public class JpaDashboardInfoDao extends JpaAbstractSearchTextDao findByTenantIdAndConfigurationText(UUID tenantId, String searchText, PageLink pageLink) { + log.debug("Try to find dashboards by tenantId [{}], configuration text [{}] and pageLink [{}]", tenantId, searchText, pageLink); + return DaoUtil.toPageData(dashboardInfoRepository + .findByTenantIdAndConfigurationText( + tenantId, + searchText, + DaoUtil.toPageable(pageLink))); + } } From bd70c896882f66e9eb50c9d05118d0264040e9ac Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 24 Feb 2023 17:14:22 +0200 Subject: [PATCH 09/16] Fixed incorrect method usage findDashboardsByTenantId -> findDashboardsByTenantIdAndConfigurationText --- .../server/service/install/update/DefaultDataUpdateService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index fec27bfe2c..849982c53b 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -734,7 +734,7 @@ public class DefaultDataUpdateService implements DataUpdateService { if (pageData.hasNext()) { pageLink = pageLink.nextPageLink(); - pageData = dashboardService.findDashboardsByTenantId(tenantId, pageLink); + pageData = dashboardService.findDashboardsByTenantIdAndConfigurationText(tenantId, filterTypeForUpdate, pageLink); } else { hasNext = false; } From c2b1a948da53758a885de6bc2142ec99a0fdc140 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 3 Mar 2023 10:17:42 +0200 Subject: [PATCH 10/16] Removed check of deprecated entity alias filter type from backend to frontend --- .../install/ThingsboardInstallService.java | 1 - .../update/DefaultDataUpdateService.java | 75 ------------------- .../dao/dashboard/DashboardService.java | 3 - .../server/common/data/DataConstants.java | 6 -- .../dao/dashboard/DashboardInfoDao.java | 3 - .../dao/dashboard/DashboardServiceImpl.java | 32 -------- .../dashboard/DashboardInfoRepository.java | 6 -- .../sql/dashboard/JpaDashboardInfoDao.java | 10 --- .../core/services/dashboard-utils.service.ts | 41 ++++++++++ ui-ngx/src/app/shared/models/alias.models.ts | 4 + 10 files changed, 45 insertions(+), 136 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java index c2bbafe015..c0f4bd5cf4 100644 --- a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java +++ b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java @@ -240,7 +240,6 @@ public class ThingsboardInstallService { case "3.4.4": log.info("Upgrading ThingsBoard from version 3.4.4 to 3.5.0 ..."); databaseEntitiesUpgradeService.upgradeDatabase("3.4.4"); - dataUpdateService.updateData("3.4.4"); log.info("Updating system data..."); systemDataLoaderService.updateSystemWidgets(); break; diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index 849982c53b..f5f36c31ac 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -30,7 +30,6 @@ import org.thingsboard.rule.engine.flow.TbRuleChainInputNode; import org.thingsboard.rule.engine.flow.TbRuleChainInputNodeConfiguration; import org.thingsboard.rule.engine.profile.TbDeviceProfileNode; import org.thingsboard.rule.engine.profile.TbDeviceProfileNodeConfiguration; -import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.DataConstants; import org.thingsboard.server.common.data.EntityView; import org.thingsboard.server.common.data.Tenant; @@ -39,7 +38,6 @@ import org.thingsboard.server.common.data.alarm.Alarm; import org.thingsboard.server.common.data.alarm.AlarmInfo; import org.thingsboard.server.common.data.alarm.AlarmQuery; import org.thingsboard.server.common.data.alarm.AlarmSeverity; -import org.thingsboard.server.common.data.id.DashboardId; import org.thingsboard.server.common.data.id.EntityViewId; import org.thingsboard.server.common.data.id.RuleChainId; import org.thingsboard.server.common.data.id.RuleNodeId; @@ -209,10 +207,6 @@ public class DefaultDataUpdateService implements DataUpdateService { log.info("Skipping edge events migration"); } break; - case "3.4.4": - log.info("Updating data from version 3.4.4 to 3.5.0 ..."); - tenantsDashboardsFiltersUpdater.updateEntities(); - break; default: throw new RuntimeException("Unable to update data, unsupported fromVersion: " + fromVersion); } @@ -690,73 +684,4 @@ public class DefaultDataUpdateService implements DataUpdateService { return Boolean.parseBoolean(env); } } - - private final PaginatedUpdater tenantsDashboardsFiltersUpdater = - new PaginatedUpdater<>() { - - @Override - protected String getName() { - return "Tenants dashboards filters updater"; - } - - @Override - protected boolean forceReportTotal() { - return true; - } - - @Override - protected PageData findEntities(String region, PageLink pageLink) { - return tenantService.findTenants(pageLink); - } - - @Override - protected void updateEntity(Tenant tenant) { - updateTenantDashboardsFilters(tenant.getId()); - } - }; - - private void updateTenantDashboardsFilters(TenantId tenantId) { - for (String filterTypeForUpdate : DataConstants.DASHBOARD_FILTER_TYPES_FOR_UPDATE) { - PageLink pageLink = new PageLink(100); - PageData pageData = dashboardService.findDashboardsByTenantIdAndConfigurationText(tenantId, filterTypeForUpdate, pageLink); - boolean hasNext = true; - while (hasNext) { - List>> updateFutures = new ArrayList<>(); - for (DashboardInfo dashboardInfo : pageData.getData()) { - updateFutures.add(updateDashboardFilters(tenantId, dashboardInfo)); - } - - try { - Futures.allAsList(updateFutures).get(); - } catch (InterruptedException | ExecutionException e) { - log.error("Failed to update dashboards filters", e); - } - - if (pageData.hasNext()) { - pageLink = pageLink.nextPageLink(); - pageData = dashboardService.findDashboardsByTenantIdAndConfigurationText(tenantId, filterTypeForUpdate, pageLink); - } else { - hasNext = false; - } - } - - } - } - - private ListenableFuture> updateDashboardFilters(TenantId tenantId, DashboardInfo dashboardInfo) { - DashboardId dashboardId = dashboardInfo.getId(); - return Futures.transform(dashboardService.findDashboardByIdAsync(tenantId, dashboardId), dashboard -> { - if (dashboard == null || dashboard.getConfiguration() == null) { - return null; - } - try { - dashboardService.saveDashboard(dashboard); - } catch (Exception e) { - log.warn("Failed to update dashboard filters. Dashboard {} ", dashboard, e); - } - return null; - }, MoreExecutors.directExecutor()); - } - - } diff --git a/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java b/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java index 110ba9f53f..c38ecd5c29 100644 --- a/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java +++ b/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java @@ -69,7 +69,4 @@ public interface DashboardService extends EntityDaoService { DashboardInfo findFirstDashboardInfoByTenantIdAndName(TenantId tenantId, String name); List findTenantDashboardsByTitle(TenantId tenantId, String title); - - PageData findDashboardsByTenantIdAndConfigurationText(TenantId tenantId, String searchText, PageLink pageLink); - } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java index 950c4c9d8f..2b44d46b4e 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java @@ -130,10 +130,4 @@ public class DataConstants { public static final String HP_QUEUE_TOPIC = "tb_rule_engine.hp"; public static final String SQ_QUEUE_NAME = "SequentialByOriginator"; public static final String SQ_QUEUE_TOPIC = "tb_rule_engine.sq"; - - public static final List DASHBOARD_FILTER_TYPES_FOR_UPDATE = Arrays.asList( - EntityFilterType.ASSET_TYPE.getLabel(), - EntityFilterType.DEVICE_TYPE.getLabel(), - EntityFilterType.ENTITY_VIEW_TYPE.getLabel(), - EntityFilterType.EDGE_TYPE.getLabel()); } diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java index 4b365e5ed1..e8eb1d7a50 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java +++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java @@ -76,7 +76,4 @@ public interface DashboardInfoDao extends Dao { PageData findDashboardsByTenantIdAndEdgeId(UUID tenantId, UUID edgeId, PageLink pageLink); DashboardInfo findFirstByTenantIdAndName(UUID tenantId, String name); - - PageData findByTenantIdAndConfigurationText(UUID tenantId, String searchText, PageLink pageLink); - } diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java index 21dea65229..b6044e89bc 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java @@ -108,9 +108,6 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb log.trace("Executing saveDashboard [{}]", dashboard); dashboardValidator.validate(dashboard, DashboardInfo::getTenantId); try { - for (JsonNode entityAlias : dashboard.getEntityAliasesConfig()) { - updateDashboardFilterIfRequired(entityAlias); - } return dashboardDao.save(dashboard.getTenantId(), dashboard); } catch (Exception e) { checkConstraintViolation(e, "dashboard_external_id_unq_key", "Dashboard with such external id already exists!"); @@ -118,29 +115,6 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb } } - private static void updateDashboardFilterIfRequired(JsonNode entityAlias) { - JsonNode filter = entityAlias.get("filter"); - if (filter == null || filter.get("type") == null) { - return; - } - for (String filterTypeForUpdate : DataConstants.DASHBOARD_FILTER_TYPES_FOR_UPDATE) { - updateFilterByTypeIfRequired(filter, filterTypeForUpdate); - } - } - - private static void updateFilterByTypeIfRequired(JsonNode filter, String filterTypeSingularLabel) { - if (filter.get(filterTypeSingularLabel) == null) { - return; - } - if (filterTypeSingularLabel.equals(filter.get("type").asText())) { - ArrayNode filterTypes = JacksonUtil.OBJECT_MAPPER.createArrayNode(); - filterTypes.add(filter.get(filterTypeSingularLabel).asText()); - final String filterTypesPluralLabel = String.format("%ss", filterTypeSingularLabel); - ((ObjectNode) filter).set(filterTypesPluralLabel, filterTypes); - ((ObjectNode) filter).remove(filterTypeSingularLabel); - } - } - @Override public Dashboard assignDashboardToCustomer(TenantId tenantId, DashboardId dashboardId, CustomerId customerId) { Dashboard dashboard = findDashboardById(tenantId, dashboardId); @@ -327,12 +301,6 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb public List findTenantDashboardsByTitle(TenantId tenantId, String title) { return dashboardDao.findByTenantIdAndTitle(tenantId.getId(), title); } - - @Override - public PageData findDashboardsByTenantIdAndConfigurationText(TenantId tenantId, String searchText, PageLink pageLink) { - return dashboardInfoDao.findByTenantIdAndConfigurationText(tenantId.getId(), searchText, pageLink); - } - private PaginatedRemover tenantDashboardsRemover = new PaginatedRemover() { diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java index b48020b617..26459b28af 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java @@ -71,10 +71,4 @@ public interface DashboardInfoRepository extends JpaRepository findByTenantIdAndConfigurationText(@Param("tenantId") UUID tenantId, - @Param("searchText") String searchText, - Pageable pageable); } diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java index 4a22008eb7..c12770cf79 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/JpaDashboardInfoDao.java @@ -118,14 +118,4 @@ public class JpaDashboardInfoDao extends JpaAbstractSearchTextDao findByTenantIdAndConfigurationText(UUID tenantId, String searchText, PageLink pageLink) { - log.debug("Try to find dashboards by tenantId [{}], configuration text [{}] and pageLink [{}]", tenantId, searchText, pageLink); - return DaoUtil.toPageData(dashboardInfoRepository - .findByTenantIdAndConfigurationText( - tenantId, - searchText, - DaoUtil.toPageable(pageLink))); - } } diff --git a/ui-ngx/src/app/core/services/dashboard-utils.service.ts b/ui-ngx/src/app/core/services/dashboard-utils.service.ts index 394e55ff4c..2d4e6af94b 100644 --- a/ui-ngx/src/app/core/services/dashboard-utils.service.ts +++ b/ui-ngx/src/app/core/services/dashboard-utils.service.ts @@ -604,6 +604,47 @@ export class DashboardUtilsService { delete entityAlias.entityType; delete entityAlias.entityFilter; } + entityAlias = this.validateAndUpdateEntityAliasSingleTypeFilters(entityAlias); + return entityAlias; + } + + private validateAndUpdateEntityAliasSingleTypeFilters(entityAlias: EntityAlias): EntityAlias { + if (entityAlias.filter.type === AliasFilterType.deviceType) { + if (entityAlias.filter.deviceType) { + if (!entityAlias.filter.deviceTypes) { + entityAlias.filter.deviceTypes = []; + } + entityAlias.filter.deviceTypes.push(entityAlias.filter.deviceType); + delete entityAlias.filter.deviceType; + } + } + if (entityAlias.filter.type === AliasFilterType.assetType) { + if (entityAlias.filter.assetType) { + if (!entityAlias.filter.assetTypes) { + entityAlias.filter.assetTypes = []; + } + entityAlias.filter.assetTypes.push(entityAlias.filter.assetType); + delete entityAlias.filter.assetType; + } + } + if (entityAlias.filter.type === AliasFilterType.entityViewType) { + if (entityAlias.filter.entityViewType) { + if (!entityAlias.filter.entityViewTypes) { + entityAlias.filter.entityViewTypes = []; + } + entityAlias.filter.entityViewTypes.push(entityAlias.filter.entityViewType); + delete entityAlias.filter.entityViewType; + } + } + if (entityAlias.filter.type === AliasFilterType.edgeType) { + if (entityAlias.filter.edgeType) { + if (!entityAlias.filter.edgeTypes) { + entityAlias.filter.edgeTypes = []; + } + entityAlias.filter.edgeTypes.push(entityAlias.filter.edgeType); + delete entityAlias.filter.edgeType; + } + } return entityAlias; } diff --git a/ui-ngx/src/app/shared/models/alias.models.ts b/ui-ngx/src/app/shared/models/alias.models.ts index e0fb82404b..3f141834a4 100644 --- a/ui-ngx/src/app/shared/models/alias.models.ts +++ b/ui-ngx/src/app/shared/models/alias.models.ts @@ -86,21 +86,25 @@ export interface StateEntityFilter { } export interface AssetTypeFilter { + assetType?: string; // deprecated assetTypes?: string[]; assetNameFilter?: string; } export interface DeviceTypeFilter { + deviceType?: string; // deprecated deviceTypes?: string[]; deviceNameFilter?: string; } export interface EdgeTypeFilter { + edgeType?: string; // deprecated edgeTypes?: string[]; edgeNameFilter?: string; } export interface EntityViewFilter { + entityViewType?: string; // deprecated entityViewTypes?: string[]; entityViewNameFilter?: string; } From 3dacb805db238fc3ba104d0755f32e3816e28d2a Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 3 Mar 2023 10:24:54 +0200 Subject: [PATCH 11/16] Code review changes --- .../service/install/update/DefaultDataUpdateService.java | 5 +---- .../thingsboard/server/dao/dashboard/DashboardService.java | 1 + .../org/thingsboard/server/common/data/DataConstants.java | 6 +----- .../server/common/data/query/EntityFilterType.java | 3 --- .../server/dao/dashboard/DashboardServiceImpl.java | 6 +----- .../server/dao/sql/dashboard/DashboardInfoRepository.java | 1 + 6 files changed, 5 insertions(+), 17 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index f5f36c31ac..13f8672d67 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -65,7 +65,6 @@ import org.thingsboard.server.common.data.tenant.profile.TenantProfileQueueConfi import org.thingsboard.server.dao.DaoUtil; import org.thingsboard.server.dao.alarm.AlarmDao; import org.thingsboard.server.dao.audit.AuditLogDao; -import org.thingsboard.server.dao.dashboard.DashboardService; import org.thingsboard.server.dao.edge.EdgeEventDao; import org.thingsboard.server.dao.entity.EntityService; import org.thingsboard.server.dao.entityview.EntityViewService; @@ -111,9 +110,6 @@ public class DefaultDataUpdateService implements DataUpdateService { @Autowired private EntityViewService entityViewService; - @Autowired - private DashboardService dashboardService; - @Autowired private TimeseriesService tsService; @@ -684,4 +680,5 @@ public class DefaultDataUpdateService implements DataUpdateService { return Boolean.parseBoolean(env); } } + } diff --git a/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java b/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java index c38ecd5c29..7c47efafc3 100644 --- a/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java +++ b/common/dao-api/src/main/java/org/thingsboard/server/dao/dashboard/DashboardService.java @@ -69,4 +69,5 @@ public interface DashboardService extends EntityDaoService { DashboardInfo findFirstDashboardInfoByTenantIdAndName(TenantId tenantId, String name); List findTenantDashboardsByTitle(TenantId tenantId, String title); + } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java index 2b44d46b4e..2cc9836864 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java @@ -15,11 +15,6 @@ */ package org.thingsboard.server.common.data; -import org.thingsboard.server.common.data.query.EntityFilterType; - -import java.util.Arrays; -import java.util.List; - /** * @author Andrew Shvayka */ @@ -130,4 +125,5 @@ public class DataConstants { public static final String HP_QUEUE_TOPIC = "tb_rule_engine.hp"; public static final String SQ_QUEUE_NAME = "SequentialByOriginator"; public static final String SQ_QUEUE_TOPIC = "tb_rule_engine.sq"; + } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java index 4105800158..2156b5f25e 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityFilterType.java @@ -15,8 +15,6 @@ */ package org.thingsboard.server.common.data.query; -import lombok.Getter; - public enum EntityFilterType { SINGLE_ENTITY("singleEntity"), ENTITY_LIST("entityList"), @@ -33,7 +31,6 @@ public enum EntityFilterType { EDGE_SEARCH_QUERY("edgeSearchQuery"), API_USAGE_STATE("apiUsageState"); - @Getter private final String label; EntityFilterType(String label) { diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java index b6044e89bc..96d56148eb 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardServiceImpl.java @@ -15,20 +15,15 @@ */ package org.thingsboard.server.dao.dashboard; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.util.concurrent.ListenableFuture; import lombok.extern.slf4j.Slf4j; import org.hibernate.exception.ConstraintViolationException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.DashboardInfo; -import org.thingsboard.server.common.data.DataConstants; import org.thingsboard.server.common.data.EntityType; import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.id.CustomerId; @@ -301,6 +296,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb public List findTenantDashboardsByTitle(TenantId tenantId, String title) { return dashboardDao.findByTenantIdAndTitle(tenantId.getId(), title); } + private PaginatedRemover tenantDashboardsRemover = new PaginatedRemover() { diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java index 26459b28af..0ede2325ac 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java @@ -71,4 +71,5 @@ public interface DashboardInfoRepository extends JpaRepository Date: Fri, 3 Mar 2023 10:41:49 +0200 Subject: [PATCH 12/16] Revert new line --- .../org/thingsboard/server/dao/dashboard/DashboardInfoDao.java | 1 + 1 file changed, 1 insertion(+) diff --git a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java index e8eb1d7a50..e0d1777112 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java +++ b/dao/src/main/java/org/thingsboard/server/dao/dashboard/DashboardInfoDao.java @@ -76,4 +76,5 @@ public interface DashboardInfoDao extends Dao { PageData findDashboardsByTenantIdAndEdgeId(UUID tenantId, UUID edgeId, PageLink pageLink); DashboardInfo findFirstByTenantIdAndName(UUID tenantId, String name); + } From dc7e872b16875a97df048f8d1ae9aa408c44b97e Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 3 Mar 2023 13:44:12 +0200 Subject: [PATCH 13/16] Fixed correct approach for deprecated ts field --- ui-ngx/src/app/shared/models/alias.models.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/shared/models/alias.models.ts b/ui-ngx/src/app/shared/models/alias.models.ts index 3f141834a4..ee64df5288 100644 --- a/ui-ngx/src/app/shared/models/alias.models.ts +++ b/ui-ngx/src/app/shared/models/alias.models.ts @@ -86,25 +86,37 @@ export interface StateEntityFilter { } export interface AssetTypeFilter { - assetType?: string; // deprecated + /** + * @deprecated + */ + assetType?: string; assetTypes?: string[]; assetNameFilter?: string; } export interface DeviceTypeFilter { - deviceType?: string; // deprecated + /** + * @deprecated + */ + deviceType?: string; deviceTypes?: string[]; deviceNameFilter?: string; } export interface EdgeTypeFilter { - edgeType?: string; // deprecated + /** + * @deprecated + */ + edgeType?: string; edgeTypes?: string[]; edgeNameFilter?: string; } export interface EntityViewFilter { - entityViewType?: string; // deprecated + /** + * @deprecated + */ + entityViewType?: string; entityViewTypes?: string[]; entityViewNameFilter?: string; } From 822228245110cb57854b85e5e948a841b3df08a9 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Mon, 6 Mar 2023 11:46:56 +0200 Subject: [PATCH 14/16] Refactoring after code review - removed utils method and move logic into entity classes --- .../common/data/query/AssetTypeFilter.java | 19 +++++++++++++++++-- .../common/data/query/DeviceTypeFilter.java | 19 +++++++++++++++++-- .../common/data/query/EdgeTypeFilter.java | 19 +++++++++++++++++-- .../data/query/EntityViewTypeFilter.java | 19 +++++++++++++++++-- .../query/DefaultEntityQueryRepository.java | 13 ------------- 5 files changed, 68 insertions(+), 21 deletions(-) diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java index 55bbf3b810..3a8669d98b 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java @@ -15,11 +15,18 @@ */ package org.thingsboard.server.common.data.query; -import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.springframework.util.CollectionUtils; +import java.util.Collections; import java.util.List; -@Data +@ToString +@EqualsAndHashCode +@Setter public class AssetTypeFilter implements EntityFilter { /** @@ -30,6 +37,14 @@ public class AssetTypeFilter implements EntityFilter { private List assetTypes; + public List getAssetTypes() { + if (CollectionUtils.isEmpty(assetTypes)) { + assetTypes = Collections.singletonList(assetType); + } + return assetTypes; + } + + @Getter private String assetNameFilter; @Override diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index dfb0771fc5..1790ca80dc 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -16,14 +16,21 @@ package org.thingsboard.server.common.data.query; import lombok.AllArgsConstructor; -import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.springframework.util.CollectionUtils; +import java.util.Collections; import java.util.List; @NoArgsConstructor @AllArgsConstructor -@Data +@ToString +@EqualsAndHashCode +@Setter public class DeviceTypeFilter implements EntityFilter { /** @@ -34,6 +41,14 @@ public class DeviceTypeFilter implements EntityFilter { private List deviceTypes; + public List getDeviceTypes() { + if (CollectionUtils.isEmpty(deviceTypes)) { + deviceTypes = Collections.singletonList(deviceType); + } + return deviceTypes; + } + + @Getter private String deviceNameFilter; public DeviceTypeFilter(List deviceTypes, String deviceNameFilter) { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index 7dbcb8ce34..e3631522cb 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -15,11 +15,18 @@ */ package org.thingsboard.server.common.data.query; -import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.springframework.util.CollectionUtils; +import java.util.Collections; import java.util.List; -@Data +@ToString +@EqualsAndHashCode +@Setter public class EdgeTypeFilter implements EntityFilter { /** @@ -30,6 +37,14 @@ public class EdgeTypeFilter implements EntityFilter { private List edgeTypes; + public List getEdgeTypes() { + if (CollectionUtils.isEmpty(edgeTypes)) { + edgeTypes = Collections.singletonList(edgeType); + } + return edgeTypes; + } + + @Getter private String edgeNameFilter; @Override diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index ad3d8af9e5..cd58a40698 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -15,11 +15,18 @@ */ package org.thingsboard.server.common.data.query; -import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.springframework.util.CollectionUtils; +import java.util.Collections; import java.util.List; -@Data +@ToString +@EqualsAndHashCode +@Setter public class EntityViewTypeFilter implements EntityFilter { /** @@ -30,6 +37,14 @@ public class EntityViewTypeFilter implements EntityFilter { private List entityViewTypes; + public List getEntityViewTypes() { + if (CollectionUtils.isEmpty(entityViewTypes)) { + entityViewTypes = Collections.singletonList(entityViewType); + } + return entityViewTypes; + } + + @Getter private String entityViewNameFilter; @Override diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java index 68c11d9d2b..22dec100c2 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java +++ b/dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultEntityQueryRepository.java @@ -53,7 +53,6 @@ import org.thingsboard.server.common.data.query.SingleEntityFilter; import org.thingsboard.server.common.data.relation.EntitySearchDirection; import org.thingsboard.server.common.data.relation.RelationEntityTypeFilter; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -820,22 +819,18 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { switch (filter.getType()) { case ASSET_TYPE: types = ((AssetTypeFilter) filter).getAssetTypes(); - types = checkTypeListForBackwardCompatibility(types, ((AssetTypeFilter) filter).getAssetType()); name = ((AssetTypeFilter) filter).getAssetNameFilter(); break; case DEVICE_TYPE: types = ((DeviceTypeFilter) filter).getDeviceTypes(); - types = checkTypeListForBackwardCompatibility(types, ((DeviceTypeFilter) filter).getDeviceType()); name = ((DeviceTypeFilter) filter).getDeviceNameFilter(); break; case ENTITY_VIEW_TYPE: types = ((EntityViewTypeFilter) filter).getEntityViewTypes(); - types = checkTypeListForBackwardCompatibility(types, ((EntityViewTypeFilter) filter).getEntityViewType()); name = ((EntityViewTypeFilter) filter).getEntityViewNameFilter(); break; case EDGE_TYPE: types = ((EdgeTypeFilter) filter).getEdgeTypes(); - types = checkTypeListForBackwardCompatibility(types, ((EdgeTypeFilter) filter).getEdgeType()); name = ((EdgeTypeFilter) filter).getEdgeNameFilter(); break; default: @@ -854,14 +849,6 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { } } - private List checkTypeListForBackwardCompatibility(List types, String subType) { - if (types == null || types.isEmpty()) { - types = new ArrayList<>(); - types.add(subType); - } - return types; - } - public static EntityType resolveEntityType(EntityFilter entityFilter) { switch (entityFilter.getType()) { case SINGLE_ENTITY: From a7e0cace139fb68aa6c104736b16daedcfc18e5e Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Mon, 3 Apr 2023 16:50:09 +0300 Subject: [PATCH 15/16] singular type has priority over multiple types --- .../thingsboard/server/common/data/query/AssetTypeFilter.java | 2 +- .../thingsboard/server/common/data/query/DeviceTypeFilter.java | 2 +- .../thingsboard/server/common/data/query/EdgeTypeFilter.java | 2 +- .../server/common/data/query/EntityViewTypeFilter.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java index 3a8669d98b..5e59069237 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java @@ -38,7 +38,7 @@ public class AssetTypeFilter implements EntityFilter { private List assetTypes; public List getAssetTypes() { - if (CollectionUtils.isEmpty(assetTypes)) { + if (assetType != null) { assetTypes = Collections.singletonList(assetType); } return assetTypes; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index 1790ca80dc..491fd2cd16 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -42,7 +42,7 @@ public class DeviceTypeFilter implements EntityFilter { private List deviceTypes; public List getDeviceTypes() { - if (CollectionUtils.isEmpty(deviceTypes)) { + if (deviceType != null) { deviceTypes = Collections.singletonList(deviceType); } return deviceTypes; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index e3631522cb..d554e513df 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -38,7 +38,7 @@ public class EdgeTypeFilter implements EntityFilter { private List edgeTypes; public List getEdgeTypes() { - if (CollectionUtils.isEmpty(edgeTypes)) { + if (edgeType != null) { edgeTypes = Collections.singletonList(edgeType); } return edgeTypes; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index cd58a40698..e2a60d6af0 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -38,7 +38,7 @@ public class EntityViewTypeFilter implements EntityFilter { private List entityViewTypes; public List getEntityViewTypes() { - if (CollectionUtils.isEmpty(entityViewTypes)) { + if (entityViewType != null) { entityViewTypes = Collections.singletonList(entityViewType); } return entityViewTypes; From c4d50181ff560bb4e72b12d00ad1a68d2dec95fb Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Tue, 11 Apr 2023 13:32:20 +0300 Subject: [PATCH 16/16] Always use multiple types if present. If not present - use singular type --- .../server/common/data/query/AssetTypeFilter.java | 5 +---- .../server/common/data/query/DeviceTypeFilter.java | 5 +---- .../thingsboard/server/common/data/query/EdgeTypeFilter.java | 5 +---- .../server/common/data/query/EntityViewTypeFilter.java | 5 +---- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java index 5e59069237..f666c02777 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/AssetTypeFilter.java @@ -38,10 +38,7 @@ public class AssetTypeFilter implements EntityFilter { private List assetTypes; public List getAssetTypes() { - if (assetType != null) { - assetTypes = Collections.singletonList(assetType); - } - return assetTypes; + return !CollectionUtils.isEmpty(assetTypes) ? assetTypes : Collections.singletonList(assetType); } @Getter diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java index 491fd2cd16..bc25d1d158 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/DeviceTypeFilter.java @@ -42,10 +42,7 @@ public class DeviceTypeFilter implements EntityFilter { private List deviceTypes; public List getDeviceTypes() { - if (deviceType != null) { - deviceTypes = Collections.singletonList(deviceType); - } - return deviceTypes; + return !CollectionUtils.isEmpty(deviceTypes) ? deviceTypes : Collections.singletonList(deviceType); } @Getter diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java index d554e513df..306aae43cc 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EdgeTypeFilter.java @@ -38,10 +38,7 @@ public class EdgeTypeFilter implements EntityFilter { private List edgeTypes; public List getEdgeTypes() { - if (edgeType != null) { - edgeTypes = Collections.singletonList(edgeType); - } - return edgeTypes; + return !CollectionUtils.isEmpty(edgeTypes) ? edgeTypes : Collections.singletonList(edgeType); } @Getter diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java index e2a60d6af0..8025cf43b5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/query/EntityViewTypeFilter.java @@ -38,10 +38,7 @@ public class EntityViewTypeFilter implements EntityFilter { private List entityViewTypes; public List getEntityViewTypes() { - if (entityViewType != null) { - entityViewTypes = Collections.singletonList(entityViewType); - } - return entityViewTypes; + return !CollectionUtils.isEmpty(entityViewTypes) ? entityViewTypes : Collections.singletonList(entityViewType); } @Getter