Search in sources :

Example 1 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class ChangeDetailsViewImpl method setSubjects.

@Override
public void setSubjects(Collection<OWLEntityData> subjects) {
    StringBuilder sb = new StringBuilder();
    for (OWLEntityData entityData : subjects) {
        sb.append("<span style=\"padding-left: 5px;\">");
        sb.append(entityData.getBrowserText());
        sb.append(",");
        sb.append("</span>");
    }
    subjectsField.setHTML(sb.toString().trim());
}
Also used : OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Example 2 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class AnnotationPropertyFrameTranslator method getFrame.

@Override
public AnnotationPropertyFrame getFrame(OWLAnnotationPropertyData subject) {
    Set<PropertyAnnotationValue> propertyValues = new HashSet<>();
    Set<OWLEntityData> domains = new HashSet<>();
    Set<OWLEntityData> ranges = new HashSet<>();
    for (OWLOntology ont : rootOntology.getImportsClosure()) {
        for (OWLAnnotationAssertionAxiom ax : ont.getAnnotationAssertionAxioms(subject.getEntity().getIRI())) {
            if (!(ax.getValue() instanceof OWLAnonymousIndividual)) {
                propertyValues.add(new PropertyAnnotationValue(renderingManager.getRendering(ax.getProperty()), renderingManager.getRendering(ax.getValue()), State.ASSERTED));
            }
        }
        for (OWLAnnotationPropertyDomainAxiom ax : ont.getAnnotationPropertyDomainAxioms(subject.getEntity())) {
            rootOntology.getEntitiesInSignature(ax.getDomain(), Imports.INCLUDED).stream().map(renderingManager::getRendering).forEach(domains::add);
        }
        for (OWLAnnotationPropertyRangeAxiom ax : ont.getAnnotationPropertyRangeAxioms(subject.getEntity())) {
            rootOntology.getEntitiesInSignature(ax.getRange(), Imports.INCLUDED).stream().map(renderingManager::getRendering).forEach(ranges::add);
        }
    }
    return new AnnotationPropertyFrame(renderingManager.getRendering(subject.getEntity()), propertyValues, domains, ranges);
}
Also used : OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) PropertyAnnotationValue(edu.stanford.bmir.protege.web.shared.frame.PropertyAnnotationValue) AnnotationPropertyFrame(edu.stanford.bmir.protege.web.shared.frame.AnnotationPropertyFrame) HashSet(java.util.HashSet)

Example 3 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class HighLevelEventGenerator method translateOntologyChanges.

