use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData 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.entity.OWLEntityData in project webprotege by protegeproject.
the class EntitySearcher method performMatch.
@Nullable
private SearchMatch performMatch(@Nonnull OWLEntity e) {
OWLEntityData rendering = renderingSupplier.getRendering(e);
MatchType matchType = null;
if (tagsByLabel.containsKey(searchString)) {
for (Tag tag : tagsByEntity.get(e)) {
if (tag.getLabel().equals(searchString)) {
matchType = MatchType.TAG;
break;
}
}
}
if (matchType == null) {
matchType = MatchType.RENDERING;
// All search words must be found
for (String searchWord : searchWords) {
if (!StringUtils.containsIgnoreCase(rendering.getBrowserText(), searchWord)) {
matchType = null;
break;
}
}
}
// If we didn't match the rendering then search the IRI remainder
IRI entityIri = rendering.getEntity().getIRI();
if (matchType == null && entityIri.toString().startsWith(Obo2OWLConstants.DEFAULT_IRI_PREFIX)) {
matchType = MatchType.IRI;
Optional<String> remainder = entityIri.getRemainder();
if (remainder.isPresent()) {
for (String searchWord : searchWords) {
if (!StringUtils.containsIgnoreCase(remainder.get(), searchWord)) {
matchType = null;
break;
}
}
}
}
if (matchType != null) {
return new SearchMatch(searchWords, rendering, matchType);
} else {
return null;
}
}
use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.
the class WatchTriggeredHandlerImpl method handleWatchTriggered.
@Override
public void handleWatchTriggered(@Nonnull Set<UserId> usersToNotify, @Nonnull OWLEntity modifiedEntity, @Nonnull UserId byUser) {
List<String> emailAddresses = usersToNotify.stream().filter(u -> accessManager.hasPermission(forUser(u), forProject(projectId), VIEW_PROJECT)).map(userDetailsManager::getEmail).filter(Optional::isPresent).map(Optional::get).distinct().collect(toList());
OWLEntityData modifiedEntityData = renderingManager.getRendering(modifiedEntity);
Map<String, Object> templateObjects = TemplateObjectsBuilder.builder().withUserId(byUser).withEntity(modifiedEntityData).withProjectDetails(projectDetailsManager.getProjectDetails(projectId)).withApplicationName(applicationNameSupplier.get()).withProjectUrl(placeUrl.getProjectUrl(projectId)).build();
String displayName = projectDetailsManager.getProjectDetails(projectId).getDisplayName();
String emailSubject = String.format("[%s] Changes made to %s in %s by %s", displayName, modifiedEntityData.getBrowserText(), displayName, userDetailsManager.getUserDetails(byUser).map(d -> "by " + d.getDisplayName()).orElse(""));
String emailBody = templateEngine.populateTemplate(watchTemplate.getContents(), templateObjects);
logger.info("{} Watch triggered by {} on {}. Notifying {}", projectId, byUser, modifiedEntity, usersToNotify);
sendMail.sendMail(emailAddresses, emailSubject, emailBody, MessageHeader.inReplyTo(projectId.getId()), MessageHeader.references(projectId.getId()));
}
use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.
the class ChangeEntityIRIActionHandler method execute.
@Nonnull
@Override
public ChangeEntityIRIResult execute(@Nonnull ChangeEntityIRIAction action, @Nonnull ExecutionContext executionContext) {
OWLEntityRenamer renamer = new OWLEntityRenamer(rootOntology.getOWLOntologyManager(), rootOntology.getImportsClosure());
List<OWLOntologyChange> changeList = renamer.changeIRI(action.getEntity(), action.getTheNewIri());
OWLEntityData oldRendering = renderer.getRendering(action.getEntity());
applyChanges.applyChanges(executionContext.getUserId(), new FixedChangeListGenerator<>(changeList, action.getEntity(), String.format("Changed %s IRI from %s to %s", action.getEntity().getEntityType().getPrintName(), action.getEntity().getIRI(), action.getTheNewIri())));
OWLEntity theNewEntity = dataFactory.getOWLEntity(action.getEntity().getEntityType(), action.getTheNewIri());
discussionThreadRepository.replaceEntity(projectId, action.getEntity(), theNewEntity);
OWLEntityData newRendering = renderer.getRendering(theNewEntity);
return new ChangeEntityIRIResult(projectId, oldRendering, newRendering);
}
use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.
the class DeprecatedEntitiesPresenter method refillView.
private void refillView() {
view.setEntities(Collections.emptyList());
int pageNumber = view.getPageNumber();
dispatchServiceManager.execute(new GetDeprecatedEntitiesAction(getProjectId(), PageRequest.requestPageWithSize(pageNumber, PAGE_SIZE), Sets.newHashSet(EntityType.values())), this, result -> {
Page<OWLEntityData> page = result.getDeprecatedEntities();
view.setEntities(page.getPageElements());
view.setPageNumber(page.getPageNumber());
view.setPageCount(page.getPageCount());
});
}
Aggregations