use of edu.stanford.bmir.protege.web.shared.search.EntitySearchResult in project webprotege by protegeproject.
the class EntitySearcher method toSearchResult.
private EntitySearchResult toSearchResult(Pattern searchPattern, SearchMatch ren) {
OWLEntityData ed = ren.getEntityData();
String rendering = ed.getBrowserText();
StringBuilder highlighted = new StringBuilder();
highlightSearchResult(searchPattern, rendering, highlighted);
if (ren.getMatchType() == MatchType.IRI) {
// Matched the IRI remainder
highlighted.append("<div class=\"searchedIri\">");
IRI iri = ed.getEntity().getIRI();
highlightSearchResult(searchPattern, iri.toString(), highlighted);
highlighted.append("</div>");
}
if (ren.getMatchType() == MatchType.TAG) {
for (Tag tag : tagsByEntity.get(ed.getEntity())) {
if (searchString.equalsIgnoreCase(tag.getLabel())) {
highlighted.append("<div class='wp-tag wp-tag--inline-tag' style='display: inline-block; color: ").append(tag.getColor().getHex()).append("; background-color:").append(tag.getBackgroundColor().getHex()).append(";'>");
highlighted.append(tag.getLabel());
highlighted.append("</div>");
}
}
}
return new EntitySearchResult(ed, displayName(), highlighted.toString());
}
use of edu.stanford.bmir.protege.web.shared.search.EntitySearchResult 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);
}
use of edu.stanford.bmir.protege.web.shared.search.EntitySearchResult in project webprotege by protegeproject.
the class SearchPresenter method performSearch.
private void performSearch() {
GWT.log("[SearchPresenter] Performing search");
if (view.getSearchString().isEmpty()) {
view.clearSearchMatches();
return;
}
int pageNumber = view.getPageNumber();
dispatchServiceManager.execute(new PerformEntitySearchAction(projectId, view.getSearchString(), entityTypes, PageRequest.requestPage(pageNumber)), view, result -> {
Page<EntitySearchResult> results = result.getResults();
view.setSearchMatches(result.getTotalResultCount(), results.getPageElements());
view.setPageCount(results.getPageCount());
view.setPageNumber(results.getPageNumber());
});
}
Aggregations