Search in sources :

Example 1 with RelationEntity

use of org.thingsboard.server.dao.model.sql.RelationEntity in project thingsboard by thingsboard.

the class JpaRelationDao method findRelations.

@Override
public ListenableFuture<List<EntityRelation>> findRelations(EntityId from, String relationType, RelationTypeGroup typeGroup, EntityType childType, TimePageLink pageLink) {
    Specification<RelationEntity> timeSearchSpec = JpaAbstractSearchTimeDao.getTimeSearchPageSpec(pageLink, "toId");
    Specification<RelationEntity> fieldsSpec = getEntityFieldsSpec(from, relationType, typeGroup, childType);
    Sort.Direction sortDirection = pageLink.isAscOrder() ? Sort.Direction.ASC : Sort.Direction.DESC;
    Pageable pageable = new PageRequest(0, pageLink.getLimit(), sortDirection, "toId");
    return service.submit(() -> DaoUtil.convertDataList(relationRepository.findAll(where(timeSearchSpec).and(fieldsSpec), pageable).getContent()));
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) RelationEntity(org.thingsboard.server.dao.model.sql.RelationEntity)

Aggregations

PageRequest (org.springframework.data.domain.PageRequest)1 Pageable (org.springframework.data.domain.Pageable)1 Sort (org.springframework.data.domain.Sort)1 RelationEntity (org.thingsboard.server.dao.model.sql.RelationEntity)1