Commit 055a91fca1164f301652750a172a48a23b1c5547

Authored by Volodymyr Babak
1 parent 7af1c86e

EdgeEventActionType introduced

Showing 54 changed files with 285 additions and 228 deletions
... ... @@ -97,7 +97,7 @@ public class RuleChainActorMessageProcessor extends ComponentMsgProcessor<RuleCh
97 97 if (!started) {
98 98 RuleChain ruleChain = service.findRuleChainById(tenantId, entityId);
99 99 if (ruleChain != null) {
100   - if (ruleChain.getType().equals(RuleChainType.CORE)) {
  100 + if (RuleChainType.CORE.equals(ruleChain.getType())) {
101 101 List<RuleNode> ruleNodeList = service.getRuleChainNodes(tenantId, entityId);
102 102 log.trace("[{}][{}] Starting rule chain with {} nodes", tenantId, entityId, ruleNodeList.size());
103 103 // Creating and starting the actors;
... ... @@ -119,7 +119,7 @@ public class RuleChainActorMessageProcessor extends ComponentMsgProcessor<RuleCh
119 119 public void onUpdate(TbActorCtx context) {
120 120 RuleChain ruleChain = service.findRuleChainById(tenantId, entityId);
121 121 if (ruleChain != null) {
122   - if (ruleChain.getType().equals(RuleChainType.CORE)) {
  122 + if (RuleChainType.CORE.equals(ruleChain.getType())) {
123 123 ruleChainName = ruleChain.getName();
124 124 List<RuleNode> ruleNodeList = service.getRuleChainNodes(tenantId, entityId);
125 125 log.trace("[{}][{}] Updating rule chain with {} nodes", tenantId, entityId, ruleNodeList.size());
... ... @@ -145,8 +145,6 @@ public class RuleChainActorMessageProcessor extends ComponentMsgProcessor<RuleCh
145 145 });
146 146
147 147 initRoutes(ruleChain, ruleNodeList);
148   - } else if (ruleChain.getType().equals(RuleChainType.EDGE)) {
149   - stop(context);
150 148 }
151 149 }
152 150 }
... ...
... ... @@ -223,7 +223,7 @@ public class TenantActor extends RuleChainManagerActor {
223 223 if (msg.getEntityId().getEntityType() == EntityType.RULE_CHAIN) {
224 224 RuleChain ruleChain = systemContext.getRuleChainService().
225 225 findRuleChainById(tenantId, new RuleChainId(msg.getEntityId().getId()));
226   - if (ruleChain != null && ruleChain.getType().equals(RuleChainType.CORE)) {
  226 + if (ruleChain != null && RuleChainType.CORE.equals(ruleChain.getType())) {
227 227 visit(ruleChain, target);
228 228 }
229 229 }
... ...
... ... @@ -34,6 +34,7 @@ import org.thingsboard.server.common.data.alarm.AlarmSearchStatus;
34 34 import org.thingsboard.server.common.data.alarm.AlarmSeverity;
35 35 import org.thingsboard.server.common.data.alarm.AlarmStatus;
36 36 import org.thingsboard.server.common.data.audit.ActionType;
  37 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
37 38 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
38 39 import org.thingsboard.server.common.data.exception.ThingsboardException;
39 40 import org.thingsboard.server.common.data.id.AlarmId;
... ... @@ -93,7 +94,7 @@ public class AlarmController extends BaseController {
93 94 alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
94 95
95 96 sendNotificationMsgToEdgeService(getTenantId(), savedAlarm.getId(),
96   - alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
  97 + alarm.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
97 98
98 99 return savedAlarm;
99 100 } catch (Exception e) {
... ... @@ -112,7 +113,7 @@ public class AlarmController extends BaseController {
112 113 AlarmId alarmId = new AlarmId(toUUID(strAlarmId));
113 114 checkAlarmId(alarmId, Operation.WRITE);
114 115
115   - sendNotificationMsgToEdgeService(getTenantId(), alarmId, ActionType.DELETED);
  116 + sendNotificationMsgToEdgeService(getTenantId(), alarmId, EdgeEventActionType.DELETED);
116 117
117 118 return alarmService.deleteAlarm(getTenantId(), alarmId);
118 119 } catch (Exception e) {
... ... @@ -133,7 +134,7 @@ public class AlarmController extends BaseController {
133 134 alarm.setAckTs(ackTs);
134 135 logEntityAction(alarmId, alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_ACK, null);
135 136
136   - sendNotificationMsgToEdgeService(getTenantId(), alarmId, ActionType.ALARM_ACK);
  137 + sendNotificationMsgToEdgeService(getTenantId(), alarmId, EdgeEventActionType.ALARM_ACK);
137 138 } catch (Exception e) {
138 139 throw handleException(e);
139 140 }
... ... @@ -152,7 +153,7 @@ public class AlarmController extends BaseController {
152 153 alarm.setClearTs(clearTs);
153 154 logEntityAction(alarmId, alarm, getCurrentUser().getCustomerId(), ActionType.ALARM_CLEAR, null);
154 155
155   - sendNotificationMsgToEdgeService(getTenantId(), alarmId, ActionType.ALARM_CLEAR);
  156 + sendNotificationMsgToEdgeService(getTenantId(), alarmId, EdgeEventActionType.ALARM_CLEAR);
156 157 } catch (Exception e) {
157 158 throw handleException(e);
158 159 }
... ...
... ... @@ -27,14 +27,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
27 27 import org.springframework.web.bind.annotation.ResponseStatus;
28 28 import org.springframework.web.bind.annotation.RestController;
29 29 import org.thingsboard.server.common.data.Customer;
30   -import org.thingsboard.server.common.data.DataConstants;
31 30 import org.thingsboard.server.common.data.EntitySubtype;
32 31 import org.thingsboard.server.common.data.EntityType;
33 32 import org.thingsboard.server.common.data.asset.Asset;
34 33 import org.thingsboard.server.common.data.asset.AssetSearchQuery;
35 34 import org.thingsboard.server.common.data.audit.ActionType;
36 35 import org.thingsboard.server.common.data.edge.Edge;
37   -import org.thingsboard.server.common.data.edge.EdgeEventType;
  36 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
38 37 import org.thingsboard.server.common.data.exception.ThingsboardException;
39 38 import org.thingsboard.server.common.data.id.AssetId;
40 39 import org.thingsboard.server.common.data.id.CustomerId;
... ... @@ -93,7 +92,7 @@ public class AssetController extends BaseController {
93 92 asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
94 93
95 94 if (asset.getId() != null) {
96   - sendNotificationMsgToEdgeService(savedAsset.getTenantId(), savedAsset.getId(), ActionType.UPDATED);
  95 + sendNotificationMsgToEdgeService(savedAsset.getTenantId(), savedAsset.getId(), EdgeEventActionType.UPDATED);
97 96 }
98 97
99 98 return savedAsset;
... ... @@ -118,7 +117,7 @@ public class AssetController extends BaseController {
118 117 asset.getCustomerId(),
119 118 ActionType.DELETED, null, strAssetId);
120 119
121   - sendNotificationMsgToEdgeService(getTenantId(), assetId, ActionType.DELETED);
  120 + sendNotificationMsgToEdgeService(getTenantId(), assetId, EdgeEventActionType.DELETED);
122 121 } catch (Exception e) {
123 122 logEntityAction(emptyId(EntityType.ASSET),
124 123 null,
... ... @@ -149,7 +148,7 @@ public class AssetController extends BaseController {
149 148 ActionType.ASSIGNED_TO_CUSTOMER, null, strAssetId, strCustomerId, customer.getName());
150 149
151 150 sendNotificationMsgToEdgeService(savedAsset.getTenantId(), savedAsset.getId(),
152   - customerId, ActionType.ASSIGNED_TO_CUSTOMER);
  151 + customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
153 152
154 153 return savedAsset;
155 154 } catch (Exception e) {
... ... @@ -183,7 +182,7 @@ public class AssetController extends BaseController {
183 182 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strAssetId, customer.getId().toString(), customer.getName());
184 183
185 184 sendNotificationMsgToEdgeService(savedAsset.getTenantId(), savedAsset.getId(),
186   - customer.getId(), ActionType.UNASSIGNED_FROM_CUSTOMER);
  185 + customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
187 186
188 187 return savedAsset;
189 188 } catch (Exception e) {
... ... @@ -367,7 +366,7 @@ public class AssetController extends BaseController {
367 366 savedAsset.getCustomerId(),
368 367 ActionType.ASSIGNED_TO_EDGE, null, strAssetId, strEdgeId, edge.getName());
369 368
370   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), ActionType.ASSIGNED_TO_EDGE);
  369 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
371 370
372 371 return savedAsset;
373 372 } catch (Exception e) {
... ... @@ -400,7 +399,7 @@ public class AssetController extends BaseController {
400 399 asset.getCustomerId(),
401 400 ActionType.UNASSIGNED_FROM_EDGE, null, strAssetId, edge.getId().toString(), edge.getName());
402 401
403   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), ActionType.UNASSIGNED_FROM_EDGE);
  402 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
404 403
405 404 return savedAsset;
406 405 } catch (Exception e) {
... ...
... ... @@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
35 35 import org.thingsboard.rule.engine.api.MailService;
36 36 import org.thingsboard.server.common.data.User;
37 37 import org.thingsboard.server.common.data.audit.ActionType;
  38 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
38 39 import org.thingsboard.server.common.data.edge.EdgeEventType;
39 40 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
40 41 import org.thingsboard.server.common.data.exception.ThingsboardException;
... ... @@ -126,7 +127,7 @@ public class AuthController extends BaseController {
126 127 userCredentials.setPassword(passwordEncoder.encode(newPassword));
127 128 userService.replaceUserCredentials(securityUser.getTenantId(), userCredentials);
128 129
129   - sendNotificationMsgToEdgeService(getTenantId(), userCredentials.getUserId(), ActionType.CREDENTIALS_UPDATED);
  130 + sendNotificationMsgToEdgeService(getTenantId(), userCredentials.getUserId(), EdgeEventActionType.CREDENTIALS_UPDATED);
130 131
131 132 } catch (Exception e) {
132 133 throw handleException(e);
... ... @@ -235,7 +236,7 @@ public class AuthController extends BaseController {
235 236 }
236 237 }
237 238
238   - sendNotificationMsgToEdgeService(user.getTenantId(), user.getId(), ActionType.CREDENTIALS_UPDATED);
  239 + sendNotificationMsgToEdgeService(user.getTenantId(), user.getId(), EdgeEventActionType.CREDENTIALS_UPDATED);
239 240
240 241 JwtToken accessToken = tokenFactory.createAccessJwtToken(securityUser);
241 242 JwtToken refreshToken = refreshTokenRepository.requestRefreshToken(securityUser);
... ...
... ... @@ -44,6 +44,7 @@ import org.thingsboard.server.common.data.alarm.AlarmInfo;
44 44 import org.thingsboard.server.common.data.asset.Asset;
45 45 import org.thingsboard.server.common.data.audit.ActionType;
46 46 import org.thingsboard.server.common.data.edge.Edge;
  47 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
47 48 import org.thingsboard.server.common.data.edge.EdgeEventType;
48 49 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
49 50 import org.thingsboard.server.common.data.exception.ThingsboardException;
... ... @@ -755,7 +756,7 @@ public abstract class BaseController {
755 756 return null;
756 757 }
757 758
758   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, ActionType action) {
  759 + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, CustomerId customerId, EdgeEventActionType action) {
759 760 if (!edgesSupportEnabled) {
760 761 return;
761 762 }
... ... @@ -766,7 +767,7 @@ public abstract class BaseController {
766 767 }
767 768 }
768 769
769   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, ActionType action) {
  770 + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, CustomerId customerId, EdgeEventActionType action) {
770 771 if (!edgesSupportEnabled) {
771 772 return;
772 773 }
... ... @@ -780,7 +781,7 @@ public abstract class BaseController {
780 781 }
781 782 }
782 783
783   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, ActionType action) {
  784 + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityRelation relation, EdgeEventActionType action) {
784 785 if (!edgesSupportEnabled) {
785 786 return;
786 787 }
... ... @@ -794,11 +795,11 @@ public abstract class BaseController {
794 795 }
795 796 }
796 797
797   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, ActionType action) {
  798 + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, EdgeEventActionType action) {
798 799 sendNotificationMsgToEdgeService(tenantId, null, entityId, action);
799 800 }
800 801
801   - protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, ActionType action) {
  802 + protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, EdgeEventActionType action) {
802 803 if (!edgesSupportEnabled) {
803 804 return;
804 805 }
... ... @@ -808,7 +809,7 @@ public abstract class BaseController {
808 809 }
809 810 }
810 811
811   - private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String body, EdgeEventType type, ActionType action) {
  812 + private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String body, EdgeEventType type, EdgeEventActionType action) {
812 813 TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder();
813 814 builder.setTenantIdMSB(tenantId.getId().getMostSignificantBits());
814 815 builder.setTenantIdLSB(tenantId.getId().getLeastSignificantBits());
... ...
... ... @@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
31 31 import org.thingsboard.server.common.data.Customer;
32 32 import org.thingsboard.server.common.data.EntityType;
33 33 import org.thingsboard.server.common.data.audit.ActionType;
  34 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
34 35 import org.thingsboard.server.common.data.exception.ThingsboardException;
35 36 import org.thingsboard.server.common.data.id.CustomerId;
36 37 import org.thingsboard.server.common.data.id.TenantId;
... ... @@ -109,7 +110,7 @@ public class CustomerController extends BaseController {
109 110 customer.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
110 111
111 112 if (customer.getId() != null) {
112   - sendNotificationMsgToEdgeService(savedCustomer.getTenantId(), savedCustomer.getId(),ActionType.UPDATED);
  113 + sendNotificationMsgToEdgeService(savedCustomer.getTenantId(), savedCustomer.getId(), EdgeEventActionType.UPDATED);
113 114 }
114 115
115 116 return savedCustomer;
... ... @@ -136,7 +137,7 @@ public class CustomerController extends BaseController {
136 137 customer.getId(),
137 138 ActionType.DELETED, null, strCustomerId);
138 139
139   - sendNotificationMsgToEdgeService(getTenantId(), customerId, ActionType.DELETED);
  140 + sendNotificationMsgToEdgeService(getTenantId(), customerId, EdgeEventActionType.DELETED);
140 141 } catch (Exception e) {
141 142
142 143 logEntityAction(emptyId(EntityType.CUSTOMER),
... ...
... ... @@ -33,6 +33,7 @@ import org.thingsboard.server.common.data.EntityType;
33 33 import org.thingsboard.server.common.data.ShortCustomerInfo;
34 34 import org.thingsboard.server.common.data.audit.ActionType;
35 35 import org.thingsboard.server.common.data.edge.Edge;
  36 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
36 37 import org.thingsboard.server.common.data.exception.ThingsboardException;
37 38 import org.thingsboard.server.common.data.id.CustomerId;
38 39 import org.thingsboard.server.common.data.id.DashboardId;
... ... @@ -116,7 +117,7 @@ public class DashboardController extends BaseController {
116 117 dashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
117 118
118 119 if (dashboard.getId() != null) {
119   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), ActionType.UPDATED);
  120 + sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), EdgeEventActionType.UPDATED);
120 121 }
121 122
122 123 return savedDashboard;
... ... @@ -142,7 +143,7 @@ public class DashboardController extends BaseController {
142 143 null,
143 144 ActionType.DELETED, null, strDashboardId);
144 145
145   - sendNotificationMsgToEdgeService(getTenantId(), dashboardId, ActionType.DELETED);
  146 + sendNotificationMsgToEdgeService(getTenantId(), dashboardId, EdgeEventActionType.DELETED);
