if (!annotationProperties.isEmpty()) {
writeBanner("Annotation properties");
for (OWLAnnotationProperty prop : annotationProperties) {
if(createGraph(prop)) {
beginObject();
render(new RDFResourceNode(prop.getIRI()));
renderAnonRoots();
endObject();
}
}
}
Set<OWLDatatype> datatypes = ontology.getDatatypesInSignature();
// for (OWLDatatype datatype : new ArrayList<OWLDatatype>(datatypes)) {
// if (datatype.isBuiltIn()) {
// datatypes.remove(datatype);
// }
// }
if (!datatypes.isEmpty()) {
writeBanner("Datatypes");
for (OWLDatatype datatype : toSortedSet(datatypes)) {
if (createGraph(datatype)) {
beginObject();
writeDatatypeComment(datatype);
render(new RDFResourceNode(datatype.getIRI()));
renderAnonRoots();
endObject();
}
}
}
Set<OWLObjectProperty> objectProperties = ontology.getObjectPropertiesInSignature();
if (!objectProperties.isEmpty()) {
first = true;
for (OWLObjectProperty prop : toSortedSet(objectProperties)) {
if (createGraph(prop)) {
if (first) {
writeBanner("Object Properties");
first = false;
}
beginObject();
writeObjectPropertyComment(prop);
render(new RDFResourceNode(prop.getIRI()));
renderAnonRoots();
endObject();
}
}
}
Set<OWLDataProperty> dataProperties = ontology.getDataPropertiesInSignature();
if (!dataProperties.isEmpty()) {
first = true;
for (OWLDataProperty prop : toSortedSet(ontology.getDataPropertiesInSignature())) {
if (createGraph(prop)) {
if (first) {
first = false;
writeBanner("Data properties");
}
beginObject();
writeDataPropertyComment(prop);
render(new RDFResourceNode(prop.getIRI()));
renderAnonRoots();
endObject();
}
}
}
Set<OWLClass> clses = ontology.getClassesInSignature();
if (!clses.isEmpty()) {
first = true;
for (OWLClass cls : toSortedSet(clses)) {
if (createGraph(cls)) {
if (first) {
first = false;
writeBanner("Classes");
}
beginObject();
writeClassComment(cls);
render(new RDFResourceNode(cls.getIRI()));
renderAnonRoots();
endObject();
}
}
}
Set<OWLNamedIndividual> individuals = ontology.getIndividualsInSignature();
if (!individuals.isEmpty()) {
first = true;
for (OWLNamedIndividual ind : toSortedSet(ontology.getIndividualsInSignature())) {
if (createGraph(ind)) {
if (first) {
writeBanner("Individuals");
first = false;
}
beginObject();
writeIndividualComments(ind);
render(new RDFResourceNode(ind.getIRI()));
renderAnonRoots();
endObject();
}
}
}
for(OWLAnonymousIndividual anonInd : ontology.getReferencedAnonymousIndividuals()) {
boolean anonRoot = true;
Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
for(OWLAxiom ax : ontology.getReferencingAxioms(anonInd)) {
if (!(ax instanceof OWLDifferentIndividualsAxiom)) {
AxiomSubjectProvider subjectProvider = new AxiomSubjectProvider();
OWLObject obj = subjectProvider.getSubject(ax);
if(!obj.equals(anonInd)) {
anonRoot = false;
break;
}
else {
axioms.add(ax);
}
}
}
if(anonRoot) {
//TODO check this: in some cases it seems to cause a StackOverflow error.
createGraph(axioms);
renderAnonRoots();
}
}
Set<IRI> annotatedIRIs = new HashSet<IRI>();
for (OWLAnnotationAssertionAxiom ax : ontology.getAxioms(AxiomType.ANNOTATION_ASSERTION)) {
OWLAnnotationSubject subject = ax.getSubject();
if (subject instanceof IRI) {
IRI iri = (IRI) subject;
if (!ontology.containsEntityInSignature(iri)) {
annotatedIRIs.add(iri);
}
}
}
if (!annotatedIRIs.isEmpty()) {
writeBanner("Annotations");
for (IRI iri : annotatedIRIs) {
beginObject();
createGraph(ontology.getAnnotationAssertionAxioms(iri));
render(new RDFResourceNode(iri));
renderAnonRoots();
endObject();
}
}
Set<OWLAxiom> generalAxioms = new HashSet<OWLAxiom>();
generalAxioms.addAll(ontology.getGeneralClassAxioms());
generalAxioms.addAll(ontology.getAxioms(AxiomType.DIFFERENT_INDIVIDUALS));
for (OWLDisjointClassesAxiom ax : ontology.getAxioms(AxiomType.DISJOINT_CLASSES)) {
if (ax.getClassExpressions().size() > 2) {
generalAxioms.add(ax);
}
}
for (OWLDisjointObjectPropertiesAxiom ax : ontology.getAxioms(AxiomType.DISJOINT_OBJECT_PROPERTIES)) {
if (ax.getProperties().size() > 2) {
generalAxioms.add(ax);
}
}
for (OWLDisjointDataPropertiesAxiom ax : ontology.getAxioms(AxiomType.DISJOINT_DATA_PROPERTIES)) {
if (ax.getProperties().size() > 2) {
generalAxioms.add(ax);
}
}
for (OWLHasKeyAxiom ax : ontology.getAxioms(AxiomType.HAS_KEY)) {
if (ax.getClassExpression().isAnonymous()) {
generalAxioms.add(ax);
}
}
createGraph(generalAxioms);
Set<RDFResourceNode> rootNodes = graph.getRootAnonymousNodes();
if (!rootNodes.isEmpty()) {
writeBanner("General axioms");
beginObject();
renderAnonRoots();
endObject();
}
Set<SWRLRule> ruleAxioms = ontology.getAxioms(AxiomType.SWRL_RULE);
createGraph(ruleAxioms);
if (!ruleAxioms.isEmpty()) {
writeBanner("Rules");
SWRLVariableExtractor variableExtractor = new SWRLVariableExtractor();
for (SWRLRule rule : ruleAxioms) {
rule.accept(variableExtractor);
}
for (SWRLVariable var : variableExtractor.getVariables()) {
render(new RDFResourceNode(var.getIRI()));
}
renderAnonRoots();
}