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