Removed unused changes to AttributeDao
This commit is contained in:
parent
90234bf7a3
commit
d2f45db0a6
@ -36,8 +36,6 @@ public interface AttributesService {
|
|||||||
|
|
||||||
ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String scope);
|
ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String scope);
|
||||||
|
|
||||||
ListenableFuture<List<EntityAttributeKvEntry>> findAllByAttributeKey(String attributeKey);
|
|
||||||
|
|
||||||
ListenableFuture<List<Void>> save(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes);
|
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);
|
ListenableFuture<List<Void>> removeAll(TenantId tenantId, EntityId entityId, String scope, List<String> attributeKeys);
|
||||||
|
|||||||
@ -36,8 +36,6 @@ public interface AttributesDao {
|
|||||||
|
|
||||||
ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String attributeType);
|
ListenableFuture<List<AttributeKvEntry>> findAll(TenantId tenantId, EntityId entityId, String attributeType);
|
||||||
|
|
||||||
ListenableFuture<List<EntityAttributeKvEntry>> findAllByAttributeKey(String attributeKey);
|
|
||||||
|
|
||||||
ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute);
|
ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute);
|
||||||
|
|
||||||
ListenableFuture<List<Void>> removeAll(TenantId tenantId, EntityId entityId, String attributeType, List<String> keys);
|
ListenableFuture<List<Void>> removeAll(TenantId tenantId, EntityId entityId, String attributeType, List<String> keys);
|
||||||
|
|||||||
@ -60,12 +60,6 @@ public class BaseAttributesService implements AttributesService {
|
|||||||
return attributesDao.findAll(tenantId, entityId, scope);
|
return attributesDao.findAll(tenantId, entityId, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ListenableFuture<List<EntityAttributeKvEntry>> findAllByAttributeKey(String attributeKey) {
|
|
||||||
Validator.validateString(attributeKey, "Incorrect attribute key " + attributeKey);
|
|
||||||
return attributesDao.findAllByAttributeKey(attributeKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<List<Void>> save(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes) {
|
public ListenableFuture<List<Void>> save(TenantId tenantId, EntityId entityId, String scope, List<AttributeKvEntry> attributes) {
|
||||||
validate(entityId, scope);
|
validate(entityId, scope);
|
||||||
|
|||||||
@ -16,10 +16,20 @@
|
|||||||
package org.thingsboard.server.dao.model.sql;
|
package org.thingsboard.server.dao.model.sql;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.common.data.kv.*;
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.BooleanDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.DoubleDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.JsonDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.KvEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.LongDataEntry;
|
||||||
|
import org.thingsboard.server.common.data.kv.StringDataEntry;
|
||||||
import org.thingsboard.server.dao.model.ToData;
|
import org.thingsboard.server.dao.model.ToData;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.EmbeddedId;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.BOOLEAN_VALUE_COLUMN;
|
import static org.thingsboard.server.dao.model.ModelConstants.BOOLEAN_VALUE_COLUMN;
|
||||||
@ -32,7 +42,6 @@ import static org.thingsboard.server.dao.model.ModelConstants.STRING_VALUE_COLUM
|
|||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "attribute_kv")
|
@Table(name = "attribute_kv")
|
||||||
// TODO maybe move ToData<AttributeKvEntry> to local field as well (or implement ToData<EntityAttributeKvEntry> differently)
|
|
||||||
public class AttributeKvEntity implements ToData<AttributeKvEntry>, Serializable {
|
public class AttributeKvEntity implements ToData<AttributeKvEntry>, Serializable {
|
||||||
|
|
||||||
@EmbeddedId
|
@EmbeddedId
|
||||||
@ -73,22 +82,4 @@ public class AttributeKvEntity implements ToData<AttributeKvEntry>, Serializable
|
|||||||
|
|
||||||
return new BaseAttributeKvEntry(kvEntry, lastUpdateTs);
|
return new BaseAttributeKvEntry(kvEntry, lastUpdateTs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transient
|
|
||||||
public final ToData<EntityAttributeKvEntry> toEntityAttributeKvEntry = () -> {
|
|
||||||
KvEntry kvEntry = null;
|
|
||||||
if (strValue != null) {
|
|
||||||
kvEntry = new StringDataEntry(id.getAttributeKey(), strValue);
|
|
||||||
} else if (booleanValue != null) {
|
|
||||||
kvEntry = new BooleanDataEntry(id.getAttributeKey(), booleanValue);
|
|
||||||
} else if (doubleValue != null) {
|
|
||||||
kvEntry = new DoubleDataEntry(id.getAttributeKey(), doubleValue);
|
|
||||||
} else if (longValue != null) {
|
|
||||||
kvEntry = new LongDataEntry(id.getAttributeKey(), longValue);
|
|
||||||
} else if (jsonValue != null) {
|
|
||||||
kvEntry = new JsonDataEntry(id.getAttributeKey(), jsonValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BaseEntityAttributeKvEntry(id.getEntityId(), lastUpdateTs, kvEntry);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,10 +36,6 @@ public interface AttributeKvRepository extends CrudRepository<AttributeKvEntity,
|
|||||||
@Param("entityId") UUID entityId,
|
@Param("entityId") UUID entityId,
|
||||||
@Param("attributeType") String attributeType);
|
@Param("attributeType") String attributeType);
|
||||||
|
|
||||||
|
|
||||||
@Query("SELECT a FROM AttributeKvEntity a WHERE a.id.attributeKey = :attributeKey")
|
|
||||||
List<AttributeKvEntity> findAllByAttributeKey(@Param("attributeKey") String attributeKey);
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query("DELETE FROM AttributeKvEntity a WHERE a.id.entityType = :entityType " +
|
@Query("DELETE FROM AttributeKvEntity a WHERE a.id.entityType = :entityType " +
|
||||||
|
|||||||
@ -137,18 +137,6 @@ public class JpaAttributeDao extends JpaAbstractDaoListeningExecutorService impl
|
|||||||
attributeType))));
|
attributeType))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ListenableFuture<List<EntityAttributeKvEntry>> findAllByAttributeKey(String attributeKey) {
|
|
||||||
return Futures.immediateFuture(
|
|
||||||
DaoUtil.convertDataList(
|
|
||||||
attributeKvRepository.findAllByAttributeKey(attributeKey).stream()
|
|
||||||
.map(attributeKvEntity -> attributeKvEntity.toEntityAttributeKvEntry)
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
)
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute) {
|
public ListenableFuture<Void> save(TenantId tenantId, EntityId entityId, String attributeType, AttributeKvEntry attribute) {
|
||||||
AttributeKvEntity entity = new AttributeKvEntity();
|
AttributeKvEntity entity = new AttributeKvEntity();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user