Browse Source

checkRelation improvements

pull/5959/head
YevhenBondarenko 4 years ago
parent
commit
c40823095e
  1. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/relation/RelationService.java
  2. 2
      dao/src/main/java/org/thingsboard/server/dao/relation/BaseRelationService.java
  3. 2
      dao/src/main/java/org/thingsboard/server/dao/relation/RelationDao.java
  4. 5
      dao/src/main/java/org/thingsboard/server/dao/sql/relation/JpaRelationDao.java

2
common/dao-api/src/main/java/org/thingsboard/server/dao/relation/RelationService.java

@ -37,7 +37,7 @@ public interface RelationService {
ListenableFuture<Boolean> checkRelationAsync(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);
Boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);
boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);
EntityRelation getRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);

2
dao/src/main/java/org/thingsboard/server/dao/relation/BaseRelationService.java

@ -97,7 +97,7 @@ public class BaseRelationService implements RelationService {
}
@Override
public Boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
public boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
log.trace("Executing checkRelation [{}][{}][{}][{}]", from, to, relationType, typeGroup);
validate(from, to, relationType, typeGroup);
return relationDao.checkRelation(tenantId, from, to, relationType, typeGroup);

2
dao/src/main/java/org/thingsboard/server/dao/relation/RelationDao.java

@ -44,7 +44,7 @@ public interface RelationDao {
ListenableFuture<Boolean> checkRelationAsync(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);
Boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);
boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);
EntityRelation getRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup);

5
dao/src/main/java/org/thingsboard/server/dao/sql/relation/JpaRelationDao.java

@ -116,12 +116,11 @@ public class JpaRelationDao extends JpaAbstractDaoListeningExecutorService imple
@Override
public ListenableFuture<Boolean> checkRelationAsync(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
RelationCompositeKey key = getRelationCompositeKey(from, to, relationType, typeGroup);
return service.submit(() -> relationRepository.existsById(key));
return service.submit(() -> checkRelation(tenantId, from, to, relationType, typeGroup));
}
@Override
public Boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
public boolean checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
RelationCompositeKey key = getRelationCompositeKey(from, to, relationType, typeGroup);
return relationRepository.existsById(key);
}

Loading…
Cancel
Save