Added reading attributes by attribute_key
This commit is contained in:
parent
1d56a1937b
commit
e650cb0c24
@ -38,10 +38,8 @@ import org.thingsboard.server.common.data.audit.ActionType;
|
||||
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
|
||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo;
|
||||
import org.thingsboard.server.common.data.security.UserCredentials;
|
||||
import org.thingsboard.server.dao.audit.AuditLogService;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2Service;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository;
|
||||
import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails;
|
||||
|
||||
@ -35,6 +35,8 @@ public interface AttributesService {
|
||||
|
||||
ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String scope);
|
||||
|
||||
ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey);
|
||||
|
||||
ListenableFuture<List<Void>> save(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes);
|
||||
|
||||
ListenableFuture<List<Void>> removeAll(TenantId tenantId, EntityId entityId, String scope, List<String> attributeKeys);
|
||||
|
||||
@ -35,6 +35,8 @@ public interface AttributesDao {
|
||||
|
||||
ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String attributeType);
|
||||
|
||||
ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey);
|
||||
|
||||
ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute);
|
||||
|
||||
ListenableFuture<List<Void>> removeAll(TenantId tenantId, EntityId entityId, String attributeType, List<String> keys);
|
||||
|
||||
@ -59,6 +59,12 @@ public class BaseAttributesService implements AttributesService {
|
||||
return attributesDao.findAll(tenantId, entityId, scope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey) {
|
||||
Validator.validateString(attributeKey, "Incorrect attribute key " + attributeKey);
|
||||
return attributesDao.findAllByAttributeKey(attributeKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<Void>> save(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes) {
|
||||
validate(entityId, scope);
|
||||
|
||||
@ -47,5 +47,7 @@ public interface AttributeKvRepository extends CrudRepository<AttributeKvEntity,
|
||||
@Param("entityId") String entityId,
|
||||
@Param("attributeType") String attributeType,
|
||||
@Param("attributeKey") String attributeKey);
|
||||
|
||||
List<AttributeKvEntity> findAllByAttributeKey(String attributeKey);
|
||||
}
|
||||
|
||||
|
||||
@ -119,6 +119,12 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
||||
attributeType))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<AttributeKvEntry>> findAllByAttributeKey(String attributeKey) {
|
||||
return Futures.immediateFuture(
|
||||
DaoUtil.convertDataList(attributeKvRepository.findAllByAttributeKey(attributeKey)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute) {
|
||||
AttributeKvEntity entity = new AttributeKvEntity();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user