From 907ac6da3df20f0e2c0a428ce35e5dba6cdabd3a Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Thu, 19 May 2022 18:45:40 +0300 Subject: [PATCH] refactoring: EntityViewController comments1 --- .../DefaultTbNotificationEntityService.java | 1 - .../entityView/DefaultTbEntityViewService.java | 17 ++++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java b/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java index 63ccd2b7a2..ad59452d64 100644 --- a/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java +++ b/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java @@ -301,5 +301,4 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS return null; } } - } diff --git a/application/src/main/java/org/thingsboard/server/service/entitiy/entityView/DefaultTbEntityViewService.java b/application/src/main/java/org/thingsboard/server/service/entitiy/entityView/DefaultTbEntityViewService.java index 6c8b49daa5..7ef353e854 100644 --- a/application/src/main/java/org/thingsboard/server/service/entitiy/entityView/DefaultTbEntityViewService.java +++ b/application/src/main/java/org/thingsboard/server/service/entitiy/entityView/DefaultTbEntityViewService.java @@ -22,20 +22,19 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.thingsboard.server.common.data.Customer; -import org.thingsboard.server.common.data.EntityView; import org.thingsboard.server.common.data.DataConstants; import org.thingsboard.server.common.data.EntityType; +import org.thingsboard.server.common.data.EntityView; import org.thingsboard.server.common.data.audit.ActionType; import org.thingsboard.server.common.data.edge.Edge; 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.EntityViewId; import org.thingsboard.server.common.data.id.EdgeId; import org.thingsboard.server.common.data.id.EntityId; +import org.thingsboard.server.common.data.id.EntityViewId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.kv.AttributeKvEntry; import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; @@ -65,8 +64,7 @@ import static org.thingsboard.server.dao.service.Validator.validateId; @Slf4j public class DefaultTbEntityViewService extends AbstractTbEntityService implements TbEntityViewService { - @Autowired - private TimeseriesService tsService; + private final TimeseriesService tsService; @Override public EntityView save(EntityView entityView, SecurityUser user) throws ThingsboardException { @@ -205,7 +203,6 @@ public class DefaultTbEntityViewService extends AbstractTbEntityService implemen } } - // @Override public EntityView unassignEntityViewFromCustomer(EntityView entityView, Customer customer, SecurityUser user) throws ThingsboardException { ActionType actionType = ActionType.UNASSIGNED_FROM_CUSTOMER; @@ -222,7 +219,6 @@ public class DefaultTbEntityViewService extends AbstractTbEntityService implemen } } - private ListenableFuture> copyAttributesFromEntityToEntityView(EntityView entityView, String scope, Collection keys, SecurityUser user) throws ThingsboardException { EntityViewId entityId = entityView.getId(); if (keys != null && !keys.isEmpty()) { @@ -305,7 +301,6 @@ public class DefaultTbEntityViewService extends AbstractTbEntityService implemen }, MoreExecutors.directExecutor()); } - private ListenableFuture deleteAttributesFromEntityView(EntityView entityView, String scope, List keys, SecurityUser user) { EntityViewId entityId = entityView.getId(); SettableFuture resultFuture = SettableFuture.create(); @@ -389,15 +384,15 @@ public class DefaultTbEntityViewService extends AbstractTbEntityService implemen } private void logAttributesUpdated(SecurityUser user, EntityId entityId, String scope, List attributes, Throwable e) throws ThingsboardException { - logEntityAction(user, user.getTenantId(), entityId, null, null, ActionType.ATTRIBUTES_UPDATED, toException(e), scope, attributes); + notificationEntityService.notifyEntity(user.getTenantId(), entityId, null, null, ActionType.ATTRIBUTES_UPDATED, user, toException(e), scope, attributes); } private void logAttributesDeleted(SecurityUser user, EntityId entityId, String scope, List keys, Throwable e) throws ThingsboardException { - logEntityAction(user, user.getTenantId(), entityId, null, null, ActionType.ATTRIBUTES_DELETED, toException(e), scope, keys); + notificationEntityService.notifyEntity(user.getTenantId(), entityId, null, null, ActionType.ATTRIBUTES_DELETED, user, toException(e), scope, keys); } private void logTimeseriesDeleted(SecurityUser user, EntityId entityId, List keys, Throwable e) throws ThingsboardException { - logEntityAction(user, user.getTenantId(), entityId, null, null, ActionType.TIMESERIES_DELETED, toException(e), keys); + notificationEntityService.notifyEntity(user.getTenantId(), entityId, null, null, ActionType.TIMESERIES_DELETED, user, toException(e), keys); } private EntityView checkEntityViewId(EntityViewId entityViewId, Operation operation, SecurityUser user) throws ThingsboardException {