Commit e650cb0c243a4046c2031f56cff9d4835a8fb6d7
1 parent
1d56a193
Added reading attributes by attribute_key
Showing
6 changed files
with
18 additions
and
2 deletions
... | ... | @@ -38,10 +38,8 @@ import org.thingsboard.server.common.data.audit.ActionType; |
38 | 38 | import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; |
39 | 39 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
40 | 40 | import org.thingsboard.server.common.data.id.TenantId; |
41 | -import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo; | |
42 | 41 | import org.thingsboard.server.common.data.security.UserCredentials; |
43 | 42 | import org.thingsboard.server.dao.audit.AuditLogService; |
44 | -import org.thingsboard.server.dao.oauth2.OAuth2Service; | |
45 | 43 | import org.thingsboard.server.queue.util.TbCoreComponent; |
46 | 44 | import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository; |
47 | 45 | import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails; | ... | ... |
... | ... | @@ -35,6 +35,8 @@ public interface AttributesService { |
35 | 35 | |
36 | 36 | ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String scope); |
37 | 37 | |
38 | + ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey); | |
39 | + | |
38 | 40 | ListenableFuture<List<Void>> save(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes); |
39 | 41 | |
40 | 42 | ListenableFuture<List<Void>> removeAll(TenantId tenantId, EntityId entityId, String scope, List<String> attributeKeys); | ... | ... |
... | ... | @@ -35,6 +35,8 @@ public interface AttributesDao { |
35 | 35 | |
36 | 36 | ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String attributeType); |
37 | 37 | |
38 | + ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey); | |
39 | + | |
38 | 40 | ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute); |
39 | 41 | |
40 | 42 | ListenableFuture<List<Void>> removeAll(TenantId tenantId, EntityId entityId, String attributeType, List<String> keys); | ... | ... |
... | ... | @@ -60,6 +60,12 @@ public class BaseAttributesService implements AttributesService { |
60 | 60 | } |
61 | 61 | |
62 | 62 | @Override |
63 | + public ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey) { | |
64 | + Validator.validateString(attributeKey, "Incorrect attribute key " + attributeKey); | |
65 | + return attributesDao.findAllByAttributeKey(attributeKey); | |
66 | + } | |
67 | + | |
68 | + @Override | |
63 | 69 | public ListenableFuture<List<Void>> save(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes) { |
64 | 70 | validate(entityId, scope); |
65 | 71 | attributes.forEach(attribute -> validate(attribute)); | ... | ... |
... | ... | @@ -47,5 +47,7 @@ public interface AttributeKvRepository extends CrudRepository<AttributeKvEntity, |
47 | 47 | @Param("entityId") String entityId, |
48 | 48 | @Param("attributeType") String attributeType, |
49 | 49 | @Param("attributeKey") String attributeKey); |
50 | + | |
51 | + List<AttributeKvEntity> findAllByAttributeKey(String attributeKey); | |
50 | 52 | } |
51 | 53 | ... | ... |
... | ... | @@ -120,6 +120,12 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl |
120 | 120 | } |
121 | 121 | |
122 | 122 | @Override |
123 | + public ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey) { | |
124 | + return Futures.immediateFuture( | |
125 | + DaoUtil.convertDataList(attributeKvRepository.findAllByAttributeKey(attributeKey))); | |
126 | + } | |
127 | + | |
128 | + @Override | |
123 | 129 | public ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute) { |
124 | 130 | AttributeKvEntity entity = new AttributeKvEntity(); |
125 | 131 | entity.setId(new AttributeKvCompositeKey(entityId.getEntityType(), fromTimeUUID(entityId.getId()), attributeType, attribute.getKey())); | ... | ... |