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.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
@ -26,7 +27,7 @@ import java.util.UUID;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AttributeKvCompositeKey implements Serializable {
|
||||
private String entityType;
|
||||
private EntityType entityType;
|
||||
private UUID entityId;
|
||||
private String attributeType;
|
||||
private String attributeKey;
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
package org.thingsboard.server.dao.sql.attributes;
|
||||
|
||||
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.model.sql.AttributeKvCompositeKey;
|
||||
import org.thingsboard.server.dao.model.sql.AttributeKvEntity;
|
||||
@ -26,7 +27,7 @@ import java.util.UUID;
|
||||
@SqlDao
|
||||
public interface AttributeKvRepository extends CrudRepository<AttributeKvEntity, AttributeKvCompositeKey> {
|
||||
|
||||
List<AttributeKvEntity> findAllByEntityTypeAndEntityIdAndAttributeType(String entityType,
|
||||
List<AttributeKvEntity> findAllByEntityTypeAndEntityIdAndAttributeType(EntityType entityType,
|
||||
UUID entityId,
|
||||
String attributeType);
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
||||
public ListenableFuture<Optional<AttributeKvEntry>> find(EntityId entityId, String attributeType, String attributeKey) {
|
||||
AttributeKvCompositeKey compositeKey =
|
||||
new AttributeKvCompositeKey(
|
||||
entityId.getEntityType().name(),
|
||||
entityId.getEntityType(),
|
||||
entityId.getId(),
|
||||
attributeType,
|
||||
attributeKey);
|
||||
@ -61,7 +61,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
||||
.stream()
|
||||
.map(attributeKey ->
|
||||
new AttributeKvCompositeKey(
|
||||
entityId.getEntityType().name(),
|
||||
entityId.getEntityType(),
|
||||
entityId.getId(),
|
||||
attributeType,
|
||||
attributeKey))
|
||||
@ -75,7 +75,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
||||
return service.submit(() ->
|
||||
DaoUtil.convertDataList(Lists.newArrayList(
|
||||
attributeKvRepository.findAllByEntityTypeAndEntityIdAndAttributeType(
|
||||
entityId.getEntityType().name(),
|
||||
entityId.getEntityType(),
|
||||
entityId.getId(),
|
||||
attributeType))));
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService imp
|
||||
return service.submit(() ->
|
||||
DaoUtil.convertDataList(Lists.newArrayList(
|
||||
tsKvLatestRepository.findAllByEntityTypeAndEntityId(
|
||||
entityId.getEntityType().name(),
|
||||
entityId.getEntityType(),
|
||||
entityId.getId()))));
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
package org.thingsboard.server.dao.sql.timeseries;
|
||||
|
||||
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.model.sql.TsKvLatestCompositeKey;
|
||||
import org.thingsboard.server.dao.model.sql.TsKvLatestEntity;
|
||||
@ -26,5 +27,5 @@ import java.util.UUID;
|
||||
@SqlDao
|
||||
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