Fixed relation propagation to edge. Code review improvements
This commit is contained in:
		
							parent
							
								
									f151737678
								
							
						
					
					
						commit
						117547ae6b
					
				@ -92,7 +92,8 @@ public class AlarmController extends BaseController {
 | 
				
			|||||||
                    getCurrentUser().getCustomerId(),
 | 
					                    getCurrentUser().getCustomerId(),
 | 
				
			||||||
                    alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
					                    alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), savedAlarm.getId(), alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), savedAlarm.getId(),
 | 
				
			||||||
 | 
					                    alarm.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedAlarm;
 | 
					            return savedAlarm;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -88,13 +88,13 @@ public class AssetController extends BaseController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            Asset savedAsset = checkNotNull(assetService.saveAsset(asset));
 | 
					            Asset savedAsset = checkNotNull(assetService.saveAsset(asset));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(savedAsset.getTenantId(), null,
 | 
					 | 
				
			||||||
                    savedAsset.getId(), EdgeEventType.ASSET, asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            logEntityAction(savedAsset.getId(), savedAsset,
 | 
					            logEntityAction(savedAsset.getId(), savedAsset,
 | 
				
			||||||
                    savedAsset.getCustomerId(),
 | 
					                    savedAsset.getCustomerId(),
 | 
				
			||||||
                    asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
					                    asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), savedAsset.getId(),
 | 
				
			||||||
 | 
					                    asset.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedAsset;
 | 
					            return savedAsset;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            logEntityAction(emptyId(EntityType.ASSET), asset,
 | 
					            logEntityAction(emptyId(EntityType.ASSET), asset,
 | 
				
			||||||
@ -117,7 +117,7 @@ public class AssetController extends BaseController {
 | 
				
			|||||||
                    asset.getCustomerId(),
 | 
					                    asset.getCustomerId(),
 | 
				
			||||||
                    ActionType.DELETED, null, strAssetId);
 | 
					                    ActionType.DELETED, null, strAssetId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, assetId, EdgeEventType.ASSET, ActionType.DELETED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), assetId, ActionType.DELETED);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            logEntityAction(emptyId(EntityType.ASSET),
 | 
					            logEntityAction(emptyId(EntityType.ASSET),
 | 
				
			||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
@ -360,7 +360,7 @@ public class AssetController extends BaseController {
 | 
				
			|||||||
                    savedAsset.getCustomerId(),
 | 
					                    savedAsset.getCustomerId(),
 | 
				
			||||||
                    ActionType.ASSIGNED_TO_EDGE, null, strAssetId, strEdgeId, edge.getName());
 | 
					                    ActionType.ASSIGNED_TO_EDGE, null, strAssetId, strEdgeId, edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), EdgeEventType.ASSET, ActionType.ASSIGNED_TO_EDGE);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), ActionType.ASSIGNED_TO_EDGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return  savedAsset;
 | 
					            return  savedAsset;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -393,8 +393,7 @@ public class AssetController extends BaseController {
 | 
				
			|||||||
                    asset.getCustomerId(),
 | 
					                    asset.getCustomerId(),
 | 
				
			||||||
                    ActionType.UNASSIGNED_FROM_EDGE, null, strAssetId, edge.getId().toString(), edge.getName());
 | 
					                    ActionType.UNASSIGNED_FROM_EDGE, null, strAssetId, edge.getId().toString(), edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedAsset.getId(), ActionType.UNASSIGNED_FROM_EDGE);
 | 
				
			||||||
                    EdgeEventType.ASSET, ActionType.UNASSIGNED_FROM_EDGE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedAsset;
 | 
					            return savedAsset;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -126,7 +126,7 @@ public class AuthController extends BaseController {
 | 
				
			|||||||
            userCredentials.setPassword(passwordEncoder.encode(newPassword));
 | 
					            userCredentials.setPassword(passwordEncoder.encode(newPassword));
 | 
				
			||||||
            userService.replaceUserCredentials(securityUser.getTenantId(), userCredentials);
 | 
					            userService.replaceUserCredentials(securityUser.getTenantId(), userCredentials);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, userCredentials.getUserId(), EdgeEventType.USER, ActionType.CREDENTIALS_UPDATED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), userCredentials.getUserId(), ActionType.CREDENTIALS_UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            throw handleException(e);
 | 
					            throw handleException(e);
 | 
				
			||||||
 | 
				
			|||||||
