public Set<OWLAxiom> write(OWLAnnotationProperty property) { Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); axioms.addAll(writeEntityStart(ANNOTATION_PROPERTY, property)); if (!isFiltered(AxiomType.ANNOTATION_ASSERTION)) { for (OWLOntology ont : getOntologies()) { Set<OWLAnnotation> annos = new TreeSet<OWLAnnotation>(); for (OWLAnnotationAssertionAxiom ax : ont.getAnnotationAssertionAxioms(property.getIRI())) { if (isDisplayed(ax)) { annos.add(ax.getAnnotation()); } } writeSection(ANNOTATIONS, annos, ",", true, ont); } } if (!isFiltered(AxiomType.SUB_ANNOTATION_PROPERTY_OF)) { for (OWLOntology ont : getOntologies()) { Set<OWLAnnotationProperty> props = new TreeSet<OWLAnnotationProperty>(); for (OWLSubAnnotationPropertyOfAxiom ax : ont.getSubAnnotationPropertyOfAxioms(property)) { if (isDisplayed(ax)) { props.add(ax.getSuperProperty()); } } writeSection(SUB_PROPERTY_OF, props, ",", true, ont); } } if (!isFiltered(AxiomType.ANNOTATION_PROPERTY_DOMAIN)) { for (OWLOntology ont : getOntologies()) { Set<IRI> iris = new TreeSet<IRI>(); for (OWLAnnotationPropertyDomainAxiom ax : ont.getAnnotationPropertyDomainAxioms(property)) { if (isDisplayed(ax)) { iris.add(ax.getDomain()); } } writeSection(DOMAIN, iris, ",", true, ont); } } if (!isFiltered(AxiomType.ANNOTATION_PROPERTY_RANGE)) { for (OWLOntology ont : getOntologies()) { Set<IRI> iris = new TreeSet<IRI>(); for (OWLAnnotationPropertyRangeAxiom ax : ont.getAnnotationPropertyRangeAxioms(property)) { if (isDisplayed(ax)) { iris.add(ax.getRange()); } } writeSection(RANGE, iris, ",", true, ont); } } writeEntitySectionEnd(ANNOTATION_PROPERTY.toString()); return axioms; }
public Set<OWLAnnotationAssertionAxiom> writeAnnotations(OWLAnnotationSubject subject) { Set<OWLAnnotationAssertionAxiom> axioms = new HashSet<OWLAnnotationAssertionAxiom>(); if (!isFiltered(AxiomType.ANNOTATION_ASSERTION)) { for (OWLOntology ontology : getOntologies()) { SectionMap sectionMap = new SectionMap(); // Set<OWLAnnotation> annos = new TreeSet<OWLAnnotation>(); for (OWLAnnotationAssertionAxiom ax : ontology.getAnnotationAssertionAxioms(subject)) { if (isDisplayed(ax)) { axioms.add(ax); sectionMap.add(ax.getAnnotation(), ax); } } writeSection(ANNOTATIONS, sectionMap, ",", true, ontology); } } return axioms; }
@Override protected Object getValueKey(Object value) { OWLAnnotation annotation = null; if (value instanceof OWLAnnotationAssertionAxiom) { OWLAnnotationAssertionAxiom axiom = (OWLAnnotationAssertionAxiom) value; if (axiom.getAnnotations().isEmpty()) { return axiom.getAnnotation(); } else { return axiom; } } else if (value instanceof AbstractAnnotationsList.AnnotationsListItem) { annotation = ((AbstractAnnotationsList.AnnotationsListItem) value).getAnnotation(); } else if (value instanceof OWLAnnotation) { annotation = (OWLAnnotation) value; } return annotation; }
@Override public void visit(OWLAnnotationAssertionAxiom axiom) { handleObject(axiom); axiom.getSubject().accept(this); axiom.getAnnotation().accept(this); }