146 147 } catch (Exception e) {
147 148
148 149 logEntityAction(emptyId(EntityType.DASHBOARD),
... ... @@ -174,7 +175,7 @@ public class DashboardController extends BaseController {
174 175 customerId,
175 176 ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, strCustomerId, customer.getName());
176 177
177   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, ActionType.ASSIGNED_TO_CUSTOMER);
  178 + sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
178 179
179 180 return savedDashboard;
180 181 } catch (Exception e) {
... ... @@ -206,7 +207,7 @@ public class DashboardController extends BaseController {
206 207 customerId,
207 208 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customer.getId().toString(), customer.getName());
208 209
209   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, ActionType.UNASSIGNED_FROM_CUSTOMER);
  210 + sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
210 211
211 212 return savedDashboard;
212 213 } catch (Exception e) {
... ... @@ -263,7 +264,7 @@ public class DashboardController extends BaseController {
263 264 logEntityAction(dashboardId, savedDashboard,
264 265 customerId,
265 266 ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
266   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, ActionType.ASSIGNED_TO_CUSTOMER);
  267 + sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
267 268 }
268 269 for (CustomerId customerId : removedCustomerIds) {
269 270 ShortCustomerInfo customerInfo = dashboard.getAssignedCustomerInfo(customerId);
... ... @@ -271,7 +272,7 @@ public class DashboardController extends BaseController {
271 272 logEntityAction(dashboardId, dashboard,
272 273 customerId,
273 274 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
274   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, ActionType.UNASSIGNED_FROM_CUSTOMER);
  275 + sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
275 276 }
276 277 return savedDashboard;
277 278 }
... ... @@ -315,7 +316,7 @@ public class DashboardController extends BaseController {
315 316 logEntityAction(dashboardId, savedDashboard,
316 317 customerId,
317 318 ActionType.ASSIGNED_TO_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
318   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, ActionType.ASSIGNED_TO_CUSTOMER);
  319 + sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
319 320 }
320 321 return savedDashboard;
321 322 }
... ... @@ -359,7 +360,7 @@ public class DashboardController extends BaseController {
359 360 logEntityAction(dashboardId, dashboard,
360 361 customerId,
361 362 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDashboardId, customerId.toString(), customerInfo.getTitle());
362   - sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, ActionType.UNASSIGNED_FROM_CUSTOMER);
  363 + sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(), customerId, EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
363 364 }
364 365 return savedDashboard;
365 366 }
... ... @@ -504,7 +505,7 @@ public class DashboardController extends BaseController {
504 505 null,
505 506 ActionType.ASSIGNED_TO_EDGE, null, strDashboardId, strEdgeId, edge.getName());
506 507
507   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), ActionType.ASSIGNED_TO_EDGE);
  508 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
508 509
509 510 return savedDashboard;
510 511 } catch (Exception e) {
... ... @@ -536,7 +537,7 @@ public class DashboardController extends BaseController {
536 537 null,
537 538 ActionType.UNASSIGNED_FROM_EDGE, null, strDashboardId, edge.getId().toString(), edge.getName());
538 539
539   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), ActionType.UNASSIGNED_FROM_EDGE);
  540 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
540 541
541 542 return savedDashboard;
542 543 } catch (Exception e) {
... ...
... ... @@ -43,6 +43,7 @@ import org.thingsboard.server.common.data.Tenant;
43 43 import org.thingsboard.server.common.data.audit.ActionType;
44 44 import org.thingsboard.server.common.data.device.DeviceSearchQuery;
45 45 import org.thingsboard.server.common.data.edge.Edge;
  46 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
46 47 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
47 48 import org.thingsboard.server.common.data.exception.ThingsboardException;
48 49 import org.thingsboard.server.common.data.id.CustomerId;
... ... @@ -112,7 +113,7 @@ public class DeviceController extends BaseController {
112 113 savedDevice.getId(), savedDevice.getName(), savedDevice.getType()), null);
113 114
114 115 if (device.getId() != null) {
115   - sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(),ActionType.UPDATED);
  116 + sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(), EdgeEventActionType.UPDATED);
116 117 }
117 118
118 119 logEntityAction(savedDevice.getId(), savedDevice,
... ... @@ -146,7 +147,7 @@ public class DeviceController extends BaseController {
146 147 device.getCustomerId(),
147 148 ActionType.DELETED, null, strDeviceId);
148 149
149   - sendNotificationMsgToEdgeService(getTenantId(), deviceId, ActionType.DELETED);
  150 + sendNotificationMsgToEdgeService(getTenantId(), deviceId, EdgeEventActionType.DELETED);
150 151
151 152 deviceStateService.onDeviceDeleted(device);
152 153 } catch (Exception e) {
... ... @@ -179,7 +180,7 @@ public class DeviceController extends BaseController {
179 180 ActionType.ASSIGNED_TO_CUSTOMER, null, strDeviceId, strCustomerId, customer.getName());
180 181
181 182 sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(),
182   - customerId, ActionType.ASSIGNED_TO_CUSTOMER);
  183 + customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
183 184
184 185 return savedDevice;
185 186 } catch (Exception e) {
... ... @@ -210,7 +211,7 @@ public class DeviceController extends BaseController {
210 211 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strDeviceId, customer.getId().toString(), customer.getName());
211 212
212 213 sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(),
213   - customer.getId(), ActionType.UNASSIGNED_FROM_CUSTOMER);
  214 + customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
214 215
215 216 return savedDevice;
216 217 } catch (Exception e) {
... ... @@ -277,7 +278,7 @@ public class DeviceController extends BaseController {
277 278
278 279 tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(getCurrentUser().getTenantId(), deviceCredentials.getDeviceId()), null);
279 280
280   - sendNotificationMsgToEdgeService(getTenantId(), device.getId(), ActionType.CREDENTIALS_UPDATED);
  281 + sendNotificationMsgToEdgeService(getTenantId(), device.getId(), EdgeEventActionType.CREDENTIALS_UPDATED);
281 282
282 283 logEntityAction(device.getId(), device,
283 284 device.getCustomerId(),
... ... @@ -578,7 +579,7 @@ public class DeviceController extends BaseController {
578 579 savedDevice.getCustomerId(),
579 580 ActionType.ASSIGNED_TO_EDGE, null, strDeviceId, strEdgeId, edge.getName());
580 581
581   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), ActionType.ASSIGNED_TO_EDGE);
  582 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
582 583
583 584 return savedDevice;
584 585 } catch (Exception e) {
... ... @@ -609,7 +610,7 @@ public class DeviceController extends BaseController {
609 610 device.getCustomerId(),
610 611 ActionType.UNASSIGNED_FROM_EDGE, null, strDeviceId, edge.getId().toString(), edge.getName());
611 612
612   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), ActionType.UNASSIGNED_FROM_EDGE);
  613 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
613 614
614 615 return savedDevice;
615 616 } catch (Exception e) {
... ...
... ... @@ -31,6 +31,7 @@ import org.thingsboard.server.common.data.EntitySubtype;
31 31 import org.thingsboard.server.common.data.EntityType;
32 32 import org.thingsboard.server.common.data.audit.ActionType;
33 33 import org.thingsboard.server.common.data.edge.Edge;
  34 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
34 35 import org.thingsboard.server.common.data.edge.EdgeSearchQuery;
35 36 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
36 37 import org.thingsboard.server.common.data.exception.ThingsboardException;
... ... @@ -185,7 +186,7 @@ public class EdgeController extends BaseController {
185 186 ActionType.ASSIGNED_TO_CUSTOMER, null, strEdgeId, strCustomerId, customer.getName());
186 187
187 188 sendNotificationMsgToEdgeService(savedEdge.getTenantId(), savedEdge.getId(),
188   - customerId, ActionType.ASSIGNED_TO_CUSTOMER);
  189 + customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
189 190
190 191 return savedEdge;
191 192 } catch (Exception e) {
... ... @@ -219,7 +220,7 @@ public class EdgeController extends BaseController {
219 220 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strEdgeId, customer.getId().toString(), customer.getName());
220 221
221 222 sendNotificationMsgToEdgeService(savedEdge.getTenantId(), savedEdge.getId(),
222   - customer.getId(), ActionType.UNASSIGNED_FROM_CUSTOMER);
  223 + customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
223 224
224 225 return savedEdge;
225 226 } catch (Exception e) {
... ...
... ... @@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
25 25 import org.springframework.web.bind.annotation.ResponseStatus;
26 26 import org.springframework.web.bind.annotation.RestController;
27 27 import org.thingsboard.server.common.data.audit.ActionType;
  28 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
28 29 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
29 30 import org.thingsboard.server.common.data.exception.ThingsboardException;
30 31 import org.thingsboard.server.common.data.id.EntityId;
... ... @@ -69,7 +70,7 @@ public class EntityRelationController extends BaseController {
69 70 logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(),
70 71 ActionType.RELATION_ADD_OR_UPDATE, null, relation);
71 72
72   - sendNotificationMsgToEdgeService(getTenantId(), relation, ActionType.RELATION_ADD_OR_UPDATE);
  73 + sendNotificationMsgToEdgeService(getTenantId(), relation, EdgeEventActionType.RELATION_ADD_OR_UPDATE);
73 74 } catch (Exception e) {
74 75 logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(),
75 76 ActionType.RELATION_ADD_OR_UPDATE, e, relation);
... ... @@ -108,7 +109,7 @@ public class EntityRelationController extends BaseController {
108 109 logEntityAction(relation.getTo(), null, getCurrentUser().getCustomerId(),
109 110 ActionType.RELATION_DELETED, null, relation);
110 111
111   - sendNotificationMsgToEdgeService(getTenantId(), relation, ActionType.RELATION_DELETED);
  112 + sendNotificationMsgToEdgeService(getTenantId(), relation, EdgeEventActionType.RELATION_DELETED);
112 113 } catch (Exception e) {
113 114 logEntityAction(relation.getFrom(), null, getCurrentUser().getCustomerId(),
114 115 ActionType.RELATION_DELETED, e, relation);
... ...
... ... @@ -37,7 +37,7 @@ import org.thingsboard.server.common.data.EntityType;
37 37 import org.thingsboard.server.common.data.EntityView;
38 38 import org.thingsboard.server.common.data.audit.ActionType;
39 39 import org.thingsboard.server.common.data.edge.Edge;
40   -import org.thingsboard.server.common.data.edge.EdgeEventType;
  40 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
41 41 import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery;
42 42 import org.thingsboard.server.common.data.exception.ThingsboardException;
43 43 import org.thingsboard.server.common.data.id.CustomerId;
... ... @@ -119,7 +119,7 @@ public class EntityViewController extends BaseController {
119 119 entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
120 120
121 121 if (entityView.getId() != null) {
122   - sendNotificationMsgToEdgeService(savedEntityView.getTenantId(), savedEntityView.getId(), ActionType.UPDATED);
  122 + sendNotificationMsgToEdgeService(savedEntityView.getTenantId(), savedEntityView.getId(), EdgeEventActionType.UPDATED);
123 123 }
124 124
125 125 return savedEntityView;
... ... @@ -192,7 +192,7 @@ public class EntityViewController extends BaseController {
192 192 logEntityAction(entityViewId, entityView, entityView.getCustomerId(),
193 193 ActionType.DELETED, null, strEntityViewId);
194 194
195   - sendNotificationMsgToEdgeService(getTenantId(), entityViewId, ActionType.DELETED);
  195 + sendNotificationMsgToEdgeService(getTenantId(), entityViewId, EdgeEventActionType.DELETED);
196 196 } catch (Exception e) {
197 197 logEntityAction(emptyId(EntityType.ENTITY_VIEW),
198 198 null,
... ... @@ -235,7 +235,7 @@ public class EntityViewController extends BaseController {
235 235 ActionType.ASSIGNED_TO_CUSTOMER, null, strEntityViewId, strCustomerId, customer.getName());
236 236
237 237 sendNotificationMsgToEdgeService(savedEntityView.getTenantId(), savedEntityView.getId(),
238   - customerId, ActionType.ASSIGNED_TO_CUSTOMER);
  238 + customerId, EdgeEventActionType.ASSIGNED_TO_CUSTOMER);
239 239
240 240 return savedEntityView;
241 241 } catch (Exception e) {
... ... @@ -264,7 +264,7 @@ public class EntityViewController extends BaseController {
264 264 ActionType.UNASSIGNED_FROM_CUSTOMER, null, strEntityViewId, customer.getId().toString(), customer.getName());
265 265
266 266 sendNotificationMsgToEdgeService(savedEntityView.getTenantId(), savedEntityView.getId(),
267   - customer.getId(), ActionType.UNASSIGNED_FROM_CUSTOMER);
  267 + customer.getId(), EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER);
268 268
269 269 return savedEntityView;
270 270 } catch (Exception e) {
... ... @@ -405,7 +405,7 @@ public class EntityViewController extends BaseController {
405 405 savedEntityView.getCustomerId(),
406 406 ActionType.ASSIGNED_TO_EDGE, null, strEntityViewId, strEdgeId, edge.getName());
407 407
408   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), ActionType.ASSIGNED_TO_EDGE);
  408 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