@ -730,15 +730,15 @@ public abstract class BaseController {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, ActionType edgeEventAction) {
 | 
					    protected void sendNotificationMsgToEdgeService(TenantId tenantId, EntityId entityId, ActionType edgeEventAction) {
 | 
				
			||||||
        EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType());
 | 
					        sendNotificationMsgToEdgeService(tenantId, null, entityId, edgeEventAction);
 | 
				
			||||||
        if (edgeEventType != null) {
 | 
					 | 
				
			||||||
            sendNotificationMsgToEdgeService(tenantId, null, entityId, null, edgeEventType, edgeEventAction);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, EdgeEventType edgeEventType, ActionType edgeEventAction) {
 | 
					    protected void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, ActionType edgeEventAction) {
 | 
				
			||||||
 | 
					        EdgeEventType edgeEventType = EdgeUtils.getEdgeEventTypeByEntityType(entityId.getEntityType());
 | 
				
			||||||
 | 
					        if (edgeEventType != null) {
 | 
				
			||||||
            sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, edgeEventType, edgeEventAction);
 | 
					            sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, edgeEventType, edgeEventAction);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String entityBody, EdgeEventType edgeEventType, ActionType edgeEventAction) {
 | 
					    private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String entityBody, EdgeEventType edgeEventType, ActionType edgeEventAction) {
 | 
				
			||||||
        TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder();
 | 
					        TransportProtos.EdgeNotificationMsgProto.Builder builder = TransportProtos.EdgeNotificationMsgProto.newBuilder();
 | 
				
			||||||
 | 
				
			|||||||
@ -117,8 +117,8 @@ public class DashboardController extends BaseController {
 | 
				
			|||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
                    dashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
					                    dashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), null, savedDashboard.getId(),
 | 
					            sendNotificationMsgToEdgeService(savedDashboard.getTenantId(), savedDashboard.getId(),
 | 
				
			||||||
                    EdgeEventType.DASHBOARD, savedDashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					                    dashboard.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedDashboard;
 | 
					            return savedDashboard;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -143,7 +143,7 @@ public class DashboardController extends BaseController {
 | 
				
			|||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
                    ActionType.DELETED, null, strDashboardId);
 | 
					                    ActionType.DELETED, null, strDashboardId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, dashboardId, EdgeEventType.DASHBOARD, ActionType.DELETED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), dashboardId, ActionType.DELETED);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logEntityAction(emptyId(EntityType.DASHBOARD),
 | 
					            logEntityAction(emptyId(EntityType.DASHBOARD),
 | 
				
			||||||
@ -500,8 +500,7 @@ public class DashboardController extends BaseController {
 | 
				
			|||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
                    ActionType.ASSIGNED_TO_EDGE, null, strDashboardId, strEdgeId, edge.getName());
 | 
					                    ActionType.ASSIGNED_TO_EDGE, null, strDashboardId, strEdgeId, edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), ActionType.ASSIGNED_TO_EDGE);
 | 
				
			||||||
                    EdgeEventType.DASHBOARD, ActionType.ASSIGNED_TO_EDGE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedDashboard;
 | 
					            return savedDashboard;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -533,8 +532,7 @@ public class DashboardController extends BaseController {
 | 
				
			|||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
                    ActionType.UNASSIGNED_FROM_EDGE, null, strDashboardId, edge.getId().toString(), edge.getName());
 | 
					                    ActionType.UNASSIGNED_FROM_EDGE, null, strDashboardId, edge.getId().toString(), edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDashboard.getId(), ActionType.UNASSIGNED_FROM_EDGE);
 | 
				
			||||||
                    EdgeEventType.DASHBOARD, ActionType.UNASSIGNED_FROM_EDGE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedDashboard;
 | 
					            return savedDashboard;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -108,8 +108,8 @@ public class DeviceController extends BaseController {
 | 
				
			|||||||
            tbClusterService.pushMsgToCore(new DeviceNameOrTypeUpdateMsg(savedDevice.getTenantId(),
 | 
					            tbClusterService.pushMsgToCore(new DeviceNameOrTypeUpdateMsg(savedDevice.getTenantId(),
 | 
				
			||||||
                    savedDevice.getId(), savedDevice.getName(), savedDevice.getType()), null);
 | 
					                    savedDevice.getId(), savedDevice.getName(), savedDevice.getType()), null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(savedDevice.getTenantId(), null, savedDevice.getId(),
 | 
					            sendNotificationMsgToEdgeService(savedDevice.getTenantId(), savedDevice.getId(),
 | 
				
			||||||
                    EdgeEventType.DEVICE, device.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					                    device.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logEntityAction(savedDevice.getId(), savedDevice,
 | 
					            logEntityAction(savedDevice.getId(), savedDevice,
 | 
				
			||||||
                    savedDevice.getCustomerId(),
 | 
					                    savedDevice.getCustomerId(),
 | 
				
			||||||
@ -142,7 +142,7 @@ public class DeviceController extends BaseController {
 | 
				
			|||||||
                    device.getCustomerId(),
 | 
					                    device.getCustomerId(),
 | 
				
			||||||
                    ActionType.DELETED, null, strDeviceId);
 | 
					                    ActionType.DELETED, null, strDeviceId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, deviceId, EdgeEventType.DEVICE, ActionType.DELETED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), deviceId, ActionType.DELETED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            deviceStateService.onDeviceDeleted(device);
 | 
					            deviceStateService.onDeviceDeleted(device);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -267,7 +267,7 @@ public class DeviceController extends BaseController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(getCurrentUser().getTenantId(), deviceCredentials.getDeviceId()), null);
 | 
					            tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(getCurrentUser().getTenantId(), deviceCredentials.getDeviceId()), null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, device.getId(), EdgeEventType.DEVICE, ActionType.CREDENTIALS_UPDATED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), device.getId(), ActionType.CREDENTIALS_UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logEntityAction(device.getId(), device,
 | 
					            logEntityAction(device.getId(), device,
 | 
				
			||||||
                    device.getCustomerId(),
 | 
					                    device.getCustomerId(),
 | 
				
			||||||
@ -518,7 +518,7 @@ public class DeviceController extends BaseController {
 | 
				
			|||||||
                    savedDevice.getCustomerId(),
 | 
					                    savedDevice.getCustomerId(),
 | 
				
			||||||
                    ActionType.ASSIGNED_TO_EDGE, null, strDeviceId, strEdgeId, edge.getName());
 | 
					                    ActionType.ASSIGNED_TO_EDGE, null, strDeviceId, strEdgeId, edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), EdgeEventType.DEVICE, ActionType.ASSIGNED_TO_EDGE);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), ActionType.ASSIGNED_TO_EDGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedDevice;
 | 
					            return savedDevice;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -549,7 +549,7 @@ public class DeviceController extends BaseController {
 | 
				
			|||||||
                    device.getCustomerId(),
 | 
					                    device.getCustomerId(),
 | 
				
			||||||
                    ActionType.UNASSIGNED_FROM_EDGE, null, strDeviceId, edge.getId().toString(), edge.getName());
 | 
					                    ActionType.UNASSIGNED_FROM_EDGE, null, strDeviceId, edge.getId().toString(), edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), EdgeEventType.DEVICE, ActionType.UNASSIGNED_FROM_EDGE);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedDevice.getId(), ActionType.UNASSIGNED_FROM_EDGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedDevice;
 | 
					            return savedDevice;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -118,8 +118,8 @@ public class EntityViewController extends BaseController {
 | 
				
			|||||||
            logEntityAction(savedEntityView.getId(), savedEntityView, null,
 | 
					            logEntityAction(savedEntityView.getId(), savedEntityView, null,
 | 
				
			||||||
                    entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
					                    entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, savedEntityView.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), savedEntityView.getId(),
 | 
				
			||||||
                    EdgeEventType.ENTITY_VIEW, entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					                    entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
            return savedEntityView;
 | 
					            return savedEntityView;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            logEntityAction(emptyId(EntityType.ENTITY_VIEW), entityView, null,
 | 
					            logEntityAction(emptyId(EntityType.ENTITY_VIEW), entityView, null,
 | 
				
			||||||
@ -190,7 +190,7 @@ public class EntityViewController extends BaseController {
 | 
				
			|||||||
            logEntityAction(entityViewId, entityView, entityView.getCustomerId(),
 | 
					            logEntityAction(entityViewId, entityView, entityView.getCustomerId(),
 | 
				
			||||||
                    ActionType.DELETED, null, strEntityViewId);
 | 
					                    ActionType.DELETED, null, strEntityViewId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, entityViewId, EdgeEventType.ENTITY_VIEW, ActionType.DELETED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), entityViewId, ActionType.DELETED);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            logEntityAction(emptyId(EntityType.ENTITY_VIEW),
 | 
					            logEntityAction(emptyId(EntityType.ENTITY_VIEW),
 | 
				
			||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
@ -396,8 +396,7 @@ public class EntityViewController extends BaseController {
 | 
				
			|||||||
                    savedEntityView.getCustomerId(),
 | 
					                    savedEntityView.getCustomerId(),
 | 
				
			||||||
                    ActionType.ASSIGNED_TO_EDGE, null, strEntityViewId, strEdgeId, edge.getName());
 | 
					                    ActionType.ASSIGNED_TO_EDGE, null, strEntityViewId, strEdgeId, edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), ActionType.ASSIGNED_TO_EDGE);
 | 
				
			||||||
                    EdgeEventType.ENTITY_VIEW, ActionType.ASSIGNED_TO_EDGE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedEntityView;
 | 
					            return savedEntityView;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -427,8 +426,7 @@ public class EntityViewController extends BaseController {
 | 
				
			|||||||
                    entityView.getCustomerId(),
 | 
					                    entityView.getCustomerId(),
 | 
				
			||||||
                    ActionType.UNASSIGNED_FROM_EDGE, null, strEntityViewId, edge.getId().toString(), edge.getName());
 | 
					                    ActionType.UNASSIGNED_FROM_EDGE, null, strEntityViewId, edge.getId().toString(), edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedEntityView.getId(), ActionType.UNASSIGNED_FROM_EDGE);
 | 
				
			||||||
                    EdgeEventType.ENTITY_VIEW, ActionType.UNASSIGNED_FROM_EDGE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedEntityView;
 | 
					            return savedEntityView;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -145,9 +145,8 @@ public class RuleChainController extends BaseController {
 | 
				
			|||||||
                    created ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
					                    created ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (RuleChainType.EDGE.equals(savedRuleChain.getType())) {
 | 
					            if (RuleChainType.EDGE.equals(savedRuleChain.getType())) {
 | 
				
			||||||
                sendNotificationMsgToEdgeService(savedRuleChain.getTenantId(), null,
 | 
					                sendNotificationMsgToEdgeService(savedRuleChain.getTenantId(), savedRuleChain.getId(),
 | 
				
			||||||
                        savedRuleChain.getId(), EdgeEventType.RULE_CHAIN,
 | 
					                        created ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
                        savedRuleChain.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedRuleChain;
 | 
					            return savedRuleChain;
 | 
				
			||||||
@ -226,9 +225,7 @@ public class RuleChainController extends BaseController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (RuleChainType.EDGE.equals(ruleChain.getType())) {
 | 
					            if (RuleChainType.EDGE.equals(ruleChain.getType())) {
 | 
				
			||||||
                sendNotificationMsgToEdgeService(ruleChain.getTenantId(),
 | 
					                sendNotificationMsgToEdgeService(ruleChain.getTenantId(),
 | 
				
			||||||
                        null,
 | 
					                        ruleChain.getId(), ActionType.UPDATED);
 | 
				
			||||||
                        ruleChain.getId(), EdgeEventType.RULE_CHAIN,
 | 
					 | 
				
			||||||
                        ActionType.UPDATED);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedRuleChainMetaData;
 | 
					            return savedRuleChainMetaData;
 | 
				
			||||||
@ -293,8 +290,7 @@ public class RuleChainController extends BaseController {
 | 
				
			|||||||
                    ActionType.DELETED, null, strRuleChainId);
 | 
					                    ActionType.DELETED, null, strRuleChainId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (RuleChainType.EDGE.equals(ruleChain.getType())) {
 | 
					            if (RuleChainType.EDGE.equals(ruleChain.getType())) {
 | 
				
			||||||
                sendNotificationMsgToEdgeService(ruleChain.getTenantId(), null,
 | 
					                sendNotificationMsgToEdgeService(ruleChain.getTenantId(), ruleChain.getId(), ActionType.DELETED);
 | 
				
			||||||
                        ruleChain.getId(), EdgeEventType.RULE_CHAIN, ActionType.DELETED);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -426,8 +422,7 @@ public class RuleChainController extends BaseController {
 | 
				
			|||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
                    ActionType.ASSIGNED_TO_EDGE, null, strRuleChainId, strEdgeId, edge.getName());
 | 
					                    ActionType.ASSIGNED_TO_EDGE, null, strRuleChainId, strEdgeId, edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), ActionType.ASSIGNED_TO_EDGE);
 | 
				
			||||||
                    EdgeEventType.RULE_CHAIN, ActionType.ASSIGNED_TO_EDGE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedRuleChain;
 | 
					            return savedRuleChain;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -459,8 +454,7 @@ public class RuleChainController extends BaseController {
 | 
				
			|||||||
                    null,
 | 
					                    null,
 | 
				
			||||||
                    ActionType.UNASSIGNED_FROM_EDGE, null, strRuleChainId, edge.getId().toString(), edge.getName());
 | 
					                    ActionType.UNASSIGNED_FROM_EDGE, null, strRuleChainId, edge.getId().toString(), edge.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(),
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), edgeId, savedRuleChain.getId(), ActionType.UNASSIGNED_FROM_EDGE);
 | 
				
			||||||
                    EdgeEventType.RULE_CHAIN, ActionType.UNASSIGNED_FROM_EDGE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedRuleChain;
 | 
					            return savedRuleChain;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -162,7 +162,8 @@ public class UserController extends BaseController {
 | 
				
			|||||||
                    savedUser.getCustomerId(),
 | 
					                    savedUser.getCustomerId(),
 | 
				
			||||||
                    user.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
					                    user.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, user.getId(), EdgeEventType.USER, user.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), savedUser.getId(),
 | 
				
			||||||
 | 
					                    user.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return savedUser;
 | 
					            return savedUser;
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
@ -239,7 +240,7 @@ public class UserController extends BaseController {
 | 
				
			|||||||
                    user.getCustomerId(),
 | 
					                    user.getCustomerId(),
 | 
				
			||||||
                    ActionType.DELETED, null, strUserId);
 | 
					                    ActionType.DELETED, null, strUserId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), null, user.getId(), EdgeEventType.USER, ActionType.DELETED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), user.getId(), ActionType.DELETED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            logEntityAction(emptyId(EntityType.USER),
 | 
					            logEntityAction(emptyId(EntityType.USER),
 | 
				
			||||||
 | 
				
			|||||||
@ -72,7 +72,8 @@ public class WidgetTypeController extends BaseController {
 | 
				
			|||||||
            checkEntity(widgetType.getId(), widgetType, Resource.WIDGET_TYPE);
 | 
					            checkEntity(widgetType.getId(), widgetType, Resource.WIDGET_TYPE);
 | 
				
			||||||
            WidgetType savedWidgetType = widgetTypeService.saveWidgetType(widgetType);
 | 
					            WidgetType savedWidgetType = widgetTypeService.saveWidgetType(widgetType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), savedWidgetType.getId(), widgetType.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), savedWidgetType.getId(),
 | 
				
			||||||
 | 
					                    widgetType.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return checkNotNull(savedWidgetType);
 | 
					            return checkNotNull(savedWidgetType);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,8 @@ public class WidgetsBundleController extends BaseController {
 | 
				
			|||||||
            checkEntity(widgetsBundle.getId(), widgetsBundle, Resource.WIDGETS_BUNDLE);
 | 
					            checkEntity(widgetsBundle.getId(), widgetsBundle, Resource.WIDGETS_BUNDLE);
 | 
				
			||||||
            WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle);
 | 
					            WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendNotificationMsgToEdgeService(getTenantId(), savedWidgetsBundle.getId(), widgetsBundle.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
					            sendNotificationMsgToEdgeService(getTenantId(), savedWidgetsBundle.getId(),
 | 
				
			||||||
 | 
					                    widgetsBundle.getId() == null ? ActionType.ADDED : ActionType.UPDATED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return checkNotNull(savedWidgetsBundle);
 | 
					            return checkNotNull(savedWidgetsBundle);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -234,6 +234,8 @@ public final class EdgeGrpcSession implements Closeable {
 | 
				
			|||||||
                            case ALARM_ACK:
 | 
					                            case ALARM_ACK:
 | 
				
			||||||
                            case ALARM_CLEAR:
 | 
					                            case ALARM_CLEAR:
 | 
				
			||||||
                            case CREDENTIALS_UPDATED:
 | 
					                            case CREDENTIALS_UPDATED:
 | 
				
			||||||
 | 
					                            case RELATION_ADD_OR_UPDATE:
 | 
				
			||||||
 | 
					                            case RELATION_DELETED:
 | 
				
			||||||
                                processEntityMessage(edgeEvent, edgeEventAction);
 | 
					                                processEntityMessage(edgeEvent, edgeEventAction);
 | 
				
			||||||
                                break;
 | 
					                                break;
 | 
				
			||||||
                            case ATTRIBUTES_UPDATED:
 | 
					                            case ATTRIBUTES_UPDATED:
 | 
				
			||||||
@ -687,9 +689,11 @@ public final class EdgeGrpcSession implements Closeable {
 | 
				
			|||||||
                return UpdateMsgType.ENTITY_UPDATED_RPC_MESSAGE;
 | 
					                return UpdateMsgType.ENTITY_UPDATED_RPC_MESSAGE;
 | 
				
			||||||
            case ADDED:
 | 
					            case ADDED:
 | 
				
			||||||
            case ASSIGNED_TO_EDGE:
 | 
					            case ASSIGNED_TO_EDGE:
 | 
				
			||||||
 | 
					            case RELATION_ADD_OR_UPDATE:
 | 
				
			||||||
                return ENTITY_CREATED_RPC_MESSAGE;
 | 
					                return ENTITY_CREATED_RPC_MESSAGE;
 | 
				
			||||||
            case DELETED:
 | 
					            case DELETED:
 | 
				
			||||||
            case UNASSIGNED_FROM_EDGE:
 | 
					            case UNASSIGNED_FROM_EDGE:
 | 
				
			||||||
 | 
					            case RELATION_DELETED:
 | 
				
			||||||
                return UpdateMsgType.ENTITY_DELETED_RPC_MESSAGE;
 | 
					                return UpdateMsgType.ENTITY_DELETED_RPC_MESSAGE;
 | 
				
			||||||
            case ALARM_ACK:
 | 
					            case ALARM_ACK:
 | 
				
			||||||
                return UpdateMsgType.ALARM_ACK_RPC_MESSAGE;
 | 
					                return UpdateMsgType.ALARM_ACK_RPC_MESSAGE;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user