Properly hanlde null values in proto classes

This commit is contained in:
Volodymyr Babak 2021-07-30 18:22:19 +03:00
parent 89644e7de4
commit e05e681bd9
16 changed files with 207 additions and 155 deletions

View File

@ -0,0 +1,60 @@
/**
* Copyright © 2016-2021 The Thingsboard Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.thingsboard.server.service.edge.rpc;
import com.google.protobuf.BoolValue;
import com.google.protobuf.ByteString;
import com.google.protobuf.BytesValue;
import com.google.protobuf.Int64Value;
import com.google.protobuf.StringValue;
public class EdgeProtoUtils {
private EdgeProtoUtils() {
}
public static BoolValue getBoolValue(Boolean value) {
BoolValue.Builder builder = BoolValue.newBuilder();
if (value != null) {
builder.setValue(value);
}
return builder.build();
}
public static StringValue getStringValue(String value) {
StringValue.Builder builder = StringValue.newBuilder();
if (value != null) {
builder.setValue(value);
}
return builder.build();
}
public static Int64Value getInt64Value(Long value) {
Int64Value.Builder builder = Int64Value.newBuilder();
if (value != null) {
builder.setValue(value);
}
return builder.build();
}
public static BytesValue getBytesValue(ByteString value) {
BytesValue.Builder builder = BytesValue.newBuilder();
if (value != null) {
builder.setValue(value);
}
return builder.build();
}
}

View File

@ -24,6 +24,9 @@ import org.thingsboard.server.gen.edge.v1.AssetUpdateMsg;
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
import org.thingsboard.server.queue.util.TbCoreComponent;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getInt64Value;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class AssetMsgConstructor {
@ -35,16 +38,12 @@ public class AssetMsgConstructor {
.setIdLSB(asset.getId().getId().getLeastSignificantBits())
.setName(asset.getName())
.setType(asset.getType());
if (asset.getLabel() != null) {
builder.setLabel(asset.getLabel());
}
builder.setLabel(getStringValue(asset.getLabel()));
if (customerId != null) {
builder.setCustomerIdMSB(customerId.getId().getMostSignificantBits());
builder.setCustomerIdLSB(customerId.getId().getLeastSignificantBits());
}
if (asset.getAdditionalInfo() != null) {
builder.setAdditionalInfo(JacksonUtil.toString(asset.getAdditionalInfo()));
builder.setCustomerIdMSB(getInt64Value(customerId.getId().getMostSignificantBits()));
builder.setCustomerIdLSB(getInt64Value(customerId.getId().getLeastSignificantBits()));
}
builder.setAdditionalInfo(getStringValue(JacksonUtil.toString(asset.getAdditionalInfo())));
return builder.build();
}

View File

@ -23,6 +23,8 @@ import org.thingsboard.server.gen.edge.v1.CustomerUpdateMsg;
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
import org.thingsboard.server.queue.util.TbCoreComponent;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class CustomerMsgConstructor {
@ -33,33 +35,15 @@ public class CustomerMsgConstructor {
.setIdMSB(customer.getId().getId().getMostSignificantBits())
.setIdLSB(customer.getId().getId().getLeastSignificantBits())
.setTitle(customer.getTitle());
if (customer.getCountry() != null) {
builder.setCountry(customer.getCountry());
}
if (customer.getState() != null) {
builder.setState(customer.getState());
}
if (customer.getCity() != null) {
builder.setCity(customer.getCity());
}
if (customer.getAddress() != null) {
builder.setAddress(customer.getAddress());
}
if (customer.getAddress2() != null) {
builder.setAddress2(customer.getAddress2());
}
if (customer.getZip() != null) {
builder.setZip(customer.getZip());
}
if (customer.getPhone() != null) {
builder.setPhone(customer.getPhone());
}
if (customer.getEmail() != null) {
builder.setEmail(customer.getEmail());
}
if (customer.getAdditionalInfo() != null) {
builder.setAdditionalInfo(JacksonUtil.toString(customer.getAdditionalInfo()));
}
builder.setCountry(getStringValue(customer.getCountry()));
builder.setState(getStringValue(customer.getState()));
builder.setCity(getStringValue(customer.getCity()));
builder.setAddress(getStringValue(customer.getAddress()));
builder.setAddress2(getStringValue(customer.getAddress2()));
builder.setZip(getStringValue(customer.getZip()));
builder.setPhone(getStringValue(customer.getPhone()));
builder.setEmail(getStringValue(customer.getEmail()));
builder.setAdditionalInfo(getStringValue(JacksonUtil.toString(customer.getAdditionalInfo())));
return builder.build();
}

View File

@ -24,6 +24,8 @@ import org.thingsboard.server.gen.edge.v1.DashboardUpdateMsg;
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
import org.thingsboard.server.queue.util.TbCoreComponent;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getInt64Value;
@Component
@TbCoreComponent
public class DashboardMsgConstructor {
@ -36,8 +38,8 @@ public class DashboardMsgConstructor {
.setTitle(dashboard.getTitle())
.setConfiguration(JacksonUtil.toString(dashboard.getConfiguration()));
if (customerId != null) {
builder.setCustomerIdMSB(customerId.getId().getMostSignificantBits());
builder.setCustomerIdLSB(customerId.getId().getLeastSignificantBits());
builder.setCustomerIdMSB(getInt64Value(customerId.getId().getMostSignificantBits()));
builder.setCustomerIdLSB(getInt64Value(customerId.getId().getLeastSignificantBits()));
}
return builder.build();
}

View File

@ -32,6 +32,9 @@ import org.thingsboard.server.queue.util.TbCoreComponent;
import java.util.UUID;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getInt64Value;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class DeviceMsgConstructor {
@ -45,23 +48,17 @@ public class DeviceMsgConstructor {
.setIdLSB(device.getId().getId().getLeastSignificantBits())
.setName(device.getName())
.setType(device.getType());
if (device.getLabel() != null) {
builder.setLabel(device.getLabel());
}
builder.setLabel(getStringValue(device.getLabel()));
if (customerId != null) {
builder.setCustomerIdMSB(customerId.getId().getMostSignificantBits());
builder.setCustomerIdLSB(customerId.getId().getLeastSignificantBits());
builder.setCustomerIdMSB(getInt64Value(customerId.getId().getMostSignificantBits()));
builder.setCustomerIdLSB(getInt64Value(customerId.getId().getLeastSignificantBits()));
}
if (device.getDeviceProfileId() != null) {
builder.setDeviceProfileIdMSB(device.getDeviceProfileId().getId().getMostSignificantBits());
builder.setDeviceProfileIdLSB(device.getDeviceProfileId().getId().getLeastSignificantBits());
}
if (device.getAdditionalInfo() != null) {
builder.setAdditionalInfo(JacksonUtil.toString(device.getAdditionalInfo()));
}
if (conflictName != null) {
builder.setConflictName(conflictName);
builder.setDeviceProfileIdMSB(getInt64Value(device.getDeviceProfileId().getId().getMostSignificantBits()));
builder.setDeviceProfileIdLSB(getInt64Value(device.getDeviceProfileId().getId().getLeastSignificantBits()));
}
builder.setAdditionalInfo(getStringValue(JacksonUtil.toString(device.getAdditionalInfo())));
builder.setConflictName(getStringValue(conflictName));
return builder.build();
}

View File

@ -27,6 +27,9 @@ import org.thingsboard.server.queue.util.TbCoreComponent;
import java.nio.charset.StandardCharsets;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getBytesValue;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class DeviceProfileMsgConstructor {
@ -51,20 +54,16 @@ public class DeviceProfileMsgConstructor {
// if (deviceProfile.getDefaultQueueName() != null) {
// builder.setDefaultQueueName(deviceProfile.getDefaultQueueName());
// }
if (deviceProfile.getDescription() != null) {
builder.setDescription(deviceProfile.getDescription());
}
builder.setDescription(getStringValue(deviceProfile.getDescription()));
if (deviceProfile.getTransportType() != null) {
builder.setTransportType(deviceProfile.getTransportType().name());
builder.setTransportType(getStringValue(deviceProfile.getTransportType().name()));
}
if (deviceProfile.getProvisionType() != null) {
builder.setProvisionType(deviceProfile.getProvisionType().name());
}
if (deviceProfile.getProvisionDeviceKey() != null) {
builder.setProvisionDeviceKey(deviceProfile.getProvisionDeviceKey());
builder.setProvisionType(getStringValue(deviceProfile.getProvisionType().name()));
}
builder.setProvisionDeviceKey(getStringValue(deviceProfile.getProvisionDeviceKey()));
if (deviceProfile.getImage() != null) {
builder.setImage(ByteString.copyFrom(deviceProfile.getImage().getBytes(StandardCharsets.UTF_8)));
builder.setImage(getBytesValue(ByteString.copyFrom(deviceProfile.getImage().getBytes(StandardCharsets.UTF_8))));
}
return builder.build();
}

View File

@ -25,6 +25,9 @@ import org.thingsboard.server.gen.edge.v1.EntityViewUpdateMsg;
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
import org.thingsboard.server.queue.util.TbCoreComponent;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getInt64Value;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class EntityViewMsgConstructor {
@ -51,12 +54,10 @@ public class EntityViewMsgConstructor {
.setEntityIdLSB(entityView.getEntityId().getId().getLeastSignificantBits())
.setEntityType(entityType);
if (customerId != null) {
builder.setCustomerIdMSB(customerId.getId().getMostSignificantBits());
builder.setCustomerIdLSB(customerId.getId().getLeastSignificantBits());
}
if (entityView.getAdditionalInfo() != null) {
builder.setAdditionalInfo(JacksonUtil.toString(entityView.getAdditionalInfo()));
builder.setCustomerIdMSB(getInt64Value(customerId.getId().getMostSignificantBits()));
builder.setCustomerIdLSB(getInt64Value(customerId.getId().getLeastSignificantBits()));
}
builder.setAdditionalInfo(getStringValue(JacksonUtil.toString(entityView.getAdditionalInfo())));
return builder.build();
}

View File

@ -22,6 +22,8 @@ import org.thingsboard.server.gen.edge.v1.RelationUpdateMsg;
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
import org.thingsboard.server.queue.util.TbCoreComponent;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class RelationMsgConstructor {
@ -38,7 +40,7 @@ public class RelationMsgConstructor {
.setType(entityRelation.getType())
.setAdditionalInfo(JacksonUtil.toString(entityRelation.getAdditionalInfo()));
if (entityRelation.getTypeGroup() != null) {
builder.setTypeGroup(entityRelation.getTypeGroup().name());
builder.setTypeGroup(getStringValue(entityRelation.getTypeGroup().name()));
}
return builder.build();
}

View File

@ -37,6 +37,8 @@ import org.thingsboard.server.queue.util.TbCoreComponent;
import java.util.ArrayList;
import java.util.List;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getInt64Value;
@Component
@Slf4j
@TbCoreComponent
@ -54,8 +56,8 @@ public class RuleChainMsgConstructor {
.setDebugMode(ruleChain.isDebugMode())
.setConfiguration(JacksonUtil.toString(ruleChain.getConfiguration()));
if (ruleChain.getFirstRuleNodeId() != null) {
builder.setFirstRuleNodeIdMSB(ruleChain.getFirstRuleNodeId().getId().getMostSignificantBits())
.setFirstRuleNodeIdLSB(ruleChain.getFirstRuleNodeId().getId().getLeastSignificantBits());
builder.setFirstRuleNodeIdMSB(getInt64Value(ruleChain.getFirstRuleNodeId().getId().getMostSignificantBits()))
.setFirstRuleNodeIdLSB(getInt64Value(ruleChain.getFirstRuleNodeId().getId().getLeastSignificantBits()));
}
return builder.build();
}

View File

@ -16,16 +16,19 @@
package org.thingsboard.server.service.edge.rpc.constructor;
import org.springframework.stereotype.Component;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.common.data.security.UserCredentials;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
import org.thingsboard.server.gen.edge.v1.UserCredentialsUpdateMsg;
import org.thingsboard.server.gen.edge.v1.UserUpdateMsg;
import org.thingsboard.server.queue.util.TbCoreComponent;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getInt64Value;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class UserMsgConstructor {
@ -38,21 +41,12 @@ public class UserMsgConstructor {
.setEmail(user.getEmail())
.setAuthority(user.getAuthority().name());
if (customerId != null) {
builder.setCustomerIdMSB(customerId.getId().getMostSignificantBits());
builder.setCustomerIdLSB(customerId.getId().getLeastSignificantBits());
}
if (user.getFirstName() != null) {
builder.setFirstName(user.getFirstName());
}
if (user.getLastName() != null) {
builder.setLastName(user.getLastName());
}
if (user.getAdditionalInfo() != null) {
builder.setAdditionalInfo(JacksonUtil.toString(user.getAdditionalInfo()));
}
if (user.getAdditionalInfo() != null) {
builder.setAdditionalInfo(JacksonUtil.toString(user.getAdditionalInfo()));
builder.setCustomerIdMSB(getInt64Value(customerId.getId().getMostSignificantBits()));
builder.setCustomerIdLSB(getInt64Value(customerId.getId().getLeastSignificantBits()));
}
builder.setFirstName(getStringValue(user.getFirstName()));
builder.setLastName(getStringValue(user.getLastName()));
builder.setAdditionalInfo(getStringValue(JacksonUtil.toString(user.getAdditionalInfo())));
return builder.build();
}

View File

@ -16,14 +16,16 @@
package org.thingsboard.server.service.edge.rpc.constructor;
import org.springframework.stereotype.Component;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.WidgetTypeId;
import org.thingsboard.server.common.data.widget.WidgetType;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
import org.thingsboard.server.gen.edge.v1.WidgetTypeUpdateMsg;
import org.thingsboard.server.queue.util.TbCoreComponent;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class WidgetTypeMsgConstructor {
@ -33,21 +35,13 @@ public class WidgetTypeMsgConstructor {
.setMsgType(msgType)
.setIdMSB(widgetType.getId().getId().getMostSignificantBits())
.setIdLSB(widgetType.getId().getId().getLeastSignificantBits());
if (widgetType.getBundleAlias() != null) {
builder.setBundleAlias(widgetType.getBundleAlias());
}
if (widgetType.getAlias() != null) {
builder.setAlias(widgetType.getAlias());
}
if (widgetType.getName() != null) {
builder.setName(widgetType.getName());
}
if (widgetType.getDescriptor() != null) {
builder.setDescriptorJson(JacksonUtil.toString(widgetType.getDescriptor()));
}
if (widgetType.getTenantId().equals(TenantId.SYS_TENANT_ID)) {
builder.setIsSystem(true);
}
builder.setBundleAlias(getStringValue(widgetType.getBundleAlias()));
builder.setAlias(getStringValue(widgetType.getAlias()));
builder.setName(getStringValue(widgetType.getName()));
builder.setDescriptorJson(getStringValue(JacksonUtil.toString(widgetType.getDescriptor())));
if (widgetType.getTenantId().equals(TenantId.SYS_TENANT_ID)) {
builder.setIsSystem(true);
}
return builder.build();
}

View File

@ -26,6 +26,9 @@ import org.thingsboard.server.queue.util.TbCoreComponent;
import java.nio.charset.StandardCharsets;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getBytesValue;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Component
@TbCoreComponent
public class WidgetsBundleMsgConstructor {
@ -38,10 +41,10 @@ public class WidgetsBundleMsgConstructor {
.setTitle(widgetsBundle.getTitle())
.setAlias(widgetsBundle.getAlias());
if (widgetsBundle.getImage() != null) {
builder.setImage(ByteString.copyFrom(widgetsBundle.getImage().getBytes(StandardCharsets.UTF_8)));
builder.setImage(getBytesValue(ByteString.copyFrom(widgetsBundle.getImage().getBytes(StandardCharsets.UTF_8))));
}
if (widgetsBundle.getDescription() != null) {
builder.setDescription(widgetsBundle.getDescription());
builder.setDescription(getStringValue(widgetsBundle.getDescription()));
}
if (widgetsBundle.getTenantId().equals(TenantId.SYS_TENANT_ID)) {
builder.setIsSystem(true);

View File

@ -162,11 +162,16 @@ public class DeviceEdgeProcessor extends BaseEdgeProcessor {
if (device != null) {
device.setName(deviceUpdateMsg.getName());
device.setType(deviceUpdateMsg.getType());
device.setLabel(deviceUpdateMsg.getLabel());
device.setAdditionalInfo(JacksonUtil.toJsonNode(deviceUpdateMsg.getAdditionalInfo()));
if (deviceUpdateMsg.getDeviceProfileIdMSB() != 0 && deviceUpdateMsg.getDeviceProfileIdLSB() != 0) {
if (deviceUpdateMsg.hasLabel()) {
device.setLabel(deviceUpdateMsg.getLabel().getValue());
}
if (deviceUpdateMsg.hasAdditionalInfo()) {
device.setAdditionalInfo(JacksonUtil.toJsonNode(deviceUpdateMsg.getAdditionalInfo().getValue()));
}
if (deviceUpdateMsg.hasDeviceProfileIdMSB() && deviceUpdateMsg.hasDeviceProfileIdLSB()) {
DeviceProfileId deviceProfileId = new DeviceProfileId(
new UUID(deviceUpdateMsg.getDeviceProfileIdMSB(), deviceUpdateMsg.getDeviceProfileIdLSB()));
new UUID(deviceUpdateMsg.getDeviceProfileIdMSB().getValue(),
deviceUpdateMsg.getDeviceProfileIdLSB().getValue()));
device.setDeviceProfileId(deviceProfileId);
}
deviceService.saveDevice(device);
@ -195,11 +200,16 @@ public class DeviceEdgeProcessor extends BaseEdgeProcessor {
device.setCustomerId(getCustomerId(edge));
device.setName(deviceName);
device.setType(deviceUpdateMsg.getType());
device.setLabel(deviceUpdateMsg.getLabel());
device.setAdditionalInfo(JacksonUtil.toJsonNode(deviceUpdateMsg.getAdditionalInfo()));
if (deviceUpdateMsg.getDeviceProfileIdMSB() != 0 && deviceUpdateMsg.getDeviceProfileIdLSB() != 0) {
if (deviceUpdateMsg.hasLabel()) {
device.setLabel(deviceUpdateMsg.getLabel().getValue());
}
if (deviceUpdateMsg.hasAdditionalInfo()) {
device.setAdditionalInfo(JacksonUtil.toJsonNode(deviceUpdateMsg.getAdditionalInfo().getValue()));
}
if (deviceUpdateMsg.hasDeviceProfileIdMSB() && deviceUpdateMsg.hasDeviceProfileIdLSB()) {
DeviceProfileId deviceProfileId = new DeviceProfileId(
new UUID(deviceUpdateMsg.getDeviceProfileIdMSB(), deviceUpdateMsg.getDeviceProfileIdLSB()));
new UUID(deviceUpdateMsg.getDeviceProfileIdMSB().getValue(),
deviceUpdateMsg.getDeviceProfileIdLSB().getValue()));
device.setDeviceProfileId(deviceProfileId);
}
Device savedDevice = deviceService.saveDevice(device, false);

View File

@ -72,7 +72,9 @@ public class RelationEdgeProcessor extends BaseEdgeProcessor {
entityRelation.setTo(toId);
entityRelation.setType(relationUpdateMsg.getType());
entityRelation.setTypeGroup(RelationTypeGroup.valueOf(relationUpdateMsg.getTypeGroup()));
if (relationUpdateMsg.hasTypeGroup()) {
entityRelation.setTypeGroup(RelationTypeGroup.valueOf(relationUpdateMsg.getTypeGroup().getValue()));
}
entityRelation.setAdditionalInfo(mapper.readTree(relationUpdateMsg.getAdditionalInfo()));
switch (relationUpdateMsg.getMsgType()) {
case ENTITY_CREATED_RPC_MESSAGE:

View File

@ -114,6 +114,7 @@ import org.thingsboard.server.gen.edge.v1.UserUpdateMsg;
import org.thingsboard.server.gen.edge.v1.WidgetTypeUpdateMsg;
import org.thingsboard.server.gen.edge.v1.WidgetsBundleUpdateMsg;
import org.thingsboard.server.gen.transport.TransportProtos;
import org.thingsboard.server.service.edge.rpc.EdgeProtoUtils;
import org.thingsboard.server.service.queue.TbClusterService;
import java.util.ArrayList;
@ -126,6 +127,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.thingsboard.server.service.edge.rpc.EdgeProtoUtils.getStringValue;
@Slf4j
abstract public class BaseEdgeTest extends AbstractControllerTest {
@ -902,7 +904,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
Assert.assertEquals(widgetTypeUpdateMsg.getIdLSB(), savedWidgetType.getUuidId().getLeastSignificantBits());
Assert.assertEquals(widgetTypeUpdateMsg.getAlias(), savedWidgetType.getAlias());
Assert.assertEquals(widgetTypeUpdateMsg.getName(), savedWidgetType.getName());
Assert.assertEquals(JacksonUtil.toJsonNode(widgetTypeUpdateMsg.getDescriptorJson()), savedWidgetType.getDescriptor());
Assert.assertEquals(JacksonUtil.toJsonNode(widgetTypeUpdateMsg.getDescriptorJson().getValue()), savedWidgetType.getDescriptor());
// 3
edgeImitator.expectMessageAmount(1);
@ -1381,7 +1383,7 @@ abstract public class BaseEdgeTest extends AbstractControllerTest {
UplinkMsg.Builder uplinkMsgBuilder = UplinkMsg.newBuilder();
RelationUpdateMsg.Builder relationUpdateMsgBuilder = RelationUpdateMsg.newBuilder();
relationUpdateMsgBuilder.setType("test");
relationUpdateMsgBuilder.setTypeGroup(RelationTypeGroup.COMMON.name());
relationUpdateMsgBuilder.setTypeGroup(getStringValue(RelationTypeGroup.COMMON.name()));
relationUpdateMsgBuilder.setToIdMSB(device1.getId().getId().getMostSignificantBits());
relationUpdateMsgBuilder.setToIdLSB(device1.getId().getId().getLeastSignificantBits());
relationUpdateMsgBuilder.setToEntityType(device1.getId().getEntityType().name());

View File

@ -20,6 +20,7 @@ option java_multiple_files = true;
option java_outer_classname = "EdgeProtos";
import "queue.proto";
import "google/protobuf/wrappers.proto";
package edge;
@ -129,8 +130,8 @@ message RuleChainUpdateMsg {
int64 idMSB = 2;
int64 idLSB = 3;
string name = 4;
int64 firstRuleNodeIdMSB = 5;
int64 firstRuleNodeIdLSB = 6;
google.protobuf.Int64Value firstRuleNodeIdMSB = 5;
google.protobuf.Int64Value firstRuleNodeIdLSB = 6;
bool root = 7;
bool debugMode = 8;
string configuration = 9;
@ -174,8 +175,8 @@ message DashboardUpdateMsg {
UpdateMsgType msgType = 1;
int64 idMSB = 2;
int64 idLSB = 3;
int64 customerIdMSB = 4;
int64 customerIdLSB = 5;
google.protobuf.Int64Value customerIdMSB = 4;
google.protobuf.Int64Value customerIdLSB = 5;
string title = 6;
string configuration = 7;
}
@ -184,15 +185,15 @@ message DeviceUpdateMsg {
UpdateMsgType msgType = 1;
int64 idMSB = 2;
int64 idLSB = 3;
int64 customerIdMSB = 4;
int64 customerIdLSB = 5;
int64 deviceProfileIdMSB = 6;
int64 deviceProfileIdLSB = 7;
google.protobuf.Int64Value customerIdMSB = 4;
google.protobuf.Int64Value customerIdLSB = 5;
google.protobuf.Int64Value deviceProfileIdMSB = 6;
google.protobuf.Int64Value deviceProfileIdLSB = 7;
string name = 8;
string type = 9;
string label = 10;
string additionalInfo = 11;
string conflictName = 12;
google.protobuf.StringValue label = 10;
google.protobuf.StringValue additionalInfo = 11;
google.protobuf.StringValue conflictName = 12;
}
message DeviceProfileUpdateMsg {
@ -200,17 +201,17 @@ message DeviceProfileUpdateMsg {
int64 idMSB = 2;
int64 idLSB = 3;
string name = 4;
string description = 5;
google.protobuf.StringValue description = 5;
bool default = 6;
string type = 7;
string transportType = 8;
string provisionType = 9;
google.protobuf.StringValue transportType = 8;
google.protobuf.StringValue provisionType = 9;
int64 defaultRuleChainIdMSB = 10;
int64 defaultRuleChainIdLSB = 11;
string defaultQueueName = 12;
bytes profileDataBytes = 13;
string provisionDeviceKey = 14;
bytes image = 15;
google.protobuf.StringValue provisionDeviceKey = 14;
google.protobuf.BytesValue image = 15;
}
message DeviceCredentialsUpdateMsg {
@ -225,26 +226,26 @@ message AssetUpdateMsg {
UpdateMsgType msgType = 1;
int64 idMSB = 2;
int64 idLSB = 3;
int64 customerIdMSB = 4;
int64 customerIdLSB = 5;
google.protobuf.Int64Value customerIdMSB = 4;
google.protobuf.Int64Value customerIdLSB = 5;
string name = 6;
string type = 7;
string label = 8;
string additionalInfo = 9;
google.protobuf.StringValue label = 8;
google.protobuf.StringValue additionalInfo = 9;
}
message EntityViewUpdateMsg {
UpdateMsgType msgType = 1;
int64 idMSB = 2;
int64 idLSB = 3;
int64 customerIdMSB = 4;
int64 customerIdLSB = 5;
google.protobuf.Int64Value customerIdMSB = 4;
google.protobuf.Int64Value customerIdLSB = 5;
string name = 6;
string type = 7;
int64 entityIdMSB = 8;
int64 entityIdLSB = 9;
EdgeEntityType entityType = 10;
string additionalInfo = 11;
google.protobuf.StringValue additionalInfo = 11;
}
message AlarmUpdateMsg {
@ -268,15 +269,15 @@ message CustomerUpdateMsg {
int64 idMSB = 2;
int64 idLSB = 3;
string title = 4;
string country = 5;
string state = 6;
string city = 7;
string address = 8;
string address2 = 9;
string zip = 10;
string phone = 11;
string email = 12;
string additionalInfo = 13;
google.protobuf.StringValue country = 5;
google.protobuf.StringValue state = 6;
google.protobuf.StringValue city = 7;
google.protobuf.StringValue address = 8;
google.protobuf.StringValue address2 = 9;
google.protobuf.StringValue zip = 10;
google.protobuf.StringValue phone = 11;
google.protobuf.StringValue email = 12;
google.protobuf.StringValue additionalInfo = 13;
}
message RelationUpdateMsg {
@ -288,7 +289,7 @@ message RelationUpdateMsg {
int64 toIdLSB = 6;
string toEntityType = 7;
string type = 8;
string typeGroup = 9;
google.protobuf.StringValue typeGroup = 9;
string additionalInfo = 10;
}
@ -296,13 +297,13 @@ message UserUpdateMsg {
UpdateMsgType msgType = 1;
int64 idMSB = 2;
int64 idLSB = 3;
int64 customerIdMSB = 4;
int64 customerIdLSB = 5;
google.protobuf.Int64Value customerIdMSB = 4;
google.protobuf.Int64Value customerIdLSB = 5;
string email = 6;
string authority = 7;
string firstName = 8;
string lastName = 9;
string additionalInfo = 10;
google.protobuf.StringValue firstName = 8;
google.protobuf.StringValue lastName = 9;
google.protobuf.StringValue additionalInfo = 10;
}
message WidgetsBundleUpdateMsg {
@ -311,19 +312,19 @@ message WidgetsBundleUpdateMsg {
int64 idLSB = 3;
string title = 4;
string alias = 5;
bytes image = 6;
google.protobuf.BytesValue image = 6;
bool isSystem = 7;
string description = 8;
google.protobuf.StringValue description = 8;
}
message WidgetTypeUpdateMsg {
UpdateMsgType msgType = 1;
int64 idMSB = 2;
int64 idLSB = 3;
string bundleAlias = 4;
string alias = 5;
string name = 6;
string descriptorJson = 7;
google.protobuf.StringValue bundleAlias = 4;
google.protobuf.StringValue alias = 5;
google.protobuf.StringValue name = 6;
google.protobuf.StringValue descriptorJson = 7;
bool isSystem = 8;
}