* @param ax
* the ax
*/
@SuppressWarnings("null")
protected void tr(@Nonnull OWLSubClassOfAxiom ax) {
OWLClassExpression sub = ax.getSubClass();
OWLClassExpression sup = ax.getSuperClass();
Set<QualifierValue> qvs = new HashSet<>();
if (sub.isOWLNothing() || sub.isTopEntity() || sup.isTopEntity()
|| sup.isOWLNothing()) {
error(TOP_BOTTOM_NONTRANSLATEABLE, ax, false);
return;
}
// 5.2.2
if (sub instanceof OWLObjectIntersectionOf) {
Set<OWLClassExpression> xs = ((OWLObjectIntersectionOf) sub)
.getOperands();
// obo-format is limited to very restricted GCIs - the LHS of the
// axiom
// must correspond to ObjectIntersectionOf(cls
// ObjectSomeValuesFrom(p filler))
if (xs.size() == 2) {
OWLClass c = null;
OWLObjectSomeValuesFrom r = null;
OWLObjectProperty p = null;
OWLClass filler = null;
for (OWLClassExpression x : xs) {
if (x instanceof OWLClass) {
c = (OWLClass) x;
}
if (x instanceof OWLObjectSomeValuesFrom) {
r = (OWLObjectSomeValuesFrom) x;
if (r.getProperty() instanceof OWLObjectProperty
&& r.getFiller() instanceof OWLClass) {
p = (OWLObjectProperty) r.getProperty();
filler = (OWLClass) r.getFiller();
}
}
}
if (c != null && p != null && filler != null) {
sub = c;
qvs.add(new QualifierValue("gci_relation", getIdentifier(p)));
qvs.add(new QualifierValue("gci_filler",
getIdentifier(filler)));
}
}
}
if (sub instanceof OWLClass) {
Frame f = getTermFrame((OWLClass) sub);
if (sup instanceof OWLClass) {
Clause c = new Clause(OboFormatTag.TAG_IS_A.getTag());
c.setValue(getIdentifier(sup));
c.setQualifierValues(qvs);
f.addClause(c);
addQualifiers(c, ax.getAnnotations());
} else if (sup instanceof OWLObjectCardinalityRestriction) {
// OWLObjectExactCardinality
// OWLObjectMinCardinality
// OWLObjectMaxCardinality
OWLObjectCardinalityRestriction cardinality = (OWLObjectCardinalityRestriction) sup;
OWLClassExpression filler = cardinality.getFiller();
if (filler.isBottomEntity() || filler.isTopEntity()) {
error(TOP_BOTTOM_NONTRANSLATEABLE, ax, false);
return;
}
String fillerId = getIdentifier(filler);
if (fillerId == null) {
error(ax, true);
return;
}
f.addClause(createRelationshipClauseWithCardinality(
cardinality, fillerId, qvs, ax));
} else if (sup instanceof OWLQuantifiedObjectRestriction) {
// OWLObjectSomeValuesFrom
// OWLObjectAllValuesFrom
OWLQuantifiedObjectRestriction r = (OWLQuantifiedObjectRestriction) sup;
OWLClassExpression filler = r.getFiller();
if (filler.isBottomEntity() || filler.isTopEntity()) {
error(TOP_BOTTOM_NONTRANSLATEABLE, ax, false);
return;
}
String fillerId = getIdentifier(filler);
if (fillerId == null) {
error(ax, true);
return;
}
f.addClause(createRelationshipClauseWithRestrictions(r,
fillerId, qvs, ax));
} else if (sup instanceof OWLObjectIntersectionOf) {
OWLObjectIntersectionOf i = (OWLObjectIntersectionOf) sup;
List<Clause> clauses = new ArrayList<>();
for (OWLClassExpression operand : i.getOperands()) {
if (operand instanceof OWLObjectCardinalityRestriction) {
OWLObjectCardinalityRestriction restriction = (OWLObjectCardinalityRestriction) operand;
OWLClassExpression filler = restriction.getFiller();
if (filler.isBottomEntity() || filler.isTopEntity()) {
error(TOP_BOTTOM_NONTRANSLATEABLE, ax, false);
return;
}
String fillerId = getIdentifier(filler);
if (fillerId == null) {
error(ax, true);
return;
}
clauses.add(createRelationshipClauseWithCardinality(
restriction, fillerId, new HashSet<>(qvs), ax));
} else if (operand instanceof OWLQuantifiedObjectRestriction) {
OWLQuantifiedObjectRestriction restriction = (OWLQuantifiedObjectRestriction) operand;
OWLClassExpression filler = restriction.getFiller();
if (filler.isBottomEntity() || filler.isTopEntity()) {
error(TOP_BOTTOM_NONTRANSLATEABLE, ax, false);
return;
}
String fillerId = getIdentifier(filler);
if (fillerId == null) {