From 2fe7c30ef0d13f8758cf50fdf7ad3530963871b8 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 3 Oct 2013 11:52:25 -0400 Subject: [PATCH] VIVO-308 Revise SelfEditorRelationshipPolicy to fit the ISF Change the RelationshipChecker classes, and update the unit tests. --- .../RelationshipChecker.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/specialrelationships/RelationshipChecker.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/specialrelationships/RelationshipChecker.java index b06407887..3016aba5d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/specialrelationships/RelationshipChecker.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/specialrelationships/RelationshipChecker.java @@ -32,6 +32,13 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; public class RelationshipChecker { private static final Log log = LogFactory.getLog(RelationshipChecker.class); + protected static final String NS_CORE = "http://vivoweb.org/ontology/core#"; + protected static final String NS_OBO = "http://purl.obolibrary.org/obo/"; + protected static final String URI_RELATES = NS_CORE + "relates"; + protected static final String URI_RELATED_BY = NS_CORE + "relatedBy"; + protected static final String URI_INHERES_IN = NS_OBO + "RO_0000052"; + protected static final String URI_REALIZES = NS_OBO + "BFO_0000055"; + private final OntModel ontModel; public RelationshipChecker(OntModel ontModel) { @@ -147,6 +154,32 @@ public class RelationshipChecker { } } + /** + * Get a list of URIs for object that link to the specified resource, by + * means of the specified properties, through a linking node of the + * specified type. + * + * So we're looking for object URIs that statisfy these statements: + * + * + * + * rdfs:type + * + * + */ + public List getObjectsThroughLinkingNode(String resourceUri, + String property1Uri, String linkNodeTypeUri, String property2Uri) { + List list = new ArrayList(); + + for (String linkNodeUri : getObjectsOfProperty(resourceUri, property1Uri)) { + if (isResourceOfType(linkNodeUri, linkNodeTypeUri)) { + list.addAll(getObjectsOfProperty(linkNodeUri, property2Uri)); + } + } + + return list; + } + public Selector createSelector(String subjectUri, String predicateUri, String objectUri) { Resource subject = (subjectUri == null) ? null : ontModel