|
|
|
@ -24,10 +24,8 @@ import org.thingsboard.server.common.data.DeviceProfileType; |
|
|
|
import org.thingsboard.server.common.data.DeviceTransportType; |
|
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
|
import org.thingsboard.server.common.data.device.profile.DeviceProfileData; |
|
|
|
import org.thingsboard.server.common.data.id.DashboardId; |
|
|
|
import org.thingsboard.server.common.data.id.DeviceProfileId; |
|
|
|
import org.thingsboard.server.common.data.id.OtaPackageId; |
|
|
|
import org.thingsboard.server.common.data.id.RuleChainId; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.gen.edge.v1.DeviceProfileUpdateMsg; |
|
|
|
import org.thingsboard.server.queue.util.DataDecodingEncodingService; |
|
|
|
@ -38,7 +36,7 @@ import java.util.Optional; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
public class BaseDeviceProfileProcessor extends BaseEdgeProcessor { |
|
|
|
public abstract class BaseDeviceProfileProcessor extends BaseEdgeProcessor { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DataDecodingEncodingService dataDecodingEncodingService; |
|
|
|
@ -72,11 +70,9 @@ public class BaseDeviceProfileProcessor extends BaseEdgeProcessor { |
|
|
|
dataDecodingEncodingService.decode(deviceProfileUpdateMsg.getProfileDataBytes().toByteArray()); |
|
|
|
deviceProfile.setProfileData(profileDataOpt.orElse(null)); |
|
|
|
|
|
|
|
UUID defaultRuleChainUUID = safeGetUUID(deviceProfileUpdateMsg.getDefaultRuleChainIdMSB(), deviceProfileUpdateMsg.getDefaultRuleChainIdLSB()); |
|
|
|
deviceProfile.setDefaultRuleChainId(defaultRuleChainUUID != null ? new RuleChainId(defaultRuleChainUUID) : null); |
|
|
|
|
|
|
|
UUID defaultDashboardUUID = safeGetUUID(deviceProfileUpdateMsg.getDefaultDashboardIdMSB(), deviceProfileUpdateMsg.getDefaultDashboardIdLSB()); |
|
|
|
deviceProfile.setDefaultDashboardId(defaultDashboardUUID != null ? new DashboardId(defaultDashboardUUID) : null); |
|
|
|
setDefaultRuleChainId(deviceProfile, deviceProfileUpdateMsg); |
|
|
|
setDefaultEdgeRuleChainId(deviceProfile, deviceProfileUpdateMsg); |
|
|
|
setDefaultDashboardId(deviceProfile, deviceProfileUpdateMsg); |
|
|
|
|
|
|
|
String defaultQueueName = StringUtils.isNotBlank(deviceProfileUpdateMsg.getDefaultQueueName()) |
|
|
|
? deviceProfileUpdateMsg.getDefaultQueueName() : null; |
|
|
|
@ -88,7 +84,6 @@ public class BaseDeviceProfileProcessor extends BaseEdgeProcessor { |
|
|
|
UUID softwareUUID = safeGetUUID(deviceProfileUpdateMsg.getSoftwareIdMSB(), deviceProfileUpdateMsg.getSoftwareIdLSB()); |
|
|
|
deviceProfile.setSoftwareId(softwareUUID != null ? new OtaPackageId(softwareUUID) : null); |
|
|
|
|
|
|
|
|
|
|
|
deviceProfileValidator.validate(deviceProfile, DeviceProfile::getTenantId); |
|
|
|
if (created) { |
|
|
|
deviceProfile.setId(deviceProfileId); |
|
|
|
@ -99,4 +94,10 @@ public class BaseDeviceProfileProcessor extends BaseEdgeProcessor { |
|
|
|
} |
|
|
|
return created; |
|
|
|
} |
|
|
|
|
|
|
|
protected abstract void setDefaultRuleChainId(DeviceProfile deviceProfile, DeviceProfileUpdateMsg deviceProfileUpdateMsg); |
|
|
|
|
|
|
|
protected abstract void setDefaultEdgeRuleChainId(DeviceProfile deviceProfile, DeviceProfileUpdateMsg deviceProfileUpdateMsg); |
|
|
|
|
|
|
|
protected abstract void setDefaultDashboardId(DeviceProfile deviceProfile, DeviceProfileUpdateMsg deviceProfileUpdateMsg); |
|
|
|
} |
|
|
|
|