use of org.semanticweb.owlapi.model.OWLClassExpression in project stanbol by apache.
the class RegistryUtils method getType.
@Deprecated
public static Type getType(final OWLIndividual ind, Set<OWLOntology> ontologies) {
// 0 is for library, 1 is for ontology (more in the future?)
final int[] pointsFor = new int[] { 0, 0 };
final int[] pointsAgainst = new int[] { 0, 0 };
OWLAxiomVisitor v = new OWLAxiomVisitorAdapter() {
@Override
public void visit(OWLClassAssertionAxiom axiom) {
if (ind.equals(axiom.getIndividual())) {
OWLClassExpression type = axiom.getClassExpression();
if (cRegistryLibrary.equals(type)) {
pointsFor[0]++;
pointsAgainst[1]++;
} else if (cOntology.equals(type)) {
pointsFor[1]++;
pointsAgainst[0]++;
}
}
}
@Override
public void visit(OWLObjectPropertyAssertionAxiom axiom) {
OWLObjectPropertyExpression prop = axiom.getProperty();
if (ind.equals(axiom.getSubject())) {
if (hasOntology.equals(prop)) {
pointsFor[0]++;
pointsAgainst[1]++;
} else if (isOntologyOf.equals(prop)) {
pointsFor[1]++;
pointsAgainst[0]++;
}
} else if (ind.equals(axiom.getObject())) {
if (isOntologyOf.equals(prop)) {
pointsFor[0]++;
pointsAgainst[1]++;
} else if (hasOntology.equals(prop)) {
pointsFor[1]++;
pointsAgainst[0]++;
}
}
}
};
// TODO use this strategy in the single pass algorithm for constructing the model.
for (OWLOntology o : ontologies) for (OWLAxiom ax : o.getAxioms()) ax.accept(v);
if (pointsFor[0] > 0 && pointsAgainst[0] == 0)
return Type.LIBRARY;
if (pointsFor[1] > 0 && pointsAgainst[1] == 0)
return Type.ONTOLOGY;
// Cannot determine registries, since they have no associated individual.
return null;
}
Aggregations