@Override
public void translateOntologyChanges(Revision revision, ChangeApplicationResult<?> changes, final List<ProjectEvent<?>> projectEventList) {
    // TODO: NEED TIDYING AND SPLITTING UP
    final Set<OWLEntity> changedEntities = new HashSet<>();
    for (OWLOntologyChange change : changes.getChangeList()) {
        change.accept(new OWLOntologyChangeVisitor() {

            @Override
            public void visit(@Nonnull AddAxiom change) {
                final OWLAxiom axiom = change.getAxiom();
                handleAxiomChange(axiom);
            }

            @Override
            public void visit(@Nonnull RemoveAxiom change) {
                handleAxiomChange(change.getAxiom());
            }

            @Override
            public void visit(@Nonnull SetOntologyID change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull AddImport change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull RemoveImport change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull AddOntologyAnnotation change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            @Override
            public void visit(@Nonnull RemoveOntologyAnnotation change) {
                projectEventList.add(new OntologyFrameChangedEvent(change.getOntology().getOntologyID(), projectId));
            }

            private void handleAxiomChange(OWLAxiom axiom) {
                AxiomSubjectProvider p = new AxiomSubjectProvider();
                OWLObject subject = p.getSubject(axiom);
                Set<OWLEntity> entities;
                if (subject instanceof IRI) {
                    entities = hasGetEntitiesWithIRI.getEntitiesWithIRI((IRI) subject);
                } else if (subject instanceof OWLEntity) {
                    entities = Collections.singleton((OWLEntity) subject);
                } else {
                    entities = Collections.emptySet();
                }
                for (OWLEntity e : entities) {
                    if (!changedEntities.contains(e)) {
                        changedEntities.add(e);
                        ProjectEvent<?> event = e.accept(new OWLEntityVisitorEx<ProjectEvent<?>>() {

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLClass cls) {
                                return new ClassFrameChangedEvent(cls, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLObjectProperty property) {
                                return new ObjectPropertyFrameChangedEvent(property, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLDataProperty property) {
                                return new DataPropertyFrameChangedEvent(property, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLNamedIndividual individual) {
                                return new NamedIndividualFrameChangedEvent(individual, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLDatatype datatype) {
                                return new DatatypeFrameChangedEvent(datatype, projectId, revision.getUserId());
                            }

                            @Nonnull
                            @Override
                            public ProjectEvent<?> visit(@Nonnull OWLAnnotationProperty property) {
                                return new AnnotationPropertyFrameChangedEvent(property, projectId, revision.getUserId());
                            }
                        });
                        projectEventList.add(event);
                    }
                }
            }
        });
    }
    Set<OWLEntityData> changedEntitiesData = new HashSet<>();
    Object subject = changes.getSubject();
    if (subject instanceof OWLEntity) {
        OWLEntity entity = (OWLEntity) subject;
        if (rootOntology.containsEntityInSignature(entity)) {
            String browserText = browserTextProvider.getOWLEntityBrowserText(entity).orElse("");
            changedEntitiesData.add(DataFactory.getOWLEntityData(entity, browserText));
        }
    } else if (subject instanceof OWLEntityData) {
        OWLEntityData entityData = (OWLEntityData) subject;
        if (rootOntology.containsEntityInSignature(entityData.getEntity())) {
            changedEntitiesData.add(entityData);
        }
    } else if (subject instanceof Collection) {
        Collection<?> collection = (Collection<?>) subject;
        collection.stream().filter(element -> element instanceof OWLEntity).map(element -> (OWLEntity) element).filter(rootOntology::containsEntityInSignature).forEach(entity -> {
            String browserText = browserTextProvider.getOWLEntityBrowserText(entity).orElse("");
            changedEntitiesData.add(DataFactory.getOWLEntityData(entity, browserText));
        });
    }
    Optional<RevisionSummary> revisionSummary = hasGetRevisionSummary.getRevisionSummary(revision.getRevisionNumber());
    if (revisionSummary.isPresent()) {
        ProjectEvent<?> event = new ProjectChangedEvent(projectId, revisionSummary.get(), changedEntitiesData);
        projectEventList.add(event);
    }
}
Also used : BrowserTextProvider(edu.stanford.bmir.protege.web.shared.BrowserTextProvider) Revision(edu.stanford.bmir.protege.web.server.revision.Revision) java.util(java.util) org.semanticweb.owlapi.model(org.semanticweb.owlapi.model) HasGetRevisionSummary(edu.stanford.bmir.protege.web.server.change.HasGetRevisionSummary) AxiomSubjectProvider(org.semanticweb.owlapi.util.AxiomSubjectProvider) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) DataFactory(edu.stanford.bmir.protege.web.shared.DataFactory) HasGetEntitiesWithIRI(edu.stanford.bmir.protege.web.shared.HasGetEntitiesWithIRI) Inject(javax.inject.Inject) edu.stanford.bmir.protege.web.shared.event(edu.stanford.bmir.protege.web.shared.event) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Nonnull(javax.annotation.Nonnull) ChangeApplicationResult(edu.stanford.bmir.protege.web.server.change.ChangeApplicationResult) RevisionSummary(edu.stanford.bmir.protege.web.shared.revision.RevisionSummary) HasGetEntitiesWithIRI(edu.stanford.bmir.protege.web.shared.HasGetEntitiesWithIRI) Nonnull(javax.annotation.Nonnull) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) AxiomSubjectProvider(org.semanticweb.owlapi.util.AxiomSubjectProvider) HasGetRevisionSummary(edu.stanford.bmir.protege.web.server.change.HasGetRevisionSummary) RevisionSummary(edu.stanford.bmir.protege.web.shared.revision.RevisionSummary)

Example 4 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class AnnotationPropertyFrameEditor method getValue.

@Override
public Optional<LabelledFrame<AnnotationPropertyFrame>> getValue() {
    if (!lastFrame.isPresent()) {
        return Optional.empty();
    }
    final Set<OWLEntityData> domainsClasses = Sets.newHashSet();
    for (OWLPrimitiveData data : domains.getValue().get()) {
        domainsClasses.add((OWLClassData) data);
    }
    final Set<OWLEntityData> rangeTypes = Sets.newHashSet();
    for (OWLPrimitiveData data : ranges.getValue().get()) {
        rangeTypes.add((OWLEntityData) data);
    }
    AnnotationPropertyFrame frame = new AnnotationPropertyFrame(lastFrame.get().getFrame().getSubject(), annotations.getValue().get().getAnnotationPropertyValues(), domainsClasses, rangeTypes);
    return Optional.of(new LabelledFrame<>(lastFrame.get().getDisplayName(), frame));
}
Also used : OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData) AnnotationPropertyFrame(edu.stanford.bmir.protege.web.shared.frame.AnnotationPropertyFrame)

Example 5 with OWLEntityData

use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.

the class ProjectChangeEventView method setChangedEntities.

public void setChangedEntities(final Set<OWLEntityData> entities) {
    changedEntitiesTable.removeAllRows();
    int row = 0;
    for (OWLEntityData entityData : entities) {
        final EntityLabel changedEntityLabel = new EntityLabel();
        changedEntityLabel.setEntity(entityData);
        changedEntityLabel.setSelectionModel(selectionModel);
        changedEntitiesTable.setWidget(row, 0, changedEntityLabel);
        row++;
    }
}
Also used : OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) EntityLabel(edu.stanford.bmir.protege.web.client.library.entitylabel.EntityLabel)

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