fix for NIHVIVO-2659 (object of most specific type annotation should be a resource)

This commit is contained in:
stellamit 2011-05-31 19:53:58 +00:00
parent 1613ecdfd0
commit a7a576340f
2 changed files with 30 additions and 32 deletions

View file

@ -12,7 +12,6 @@ import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.ontology.AnnotationProperty;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
@ -54,7 +53,7 @@ public class SimpleReasoner extends StatementListener {
private static final String bottomObjectPropertyURI = "http://www.w3.org/2002/07/owl#bottomObjectProperty";
private static final String topDataPropertyURI = "http://www.w3.org/2002/07/owl#topDataProperty";
private static final String bottomDataPropertyURI = "http://www.w3.org/2002/07/owl#bottomDataProperty";
private static final String mostSpecificTypePropertyURI = "http://vivoweb.org/ontology/core#mostSpecificType";
private static final String mostSpecificTypePropertyURI = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType";
private AnnotationProperty mostSpecificType = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createAnnotationProperty(mostSpecificTypePropertyURI);
@ -773,13 +772,13 @@ public class SimpleReasoner extends StatementListener {
while (iter.hasNext()) {
Statement stmt = iter.next();
if ( !stmt.getObject().isLiteral() ) {
log.warn("The object of this assertion is expected to be a literal: " + stmtString(stmt));
if ( !stmt.getObject().isResource() ) {
log.warn("The object of this assertion is expected to be a resource: " + stmtString(stmt));
continue;
}
if (!typeURIs.contains(stmt.getObject().asLiteral().getLexicalForm())) {
if (!typeURIs.contains(stmt.getObject().asResource().getURI())) {
retractions.add(stmt);
}
}
@ -791,11 +790,10 @@ public class SimpleReasoner extends StatementListener {
while (typeIter.hasNext()) {
String typeURI = typeIter.next();
Literal uriLiteral = ResourceFactory.createTypedLiteral(typeURI, XSDDatatype.XSDanyURI);
Resource mstResource = ResourceFactory.createResource(typeURI);
if (!aboxModel.contains(individual, mostSpecificType, uriLiteral)) {
Statement toAdd = ResourceFactory.createStatement(individual, mostSpecificType, uriLiteral);
aboxModel.add(individual, mostSpecificType, uriLiteral);
if (!aboxModel.contains(individual, mostSpecificType, mstResource)) {
aboxModel.add(individual, mostSpecificType, mstResource);
}
}
} finally {