VIVO-112: updates to handle grant roles correctly

This commit is contained in:
tworrall 2013-09-09 13:32:10 -04:00
parent aeac0411d4
commit e3de41dc64
2 changed files with 51 additions and 8 deletions

View file

@ -33,8 +33,15 @@
?activity vitro:mostSpecificType ?subclass
</collated>
}
OPTIONAL { ?role core:relatedBy ?activity
OPTIONAL { ?role core:relates ?activity
LET (?activityName := afn:localname(?activity))
OPTIONAL { ?activity rdfs:label ?activityLabel }
<collated>
?activity vitro:mostSpecificType ?subclass
</collated>
}
OPTIONAL { ?role core:roleContributesTo ?activity
LET (?activityName := afn:localname(?activity))
OPTIONAL { ?activity rdfs:label ?activityLabel }
@ -65,15 +72,31 @@
CONSTRUCT {
?subject ?property ?role .
?role core:relatedBy ?activity .
?role core:relates ?activity .
?activity vitro:mostSpecificType ?subclass .
} WHERE {
?subject ?property ?role .
?role core:relatedBy ?activity .
?role core:relates ?activity .
?activity vitro:mostSpecificType ?subclass
}
</query-construct>
<query-construct>
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
PREFIX vitro: &lt;http://vitro.mannlib.cornell.edu/ns/vitro/0.7#&gt;
CONSTRUCT {
?subject ?property ?role .
?role core:roleContributesTo ?activity .
?activity vitro:mostSpecificType ?subclass .
} WHERE {
?subject ?property ?role .
?role core:roleContributesTo ?activity .
?activity vitro:mostSpecificType ?subclass
}
</query-construct>
<query-construct>
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
@ -105,12 +128,16 @@
?role ?roleProperty ?roleValue
} UNION {
?subject ?property ?role .
?role core:relatedBy ?activity .
?role core:relates ?activity .
?activity rdfs:label ?activityName
} UNION {
?subject ?property ?role .
?role &lt;http://purl.obolibrary.org/obo/BFO_0000054&gt; ?activity .
?activity rdfs:label ?activityName
} UNION {
?subject ?property ?role .
?role core:roleContributesTo ?activity .
?activity rdfs:label ?activityName
}
}
</query-construct>

View file

@ -22,8 +22,10 @@ public class ModelUtils {
private static final String processPropertyURI = "http://purl.obolibrary.org/obo/BFO_0000054";
private static final String processPropertyInverseURI = "http://purl.obolibrary.org/obo/BFO_0000055";
private static final String nonProcessPropertyURI = "http://vivoweb.org/ontology/core#relatedBy";
private static final String nonProcessPropertyInverseURI = "http://purl.obolibrary.org/obo/RO_0000052";
private static final String nonProcessPropertyURI = "http://vivoweb.org/ontology/core#roleContributesTo";
private static final String nonProcessPropertyInverseURI = "http://vivoweb.org/ontology/core#contributingRole";
private static final String grantPropertyURI = "http://vivoweb.org/ontology/core#relates";
private static final String grantPropertyInverseURI = "http://vivoweb.org/ontology/core#relatedBy";
private static Set<String> processClass = new HashSet<String>();
static {
@ -32,6 +34,10 @@ public class ModelUtils {
processClass.add("http://vivoweb.org/ontology/core#EventSeries");
}
private static Set<String> grantClass = new HashSet<String>();
static {
grantClass.add("http://vivoweb.org/ontology/core#Grant");
}
/*
* Given a class URI that represents the type of entity that a Role
* is in (in, in any of its senses) this method returns the URIs of
@ -61,6 +67,7 @@ public class ModelUtils {
ObjectProperty op = new ObjectProperty();
boolean isBFOProcess = false;
boolean isGrantClass = false;
while (iter.hasNext()) {
String superClassURI = iter.next();
@ -69,12 +76,21 @@ public class ModelUtils {
isBFOProcess = true;
break;
}
if (grantClass.contains(superClassURI)) {
isGrantClass = true;
break;
}
}
if (isBFOProcess) {
op.setURI(processPropertyURI);
op.setURIInverse(processPropertyInverseURI);
} else {
}
else if (isGrantClass){
op.setURI(grantPropertyURI);
op.setURIInverse(grantPropertyInverseURI);
}
else {
op.setURI(nonProcessPropertyURI);
op.setURIInverse(nonProcessPropertyInverseURI);
}