List<String> danglingReferences = new ArrayList<>();
// check term frames
for (Frame f : doc.getTermFrames()) {
for (String tag : f.getTags()) {
OboFormatTag tagconstant = OBOFormatConstants.getTag(tag);
Clause c = f.getClause(tag);
if (tagconstant == OboFormatTag.TAG_INTERSECTION_OF
|| tagconstant == OboFormatTag.TAG_UNION_OF
|| tagconstant == OboFormatTag.TAG_EQUIVALENT_TO
|| tagconstant == OboFormatTag.TAG_DISJOINT_FROM
|| tagconstant == OboFormatTag.TAG_RELATIONSHIP
|| tagconstant == OboFormatTag.TAG_IS_A) {
if (c.getValues().size() > 1) {
String error = checkRelation(c.getValue(String.class),
tag, f.getId(), doc);
if (error != null) {
danglingReferences.add(error);
}
error = checkClassReference(c.getValue2(String.class),
tag, f.getId(), doc);
if (error != null) {
danglingReferences.add(error);
}
} else {
String error = checkClassReference(
c.getValue(String.class), tag, f.getId(), doc);
if (error != null) {
danglingReferences.add(error);
}
}
}
}
}
// check typedef frames
for (Frame f : doc.getTypedefFrames()) {
for (String tag : f.getTags()) {
OboFormatTag tagConstant = OBOFormatConstants.getTag(tag);
Clause c = f.getClause(tag);
assert c != null;
if (tagConstant == OboFormatTag.TAG_IS_A
|| tagConstant == OboFormatTag.TAG_INTERSECTION_OF
|| tagConstant == OboFormatTag.TAG_UNION_OF
|| tagConstant == OboFormatTag.TAG_EQUIVALENT_TO
|| tagConstant == OboFormatTag.TAG_DISJOINT_FROM
|| tagConstant == OboFormatTag.TAG_INVERSE_OF
|| tagConstant == OboFormatTag.TAG_TRANSITIVE_OVER
|| tagConstant == OboFormatTag.TAG_DISJOINT_OVER) {
String error = checkRelation(c.getValue(String.class), tag,
f.getId(), doc);
if (error != null) {
danglingReferences.add(error);
}
} else if (tagConstant == OboFormatTag.TAG_HOLDS_OVER_CHAIN
|| tagConstant == OboFormatTag.TAG_EQUIVALENT_TO_CHAIN
|| tagConstant == OboFormatTag.TAG_RELATIONSHIP) {
String error = checkRelation(c.getValue().toString(), tag,
f.getId(), doc);
if (error != null) {
danglingReferences.add(error);
}
error = checkRelation(c.getValue2().toString(), tag,
f.getId(), doc);
if (error != null) {
danglingReferences.add(error);
}
} else if (tagConstant == OboFormatTag.TAG_DOMAIN
|| tagConstant == OboFormatTag.TAG_RANGE) {
String error = checkClassReference(c.getValue().toString(),
tag, f.getId(), doc);
if (error != null) {
danglingReferences.add(error);
}
}