Skip to content

Commit

Permalink
fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Apr 9, 2024
1 parent 23658ee commit 9d159ab
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
import org.hibernate.search.engine.search.predicate.SearchPredicate;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;
import org.hibernate.search.engine.search.query.SearchResult;
import org.hibernate.search.engine.search.sort.dsl.SearchSortFactory;
import org.hibernate.search.mapper.orm.Search;
import org.hibernate.search.mapper.orm.session.SearchSession;
import org.sagebionetworks.openchallenges.challenge.service.model.dto.EdamConceptSearchQueryDto;
import org.sagebionetworks.openchallenges.challenge.service.model.entity.EdamConceptEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
Expand All @@ -23,8 +20,6 @@
@Repository
public class CustomEdamConceptRepositoryImpl implements CustomEdamConceptRepository {

private static final Logger LOG = LoggerFactory.getLogger(CustomEdamConceptRepositoryImpl.class);

@PersistenceContext private EntityManager entityManager;

@Override
Expand All @@ -38,7 +33,6 @@ private SearchResult<EdamConceptEntity> getSearchResult(
Pageable pageable, EdamConceptSearchQueryDto query, String[] fields) {
SearchSession searchSession = Search.session(entityManager);
SearchPredicateFactory pf = searchSession.scope(EdamConceptEntity.class).predicate();
SearchSortFactory sf = searchSession.scope(EdamConceptEntity.class).sort();
List<SearchPredicate> predicates = new ArrayList<>();

if (query.getSearchTerms() != null && !query.getSearchTerms().isBlank()) {
Expand All @@ -47,12 +41,10 @@ private SearchResult<EdamConceptEntity> getSearchResult(

SearchPredicate topLevelPredicate = buildTopLevelPredicate(pf, predicates);

SearchResult<EdamConceptEntity> result =
searchSession
.search(EdamConceptEntity.class)
.where(topLevelPredicate)
.fetch((int) pageable.getOffset(), pageable.getPageSize());
return result;
return searchSession
.search(EdamConceptEntity.class)
.where(topLevelPredicate)
.fetch((int) pageable.getOffset(), pageable.getPageSize());
}

/**
Expand Down

0 comments on commit 9d159ab

Please sign in to comment.