409 409
410 410 return savedEntityView;
411 411 } catch (Exception e) {
... ... @@ -435,7 +435,7 @@ public class EntityViewController extends BaseController {
435 435 entityView.getCustomerId(),
436 436 ActionType.UNASSIGNED_FROM_EDGE, null, strEntityViewId, edge.getId().toString(), edge.getName());
437 437
438   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), ActionType.UNASSIGNED_FROM_EDGE);
  438 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
439 439
440 440 return savedEntityView;
441 441 } catch (Exception e) {
... ...
... ... @@ -41,6 +41,7 @@ import org.thingsboard.server.common.data.EntityType;
41 41 import org.thingsboard.server.common.data.Event;
42 42 import org.thingsboard.server.common.data.audit.ActionType;
43 43 import org.thingsboard.server.common.data.edge.Edge;
  44 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
44 45 import org.thingsboard.server.common.data.edge.EdgeEventType;
45 46 import org.thingsboard.server.common.data.exception.ThingsboardException;
46 47 import org.thingsboard.server.common.data.id.EdgeId;
... ... @@ -146,7 +147,7 @@ public class RuleChainController extends BaseController {
146 147
147 148 if (RuleChainType.EDGE.equals(savedRuleChain.getType())) {
148 149 if (!created) {
149   - sendNotificationMsgToEdgeService(savedRuleChain.getTenantId(), savedRuleChain.getId(), ActionType.UPDATED);
  150 + sendNotificationMsgToEdgeService(savedRuleChain.getTenantId(), savedRuleChain.getId(), EdgeEventActionType.UPDATED);
150 151 }
151 152 }
152 153
... ... @@ -226,7 +227,7 @@ public class RuleChainController extends BaseController {
226 227
227 228 if (RuleChainType.EDGE.equals(ruleChain.getType())) {
228 229 sendNotificationMsgToEdgeService(ruleChain.getTenantId(),
229   - ruleChain.getId(), ActionType.UPDATED);
  230 + ruleChain.getId(), EdgeEventActionType.UPDATED);
230 231 }
231 232
232 233 return savedRuleChainMetaData;
... ... @@ -291,7 +292,7 @@ public class RuleChainController extends BaseController {
291 292 ActionType.DELETED, null, strRuleChainId);
292 293
293 294 if (RuleChainType.EDGE.equals(ruleChain.getType())) {
294   - sendNotificationMsgToEdgeService(ruleChain.getTenantId(), ruleChain.getId(), ActionType.DELETED);
  295 + sendNotificationMsgToEdgeService(ruleChain.getTenantId(), ruleChain.getId(), EdgeEventActionType.DELETED);
295 296 }
296 297
297 298 } catch (Exception e) {
... ... @@ -423,7 +424,7 @@ public class RuleChainController extends BaseController {
423 424 null,
424 425 ActionType.ASSIGNED_TO_EDGE, null, strRuleChainId, strEdgeId, edge.getName());
425 426
426   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), ActionType.ASSIGNED_TO_EDGE);
  427 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), EdgeEventActionType.ASSIGNED_TO_EDGE);
427 428
428 429 return savedRuleChain;
429 430 } catch (Exception e) {
... ... @@ -455,7 +456,7 @@ public class RuleChainController extends BaseController {
455 456 null,
456 457 ActionType.UNASSIGNED_FROM_EDGE, null, strRuleChainId, edge.getId().toString(), edge.getName());
457 458
458   - sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), ActionType.UNASSIGNED_FROM_EDGE);
  459 + sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), EdgeEventActionType.UNASSIGNED_FROM_EDGE);
459 460
460 461 return savedRuleChain;
461 462 } catch (Exception e) {
... ...
... ... @@ -35,7 +35,7 @@ import org.thingsboard.rule.engine.api.MailService;
35 35 import org.thingsboard.server.common.data.EntityType;
36 36 import org.thingsboard.server.common.data.User;
37 37 import org.thingsboard.server.common.data.audit.ActionType;
38   -import org.thingsboard.server.common.data.edge.EdgeEventType;
  38 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
39 39 import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
40 40 import org.thingsboard.server.common.data.exception.ThingsboardException;
41 41 import org.thingsboard.server.common.data.id.CustomerId;
... ... @@ -163,7 +163,7 @@ public class UserController extends BaseController {
163 163 user.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
164 164
165 165 sendNotificationMsgToEdgeService(getTenantId(), savedUser.getId(),
166   - user.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
  166 + user.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
167 167
168 168 return savedUser;
169 169 } catch (Exception e) {
... ... @@ -240,7 +240,7 @@ public class UserController extends BaseController {
240 240 user.getCustomerId(),
241 241 ActionType.DELETED, null, strUserId);
242 242
243   - sendNotificationMsgToEdgeService(getTenantId(), user.getId(), ActionType.DELETED);
  243 + sendNotificationMsgToEdgeService(getTenantId(), user.getId(), EdgeEventActionType.DELETED);
244 244
245 245 } catch (Exception e) {
246 246 logEntityAction(emptyId(EntityType.USER),
... ...
... ... @@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
27 27 import org.springframework.web.bind.annotation.ResponseStatus;
28 28 import org.springframework.web.bind.annotation.RestController;
29 29 import org.thingsboard.server.common.data.audit.ActionType;
  30 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
30 31 import org.thingsboard.server.common.data.exception.ThingsboardException;
31 32 import org.thingsboard.server.common.data.id.TenantId;
32 33 import org.thingsboard.server.common.data.id.WidgetTypeId;
... ... @@ -73,7 +74,7 @@ public class WidgetTypeController extends BaseController {
73 74 WidgetType savedWidgetType = widgetTypeService.saveWidgetType(widgetType);
74 75
75 76 sendNotificationMsgToEdgeService(getTenantId(), savedWidgetType.getId(),
76   - widgetType.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
  77 + widgetType.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
77 78
78 79 return checkNotNull(savedWidgetType);
79 80 } catch (Exception e) {
... ... @@ -91,7 +92,7 @@ public class WidgetTypeController extends BaseController {
91 92 checkWidgetTypeId(widgetTypeId, Operation.DELETE);
92 93 widgetTypeService.deleteWidgetType(getCurrentUser().getTenantId(), widgetTypeId);
93 94
94   - sendNotificationMsgToEdgeService(getTenantId(), widgetTypeId, ActionType.DELETED);
  95 + sendNotificationMsgToEdgeService(getTenantId(), widgetTypeId, EdgeEventActionType.DELETED);
95 96
96 97 } catch (Exception e) {
97 98 throw handleException(e);
... ...
... ... @@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
26 26 import org.springframework.web.bind.annotation.ResponseStatus;
27 27 import org.springframework.web.bind.annotation.RestController;
28 28 import org.thingsboard.server.common.data.audit.ActionType;
  29 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
29 30 import org.thingsboard.server.common.data.exception.ThingsboardException;
30 31 import org.thingsboard.server.common.data.id.TenantId;
31 32 import org.thingsboard.server.common.data.id.WidgetsBundleId;
... ... @@ -72,7 +73,7 @@ public class WidgetsBundleController extends BaseController {
72 73 WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle);
73 74
74 75 sendNotificationMsgToEdgeService(getTenantId(), savedWidgetsBundle.getId(),
75   - widgetsBundle.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
  76 + widgetsBundle.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED);
76 77
77 78 return checkNotNull(savedWidgetsBundle);
78 79 } catch (Exception e) {
... ... @@ -90,7 +91,7 @@ public class WidgetsBundleController extends BaseController {
90 91 checkWidgetsBundleId(widgetsBundleId, Operation.DELETE);
91 92 widgetsBundleService.deleteWidgetsBundle(getTenantId(), widgetsBundleId);
92 93
93   - sendNotificationMsgToEdgeService(getTenantId(), widgetsBundleId, ActionType.DELETED);
  94 + sendNotificationMsgToEdgeService(getTenantId(), widgetsBundleId, EdgeEventActionType.DELETED);
94 95
95 96 } catch (Exception e) {
96 97 throw handleException(e);
... ...
... ... @@ -28,9 +28,9 @@ import org.springframework.stereotype.Service;
28 28 import org.thingsboard.server.common.data.EntityType;
29 29 import org.thingsboard.server.common.data.User;
30 30 import org.thingsboard.server.common.data.alarm.Alarm;
31   -import org.thingsboard.server.common.data.audit.ActionType;
32 31 import org.thingsboard.server.common.data.edge.Edge;
33 32 import org.thingsboard.server.common.data.edge.EdgeEvent;
  33 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
34 34 import org.thingsboard.server.common.data.edge.EdgeEventType;
35 35 import org.thingsboard.server.common.data.id.AlarmId;
36 36 import org.thingsboard.server.common.data.id.CustomerId;
... ... @@ -50,7 +50,6 @@ import org.thingsboard.server.common.msg.queue.TbCallback;
50 50 import org.thingsboard.server.dao.alarm.AlarmService;
51 51 import org.thingsboard.server.dao.edge.EdgeEventService;
52 52 import org.thingsboard.server.dao.edge.EdgeService;
53   -import org.thingsboard.server.dao.relation.RelationService;
54 53 import org.thingsboard.server.dao.rule.RuleChainService;
55 54 import org.thingsboard.server.dao.user.UserService;
56 55 import org.thingsboard.server.gen.transport.TransportProtos;
... ... @@ -116,14 +115,14 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
116 115 public Edge setEdgeRootRuleChain(TenantId tenantId, Edge edge, RuleChainId ruleChainId) throws IOException {
117 116 edge.setRootRuleChainId(ruleChainId);
118 117 Edge savedEdge = edgeService.saveEdge(edge);
119   - saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.RULE_CHAIN, ActionType.UPDATED, ruleChainId, null);
  118 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.RULE_CHAIN, EdgeEventActionType.UPDATED, ruleChainId, null);
120 119 return savedEdge;
121 120 }
122 121
123 122 private void saveEdgeEvent(TenantId tenantId,
124 123 EdgeId edgeId,
125 124 EdgeEventType type,
126   - ActionType action,
  125 + EdgeEventActionType action,
127 126 EntityId entityId,
128 127 JsonNode body) {
129 128 log.debug("Pushing edge event to edge queue. tenantId [{}], edgeId [{}], type [{}], action[{}], entityId [{}], body [{}]",
... ... @@ -133,7 +132,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
133 132 edgeEvent.setEdgeId(edgeId);
134 133 edgeEvent.setTenantId(tenantId);
135 134 edgeEvent.setType(type);
136   - edgeEvent.setAction(action.name());
  135 + edgeEvent.setAction(action);
137 136 if (entityId != null) {
138 137 edgeEvent.setEntityId(entityId.getId());
139 138 }
... ... @@ -184,7 +183,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
184 183
185 184 private void processEdge(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) {
186 185 try {
187   - ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction());
  186 + EdgeEventActionType actionType = EdgeEventActionType.valueOf(edgeNotificationMsg.getAction());
188 187 EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB()));
189 188 ListenableFuture<Edge> edgeFuture;
190 189 switch (actionType) {
... ... @@ -195,12 +194,12 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
195 194 @Override
196 195 public void onSuccess(@Nullable Edge edge) {
197 196 if (edge != null && !customerId.isNullUid()) {
198   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.CUSTOMER, ActionType.ADDED, customerId, null);
  197 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.CUSTOMER, EdgeEventActionType.ADDED, customerId, null);
199 198 TextPageData<User> pageData = userService.findCustomerUsers(tenantId, customerId, new TextPageLink(Integer.MAX_VALUE));
200 199 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
201 200 log.trace("[{}] [{}] user(s) are going to be added to edge.", edge.getId(), pageData.getData().size());
202 201 for (User user : pageData.getData()) {
203   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, ActionType.ADDED, user.getId(), null);
  202 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, EdgeEventActionType.ADDED, user.getId(), null);
204 203 }
205 204 }
206 205 }
... ... @@ -219,7 +218,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
219 218 @Override
220 219 public void onSuccess(@Nullable Edge edge) {
221 220 if (edge != null && !customerIdToDelete.isNullUid()) {
222   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.CUSTOMER, ActionType.DELETED, customerIdToDelete, null);
  221 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.CUSTOMER, EdgeEventActionType.DELETED, customerIdToDelete, null);
223 222 }
224 223 }
225 224
... ... @@ -236,7 +235,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
236 235 }
237 236
238 237 private void processWidgetBundleOrWidgetType(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) {
239   - ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction());
  238 + EdgeEventActionType actionType = EdgeEventActionType.valueOf(edgeNotificationMsg.getAction());
240 239 EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType());
241 240 EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB()));
242 241 switch (actionType) {
... ... @@ -254,7 +253,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
254 253 }
255 254
256 255 private void processCustomer(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) {
257   - ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction());
  256 + EdgeEventActionType actionType = EdgeEventActionType.valueOf(edgeNotificationMsg.getAction());
