|
|
|
@ -15,13 +15,16 @@ |
|
|
|
*/ |
|
|
|
package org.thingsboard.server.service.edge.rpc.constructor; |
|
|
|
|
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.google.gson.JsonArray; |
|
|
|
import com.google.gson.JsonElement; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import com.google.gson.JsonPrimitive; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.thingsboard.server.common.data.DataConstants; |
|
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
|
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
|
|
|
@ -62,7 +65,7 @@ public class EntityDataMsgConstructor { |
|
|
|
JsonObject data = entityData.getAsJsonObject(); |
|
|
|
TransportProtos.PostAttributeMsg attributesUpdatedMsg = JsonConverter.convertToAttributesProto(data.getAsJsonObject("kv")); |
|
|
|
builder.setAttributesUpdatedMsg(attributesUpdatedMsg); |
|
|
|
builder.setPostAttributeScope(data.getAsJsonPrimitive("scope").getAsString()); |
|
|
|
builder.setPostAttributeScope(getScopeOfDefault(data)); |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("[{}] Can't convert to AttributesUpdatedMsg proto, entityData [{}]", entityId, entityData, e); |
|
|
|
} |
|
|
|
@ -72,7 +75,7 @@ public class EntityDataMsgConstructor { |
|
|
|
JsonObject data = entityData.getAsJsonObject(); |
|
|
|
TransportProtos.PostAttributeMsg postAttributesMsg = JsonConverter.convertToAttributesProto(data.getAsJsonObject("kv")); |
|
|
|
builder.setPostAttributesMsg(postAttributesMsg); |
|
|
|
builder.setPostAttributeScope(data.getAsJsonPrimitive("scope").getAsString()); |
|
|
|
builder.setPostAttributeScope(getScopeOfDefault(data)); |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("[{}] Can't convert to PostAttributesMsg, entityData [{}]", entityId, entityData, e); |
|
|
|
} |
|
|
|
@ -94,4 +97,13 @@ public class EntityDataMsgConstructor { |
|
|
|
return builder.build(); |
|
|
|
} |
|
|
|
|
|
|
|
private String getScopeOfDefault(JsonObject data) { |
|
|
|
JsonPrimitive scope = data.getAsJsonPrimitive("scope"); |
|
|
|
String result = DataConstants.SERVER_SCOPE; |
|
|
|
if (scope != null && StringUtils.isNotBlank(scope.getAsString())) { |
|
|
|
result = scope.getAsString(); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|