Added propagation of asset and device profiles to cloud in case of entity created event
This commit is contained in:
		
							parent
							
								
									6cfdedeaa1
								
							
						
					
					
						commit
						ee378b6170
					
				@ -18,8 +18,10 @@ package org.thingsboard.server.service.edge.rpc.processor;
 | 
			
		||||
import com.google.common.util.concurrent.ListenableFuture;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfile;
 | 
			
		||||
import org.thingsboard.server.common.data.EdgeUtils;
 | 
			
		||||
import org.thingsboard.server.common.data.asset.Asset;
 | 
			
		||||
import org.thingsboard.server.common.data.asset.AssetProfile;
 | 
			
		||||
import org.thingsboard.server.common.data.edge.EdgeEvent;
 | 
			
		||||
import org.thingsboard.server.common.data.id.AssetId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.TenantId;
 | 
			
		||||
@ -48,10 +50,14 @@ public class AssetEdgeProcessor extends BaseEdgeProcessor {
 | 
			
		||||
                    UpdateMsgType msgType = getUpdateMsgType(edgeEvent.getAction());
 | 
			
		||||
                    AssetUpdateMsg assetUpdateMsg =
 | 
			
		||||
                            assetMsgConstructor.constructAssetUpdatedMsg(msgType, asset);
 | 
			
		||||
                    downlinkMsg = DownlinkMsg.newBuilder()
 | 
			
		||||
                    DownlinkMsg.Builder builder = DownlinkMsg.newBuilder()
 | 
			
		||||
                            .setDownlinkMsgId(EdgeUtils.nextPositiveInt())
 | 
			
		||||
                            .addAssetUpdateMsg(assetUpdateMsg)
 | 
			
		||||
                            .build();
 | 
			
		||||
                            .addAssetUpdateMsg(assetUpdateMsg);
 | 
			
		||||
                    if (UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE.equals(msgType)) {
 | 
			
		||||
                        AssetProfile assetProfile = assetProfileService.findAssetProfileById(edgeEvent.getTenantId(), asset.getAssetProfileId());
 | 
			
		||||
                        builder.addAssetProfileUpdateMsg(assetProfileMsgConstructor.constructAssetProfileUpdatedMsg(msgType, assetProfile));
 | 
			
		||||
                    }
 | 
			
		||||
                    downlinkMsg = builder.build();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case DELETED:
 | 
			
		||||
 | 
			
		||||
@ -27,6 +27,7 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
import org.thingsboard.common.util.JacksonUtil;
 | 
			
		||||
import org.thingsboard.server.common.data.DataConstants;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.common.data.DeviceProfile;
 | 
			
		||||
import org.thingsboard.server.common.data.EdgeUtils;
 | 
			
		||||
import org.thingsboard.server.common.data.StringUtils;
 | 
			
		||||
import org.thingsboard.server.common.data.device.data.DeviceData;
 | 
			
		||||
@ -372,10 +373,14 @@ public class DeviceEdgeProcessor extends BaseEdgeProcessor {
 | 
			
		||||
                    UpdateMsgType msgType = getUpdateMsgType(edgeEvent.getAction());
 | 
			
		||||
                    DeviceUpdateMsg deviceUpdateMsg =
 | 
			
		||||
                            deviceMsgConstructor.constructDeviceUpdatedMsg(msgType, device, null);
 | 
			
		||||
                    downlinkMsg = DownlinkMsg.newBuilder()
 | 
			
		||||
                    DownlinkMsg.Builder builder = DownlinkMsg.newBuilder()
 | 
			
		||||
                            .setDownlinkMsgId(EdgeUtils.nextPositiveInt())
 | 
			
		||||
                            .addDeviceUpdateMsg(deviceUpdateMsg)
 | 
			
		||||
                            .build();
 | 
			
		||||
                            .addDeviceUpdateMsg(deviceUpdateMsg);
 | 
			
		||||
                    if (UpdateMsgType.ENTITY_CREATED_RPC_MESSAGE.equals(msgType)) {
 | 
			
		||||
                        DeviceProfile deviceProfile = deviceProfileService.findDeviceProfileById(edgeEvent.getTenantId(), device.getDeviceProfileId());
 | 
			
		||||
                        builder.addDeviceProfileUpdateMsg(deviceProfileMsgConstructor.constructDeviceProfileUpdatedMsg(msgType, deviceProfile));
 | 
			
		||||
                    }
 | 
			
		||||
                    downlinkMsg = builder.build();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case DELETED:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user