258 257 EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType());
259 258 EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB()));
260 259 TextPageData<Edge> edgesByTenantId = edgeService.findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE));
... ... @@ -275,7 +274,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
275 274 }
276 275
277 276 private void processEntity(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) {
278   - ActionType actionType = ActionType.valueOf(edgeNotificationMsg.getAction());
  277 + EdgeEventActionType actionType = EdgeEventActionType.valueOf(edgeNotificationMsg.getAction());
279 278 EdgeEventType type = EdgeEventType.valueOf(edgeNotificationMsg.getType());
280 279 EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(type,
281 280 new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB()));
... ... @@ -372,7 +371,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
372 371 saveEdgeEvent(tenantId,
373 372 edgeId,
374 373 EdgeEventType.RULE_CHAIN_METADATA,
375   - ActionType.UPDATED,
  374 + EdgeEventActionType.UPDATED,
376 375 ruleChain.getId(),
377 376 null);
378 377 }
... ... @@ -404,7 +403,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
404 403 saveEdgeEvent(tenantId,
405 404 edgeId,
406 405 EdgeEventType.ALARM,
407   - ActionType.valueOf(edgeNotificationMsg.getAction()),
  406 + EdgeEventActionType.valueOf(edgeNotificationMsg.getAction()),
408 407 alarmId,
409 408 null);
410 409 }
... ... @@ -439,7 +438,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
439 438 saveEdgeEvent(tenantId,
440 439 edgeId,
441 440 EdgeEventType.RELATION,
442   - ActionType.valueOf(edgeNotificationMsg.getAction()),
  441 + EdgeEventActionType.valueOf(edgeNotificationMsg.getAction()),
443 442 null,
444 443 mapper.valueToTree(relation));
445 444 }
... ...
... ... @@ -37,9 +37,9 @@ import org.thingsboard.server.common.data.HasCustomerId;
37 37 import org.thingsboard.server.common.data.User;
38 38 import org.thingsboard.server.common.data.alarm.Alarm;
39 39 import org.thingsboard.server.common.data.asset.Asset;
40   -import org.thingsboard.server.common.data.audit.ActionType;
41 40 import org.thingsboard.server.common.data.edge.Edge;
42 41 import org.thingsboard.server.common.data.edge.EdgeEvent;
  42 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
