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());
}
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);
}
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);
}
}
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));
}
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++;
}
}
Aggregations