Search in sources :

Example 6 with OWLEntityData

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());
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) Tag(edu.stanford.bmir.protege.web.shared.tag.Tag) EntitySearchResult(edu.stanford.bmir.protege.web.shared.search.EntitySearchResult)

Example 7 with OWLEntityData

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;
    }
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) SearchMatch(org.eclipse.jdt.core.search.SearchMatch) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) Tag(edu.stanford.bmir.protege.web.shared.tag.Tag) Nullable(javax.annotation.Nullable)

Example 8 with OWLEntityData

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()));
}
Also used : SendMail(edu.stanford.bmir.protege.web.server.mail.SendMail) LoggerFactory(org.slf4j.LoggerFactory) Inject(javax.inject.Inject) RenderingManager(edu.stanford.bmir.protege.web.server.renderer.RenderingManager) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) ProjectDetailsManager(edu.stanford.bmir.protege.web.server.project.ProjectDetailsManager) TemplateObjectsBuilder(edu.stanford.bmir.protege.web.server.templates.TemplateObjectsBuilder) Map(java.util.Map) Nonnull(javax.annotation.Nonnull) FileContents(edu.stanford.bmir.protege.web.server.filemanager.FileContents) UserDetailsManager(edu.stanford.bmir.protege.web.server.user.UserDetailsManager) Logger(org.slf4j.Logger) MessageHeader(edu.stanford.bmir.protege.web.server.mail.MessageHeader) PlaceUrl(edu.stanford.bmir.protege.web.server.app.PlaceUrl) Subject.forUser(edu.stanford.bmir.protege.web.server.access.Subject.forUser) VIEW_PROJECT(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT) Set(java.util.Set) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) ApplicationNameSupplier(edu.stanford.bmir.protege.web.server.app.ApplicationNameSupplier) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Optional(java.util.Optional) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) ProjectResource.forProject(edu.stanford.bmir.protege.web.server.access.ProjectResource.forProject) TemplateEngine(edu.stanford.bmir.protege.web.server.templates.TemplateEngine) Optional(java.util.Optional) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Example 9 with OWLEntityData

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);
}
Also used : ChangeEntityIRIResult(edu.stanford.bmir.protege.web.shared.entity.ChangeEntityIRIResult) OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) OWLEntityRenamer(org.semanticweb.owlapi.util.OWLEntityRenamer) Nonnull(javax.annotation.Nonnull)

Example 10 with OWLEntityData

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());
    });
}
Also used : GetDeprecatedEntitiesAction(edu.stanford.bmir.protege.web.shared.entity.GetDeprecatedEntitiesAction) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Aggregations

OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)18 Nonnull (javax.annotation.Nonnull)5 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)5 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)3 EntitySuggestion (edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion)2 AnnotationPropertyFrame (edu.stanford.bmir.protege.web.shared.frame.AnnotationPropertyFrame)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 Tag (edu.stanford.bmir.protege.web.shared.tag.Tag)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Inject (javax.inject.Inject)2 IRI (org.semanticweb.owlapi.model.IRI)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 EntityLabel (edu.stanford.bmir.protege.web.client.library.entitylabel.EntityLabel)1 PrimitiveDataParserImpl (edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataParserImpl)1 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 ProjectResource.forProject (edu.stanford.bmir.protege.web.server.access.ProjectResource.forProject)1 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)1 ApplicationNameSupplier (edu.stanford.bmir.protege.web.server.app.ApplicationNameSupplier)1