43 43 import org.thingsboard.server.common.data.edge.EdgeEventType;
44 44 import org.thingsboard.server.common.data.id.AlarmId;
45 45 import org.thingsboard.server.common.data.id.AssetId;
... ... @@ -313,8 +313,7 @@ public final class EdgeGrpcSession implements Closeable {
313 313 log.trace("Processing edge event [{}]", edgeEvent);
314 314 try {
315 315 DownlinkMsg downlinkMsg = null;
316   - ActionType action = ActionType.valueOf(edgeEvent.getAction());
317   - switch (action) {
  316 + switch (edgeEvent.getAction()) {
318 317 case UPDATED:
319 318 case ADDED:
320 319 case DELETED:
... ... @@ -327,7 +326,7 @@ public final class EdgeGrpcSession implements Closeable {
327 326 case RELATION_DELETED:
328 327 case ASSIGNED_TO_CUSTOMER:
329 328 case UNASSIGNED_FROM_CUSTOMER:
330   - downlinkMsg = processEntityMessage(edgeEvent, action);
  329 + downlinkMsg = processEntityMessage(edgeEvent, edgeEvent.getAction());
331 330 break;
332 331 case ATTRIBUTES_UPDATED:
333 332 case ATTRIBUTES_DELETED:
... ... @@ -439,8 +438,7 @@ public final class EdgeGrpcSession implements Closeable {
439 438 if (entityId != null) {
440 439 log.debug("Sending telemetry data msg, entityId [{}], body [{}]", edgeEvent.getEntityId(), edgeEvent.getBody());
441 440 try {
442   - ActionType actionType = ActionType.valueOf(edgeEvent.getAction());
443   - downlinkMsg = constructEntityDataProtoMsg(entityId, actionType, JsonUtils.parse(mapper.writeValueAsString(edgeEvent.getBody())));
  441 + downlinkMsg = constructEntityDataProtoMsg(entityId, edgeEvent.getAction(), JsonUtils.parse(mapper.writeValueAsString(edgeEvent.getBody())));
444 442 } catch (Exception e) {
445 443 log.warn("Can't send telemetry data msg, entityId [{}], body [{}]", edgeEvent.getEntityId(), edgeEvent.getBody(), e);
446 444 }
... ... @@ -448,8 +446,8 @@ public final class EdgeGrpcSession implements Closeable {
448 446 return downlinkMsg;
449 447 }
450 448
451   - private DownlinkMsg processEntityMessage(EdgeEvent edgeEvent, ActionType action) {
452   - UpdateMsgType msgType = getResponseMsgType(ActionType.valueOf(edgeEvent.getAction()));
  449 + private DownlinkMsg processEntityMessage(EdgeEvent edgeEvent, EdgeEventActionType action) {
  450 + UpdateMsgType msgType = getResponseMsgType(edgeEvent.getAction());
453 451 log.trace("Executing processEntityMessage, edgeEvent [{}], action [{}], msgType [{}]", edgeEvent, action, msgType);
454 452 switch (edgeEvent.getType()) {
455 453 case EDGE:
... ... @@ -487,10 +485,10 @@ public final class EdgeGrpcSession implements Closeable {
487 485 }
488 486 }
489 487
490   - private DownlinkMsg processDevice(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeActionType) {
  488 + private DownlinkMsg processDevice(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType edgeEdgeEventActionType) {
491 489 DeviceId deviceId = new DeviceId(edgeEvent.getEntityId());
492 490 DownlinkMsg downlinkMsg = null;
493   - switch (edgeActionType) {
  491 + switch (edgeEdgeEventActionType) {
494 492 case ADDED:
495 493 case UPDATED:
496 494 case ASSIGNED_TO_EDGE:
... ... @@ -528,7 +526,7 @@ public final class EdgeGrpcSession implements Closeable {
528 526 return downlinkMsg;
529 527 }
530 528
531   - private DownlinkMsg processAsset(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) {
  529 + private DownlinkMsg processAsset(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
532 530 AssetId assetId = new AssetId(edgeEvent.getEntityId());
533 531 DownlinkMsg downlinkMsg = null;
534 532 switch (action) {
... ... @@ -559,7 +557,7 @@ public final class EdgeGrpcSession implements Closeable {
559 557 return downlinkMsg;
560 558 }
561 559
562   - private DownlinkMsg processEntityView(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) {
  560 + private DownlinkMsg processEntityView(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
563 561 EntityViewId entityViewId = new EntityViewId(edgeEvent.getEntityId());
564 562 DownlinkMsg downlinkMsg = null;
565 563 switch (action) {
... ... @@ -590,7 +588,7 @@ public final class EdgeGrpcSession implements Closeable {
590 588 return downlinkMsg;
591 589 }
592 590
593   - private DownlinkMsg processDashboard(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) {
  591 + private DownlinkMsg processDashboard(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
594 592 DashboardId dashboardId = new DashboardId(edgeEvent.getEntityId());
595 593 DownlinkMsg downlinkMsg = null;
596 594 switch (action) {
... ... @@ -624,7 +622,7 @@ public final class EdgeGrpcSession implements Closeable {
624 622 return downlinkMsg;
625 623 }
626 624
627   - private DownlinkMsg processCustomer(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) {
  625 + private DownlinkMsg processCustomer(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
628 626 CustomerId customerId = new CustomerId(edgeEvent.getEntityId());
629 627 DownlinkMsg downlinkMsg = null;
630 628 switch (action) {
... ... @@ -650,7 +648,7 @@ public final class EdgeGrpcSession implements Closeable {
650 648 return downlinkMsg;
651 649 }
652 650
653   - private DownlinkMsg processRuleChain(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType action) {
  651 + private DownlinkMsg processRuleChain(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
654 652 RuleChainId ruleChainId = new RuleChainId(edgeEvent.getEntityId());
655 653 DownlinkMsg downlinkMsg = null;
656 654 switch (action) {
... ... @@ -693,10 +691,10 @@ public final class EdgeGrpcSession implements Closeable {
693 691 return downlinkMsg;
694 692 }
695 693
696   - private DownlinkMsg processUser(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeActionType) {
  694 + private DownlinkMsg processUser(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType edgeEdgeEventActionType) {
697 695 UserId userId = new UserId(edgeEvent.getEntityId());
698 696 DownlinkMsg downlinkMsg = null;
699   - switch (edgeActionType) {
  697 + switch (edgeEdgeEventActionType) {
700 698 case ADDED:
701 699 case UPDATED:
702 700 User user = ctx.getUserService().findUserById(edgeEvent.getTenantId(), userId);
... ... @@ -757,10 +755,10 @@ public final class EdgeGrpcSession implements Closeable {
757 755 return downlinkMsg;
758 756 }
759 757
760   - private DownlinkMsg processWidgetsBundle(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeActionType) {
  758 + private DownlinkMsg processWidgetsBundle(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType edgeEdgeEventActionType) {
761 759 WidgetsBundleId widgetsBundleId = new WidgetsBundleId(edgeEvent.getEntityId());
762 760 DownlinkMsg downlinkMsg = null;
763   - switch (edgeActionType) {
  761 + switch (edgeEdgeEventActionType) {
764 762 case ADDED:
765 763 case UPDATED:
766 764 WidgetsBundle widgetsBundle = ctx.getWidgetsBundleService().findWidgetsBundleById(edgeEvent.getTenantId(), widgetsBundleId);
... ... @@ -783,10 +781,10 @@ public final class EdgeGrpcSession implements Closeable {
783 781 return downlinkMsg;
784 782 }
785 783
786   - private DownlinkMsg processWidgetType(EdgeEvent edgeEvent, UpdateMsgType msgType, ActionType edgeActionType) {
  784 + private DownlinkMsg processWidgetType(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType edgeEdgeEventActionType) {
787 785 WidgetTypeId widgetTypeId = new WidgetTypeId(edgeEvent.getEntityId());
788 786 DownlinkMsg downlinkMsg = null;
789   - switch (edgeActionType) {
  787 + switch (edgeEdgeEventActionType) {
790 788 case ADDED:
791 789 case UPDATED:
792 790 WidgetType widgetType = ctx.getWidgetTypeService().findWidgetTypeById(edgeEvent.getTenantId(), widgetTypeId);
... ... @@ -817,7 +815,7 @@ public final class EdgeGrpcSession implements Closeable {
817 815 .build();
818 816 }
819 817
820   - private UpdateMsgType getResponseMsgType(ActionType actionType) {
  818 + private UpdateMsgType getResponseMsgType(EdgeEventActionType actionType) {
821 819 switch (actionType) {
822 820 case UPDATED:
823 821 case CREDENTIALS_UPDATED:
... ... @@ -841,7 +839,7 @@ public final class EdgeGrpcSession implements Closeable {
841 839 }
842 840 }
843 841
844   - private DownlinkMsg constructEntityDataProtoMsg(EntityId entityId, ActionType actionType, JsonElement entityData) {
  842 + private DownlinkMsg constructEntityDataProtoMsg(EntityId entityId, EdgeEventActionType actionType, JsonElement entityData) {
845 843 EntityDataProto entityDataProto = ctx.getEntityDataMsgConstructor().constructEntityDataMsg(entityId, actionType, entityData);
846 844 DownlinkMsg.Builder builder = DownlinkMsg.newBuilder()
847 845 .addAllEntityData(Collections.singletonList(entityDataProto));
... ...
... ... @@ -15,14 +15,14 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.AdminSettings;
21 20 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
22 21 import org.thingsboard.server.gen.edge.AdminSettingsUpdateMsg;
  22 +import org.thingsboard.server.queue.util.TbCoreComponent;
23 23
24   -@Slf4j
25 24 @Component
  25 +@TbCoreComponent
26 26 public class AdminSettingsMsgConstructor {
27 27
28 28 public AdminSettingsUpdateMsg constructAdminSettingsUpdateMsg(AdminSettings adminSettings) {
... ...
... ... @@ -15,12 +15,9 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19   -import org.bouncycastle.jcajce.provider.symmetric.DES;
20 18 import org.springframework.beans.factory.annotation.Autowired;
21 19 import org.springframework.stereotype.Component;
22 20 import org.thingsboard.server.common.data.alarm.Alarm;
23   -import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery;
24 21 import org.thingsboard.server.common.data.id.AssetId;
25 22 import org.thingsboard.server.common.data.id.DeviceId;
26 23 import org.thingsboard.server.common.data.id.EntityViewId;
... ... @@ -31,9 +28,10 @@ import org.thingsboard.server.dao.entityview.EntityViewService;
31 28 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
32 29 import org.thingsboard.server.gen.edge.AlarmUpdateMsg;
33 30 import org.thingsboard.server.gen.edge.UpdateMsgType;
  31 +import org.thingsboard.server.queue.util.TbCoreComponent;
34 32
35 33 @Component
36   -@Slf4j
  34 +@TbCoreComponent
37 35 public class AlarmMsgConstructor {
38 36
39 37 @Autowired
... ...
... ... @@ -15,7 +15,6 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.asset.Asset;
21 20 import org.thingsboard.server.common.data.id.AssetId;
... ... @@ -23,9 +22,10 @@ import org.thingsboard.server.common.data.id.CustomerId;
23 22 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
24 23 import org.thingsboard.server.gen.edge.AssetUpdateMsg;
25 24 import org.thingsboard.server.gen.edge.UpdateMsgType;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
26 26
27 27 @Component
28   -@Slf4j
  28 +@TbCoreComponent
29 29 public class AssetMsgConstructor {
30 30
31 31 public AssetUpdateMsg constructAssetUpdatedMsg(UpdateMsgType msgType, Asset asset, CustomerId customerId) {
... ...
... ... @@ -15,16 +15,16 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.Customer;
21 20 import org.thingsboard.server.common.data.id.CustomerId;
22 21 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
23 22 import org.thingsboard.server.gen.edge.CustomerUpdateMsg;
24 23 import org.thingsboard.server.gen.edge.UpdateMsgType;
  24 +import org.thingsboard.server.queue.util.TbCoreComponent;
25 25
26 26 @Component
27   -@Slf4j
  27 +@TbCoreComponent
28 28 public class CustomerMsgConstructor {
29 29
30 30 public CustomerUpdateMsg constructCustomerUpdatedMsg(UpdateMsgType msgType, Customer customer) {
... ...
... ... @@ -15,18 +15,17 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.Dashboard;
21 20 import org.thingsboard.server.common.data.id.CustomerId;
22 21 import org.thingsboard.server.common.data.id.DashboardId;
23   -import org.thingsboard.server.common.data.id.EntityId;
24 22 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
25 23 import org.thingsboard.server.gen.edge.DashboardUpdateMsg;
26 24 import org.thingsboard.server.gen.edge.UpdateMsgType;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
27 26
28 27 @Component
29   -@Slf4j
  28 +@TbCoreComponent
30 29 public class DashboardMsgConstructor {
31 30
32 31 public DashboardUpdateMsg constructDashboardUpdatedMsg(UpdateMsgType msgType, Dashboard dashboard, CustomerId customerId) {
... ...
... ... @@ -17,7 +17,6 @@ package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18 18 import com.fasterxml.jackson.databind.JsonNode;
19 19 import com.fasterxml.jackson.databind.ObjectMapper;
20   -import lombok.extern.slf4j.Slf4j;
21 20 import org.springframework.stereotype.Component;
22 21 import org.thingsboard.rule.engine.api.RuleEngineDeviceRpcRequest;
23 22 import org.thingsboard.server.common.data.Device;
... ... @@ -30,9 +29,10 @@ import org.thingsboard.server.gen.edge.DeviceRpcCallMsg;
30 29 import org.thingsboard.server.gen.edge.DeviceUpdateMsg;
31 30 import org.thingsboard.server.gen.edge.RpcRequestMsg;
32 31 import org.thingsboard.server.gen.edge.UpdateMsgType;
  32 +import org.thingsboard.server.queue.util.TbCoreComponent;
33 33
34 34 @Component
35   -@Slf4j
  35 +@TbCoreComponent
36 36 public class DeviceMsgConstructor {
37 37
38 38 protected static final ObjectMapper mapper = new ObjectMapper();
... ...
... ... @@ -22,19 +22,22 @@ import com.google.gson.JsonObject;
22 22 import lombok.extern.slf4j.Slf4j;
23 23 import org.springframework.stereotype.Component;
24 24 import org.thingsboard.server.common.data.audit.ActionType;
  25 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
25 26 import org.thingsboard.server.common.data.id.EntityId;
26 27 import org.thingsboard.server.common.transport.adaptor.JsonConverter;
27 28 import org.thingsboard.server.gen.edge.AttributeDeleteMsg;
28 29 import org.thingsboard.server.gen.edge.EntityDataProto;
29 30 import org.thingsboard.server.gen.transport.TransportProtos;
  31 +import org.thingsboard.server.queue.util.TbCoreComponent;
30 32
31 33 import java.util.List;
32 34
33 35 @Component
34 36 @Slf4j
  37 +@TbCoreComponent
35 38 public class EntityDataMsgConstructor {
36 39
37   - public EntityDataProto constructEntityDataMsg(EntityId entityId, ActionType actionType, JsonElement entityData) {
  40 + public EntityDataProto constructEntityDataMsg(EntityId entityId, EdgeEventActionType actionType, JsonElement entityData) {
38 41 EntityDataProto.Builder builder = EntityDataProto.newBuilder()
39 42 .setEntityIdMSB(entityId.getId().getMostSignificantBits())
40 43 .setEntityIdLSB(entityId.getId().getLeastSignificantBits())
... ... @@ -51,7 +54,7 @@ public class EntityDataMsgConstructor {
51 54 }
52 55 builder.setPostTelemetryMsg(JsonConverter.convertToTelemetryProto(data.getAsJsonObject("data"), ts));
53 56 } catch (Exception e) {
54   - log.warn("Can't convert to telemetry proto, entityData [{}]", entityData, e);
  57 + log.warn("[{}] Can't convert to telemetry proto, entityData [{}]", entityId, entityData, e);
55 58 }
56 59 break;
57 60 case ATTRIBUTES_UPDATED:
... ... @@ -65,7 +68,7 @@ public class EntityDataMsgConstructor {
65 68 }
66 69 builder.setPostAttributeScope(data.getAsJsonPrimitive("scope").getAsString());
67 70 } catch (Exception e) {
68   - log.warn("Can't convert to attributes proto, entityData [{}]", entityData, e);
  71 + log.warn("[{}] Can't convert to attributes proto, entityData [{}]", entityId, entityData, e);
69 72 }
70 73 break;
71 74 case ATTRIBUTES_DELETED:
... ... @@ -78,7 +81,7 @@ public class EntityDataMsgConstructor {
78 81 attributeDeleteMsg.build();
79 82 builder.setAttributeDeleteMsg(attributeDeleteMsg);
80 83 } catch (Exception e) {
81   - log.warn("Can't convert to AttributeDeleteMsg proto, entityData [{}]", entityData, e);
  84 + log.warn("[{}] Can't convert to AttributeDeleteMsg proto, entityData [{}]", entityId, entityData, e);
82 85 }
83 86 break;
84 87 }
... ...
... ... @@ -15,7 +15,6 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.EntityView;
21 20 import org.thingsboard.server.common.data.id.CustomerId;
... ... @@ -24,9 +23,10 @@ import org.thingsboard.server.dao.util.mapping.JacksonUtil;
24 23 import org.thingsboard.server.gen.edge.EdgeEntityType;
25 24 import org.thingsboard.server.gen.edge.EntityViewUpdateMsg;
26 25 import org.thingsboard.server.gen.edge.UpdateMsgType;
  26 +import org.thingsboard.server.queue.util.TbCoreComponent;
27 27
28 28 @Component
29   -@Slf4j
  29 +@TbCoreComponent
30 30 public class EntityViewMsgConstructor {
31 31
32 32 public EntityViewUpdateMsg constructEntityViewUpdatedMsg(UpdateMsgType msgType, EntityView entityView, CustomerId customerId) {
... ...
... ... @@ -15,15 +15,15 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.relation.EntityRelation;
21 20 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
22 21 import org.thingsboard.server.gen.edge.RelationUpdateMsg;
23 22 import org.thingsboard.server.gen.edge.UpdateMsgType;
  23 +import org.thingsboard.server.queue.util.TbCoreComponent;
24 24
25 25 @Component
26   -@Slf4j
  26 +@TbCoreComponent
27 27 public class RelationMsgConstructor {
28 28
29 29 public RelationUpdateMsg constructRelationUpdatedMsg(UpdateMsgType msgType, EntityRelation entityRelation) {
... ...
... ... @@ -32,12 +32,14 @@ import org.thingsboard.server.gen.edge.RuleChainMetadataUpdateMsg;
32 32 import org.thingsboard.server.gen.edge.RuleChainUpdateMsg;
33 33 import org.thingsboard.server.gen.edge.RuleNodeProto;
34 34 import org.thingsboard.server.gen.edge.UpdateMsgType;
  35 +import org.thingsboard.server.queue.util.TbCoreComponent;
35 36
36 37 import java.util.ArrayList;
37 38 import java.util.List;
38 39
39 40 @Component
40 41 @Slf4j
  42 +@TbCoreComponent
41 43 public class RuleChainMsgConstructor {
42 44
43 45 private static final ObjectMapper objectMapper = new ObjectMapper();
... ...
... ... @@ -15,22 +15,19 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.User;
21 20 import org.thingsboard.server.common.data.id.CustomerId;
22   -import org.thingsboard.server.common.data.id.EntityId;
23 21 import org.thingsboard.server.common.data.id.UserId;
24 22 import org.thingsboard.server.common.data.security.UserCredentials;
25 23 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
26 24 import org.thingsboard.server.gen.edge.UpdateMsgType;
27 25 import org.thingsboard.server.gen.edge.UserCredentialsUpdateMsg;
28 26 import org.thingsboard.server.gen.edge.UserUpdateMsg;
29   -
30   -import java.util.UUID;
  27 +import org.thingsboard.server.queue.util.TbCoreComponent;
31 28
32 29 @Component
33   -@Slf4j
  30 +@TbCoreComponent
34 31 public class UserMsgConstructor {
35 32
36 33 public UserUpdateMsg constructUserUpdatedMsg(UpdateMsgType msgType, User user, CustomerId customerId) {
... ...
... ... @@ -15,7 +15,6 @@
15 15 */
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18   -import lombok.extern.slf4j.Slf4j;
19 18 import org.springframework.stereotype.Component;
20 19 import org.thingsboard.server.common.data.id.TenantId;
21 20 import org.thingsboard.server.common.data.id.WidgetTypeId;
... ... @@ -23,9 +22,10 @@ import org.thingsboard.server.common.data.widget.WidgetType;
23 22 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
24 23 import org.thingsboard.server.gen.edge.UpdateMsgType;
25 24 import org.thingsboard.server.gen.edge.WidgetTypeUpdateMsg;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
26 26
27 27 @Component
28   -@Slf4j
  28 +@TbCoreComponent
29 29 public class WidgetTypeMsgConstructor {
30 30
31 31 public WidgetTypeUpdateMsg constructWidgetTypeUpdateMsg(UpdateMsgType msgType, WidgetType widgetType) {
... ...
... ... @@ -16,16 +16,16 @@
16 16 package org.thingsboard.server.service.edge.rpc.constructor;
17 17
18 18 import com.google.protobuf.ByteString;
19   -import lombok.extern.slf4j.Slf4j;
20 19 import org.springframework.stereotype.Component;
21 20 import org.thingsboard.server.common.data.id.TenantId;
22 21 import org.thingsboard.server.common.data.id.WidgetsBundleId;
23 22 import org.thingsboard.server.common.data.widget.WidgetsBundle;
24 23 import org.thingsboard.server.gen.edge.UpdateMsgType;
25 24 import org.thingsboard.server.gen.edge.WidgetsBundleUpdateMsg;
  25 +import org.thingsboard.server.queue.util.TbCoreComponent;
26 26
27 27 @Component
28   -@Slf4j
  28 +@TbCoreComponent
29 29 public class WidgetsBundleMsgConstructor {
30 30
31 31 public WidgetsBundleUpdateMsg constructWidgetsBundleUpdateMsg(UpdateMsgType msgType, WidgetsBundle widgetsBundle) {
... ...
... ... @@ -39,9 +39,9 @@ import org.thingsboard.server.common.data.EntityType;
39 39 import org.thingsboard.server.common.data.EntityView;
40 40 import org.thingsboard.server.common.data.User;
41 41 import org.thingsboard.server.common.data.asset.Asset;
42   -import org.thingsboard.server.common.data.audit.ActionType;
43 42 import org.thingsboard.server.common.data.edge.Edge;
44 43 import org.thingsboard.server.common.data.edge.EdgeEvent;
  44 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
45 45 import org.thingsboard.server.common.data.edge.EdgeEventType;
46 46 import org.thingsboard.server.common.data.id.AdminSettingsId;
47 47 import org.thingsboard.server.common.data.id.DeviceId;
... ... @@ -164,7 +164,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
164 164 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
165 165 log.trace("[{}] [{}] rule chains(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
166 166 for (RuleChain ruleChain : pageData.getData()) {
167   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.RULE_CHAIN, ActionType.ADDED, ruleChain.getId(), null);
  167 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.RULE_CHAIN, EdgeEventActionType.ADDED, ruleChain.getId(), null);
168 168 }
169 169 }
170 170 }
... ... @@ -189,7 +189,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
189 189 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
190 190 log.trace("[{}] [{}] device(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
191 191 for (Device device : pageData.getData()) {
192   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE, ActionType.ADDED, device.getId(), null);
  192 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.ADDED, device.getId(), null);
193 193 }
194 194 }
195 195 }
... ... @@ -213,7 +213,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
213 213 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
214 214 log.trace("[{}] [{}] asset(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
215 215 for (Asset asset : pageData.getData()) {
216   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ASSET, ActionType.ADDED, asset.getId(), null);
  216 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ASSET, EdgeEventActionType.ADDED, asset.getId(), null);
217 217 }
218 218 }
219 219 }
... ... @@ -237,7 +237,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
237 237 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
238 238 log.trace("[{}] [{}] entity view(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
239 239 for (EntityView entityView : pageData.getData()) {
240   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ENTITY_VIEW, ActionType.ADDED, entityView.getId(), null);
  240 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ENTITY_VIEW, EdgeEventActionType.ADDED, entityView.getId(), null);
241 241 }
242 242 }
243 243 }
... ... @@ -261,7 +261,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
261 261 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
262 262 log.trace("[{}] [{}] dashboard(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
263 263 for (DashboardInfo dashboardInfo : pageData.getData()) {
264   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DASHBOARD, ActionType.ADDED, dashboardInfo.getId(), null);
  264 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DASHBOARD, EdgeEventActionType.ADDED, dashboardInfo.getId(), null);
265 265 }
266 266 }
267 267 }
... ... @@ -281,7 +281,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
281 281 TextPageData<User> pageData = userService.findTenantAdmins(edge.getTenantId(), new TextPageLink(Integer.MAX_VALUE));
282 282 pushUsersToEdge(pageData, edge);
283 283 if (edge.getCustomerId() != null && !EntityId.NULL_UUID.equals(edge.getCustomerId().getId())) {
284   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.CUSTOMER, ActionType.ADDED, edge.getCustomerId(), null);
  284 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.CUSTOMER, EdgeEventActionType.ADDED, edge.getCustomerId(), null);
285 285 pageData = userService.findCustomerUsers(edge.getTenantId(), edge.getCustomerId(), new TextPageLink(Integer.MAX_VALUE));
286 286 pushUsersToEdge(pageData, edge);
287 287 }
... ... @@ -297,11 +297,11 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
297 297 widgetsBundlesToPush.addAll(widgetsBundleService.findSystemWidgetsBundles(edge.getTenantId()));
298 298 try {
299 299 for (WidgetsBundle widgetsBundle: widgetsBundlesToPush) {
300   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGETS_BUNDLE, ActionType.ADDED, widgetsBundle.getId(), null);
  300 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGETS_BUNDLE, EdgeEventActionType.ADDED, widgetsBundle.getId(), null);
301 301 widgetTypesToPush.addAll(widgetTypeService.findWidgetTypesByTenantIdAndBundleAlias(widgetsBundle.getTenantId(), widgetsBundle.getAlias()));
302 302 }
303 303 for (WidgetType widgetType: widgetTypesToPush) {
304   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGET_TYPE, ActionType.ADDED, widgetType.getId(), null);
  304 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGET_TYPE, EdgeEventActionType.ADDED, widgetType.getId(), null);
305 305 }
306 306 } catch (Exception e) {
307 307 log.error("Exception during loading widgets bundle(s) and widget type(s) on sync!", e);
... ... @@ -311,13 +311,13 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
311 311 private void syncAdminSettings(Edge edge) {
312 312 try {
313 313 AdminSettings systemMailSettings = adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "mail");
314   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, ActionType.UPDATED, null, mapper.valueToTree(systemMailSettings));
  314 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(systemMailSettings));
315 315 AdminSettings tenantMailSettings = convertToTenantAdminSettings(systemMailSettings.getKey(), (ObjectNode) systemMailSettings.getJsonValue());
316   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, ActionType.UPDATED, null, mapper.valueToTree(tenantMailSettings));
  316 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(tenantMailSettings));
317 317 AdminSettings systemMailTemplates = loadMailTemplates();
318   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, ActionType.UPDATED, null, mapper.valueToTree(systemMailTemplates));
  318 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(systemMailTemplates));
319 319 AdminSettings tenantMailTemplates = convertToTenantAdminSettings(systemMailTemplates.getKey(), (ObjectNode) systemMailTemplates.getJsonValue());
320   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, ActionType.UPDATED, null, mapper.valueToTree(tenantMailTemplates));
  320 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.ADMIN_SETTINGS, EdgeEventActionType.UPDATED, null, mapper.valueToTree(tenantMailTemplates));
321 321 } catch (Exception e) {
322 322 log.error("Can't load admin settings", e);
323 323 }
... ... @@ -379,7 +379,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
379 379 if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
380 380 log.trace("[{}] [{}] user(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
381 381 for (User user : pageData.getData()) {
382   - saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, ActionType.ADDED, user.getId(), null);
  382 + saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, EdgeEventActionType.ADDED, user.getId(), null);
383 383 }
384 384 }
385 385 }
... ... @@ -390,7 +390,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
390 390 if (ruleChainMetadataRequestMsg.getRuleChainIdMSB() != 0 && ruleChainMetadataRequestMsg.getRuleChainIdLSB() != 0) {
391 391 RuleChainId ruleChainId =
392 392 new RuleChainId(new UUID(ruleChainMetadataRequestMsg.getRuleChainIdMSB(), ruleChainMetadataRequestMsg.getRuleChainIdLSB()));
393   - ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.RULE_CHAIN_METADATA, ActionType.ADDED, ruleChainId, null);
  393 + ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.RULE_CHAIN_METADATA, EdgeEventActionType.ADDED, ruleChainId, null);
394 394 Futures.addCallback(future, new FutureCallback<EdgeEvent>() {
395 395 @Override
396 396 public void onSuccess(@Nullable EdgeEvent result) {
... ... @@ -441,7 +441,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
441 441 saveEdgeEvent(edge.getTenantId(),
442 442 edge.getId(),
443 443 type,
444   - ActionType.ATTRIBUTES_UPDATED,
  444 + EdgeEventActionType.ATTRIBUTES_UPDATED,
445 445 entityId,
446 446 body);
447 447 } catch (Exception e) {
... ... @@ -502,7 +502,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
502 502 saveEdgeEvent(edge.getTenantId(),
503 503 edge.getId(),
504 504 EdgeEventType.RELATION,
505   - ActionType.ADDED,
  505 + EdgeEventActionType.ADDED,
506 506 null,
507 507 mapper.valueToTree(relation));
508 508 }
... ... @@ -531,7 +531,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
531 531 SettableFuture<Void> futureToSet = SettableFuture.create();
532 532 if (deviceCredentialsRequestMsg.getDeviceIdMSB() != 0 && deviceCredentialsRequestMsg.getDeviceIdLSB() != 0) {
533 533 DeviceId deviceId = new DeviceId(new UUID(deviceCredentialsRequestMsg.getDeviceIdMSB(), deviceCredentialsRequestMsg.getDeviceIdLSB()));
534   - ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE, ActionType.CREDENTIALS_UPDATED, deviceId, null);
  534 + ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.CREDENTIALS_UPDATED, deviceId, null);
535 535 Futures.addCallback(future, new FutureCallback<EdgeEvent>() {
536 536 @Override
537 537 public void onSuccess(@Nullable EdgeEvent result) {
... ... @@ -553,7 +553,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
553 553 SettableFuture<Void> futureToSet = SettableFuture.create();
554 554 if (userCredentialsRequestMsg.getUserIdMSB() != 0 && userCredentialsRequestMsg.getUserIdLSB() != 0) {
555 555 UserId userId = new UserId(new UUID(userCredentialsRequestMsg.getUserIdMSB(), userCredentialsRequestMsg.getUserIdLSB()));
556   - ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, ActionType.CREDENTIALS_UPDATED, userId, null);
  556 + ListenableFuture<EdgeEvent> future = saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.USER, EdgeEventActionType.CREDENTIALS_UPDATED, userId, null);
557 557 Futures.addCallback(future, new FutureCallback<EdgeEvent>() {
558 558 @Override
559 559 public void onSuccess(@Nullable EdgeEvent result) {
... ... @@ -573,7 +573,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
573 573 private ListenableFuture<EdgeEvent> saveEdgeEvent(TenantId tenantId,
574 574 EdgeId edgeId,
575 575 EdgeEventType type,
576   - ActionType action,
  576 + EdgeEventActionType action,
577 577 EntityId entityId,
578 578 JsonNode body) {
579 579 log.debug("Pushing edge event to edge queue. tenantId [{}], edgeId [{}], type [{}], action[{}], entityId [{}], body [{}]",
... ... @@ -583,7 +583,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
583 583 edgeEvent.setTenantId(tenantId);
584 584 edgeEvent.setEdgeId(edgeId);
585 585 edgeEvent.setType(type);
586   - edgeEvent.setAction(action.name());
  586 + edgeEvent.setAction(action);
587 587 if (entityId != null) {
588 588 edgeEvent.setEntityId(entityId.getId());
589 589 }
... ...
... ... @@ -34,6 +34,7 @@ import org.thingsboard.server.queue.util.TbCoreComponent;
34 34 public class AlarmProcessor extends BaseProcessor {
35 35
36 36 public ListenableFuture<Void> onAlarmUpdate(TenantId tenantId, AlarmUpdateMsg alarmUpdateMsg) {
  37 + log.trace("[{}] onAlarmUpdate [{}]", tenantId, alarmUpdateMsg);
37 38 EntityId originatorId = getAlarmOriginator(tenantId, alarmUpdateMsg.getOriginatorName(),
38 39 EntityType.valueOf(alarmUpdateMsg.getOriginatorType()));
39 40 if (originatorId == null) {
... ...
... ... @@ -20,8 +20,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
20 20 import com.google.common.util.concurrent.ListenableFuture;
21 21 import lombok.extern.slf4j.Slf4j;
22 22 import org.springframework.beans.factory.annotation.Autowired;
23   -import org.thingsboard.server.common.data.audit.ActionType;
24 23 import org.thingsboard.server.common.data.edge.EdgeEvent;
  24 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
25 25 import org.thingsboard.server.common.data.edge.EdgeEventType;
26 26 import org.thingsboard.server.common.data.id.EdgeId;
27 27 import org.thingsboard.server.common.data.id.EntityId;
... ... @@ -39,7 +39,6 @@ import org.thingsboard.server.dao.relation.RelationService;
39 39 import org.thingsboard.server.dao.user.UserService;
40 40 import org.thingsboard.server.service.executors.DbCallbackExecutorService;
41 41 import org.thingsboard.server.service.queue.TbClusterService;
42   -import org.thingsboard.server.service.rpc.TbRuleEngineDeviceRpcService;
43 42 import org.thingsboard.server.service.state.DeviceStateService;
44 43
45 44 @Slf4j
... ... @@ -92,7 +91,7 @@ public abstract class BaseProcessor {
92 91 protected ListenableFuture<EdgeEvent> saveEdgeEvent(TenantId tenantId,
93 92 EdgeId edgeId,
94 93 EdgeEventType type,
95   - ActionType action,
  94 + EdgeEventActionType action,
96 95 EntityId entityId,
97 96 JsonNode body) {
98 97 log.debug("Pushing event to edge queue. tenantId [{}], edgeId [{}], type[{}], " +
... ... @@ -103,7 +102,7 @@ public abstract class BaseProcessor {
103 102 edgeEvent.setTenantId(tenantId);
104 103 edgeEvent.setEdgeId(edgeId);
105 104 edgeEvent.setType(type);
106   - edgeEvent.setAction(action.name());
  105 + edgeEvent.setAction(action);
107 106 if (entityId != null) {
108 107 edgeEvent.setEntityId(entityId.getId());
109 108 }
... ...
... ... @@ -27,8 +27,8 @@ import org.springframework.stereotype.Component;
27 27 import org.thingsboard.rule.engine.api.RpcError;
28 28 import org.thingsboard.server.common.data.DataConstants;
29 29 import org.thingsboard.server.common.data.Device;
30   -import org.thingsboard.server.common.data.audit.ActionType;
31 30 import org.thingsboard.server.common.data.edge.Edge;
  31 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
32 32 import org.thingsboard.server.common.data.edge.EdgeEventType;
33 33 import org.thingsboard.server.common.data.id.CustomerId;
34 34 import org.thingsboard.server.common.data.id.DeviceId;
... ... @@ -62,22 +62,23 @@ public class DeviceProcessor extends BaseProcessor {
62 62 private static final ReentrantLock deviceCreationLock = new ReentrantLock();
63 63
64 64 public ListenableFuture<Void> onDeviceUpdate(TenantId tenantId, Edge edge, DeviceUpdateMsg deviceUpdateMsg) {
  65 + log.trace("[{}] onDeviceUpdate [{}] from edge [{}]", tenantId, deviceUpdateMsg, edge.getName());
65 66 DeviceId edgeDeviceId = new DeviceId(new UUID(deviceUpdateMsg.getIdMSB(), deviceUpdateMsg.getIdLSB()));
66 67 switch (deviceUpdateMsg.getMsgType()) {
67 68 case ENTITY_CREATED_RPC_MESSAGE:
68 69 String deviceName = deviceUpdateMsg.getName();
69 70 Device device = deviceService.findDeviceByTenantIdAndName(tenantId, deviceName);
70 71 if (device != null) {
71   - // device with this name already exists on the cloud - update ID on the edge
  72 + log.info("[{}] Device with name '{}' already exists on the cloud. Updating id of device entity on the edge", tenantId, deviceName);
72 73 if (!device.getId().equals(edgeDeviceId)) {
73   - saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, ActionType.ENTITY_EXISTS_REQUEST, device.getId(), null);
  74 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.ENTITY_EXISTS_REQUEST, device.getId(), null);
74 75 }
75 76 } else {
76 77 Device deviceById = deviceService.findDeviceById(edge.getTenantId(), edgeDeviceId);
77 78 if (deviceById != null) {
78   - // this ID already used by other device - create new device and update ID on the edge
  79 + log.info("[{}] Device ID [{}] already used by other device on the cloud. Creating new device and replacing device entity on the edge", tenantId, edgeDeviceId.getId());
79 80 device = createDevice(tenantId, edge, deviceUpdateMsg);
80   - saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, ActionType.ENTITY_EXISTS_REQUEST, device.getId(), null);
  81 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.ENTITY_EXISTS_REQUEST, device.getId(), null);
81 82 } else {
82 83 device = createDevice(tenantId, edge, deviceUpdateMsg);
83 84 }
... ... @@ -135,13 +136,14 @@ public class DeviceProcessor extends BaseProcessor {
135 136 device.setAdditionalInfo(JacksonUtil.toJsonNode(deviceUpdateMsg.getAdditionalInfo()));
136 137 deviceService.saveDevice(device);
137 138
138   - saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, ActionType.CREDENTIALS_REQUEST, deviceId, null);
  139 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.CREDENTIALS_REQUEST, deviceId, null);
139 140 }
140 141
141 142 private Device createDevice(TenantId tenantId, Edge edge, DeviceUpdateMsg deviceUpdateMsg) {
142 143 Device device;
143 144 try {
144 145 deviceCreationLock.lock();
  146 + log.debug("[{}] Creating device entity [{}] from edge [{}]", tenantId, deviceUpdateMsg, edge.getName());
145 147 DeviceId deviceId = new DeviceId(new UUID(deviceUpdateMsg.getIdMSB(), deviceUpdateMsg.getIdLSB()));
146 148 device = new Device();
147 149 device.setTenantId(edge.getTenantId());
... ... @@ -157,7 +159,7 @@ public class DeviceProcessor extends BaseProcessor {
157 159 deviceStateService.onDeviceAdded(device);
158 160 pushDeviceCreatedEventToRuleEngine(tenantId, edge, device);
159 161
160   - saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, ActionType.CREDENTIALS_REQUEST, deviceId, null);
  162 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.CREDENTIALS_REQUEST, deviceId, null);
161 163 } finally {
162 164 deviceCreationLock.unlock();
163 165 }
... ... @@ -190,24 +192,19 @@ public class DeviceProcessor extends BaseProcessor {
190 192 tbClusterService.pushMsgToRuleEngine(tenantId, deviceId, tbMsg, new TbQueueCallback() {
191 193 @Override
192 194 public void onSuccess(TbQueueMsgMetadata metadata) {
193   - // TODO: voba - handle success
194 195 log.debug("Successfully send ENTITY_CREATED EVENT to rule engine [{}]", device);
195 196 }
196 197
197 198 @Override
198 199 public void onFailure(Throwable t) {
199   - // TODO: voba - handle failure
200 200 log.debug("Failed to send ENTITY_CREATED EVENT to rule engine [{}]", device, t);
201 201 }
202   -
203   - ;
204 202 });
205 203 } catch (JsonProcessingException | IllegalArgumentException e) {
206 204 log.warn("[{}] Failed to push device action to rule engine: {}", device.getId(), DataConstants.ENTITY_CREATED, e);
207 205 }
208 206 }
209 207
210   -
211 208 private TbMsgMetaData getActionTbMsgMetaData(Edge edge, CustomerId customerId) {
212 209 TbMsgMetaData metaData = getTbMsgMetaData(edge);
213 210 if (customerId != null && !customerId.isNullUid()) {
... ... @@ -216,7 +213,6 @@ public class DeviceProcessor extends BaseProcessor {
216 213 return metaData;
217 214 }
218 215
219   -
220 216 private TbMsgMetaData getTbMsgMetaData(Edge edge) {
221 217 TbMsgMetaData metaData = new TbMsgMetaData();
222 218 metaData.putValue("edgeId", edge.getId().toString());
... ...
... ... @@ -44,7 +44,7 @@ import java.util.UUID;
44 44 public class RelationProcessor extends BaseProcessor {
45 45
46 46 public ListenableFuture<Void> onRelationUpdate(TenantId tenantId, RelationUpdateMsg relationUpdateMsg) {
47   - log.info("onRelationUpdate {}", relationUpdateMsg);
  47 + log.trace("[{}] onRelationUpdate [{}]", tenantId, relationUpdateMsg);
48 48 try {
49 49 EntityRelation entityRelation = new EntityRelation();
50 50
... ...
... ... @@ -66,6 +66,7 @@ public class TelemetryProcessor extends BaseProcessor {
66 66 private final Gson gson = new Gson();
67 67
68 68 public List<ListenableFuture<Void>> onTelemetryUpdate(TenantId tenantId, EntityDataProto entityData) {
  69 + log.trace("[{}] onTelemetryUpdate [{}]", tenantId, entityData);
69 70 List<ListenableFuture<Void>> result = new ArrayList<>();
70 71 EntityId entityId = constructEntityId(entityData);
71 72 if ((entityData.hasPostAttributesMsg() || entityData.hasPostTelemetryMsg() || entityData.hasAttributesUpdatedMsg()) && entityId != null) {
... ...
... ... @@ -151,8 +151,7 @@ public class DefaultTbRuleEngineRpcService implements TbRuleEngineDeviceRpcServi
151 151 }
152 152 }
153 153
154   - @Override
155   - public void sendRpcResponseToTbCore(String originServiceId, FromDeviceRpcResponse response) {
  154 + private void sendRpcResponseToTbCore(String originServiceId, FromDeviceRpcResponse response) {
156 155 if (serviceId.equals(originServiceId)) {
157 156 if (tbCoreRpcService.isPresent()) {
158 157 tbCoreRpcService.get().processRpcResponseFromRuleEngine(response);
... ...
... ... @@ -28,14 +28,4 @@ public interface TbRuleEngineDeviceRpcService extends RuleEngineRpcService {
28 28 * @param response the RPC response
29 29 */
30 30 void processRpcResponseFromDevice(FromDeviceRpcResponse response);
31   -
32   -
33   - /**
34   - * Sends Rpc response from the Device to TB Core.
35   - *
36   - * @param originServiceId Service ID of the origin component
37   - * @param response the RPC response
38   - */
39   - void sendRpcResponseToTbCore(String originServiceId, FromDeviceRpcResponse response);
40   -
41 31 }
... ...
... ... @@ -27,12 +27,12 @@ public enum Resource {
27 27 CUSTOMER(EntityType.CUSTOMER),
28 28 DASHBOARD(EntityType.DASHBOARD),
29 29 ENTITY_VIEW(EntityType.ENTITY_VIEW),
30   - EDGE(EntityType.EDGE),
31 30 TENANT(EntityType.TENANT),
32 31 RULE_CHAIN(EntityType.RULE_CHAIN),
33 32 USER(EntityType.USER),
34 33 WIDGETS_BUNDLE(EntityType.WIDGETS_BUNDLE),
35   - WIDGET_TYPE(EntityType.WIDGET_TYPE);
  34 + WIDGET_TYPE(EntityType.WIDGET_TYPE),
  35 + EDGE(EntityType.EDGE);
36 36
37 37 private final EntityType entityType;
38 38
... ...
... ... @@ -53,4 +53,4 @@ public class EdgeEventsCleanUpService extends AbstractCleanUpService {
53 53 long totalEdgeEventsRemoved = executeQuery(connection, "call cleanup_edge_events_by_ttl(" + ttl + ", 0);");
54 54 log.info("Total edge events removed by TTL: [{}]", totalEdgeEventsRemoved);
55 55 }
56   -}
\ No newline at end of file
  56 +}
... ...
... ... @@ -40,9 +40,9 @@ import org.thingsboard.server.common.data.alarm.AlarmInfo;
40 40 import org.thingsboard.server.common.data.alarm.AlarmSeverity;
41 41 import org.thingsboard.server.common.data.alarm.AlarmStatus;
42 42 import org.thingsboard.server.common.data.asset.Asset;
43   -import org.thingsboard.server.common.data.audit.ActionType;
44 43 import org.thingsboard.server.common.data.edge.Edge;
45 44 import org.thingsboard.server.common.data.edge.EdgeEvent;
  45 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
46 46 import org.thingsboard.server.common.data.edge.EdgeEventType;
47 47 import org.thingsboard.server.common.data.id.EdgeId;
48 48 import org.thingsboard.server.common.data.id.RuleChainId;
... ... @@ -60,7 +60,7 @@ import org.thingsboard.server.common.data.widget.WidgetType;
60 60 import org.thingsboard.server.common.data.widget.WidgetsBundle;
61 61 import org.thingsboard.server.common.transport.adaptor.JsonConverter;
62 62 import org.thingsboard.server.controller.AbstractControllerTest;
63   -import org.thingsboard.server.dao.edge.EdgeEventService;;
  63 +import org.thingsboard.server.dao.edge.EdgeEventService;
64 64 import org.thingsboard.server.dao.util.mapping.JacksonUtil;
65 65 import org.thingsboard.server.edge.imitator.EdgeImitator;
66 66 import org.thingsboard.server.gen.edge.AlarmUpdateMsg;
... ... @@ -92,6 +92,8 @@ import java.util.UUID;
92 92
93 93 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
94 94
  95 +;
  96 +
95 97
96 98 @Slf4j
97 99 abstract public class BaseEdgeTest extends AbstractControllerTest {
... ... @@ -712,7 +714,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
712 714
713 715 String timeseriesData = "{\"data\":{\"temperature\":25},\"ts\":" + System.currentTimeMillis() + "}";
714 716 JsonNode timeseriesEntityData = mapper.readTree(timeseriesData);
715   - EdgeEvent edgeEvent1 = constructEdgeEvent(tenantId, edge.getId(), ActionType.TIMESERIES_UPDATED, device.getId().getId(), EdgeEventType.DEVICE, timeseriesEntityData);
  717 + EdgeEvent edgeEvent1 = constructEdgeEvent(tenantId, edge.getId(), EdgeEventActionType.TIMESERIES_UPDATED, device.getId().getId(), EdgeEventType.DEVICE, timeseriesEntityData);
716 718 edgeImitator.expectMessageAmount(1);
717 719 edgeEventService.saveAsync(edgeEvent1);
718 720 edgeImitator.waitForMessages();
... ... @@ -746,7 +748,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
746 748
747 749 String attributesData = "{\"scope\":\"SERVER_SCOPE\",\"kv\":{\"key\":\"value\"}}";
748 750 JsonNode attributesEntityData = mapper.readTree(attributesData);
749   - EdgeEvent edgeEvent1 = constructEdgeEvent(tenantId, edge.getId(), ActionType.ATTRIBUTES_UPDATED, device.getId().getId(), EdgeEventType.DEVICE, attributesEntityData);
  751 + EdgeEvent edgeEvent1 = constructEdgeEvent(tenantId, edge.getId(), EdgeEventActionType.ATTRIBUTES_UPDATED, device.getId().getId(), EdgeEventType.DEVICE, attributesEntityData);
750 752 edgeImitator.expectMessageAmount(1);
751 753 edgeEventService.saveAsync(edgeEvent1);
752 754 edgeImitator.waitForMessages();
... ... @@ -767,7 +769,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
767 769 Assert.assertEquals("value", keyValueProto.getStringV());
768 770
769 771 ((ObjectNode) attributesEntityData).put("isPostAttributes", true);
770   - EdgeEvent edgeEvent2 = constructEdgeEvent(tenantId, edge.getId(), ActionType.ATTRIBUTES_UPDATED, device.getId().getId(), EdgeEventType.DEVICE, attributesEntityData);
  772 + EdgeEvent edgeEvent2 = constructEdgeEvent(tenantId, edge.getId(), EdgeEventActionType.ATTRIBUTES_UPDATED, device.getId().getId(), EdgeEventType.DEVICE, attributesEntityData);
771 773 edgeImitator.expectMessageAmount(1);
772 774 edgeEventService.saveAsync(edgeEvent2);
773 775 edgeImitator.waitForMessages();
... ... @@ -1075,11 +1077,11 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
1075 1077 .andExpect(status().isOk());
1076 1078 }
1077 1079
1078   - private EdgeEvent constructEdgeEvent(TenantId tenantId, EdgeId edgeId, ActionType edgeEventAction, UUID entityId, EdgeEventType edgeEventType, JsonNode entityBody) {
  1080 + private EdgeEvent constructEdgeEvent(TenantId tenantId, EdgeId edgeId, EdgeEventActionType edgeEventAction, UUID entityId, EdgeEventType edgeEventType, JsonNode entityBody) {
1079 1081 EdgeEvent edgeEvent = new EdgeEvent();
1080 1082 edgeEvent.setEdgeId(edgeId);
1081 1083 edgeEvent.setTenantId(tenantId);
1082   - edgeEvent.setAction(edgeEventAction.name());
  1084 + edgeEvent.setAction(edgeEventAction);
1083 1085 edgeEvent.setEntityId(entityId);
1084 1086 edgeEvent.setType(edgeEventType);
1085 1087 edgeEvent.setBody(entityBody);
... ...
... ... @@ -24,7 +24,6 @@ public enum ActionType {
24 24 UPDATED(false), // log entity
25 25 ATTRIBUTES_UPDATED(false), // log attributes/values
26 26 ATTRIBUTES_DELETED(false), // log attributes
27   - TIMESERIES_UPDATED(false), // log timeseries
28 27 TIMESERIES_DELETED(false), // log timeseries
29 28 RPC_CALL(false), // log method and params
30 29 CREDENTIALS_UPDATED(false), // log new credentials
... ... @@ -45,9 +44,7 @@ public enum ActionType {
45 44 ASSIGNED_FROM_TENANT(false),
46 45 ASSIGNED_TO_TENANT(false),
47 46 ASSIGNED_TO_EDGE(false), // log edge name
48   - UNASSIGNED_FROM_EDGE(false), // log edge name
49   - CREDENTIALS_REQUEST(false), // request credentials from edge
50   - ENTITY_EXISTS_REQUEST(false); // request to recreate entity on edge
  47 + UNASSIGNED_FROM_EDGE(false);
51 48
52 49 private final boolean isRead;
53 50
... ...
... ... @@ -29,7 +29,7 @@ public class EdgeEvent extends BaseData<EdgeEventId> {
29 29
30 30 private TenantId tenantId;
31 31 private EdgeId edgeId;
32   - private String action;
  32 + private EdgeEventActionType action;
33 33 private UUID entityId;
34 34 private String uid;
35 35 private EdgeEventType type;
... ...
  1 +/**
  2 + * Copyright © 2016-2020 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.common.data.edge;
  17 +
  18 +public enum EdgeEventActionType {
  19 + ADDED,
  20 + DELETED,
  21 + UPDATED,
  22 + ATTRIBUTES_UPDATED,
  23 + ATTRIBUTES_DELETED,
  24 + TIMESERIES_UPDATED,
  25 + CREDENTIALS_UPDATED,
  26 + ASSIGNED_TO_CUSTOMER,
  27 + UNASSIGNED_FROM_CUSTOMER,
  28 + RELATION_ADD_OR_UPDATE,
  29 + RELATION_DELETED,
  30 + RPC_CALL,
  31 + ALARM_ACK,
  32 + ALARM_CLEAR,
  33 + ASSIGNED_TO_EDGE,
  34 + UNASSIGNED_FROM_EDGE,
  35 + CREDENTIALS_REQUEST,
  36 + ENTITY_EXISTS_REQUEST
  37 +}
\ No newline at end of file
... ...
... ... @@ -56,7 +56,7 @@ public class BaseEdgeEventService implements EdgeEventService {
56 56 if (edgeEvent.getEdgeId() == null) {
57 57 throw new DataValidationException("Edge id should be specified!");
58 58 }
59   - if (StringUtils.isEmpty(edgeEvent.getAction())) {
  59 + if (edgeEvent.getAction() == null) {
60 60 throw new DataValidationException("Edge Event action should be specified!");
61 61 }
62 62 }
... ...
... ... @@ -26,8 +26,8 @@ import lombok.extern.slf4j.Slf4j;
26 26 import org.apache.commons.lang3.StringUtils;
27 27 import org.springframework.beans.factory.annotation.Value;
28 28 import org.springframework.stereotype.Component;
29   -import org.thingsboard.server.common.data.audit.ActionType;
30 29 import org.thingsboard.server.common.data.edge.EdgeEvent;
  30 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
31 31 import org.thingsboard.server.common.data.id.EdgeEventId;
32 32 import org.thingsboard.server.common.data.id.EdgeId;
33 33 import org.thingsboard.server.common.data.id.TenantId;
... ... @@ -118,7 +118,7 @@ public class CassandraEdgeEventDao extends CassandraAbstractSearchTimeDao<EdgeEv
118 118 List<EdgeEvent> edgeEvents = DaoUtil.convertDataList(entities);
119 119 if (!withTsUpdate) {
120 120 return edgeEvents.stream()
121   - .filter(edgeEvent -> !edgeEvent.getAction().equals(ActionType.TIMESERIES_UPDATED.name()))
  121 + .filter(edgeEvent -> !edgeEvent.getAction().equals(EdgeEventActionType.TIMESERIES_UPDATED.name()))
122 122 .collect(Collectors.toList());
123 123 } else {
124 124 return edgeEvents;
... ...
... ... @@ -24,11 +24,13 @@ import com.fasterxml.jackson.databind.JsonNode;
24 24 import lombok.Data;
25 25 import lombok.NoArgsConstructor;
26 26 import org.thingsboard.server.common.data.edge.EdgeEvent;
  27 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
27 28 import org.thingsboard.server.common.data.edge.EdgeEventType;
28 29 import org.thingsboard.server.common.data.id.EdgeEventId;
29 30 import org.thingsboard.server.common.data.id.EdgeId;
30 31 import org.thingsboard.server.common.data.id.TenantId;
31 32 import org.thingsboard.server.dao.model.BaseEntity;
  33 +import org.thingsboard.server.dao.model.type.EdgeEventActionTypeCodec;
32 34 import org.thingsboard.server.dao.model.type.EdgeEventTypeCodec;
33 35 import org.thingsboard.server.dao.model.type.JsonCodec;
34 36
... ... @@ -65,8 +67,8 @@ public class EdgeEventEntity implements BaseEntity<EdgeEvent> {
65 67 private EdgeEventType edgeEventType;
66 68
67 69 @ClusteringColumn(value = 1)
68   - @Column(name = EDGE_EVENT_ACTION_PROPERTY)
69   - private String edgeEventAction;
  70 + @Column(name = EDGE_EVENT_ACTION_PROPERTY, codec = EdgeEventActionTypeCodec.class)
  71 + private EdgeEventActionType edgeEventAction;
70 72
71 73 @ClusteringColumn(value = 2)
72 74 @Column(name = EDGE_EVENT_UID_PROPERTY)
... ...
... ... @@ -23,6 +23,7 @@ import lombok.NoArgsConstructor;
23 23 import org.hibernate.annotations.Type;
24 24 import org.hibernate.annotations.TypeDef;
25 25 import org.thingsboard.server.common.data.edge.EdgeEvent;
  26 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
26 27 import org.thingsboard.server.common.data.edge.EdgeEventType;
27 28 import org.thingsboard.server.common.data.id.EdgeEventId;
28 29 import org.thingsboard.server.common.data.id.EdgeId;
... ... @@ -71,8 +72,9 @@ public class EdgeEventEntity extends BaseSqlEntity<EdgeEvent> implements BaseEnt
71 72 @Column(name = EDGE_EVENT_TYPE_PROPERTY)
72 73 private EdgeEventType edgeEventType;
73 74
  75 + @Enumerated(EnumType.STRING)
74 76 @Column(name = EDGE_EVENT_ACTION_PROPERTY)
75   - private String edgeEventAction;
  77 + private EdgeEventActionType edgeEventAction;
76 78
77 79 @Type(type = "json")
78 80 @Column(name = EDGE_EVENT_BODY_PROPERTY)
... ...
  1 +/**
  2 + * Copyright © 2016-2020 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.dao.model.type;
  17 +
  18 +import com.datastax.driver.extras.codecs.enums.EnumNameCodec;
  19 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
  20 +
  21 +public class EdgeEventActionTypeCodec extends EnumNameCodec<EdgeEventActionType> {
  22 +
  23 + public EdgeEventActionTypeCodec() {
  24 + super(EdgeEventActionType.class);
  25 + }
  26 +
  27 +}
... ...
... ... @@ -28,6 +28,7 @@ import org.springframework.stereotype.Component;
28 28 import org.thingsboard.server.common.data.UUIDConverter;
29 29 import org.thingsboard.server.common.data.audit.ActionType;
30 30 import org.thingsboard.server.common.data.edge.EdgeEvent;
  31 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
31 32 import org.thingsboard.server.common.data.id.EdgeEventId;
32 33 import org.thingsboard.server.common.data.id.EdgeId;
33 34 import org.thingsboard.server.common.data.page.TimePageLink;
... ... @@ -108,7 +109,7 @@ public class JpaBaseEdgeEventDao extends JpaAbstractSearchTimeDao<EdgeEventEntit
108 109 predicates.add(entityIdPredicate);
109 110 }
110 111 if (!withTsUpdate) {
111   - Predicate edgeEventActionPredicate = criteriaBuilder.notEqual(root.get("edgeEventAction"), ActionType.TIMESERIES_UPDATED.name());
  112 + Predicate edgeEventActionPredicate = criteriaBuilder.notEqual(root.get("edgeEventAction"), EdgeEventActionType.TIMESERIES_UPDATED);
112 113 predicates.add(edgeEventActionPredicate);
113 114 }
114 115 return criteriaBuilder.and(predicates.toArray(new Predicate[]{}));
... ...
... ... @@ -18,9 +18,8 @@ package org.thingsboard.server.dao.service;
18 18 import com.datastax.driver.core.utils.UUIDs;
19 19 import org.junit.Assert;
20 20 import org.junit.Test;
21   -import org.thingsboard.server.common.data.DataConstants;
22   -import org.thingsboard.server.common.data.audit.ActionType;
23 21 import org.thingsboard.server.common.data.edge.EdgeEvent;
  22 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
24 23 import org.thingsboard.server.common.data.edge.EdgeEventType;
25 24 import org.thingsboard.server.common.data.id.DeviceId;
26 25 import org.thingsboard.server.common.data.id.EdgeEventId;
... ... @@ -41,7 +40,7 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest {
41 40 public void saveEdgeEvent() throws Exception {
42 41 EdgeId edgeId = new EdgeId(UUIDs.timeBased());
43 42 DeviceId deviceId = new DeviceId(UUIDs.timeBased());
44   - EdgeEvent edgeEvent = generateEdgeEvent(null, edgeId, deviceId, DataConstants.ENTITY_CREATED);
  43 + EdgeEvent edgeEvent = generateEdgeEvent(null, edgeId, deviceId, EdgeEventActionType.ADDED);
45 44 EdgeEvent saved = edgeEventService.saveAsync(edgeEvent).get();
46 45 Assert.assertEquals(saved.getTenantId(), edgeEvent.getTenantId());
47 46 Assert.assertEquals(saved.getEdgeId(), edgeEvent.getEdgeId());
... ... @@ -51,7 +50,7 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest {
51 50 Assert.assertEquals(saved.getBody(), edgeEvent.getBody());
52 51 }
53 52
54   - protected EdgeEvent generateEdgeEvent(TenantId tenantId, EdgeId edgeId, EntityId entityId, String edgeEventAction) throws IOException {
  53 + protected EdgeEvent generateEdgeEvent(TenantId tenantId, EdgeId edgeId, EntityId entityId, EdgeEventActionType edgeEventAction) throws IOException {
55 54 if (tenantId == null) {
56 55 tenantId = new TenantId(UUIDs.timeBased());
57 56 }
... ... @@ -108,7 +107,7 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest {
108 107 TenantId tenantId = new TenantId(UUIDs.timeBased());
109 108 TimePageLink pageLink = new TimePageLink(1);
110 109
111   - EdgeEvent edgeEventWithTsUpdate = generateEdgeEvent(tenantId, edgeId, deviceId, ActionType.TIMESERIES_UPDATED.name());
  110 + EdgeEvent edgeEventWithTsUpdate = generateEdgeEvent(tenantId, edgeId, deviceId, EdgeEventActionType.TIMESERIES_UPDATED);
112 111 edgeEventService.saveAsync(edgeEventWithTsUpdate).get();
113 112
114 113 TimePageData<EdgeEvent> allEdgeEvents = edgeEventService.findEdgeEvents(tenantId, edgeId, pageLink, true);
... ... @@ -122,7 +121,7 @@ public abstract class BaseEdgeEventServiceTest extends AbstractServiceTest {
122 121 }
123 122
124 123 private EdgeEvent saveEdgeEventWithProvidedTime(long time, EdgeId edgeId, EntityId entityId, TenantId tenantId) throws Exception {
125   - EdgeEvent edgeEvent = generateEdgeEvent(tenantId, edgeId, entityId, DataConstants.ENTITY_CREATED);
  124 + EdgeEvent edgeEvent = generateEdgeEvent(tenantId, edgeId, entityId, EdgeEventActionType.ADDED);
126 125 edgeEvent.setId(new EdgeEventId(UUIDs.startOf(time)));
127 126 return edgeEventService.saveAsync(edgeEvent).get();
128 127 }
... ...
... ... @@ -32,8 +32,8 @@ import org.thingsboard.rule.engine.api.util.TbNodeUtils;
32 32 import org.thingsboard.server.common.data.DataConstants;
33 33 import org.thingsboard.server.common.data.EdgeUtils;
34 34 import org.thingsboard.server.common.data.EntityType;
35   -import org.thingsboard.server.common.data.audit.ActionType;
36 35 import org.thingsboard.server.common.data.edge.EdgeEvent;
  36 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
37 37 import org.thingsboard.server.common.data.edge.EdgeEventType;
38 38 import org.thingsboard.server.common.data.id.EdgeId;
39 39 import org.thingsboard.server.common.data.id.TenantId;
... ... @@ -140,13 +140,13 @@ public class TbMsgPushToEdgeNode implements TbNode {
140 140 private EdgeEvent buildEdgeEvent(TbMsg msg, TbContext ctx) throws JsonProcessingException {
141 141 String msgType = msg.getType();
142 142 if (DataConstants.ALARM.equals(msgType)) {
143   - return buildEdgeEvent(ctx.getTenantId(), ActionType.ADDED, getUUIDFromMsgData(msg), EdgeEventType.ALARM, null);
  143 + return buildEdgeEvent(ctx.getTenantId(), EdgeEventActionType.ADDED, getUUIDFromMsgData(msg), EdgeEventType.ALARM, null);
144 144 } else {
145 145 EdgeEventType edgeEventTypeByEntityType = EdgeUtils.getEdgeEventTypeByEntityType(msg.getOriginator().getEntityType());
146 146 if (edgeEventTypeByEntityType == null) {
147 147 return null;
148 148 }
149   - ActionType actionType = getActionTypeByMsgType(msgType);
  149 + EdgeEventActionType actionType = getEdgeEventActionTypeByMsgType(msgType);
150 150 Map<String, Object> entityBody = new HashMap<>();
151 151 Map<String, String> metadata = msg.getMetaData().getData();
152 152 JsonNode dataJson = json.readTree(msg.getData());
... ... @@ -172,10 +172,10 @@ public class TbMsgPushToEdgeNode implements TbNode {
172 172 }
173 173 }
174 174
175   - private EdgeEvent buildEdgeEvent(TenantId tenantId, ActionType edgeEventAction, UUID entityId, EdgeEventType edgeEventType, JsonNode entityBody) {
  175 + private EdgeEvent buildEdgeEvent(TenantId tenantId, EdgeEventActionType edgeEventAction, UUID entityId, EdgeEventType edgeEventType, JsonNode entityBody) {
176 176 EdgeEvent edgeEvent = new EdgeEvent();
177 177 edgeEvent.setTenantId(tenantId);
178   - edgeEvent.setAction(edgeEventAction.name());
  178 + edgeEvent.setAction(edgeEventAction);
179 179 edgeEvent.setEntityId(entityId);
180 180 edgeEvent.setType(edgeEventType);
181 181 edgeEvent.setBody(entityBody);
... ... @@ -188,15 +188,15 @@ public class TbMsgPushToEdgeNode implements TbNode {
188 188 return UUID.fromString(id);
189 189 }
190 190
191   - private ActionType getActionTypeByMsgType(String msgType) {
192   - ActionType actionType;
  191 + private EdgeEventActionType getEdgeEventActionTypeByMsgType(String msgType) {
  192 + EdgeEventActionType actionType;
193 193 if (SessionMsgType.POST_TELEMETRY_REQUEST.name().equals(msgType)) {
194   - actionType = ActionType.TIMESERIES_UPDATED;
  194 + actionType = EdgeEventActionType.TIMESERIES_UPDATED;
195 195 } else if (SessionMsgType.POST_ATTRIBUTES_REQUEST.name().equals(msgType)
196 196 || DataConstants.ATTRIBUTES_UPDATED.equals(msgType)) {
197   - actionType = ActionType.ATTRIBUTES_UPDATED;
  197 + actionType = EdgeEventActionType.ATTRIBUTES_UPDATED;
198 198 } else {
199   - actionType = ActionType.ATTRIBUTES_DELETED;
  199 + actionType = EdgeEventActionType.ATTRIBUTES_DELETED;
200 200 }
201 201 return actionType;
202 202 }
... ...
... ... @@ -36,8 +36,8 @@ import org.thingsboard.rule.engine.api.TbRelationTypes;
36 36 import org.thingsboard.rule.engine.api.util.TbNodeUtils;
37 37 import org.thingsboard.server.common.data.DataConstants;
38 38 import org.thingsboard.server.common.data.EntityType;
39   -import org.thingsboard.server.common.data.audit.ActionType;
40 39 import org.thingsboard.server.common.data.edge.EdgeEvent;
  40 +import org.thingsboard.server.common.data.edge.EdgeEventActionType;
41 41 import org.thingsboard.server.common.data.edge.EdgeEventType;
42 42 import org.thingsboard.server.common.data.id.DeviceId;
43 43 import org.thingsboard.server.common.data.id.EdgeId;
... ... @@ -156,7 +156,7 @@ public class TbSendRPCRequestNode implements TbNode {
156 156 private void sendRpcRequestToEdgeDevice(TbContext ctx, TbMsg msg, EdgeId edgeId, RuleEngineDeviceRpcRequest request) {
157 157 EdgeEvent edgeEvent = new EdgeEvent();
158 158 edgeEvent.setTenantId(ctx.getTenantId());
159   - edgeEvent.setAction(ActionType.RPC_CALL.name());
  159 + edgeEvent.setAction(EdgeEventActionType.RPC_CALL);
160 160 edgeEvent.setEntityId(request.getDeviceId().getId());
161 161 edgeEvent.setType(EdgeEventType.DEVICE);
162 162 edgeEvent.setBody(json.valueToTree(request));
... ...