Fixed entityType mapping
This commit is contained in:
parent
6048b45e39
commit
09858d6515
@ -18,6 +18,7 @@ package org.thingsboard.server.dao.model.sql;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -26,7 +27,7 @@ import java.util.UUID;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class AttributeKvCompositeKey implements Serializable {
|
public class AttributeKvCompositeKey implements Serializable {
|
||||||
private String entityType;
|
private EntityType entityType;
|
||||||
private UUID entityId;
|
private UUID entityId;
|
||||||
private String attributeType;
|
private String attributeType;
|
||||||
private String attributeKey;
|
private String attributeKey;
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
package org.thingsboard.server.dao.sql.attributes;
|
package org.thingsboard.server.dao.sql.attributes;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.dao.annotation.SqlDao;
|
import org.thingsboard.server.dao.annotation.SqlDao;
|
||||||
import org.thingsboard.server.dao.model.sql.AttributeKvCompositeKey;
|
import org.thingsboard.server.dao.model.sql.AttributeKvCompositeKey;
|
||||||
import org.thingsboard.server.dao.model.sql.AttributeKvEntity;
|
import org.thingsboard.server.dao.model.sql.AttributeKvEntity;
|
||||||
@ -26,7 +27,7 @@ import java.util.UUID;
|
|||||||
@SqlDao
|
@SqlDao
|
||||||
public interface AttributeKvRepository extends CrudRepository<AttributeKvEntity, AttributeKvCompositeKey> {
|
public interface AttributeKvRepository extends CrudRepository<AttributeKvEntity, AttributeKvCompositeKey> {
|
||||||
|
|
||||||
List<AttributeKvEntity> findAllByEntityTypeAndEntityIdAndAttributeType(String entityType,
|
List<AttributeKvEntity> findAllByEntityTypeAndEntityIdAndAttributeType(EntityType entityType,
|
||||||
UUID entityId,
|
UUID entityId,
|
||||||
String attributeType);
|
String attributeType);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
|||||||
public ListenableFuture<Optional<AttributeKvEntry>> find(EntityId entityId, String attributeType, String attributeKey) {
|
public ListenableFuture<Optional<AttributeKvEntry>> find(EntityId entityId, String attributeType, String attributeKey) {
|
||||||
AttributeKvCompositeKey compositeKey =
|
AttributeKvCompositeKey compositeKey =
|
||||||
new AttributeKvCompositeKey(
|
new AttributeKvCompositeKey(
|
||||||
entityId.getEntityType().name(),
|
entityId.getEntityType(),
|
||||||
entityId.getId(),
|
entityId.getId(),
|
||||||
attributeType,
|
attributeType,
|
||||||
attributeKey);
|
attributeKey);
|
||||||
@ -61,7 +61,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
|||||||
.stream()
|
.stream()
|
||||||
.map(attributeKey ->
|
.map(attributeKey ->
|
||||||
new AttributeKvCompositeKey(
|
new AttributeKvCompositeKey(
|
||||||
entityId.getEntityType().name(),
|
entityId.getEntityType(),
|
||||||
entityId.getId(),
|
entityId.getId(),
|
||||||
attributeType,
|
attributeType,
|
||||||
attributeKey))
|
attributeKey))
|
||||||
@ -75,7 +75,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
|||||||
return service.submit(() ->
|
return service.submit(() ->
|
||||||
DaoUtil.convertDataList(Lists.newArrayList(
|
DaoUtil.convertDataList(Lists.newArrayList(
|
||||||
attributeKvRepository.findAllByEntityTypeAndEntityIdAndAttributeType(
|
attributeKvRepository.findAllByEntityTypeAndEntityIdAndAttributeType(
|
||||||
entityId.getEntityType().name(),
|
entityId.getEntityType(),
|
||||||
entityId.getId(),
|
entityId.getId(),
|
||||||
attributeType))));
|
attributeType))));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -173,7 +173,7 @@ public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService imp
|
|||||||
return service.submit(() ->
|
return service.submit(() ->
|
||||||
DaoUtil.convertDataList(Lists.newArrayList(
|
DaoUtil.convertDataList(Lists.newArrayList(
|
||||||
tsKvLatestRepository.findAllByEntityTypeAndEntityId(
|
tsKvLatestRepository.findAllByEntityTypeAndEntityId(
|
||||||
entityId.getEntityType().name(),
|
entityId.getEntityType(),
|
||||||
entityId.getId()))));
|
entityId.getId()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
package org.thingsboard.server.dao.sql.timeseries;
|
package org.thingsboard.server.dao.sql.timeseries;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.dao.annotation.SqlDao;
|
import org.thingsboard.server.dao.annotation.SqlDao;
|
||||||
import org.thingsboard.server.dao.model.sql.TsKvLatestCompositeKey;
|
import org.thingsboard.server.dao.model.sql.TsKvLatestCompositeKey;
|
||||||
import org.thingsboard.server.dao.model.sql.TsKvLatestEntity;
|
import org.thingsboard.server.dao.model.sql.TsKvLatestEntity;
|
||||||
@ -26,5 +27,5 @@ import java.util.UUID;
|
|||||||
@SqlDao
|
@SqlDao
|
||||||
public interface TsKvLatestRepository extends CrudRepository<TsKvLatestEntity, TsKvLatestCompositeKey> {
|
public interface TsKvLatestRepository extends CrudRepository<TsKvLatestEntity, TsKvLatestCompositeKey> {
|
||||||
|
|
||||||
List<TsKvLatestEntity> findAllByEntityTypeAndEntityId(String entityType, UUID entityId);
|
List<TsKvLatestEntity> findAllByEntityTypeAndEntityId(EntityType entityType, UUID entityId);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user