Commit 09858d651535ac73102d692dc7b46f6e91e6928b

Authored by Volodymyr Babak
1 parent 6048b45e

Fixed entityType mapping

... ... @@ -18,6 +18,7 @@ package org.thingsboard.server.dao.model.sql;
18 18 import lombok.AllArgsConstructor;
19 19 import lombok.Data;
20 20 import lombok.NoArgsConstructor;
  21 +import org.thingsboard.server.common.data.EntityType;
21 22
22 23 import java.io.Serializable;
23 24 import java.util.UUID;
... ... @@ -26,7 +27,7 @@ import java.util.UUID;
26 27 @AllArgsConstructor
27 28 @NoArgsConstructor
28 29 public class AttributeKvCompositeKey implements Serializable {
29   - private String entityType;
  30 + private EntityType entityType;
30 31 private UUID entityId;
31 32 private String attributeType;
32 33 private String attributeKey;
... ...
... ... @@ -16,6 +16,7 @@
16 16 package org.thingsboard.server.dao.sql.attributes;
17 17
18 18 import org.springframework.data.repository.CrudRepository;
  19 +import org.thingsboard.server.common.data.EntityType;
19 20 import org.thingsboard.server.dao.annotation.SqlDao;
20 21 import org.thingsboard.server.dao.model.sql.AttributeKvCompositeKey;
21 22 import org.thingsboard.server.dao.model.sql.AttributeKvEntity;
... ... @@ -26,7 +27,7 @@ import java.util.UUID;
26 27 @SqlDao
27 28 public interface AttributeKvRepository extends CrudRepository<AttributeKvEntity, AttributeKvCompositeKey> {
28 29
29   - List<AttributeKvEntity> findAllByEntityTypeAndEntityIdAndAttributeType(String entityType,
  30 + List<AttributeKvEntity> findAllByEntityTypeAndEntityIdAndAttributeType(EntityType entityType,
30 31 UUID entityId,
31 32 String attributeType);
32 33 }
... ...
... ... @@ -46,7 +46,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
46 46 public ListenableFuture<Optional<AttributeKvEntry>> find(EntityId entityId, String attributeType, String attributeKey) {
47 47 AttributeKvCompositeKey compositeKey =
48 48 new AttributeKvCompositeKey(
49   - entityId.getEntityType().name(),
  49 + entityId.getEntityType(),
50 50 entityId.getId(),
51 51 attributeType,
52 52 attributeKey);
... ... @@ -61,7 +61,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
61 61 .stream()
62 62 .map(attributeKey ->
63 63 new AttributeKvCompositeKey(
64   - entityId.getEntityType().name(),
  64 + entityId.getEntityType(),
65 65 entityId.getId(),
66 66 attributeType,
67 67 attributeKey))
... ... @@ -75,7 +75,7 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
75 75 return service.submit(() ->
76 76 DaoUtil.convertDataList(Lists.newArrayList(
77 77 attributeKvRepository.findAllByEntityTypeAndEntityIdAndAttributeType(
78   - entityId.getEntityType().name(),
  78 + entityId.getEntityType(),
79 79 entityId.getId(),
80 80 attributeType))));
81 81 }
... ...
... ... @@ -173,7 +173,7 @@ public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService imp
173 173 return service.submit(() ->
174 174 DaoUtil.convertDataList(Lists.newArrayList(
175 175 tsKvLatestRepository.findAllByEntityTypeAndEntityId(
176   - entityId.getEntityType().name(),
  176 + entityId.getEntityType(),
177 177 entityId.getId()))));
178 178 }
179 179
... ...
... ... @@ -16,6 +16,7 @@
16 16 package org.thingsboard.server.dao.sql.timeseries;
17 17
18 18 import org.springframework.data.repository.CrudRepository;
  19 +import org.thingsboard.server.common.data.EntityType;
19 20 import org.thingsboard.server.dao.annotation.SqlDao;
20 21 import org.thingsboard.server.dao.model.sql.TsKvLatestCompositeKey;
21 22 import org.thingsboard.server.dao.model.sql.TsKvLatestEntity;
... ... @@ -26,5 +27,5 @@ import java.util.UUID;
26 27 @SqlDao
27 28 public interface TsKvLatestRepository extends CrudRepository<TsKvLatestEntity, TsKvLatestCompositeKey> {
28 29
29   - List<TsKvLatestEntity> findAllByEntityTypeAndEntityId(String entityType, UUID entityId);
  30 + List<TsKvLatestEntity> findAllByEntityTypeAndEntityId(EntityType entityType, UUID entityId);
30 31 }
... ...