use of edu.stanford.bmir.protege.web.shared.search.PerformEntitySearchResult in project webprotege by protegeproject.
the class PerformEntitySearchActionHandler method execute.
@Nonnull
@Override
public PerformEntitySearchResult execute(@Nonnull PerformEntitySearchAction action, @Nonnull ExecutionContext executionContext) {
Set<EntityType<?>> entityTypes = action.getEntityTypes();
String searchString = action.getSearchString();
EntitySearcher entitySearcher = EntitySearcher.get(projectId, tagsManager, executionContext.getUserId(), () -> entityStream(entityTypes, rootOntology, Imports.INCLUDED), renderer, entityTypes, searchString);
PageRequest pageRequest = action.getPageRequest();
int pageSize = pageRequest.getPageSize();
entitySearcher.setLimit(pageSize);
int pageNumber = pageRequest.getPageNumber();
entitySearcher.setSkip((pageNumber - 1) * pageSize);
entitySearcher.invoke();
int totalSearchResults = entitySearcher.getSearchResultsCount();
List<EntitySearchResult> results = entitySearcher.getResults();
int pageCount = (totalSearchResults / pageSize) + 1;
Page<EntitySearchResult> page = new Page<>(pageNumber > pageCount ? 1 : pageNumber, pageCount, results, totalSearchResults);
return new PerformEntitySearchResult(totalSearchResults, page);
}
Aggregations