|
|
@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.kv.StringDataEntry; |
|
|
import org.thingsboard.server.dao.model.ToData; |
|
|
import org.thingsboard.server.dao.model.ToData; |
|
|
|
|
|
|
|
|
import javax.persistence.Column; |
|
|
import javax.persistence.Column; |
|
|
|
|
|
import javax.persistence.EmbeddedId; |
|
|
import javax.persistence.Entity; |
|
|
import javax.persistence.Entity; |
|
|
import javax.persistence.EnumType; |
|
|
import javax.persistence.EnumType; |
|
|
import javax.persistence.Enumerated; |
|
|
import javax.persistence.Enumerated; |
|
|
@ -48,25 +49,10 @@ import static org.thingsboard.server.dao.model.ModelConstants.STRING_VALUE_COLUM |
|
|
@Data |
|
|
@Data |
|
|
@Entity |
|
|
@Entity |
|
|
@Table(name = "attribute_kv") |
|
|
@Table(name = "attribute_kv") |
|
|
@IdClass(AttributeKvCompositeKey.class) |
|
|
|
|
|
public class AttributeKvEntity implements ToData<AttributeKvEntry>, Serializable { |
|
|
public class AttributeKvEntity implements ToData<AttributeKvEntry>, Serializable { |
|
|
|
|
|
|
|
|
@Id |
|
|
@EmbeddedId |
|
|
@Enumerated(EnumType.STRING) |
|
|
private AttributeKvCompositeKey id; |
|
|
@Column(name = ENTITY_TYPE_COLUMN) |
|
|
|
|
|
private EntityType entityType; |
|
|
|
|
|
|
|
|
|
|
|
@Id |
|
|
|
|
|
@Column(name = ENTITY_ID_COLUMN) |
|
|
|
|
|
private String entityId; |
|
|
|
|
|
|
|
|
|
|
|
@Id |
|
|
|
|
|
@Column(name = ATTRIBUTE_TYPE_COLUMN) |
|
|
|
|
|
private String attributeType; |
|
|
|
|
|
|
|
|
|
|
|
@Id |
|
|
|
|
|
@Column(name = ATTRIBUTE_KEY_COLUMN) |
|
|
|
|
|
private String attributeKey; |
|
|
|
|
|
|
|
|
|
|
|
@Column(name = BOOLEAN_VALUE_COLUMN) |
|
|
@Column(name = BOOLEAN_VALUE_COLUMN) |
|
|
private Boolean booleanValue; |
|
|
private Boolean booleanValue; |
|
|
@ -87,13 +73,13 @@ public class AttributeKvEntity implements ToData<AttributeKvEntry>, Serializable |
|
|
public AttributeKvEntry toData() { |
|
|
public AttributeKvEntry toData() { |
|
|
KvEntry kvEntry = null; |
|
|
KvEntry kvEntry = null; |
|
|
if (strValue != null) { |
|
|
if (strValue != null) { |
|
|
kvEntry = new StringDataEntry(attributeKey, strValue); |
|
|
kvEntry = new StringDataEntry(id.getAttributeKey(), strValue); |
|
|
} else if (booleanValue != null) { |
|
|
} else if (booleanValue != null) { |
|
|
kvEntry = new BooleanDataEntry(attributeKey, booleanValue); |
|
|
kvEntry = new BooleanDataEntry(id.getAttributeKey(), booleanValue); |
|
|
} else if (doubleValue != null) { |
|
|
} else if (doubleValue != null) { |
|
|
kvEntry = new DoubleDataEntry(attributeKey, doubleValue); |
|
|
kvEntry = new DoubleDataEntry(id.getAttributeKey(), doubleValue); |
|
|
} else if (longValue != null) { |
|
|
} else if (longValue != null) { |
|
|
kvEntry = new LongDataEntry(attributeKey, longValue); |
|
|
kvEntry = new LongDataEntry(id.getAttributeKey(), longValue); |
|
|
} |
|
|
} |
|
|
return new BaseAttributeKvEntry(kvEntry, lastUpdateTs); |
|
|
return new BaseAttributeKvEntry(kvEntry, lastUpdateTs); |
|
|
} |
|
|
} |
|
|
|