From 2fe7c30ef0d13f8758cf50fdf7ad3530963871b8 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 3 Oct 2013 11:52:25 -0400 Subject: [PATCH 1/2] 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 From bbae772a6a91f8c918b92348a987e426f27a0244 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 3 Oct 2013 11:53:08 -0400 Subject: [PATCH 2/2] Make startup log messages more compact --- .../mannlib/vitro/webapp/servlet/setup/FileGraphSetup.java | 2 +- .../mannlib/vitro/webapp/servlet/setup/RDFFilesLoader.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/FileGraphSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/FileGraphSetup.java index 5e039e808..257edd9cf 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/FileGraphSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/FileGraphSetup.java @@ -174,7 +174,7 @@ public class FileGraphSetup implements ServletContextListener { if ( !model.isEmpty() ) { baseModel.addSubModel(model); - log.info("Attached file graph as " + type + " submodel " + pathToURI(p, type)); + log.info("Attached file graph as " + type + " submodel " + p.getFileName()); } modelChanged = modelChanged | updateGraphInDB(dataset, model, type, p); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/RDFFilesLoader.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/RDFFilesLoader.java index 50838e472..f01b5b244 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/RDFFilesLoader.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/RDFFilesLoader.java @@ -148,7 +148,7 @@ public class RDFFilesLoader { private static void readOntologyFileIntoModel(Path p, Model model) { String format = getRdfFormat(p); - log.info("Loading file at " + p + " as " + format); + log.info("Loading "+ p); try (InputStream stream = new FileInputStream(p.toFile())) { model.read(stream, null, format); log.debug("...successful");