// we only allow for either right or left identity axiom,
// otherwise it is
// expressed via role-inclusion axioms
Set<OWLSubPropertyChainOfAxiom> chainAxioms = getPropertyChainSubPropertyAxiomsFor(property);
if (chainAxioms.size() == 1) {
OWLSubPropertyChainOfAxiom axiom = chainAxioms
.iterator().next();
if (isLeftIdentityAxiom(axiom, property)) {
leftRightIdentityUsed.add(axiom);
writeSpace();
write(LEFTIDENTITY_ATTR);
write(axiom.getPropertyChain().get(0));
} else if (isRightIdentityAxiom(axiom, property)) {
leftRightIdentityUsed.add(axiom);
writeSpace();
write(RIGHTIDENTITY_ATTR);
write(axiom.getPropertyChain().get(1));
}
}
}
} else {
if (properties.isEmpty()) {
write(DEFINE_PRIMITIVE_ROLE);
write(property);
writeSpace();
} else {
write(DEFINE_ROLE);
write(property);
OWLObjectPropertyExpression expr = properties.iterator()
.next();
write(expr);
properties.remove(expr);
writeSpace();
}
}
if (isTransitive(property, ontology)) {
writeSpace();
write(TRANSITIVE_ATTR);
writeSpace();
write(TRUE);
}
if (isSymmetric(property, ontology)) {
writeSpace();
write(SYMMETRIC_ATTR);
writeSpace();
write(TRUE);
}
if (isReflexive(property, ontology)) {
writeSpace();
write(REFLEXIVE_ATTR);
writeSpace();
write(TRUE);
}
Iterator<OWLObjectPropertyExpression> inverses = inverse(
ontology.getInverseObjectPropertyAxioms(property), property)
.iterator();
if (!inverses.hasNext()) {
writeSpace();
write(INVERSE_ATTR);
write(inverses.next());
}
Collection<OWLClassExpression> desc = domain(ontology
.getObjectPropertyDomainAxioms(property));
if (!desc.isEmpty()) {
writeSpace();
write(DOMAIN_ATTR);
flatten(desc, KRSSVocabulary.AND);
}
desc = range(ontology.getObjectPropertyRangeAxioms(property));
if (!desc.isEmpty()) {
writeSpace();
write(RANGE_ATTR);
flatten(desc, KRSSVocabulary.AND);
}
writeCloseBracket();
writeln();
while (inverses.hasNext()) {
writeOpenBracket();
write(INVERSE);
write(property);
write(inverses.next());
writeOpenBracket();
writeln();
}
for (OWLObjectPropertyExpression expr : properties) {
writeOpenBracket();
write(ROLES_EQUIVALENT);
write(property);
write(expr);
writeCloseBracket();
writeln();
}
}
for (OWLNamedIndividual individual : sort(ontology
.getIndividualsInSignature())) {
if (ignoreDeclarations) {
if (ontology.getAxioms(individual, EXCLUDED).size() == 1
&& ontology.getDeclarationAxioms(individual).size() == 1) {
continue;
}
}
writeOpenBracket();
write(DEFINE_INDIVIDUAL);
write(individual);
writeCloseBracket();
writeln();
}
for (OWLAxiom axiom : ontology.getAxioms()) {
axiom.accept(this);
}
try {
writer.flush();
} catch (IOException io) {
throw new OWLRuntimeException(io);