VIVO-692 Restrict LOD by Publish level, not by Display level

Create a new annotation for properties and classes, HiddenFromPublishBelowRoleLevelAnnot.
Provide the means to initialize these annotations, edit them, and display them in the verbose property display.
Create a Permission and some requested actions so the policies can decide which statements must be filtered out, based on the user's role.
Add unit tests and improve acceptance tests
This commit is contained in:
j2blake 2014-03-10 17:42:05 -04:00
parent 95538e4c8a
commit fdeee35bb4
55 changed files with 1977 additions and 251 deletions

View file

@ -47,6 +47,13 @@ import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ProxyRelationshipSelectorTest;
/**
* A collection of useful routines to help when testing.
* <ul>
@ -404,8 +411,22 @@ public abstract class AbstractTestClass {
assertEquals(message, expected, actual);
}
@SuppressWarnings("unchecked")
protected <T> Set<T> buildSet(T... array) {
return new HashSet<T>(Arrays.asList(array));
}
protected OntModel readModelFromFile(String relativePath, String rdfType) throws IOException {
InputStream stream = this.getClass()
.getResourceAsStream(relativePath);
Model model = ModelFactory.createDefaultModel();
model.read(stream, null, rdfType);
stream.close();
OntModel ontModel = ModelFactory.createOntologyModel(
OntModelSpec.OWL_DL_MEM, model);
ontModel.prepare();
return ontModel;
}
}

View file

@ -35,7 +35,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
/**
* Check that the bean gets built properly, and check that the bean works properly.
* Check that the bean gets built properly, and check that the bean works
* properly.
*/
public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
private static final Log log = LogFactory
@ -43,12 +44,12 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
private static final String PROPERTY_DISPLAY_THRESHOLD = VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT;
private static final String PROPERTY_MODIFY_THRESHOLD = VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT;
private static final String PROPERTY_PUBLISH_THRESHOLD = VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT;
private static final String[] PROHIBITED_NAMESPACES = new String[] {
VitroVocabulary.vitroURI, "" };
private static final String[] PERMITTED_EXCEPTIONS = new String[] {
VitroVocabulary.MONIKER };
private static final String[] PERMITTED_EXCEPTIONS = new String[] { VitroVocabulary.MONIKER };
private OntModel ontModel;
private ModelWrapper wrapper;
@ -56,33 +57,35 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
@Before
public void setLoggingLevel() {
// setLoggerLevel(PropertyRestrictionPolicyHelper.class, Level.DEBUG);
// setLoggerLevel(PropertyRestrictionPolicyHelper.class, Level.DEBUG);
}
private void mapPut(String predicateURI, RoleLevel roleLevel,
Map<Pair<String, Pair<String,String>>, RoleLevel> map) {
map.put(new Pair<String, Pair<String,String>>(
OWL.Thing.getURI(), new Pair<String, String>(
predicateURI, OWL.Thing.getURI())), roleLevel);
private void mapPut(String predicateURI, RoleLevel roleLevel,
Map<Pair<String, Pair<String, String>>, RoleLevel> map) {
map.put(new Pair<String, Pair<String, String>>(OWL.Thing.getURI(),
new Pair<String, String>(predicateURI, OWL.Thing.getURI())),
roleLevel);
}
@Before
public void createTheBean() {
Map<Pair<String, Pair<String,String>>, RoleLevel> displayLevels =
new HashMap<Pair<String, Pair<String,String>>, RoleLevel>();
Map<Pair<String, Pair<String, String>>, RoleLevel> displayLevels = new HashMap<>();
mapPut("http://predicates#display_curator", CURATOR, displayLevels);
mapPut("http://predicates#display_hidden", NOBODY, displayLevels);
Map<Pair<String, Pair<String,String>>, RoleLevel> modifyLevels =
new HashMap<Pair<String, Pair<String,String>>, RoleLevel>();
Map<Pair<String, Pair<String, String>>, RoleLevel> modifyLevels = new HashMap<>();
mapPut("http://predicates#modify_self", SELF, modifyLevels);
mapPut("http://predicates#modify_curator", CURATOR, modifyLevels);
mapPut("http://predicates#modify_hidden", NOBODY, modifyLevels);
Map<Pair<String, Pair<String, String>>, RoleLevel> publishLevels = new HashMap<>();
mapPut("http://predicates#publish_curator", CURATOR, publishLevels);
mapPut("http://predicates#publish_hidden", NOBODY, publishLevels);
bean = new PropertyRestrictionPolicyHelper(
Arrays.asList(PROHIBITED_NAMESPACES),
Arrays.asList(PERMITTED_EXCEPTIONS), displayLevels,
modifyLevels, ModelFactory.createDefaultModel());
modifyLevels, publishLevels);
}
@Before
@ -100,6 +103,11 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
PROPERTY_MODIFY_THRESHOLD, EDITOR.getURI());
wrapper.add("http://thresholds#modify_curator",
PROPERTY_MODIFY_THRESHOLD, CURATOR.getURI());
wrapper.add("http://thresholds#publish_public",
PROPERTY_PUBLISH_THRESHOLD, PUBLIC.getURI());
wrapper.add("http://thresholds#publish_hidden",
PROPERTY_PUBLISH_THRESHOLD, NOBODY.getURI());
}
// ----------------------------------------------------------------------
@ -125,6 +133,12 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
null));
}
@Test
public void publishResource() {
assertEquals("publish a random resource", true,
bean.canPublishResource("http://someRandom#string", null));
}
@Test
public void modifyResourcePermittedException() {
assertEquals("modify a exception resource", true,
@ -133,76 +147,119 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
@Test
public void displayPredicateNoRestriction() {
assertEquals("displayPredicate: open", true,
bean.canDisplayPredicate(createVitroProperty(
"http://predicates#open"), PUBLIC));
assertEquals("displayPredicate: open", true, bean.canDisplayPredicate(
createVitroProperty("http://predicates#open"), PUBLIC));
}
@Test
public void displayPredicateRestrictionLower() {
assertEquals("displayPredicate: lower restriction", true,
bean.canDisplayPredicate(createVitroProperty(
"http://predicates#display_self"), CURATOR));
bean.canDisplayPredicate(
createVitroProperty("http://predicates#display_self"),
CURATOR));
}
@Test
public void displayPredicateRestrictionEqual() {
assertEquals("displayPredicate: equal restriction", true,
bean.canDisplayPredicate(createVitroProperty(
"http://predicates#display_curator"), CURATOR));
assertEquals(
"displayPredicate: equal restriction",
true,
bean.canDisplayPredicate(
createVitroProperty("http://predicates#display_curator"),
CURATOR));
}
@Test
public void displayPredicateRestrictionHigher() {
assertEquals("displayPredicate: higher restriction", false,
bean.canDisplayPredicate(createVitroProperty(
"http://predicates#display_hidden"), CURATOR));
assertEquals(
"displayPredicate: higher restriction",
false,
bean.canDisplayPredicate(
createVitroProperty("http://predicates#display_hidden"),
CURATOR));
}
@Test
public void modifyPredicateNoRestriction() {
assertEquals("modifyPredicate: open", true,
bean.canModifyPredicate(new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#open"), PUBLIC));
assertEquals("modifyPredicate: open", true, bean.canModifyPredicate(
new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#open"), PUBLIC));
}
@Test
public void modifyPredicateRestrictionLower() {
assertEquals("modifyPredicate: lower restriction", true,
bean.canModifyPredicate(new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#modify_self"),
CURATOR));
bean.canModifyPredicate(
new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#modify_self"), CURATOR));
}
@Test
public void modifyPredicateRestrictionEqual() {
assertEquals("modifyPredicate: equal restriction", true,
bean.canModifyPredicate(new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#modify_curator"),
CURATOR));
bean.canModifyPredicate(
new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#modify_curator"), CURATOR));
}
@Test
public void modifyPredicateRestrictionHigher() {
assertEquals("modifyPredicate: higher restriction", false,
bean.canModifyPredicate(new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#modify_hidden"),
CURATOR));
bean.canModifyPredicate(
new edu.cornell.mannlib.vitro.webapp.beans.Property(
"http://predicates#modify_hidden"), CURATOR));
}
@Test
public void modifyPredicateProhibitedNamespace() {
assertEquals("modifyPredicate: prohibited namespace", false,
bean.canModifyPredicate(new edu.cornell.mannlib.vitro.webapp.beans.Property(
PROHIBITED_NAMESPACES[0] + "randoom"),
DB_ADMIN));
assertEquals(
"modifyPredicate: prohibited namespace",
false,
bean.canModifyPredicate(
new edu.cornell.mannlib.vitro.webapp.beans.Property(
PROHIBITED_NAMESPACES[0] + "randoom"), DB_ADMIN));
}
@Test
public void modifyPredicatePermittedException() {
assertEquals("modifyPredicate: permitted exception", true,
bean.canModifyPredicate(new edu.cornell.mannlib.vitro.webapp.beans.Property(
PERMITTED_EXCEPTIONS[0]), DB_ADMIN));
bean.canModifyPredicate(
new edu.cornell.mannlib.vitro.webapp.beans.Property(
PERMITTED_EXCEPTIONS[0]), DB_ADMIN));
}
@Test
public void publishPredicateNoRestriction() {
assertEquals("publishPredicate: open", true, bean.canPublishPredicate(
createVitroProperty("http://predicates#open"), PUBLIC));
}
@Test
public void publishPredicateRestrictionLower() {
assertEquals("publishPredicate: lower restriction", true,
bean.canPublishPredicate(
createVitroProperty("http://predicates#publish_self"),
CURATOR));
}
@Test
public void publishPredicateRestrictionEqual() {
assertEquals(
"publishPredicate: equal restriction",
true,
bean.canPublishPredicate(
createVitroProperty("http://predicates#publish_curator"),
CURATOR));
}
@Test
public void publishPredicateRestrictionHigher() {
assertEquals(
"publishPredicate: higher restriction",
false,
bean.canPublishPredicate(
createVitroProperty("http://predicates#publish_hidden"),
CURATOR));
}
// ----------------------------------------------------------------------
@ -211,8 +268,7 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
@Test
public void buildDisplayThresholds() {
Map<Pair<String, Pair<String,String>>, BaseResourceBean.RoleLevel> expectedMap =
new HashMap<Pair<String, Pair<String,String>>, BaseResourceBean.RoleLevel>();
Map<Pair<String, Pair<String, String>>, BaseResourceBean.RoleLevel> expectedMap = new HashMap<>();
mapPut("http://thresholds#display_public", PUBLIC, expectedMap);
mapPut("http://thresholds#display_hidden", NOBODY, expectedMap);
@ -222,8 +278,7 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
@Test
public void buildModifyThresholds() {
Map<Pair<String, Pair<String,String>>, BaseResourceBean.RoleLevel> expectedMap =
new HashMap<Pair<String, Pair<String,String>>, BaseResourceBean.RoleLevel>();
Map<Pair<String, Pair<String, String>>, BaseResourceBean.RoleLevel> expectedMap = new HashMap<>();
mapPut("http://thresholds#modify_editor", EDITOR, expectedMap);
mapPut("http://thresholds#modify_curator", CURATOR, expectedMap);
@ -231,6 +286,16 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
assertEquals("modify thresholds", expectedMap, actualMap);
}
@Test
public void buildPublishThresholds() {
Map<Pair<String, Pair<String, String>>, BaseResourceBean.RoleLevel> expectedMap = new HashMap<>();
mapPut("http://thresholds#publish_public", PUBLIC, expectedMap);
mapPut("http://thresholds#publish_hidden", NOBODY, expectedMap);
Map<String, RoleLevel> actualMap = populateThresholdMap(PROPERTY_PUBLISH_THRESHOLD);
assertEquals("publish thresholds", expectedMap, actualMap);
}
/** Invoke the private static method "populateThresholdMap" */
private Map<String, RoleLevel> populateThresholdMap(String propertyUri) {
Map<String, RoleLevel> map = new HashMap<String, BaseResourceBean.RoleLevel>();
@ -262,9 +327,9 @@ public class PropertyRestrictionPolicyHelperTest extends AbstractTestClass {
model.add(subject, property, object);
}
}
private edu.cornell.mannlib.vitro.webapp.beans.Property createVitroProperty(
String propertyURI) {
return new edu.cornell.mannlib.vitro.webapp.beans.Property(propertyURI);
String propertyURI) {
return new edu.cornell.mannlib.vitro.webapp.beans.Property(propertyURI);
}
}

View file

@ -0,0 +1,154 @@
@prefix ocresd: <http://purl.org/net/OCRe/study_design.owl#> .
@prefix geo: <http://aims.fao.org/aos/geopolitical.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix scires: <http://vivoweb.org/ontology/scientific-research#> .
@prefix cito: <http://purl.org/spar/cito/> .
@prefix fabio: <http://purl.org/spar/fabio/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ocrer: <http://purl.org/net/OCRe/research.owl#> .
@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> .
@prefix event: <http://purl.org/NET/c4dm/event.owl#> .
@prefix bibo: <http://purl.org/ontology/bibo/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix c4o: <http://purl.org/spar/c4o/> .
@prefix vitro-public: <http://vitro.mannlib.cornell.edu/ns/vitro/public#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix vivo: <http://vivoweb.org/ontology/core#> .
<http://vivo.mydomain.edu/individual/n3639>
a vivo:FacultyMember ,
foaf:Person ,
owl:Thing ,
foaf:Agent ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
obo:BFO_0000004 ;
rdfs:label "Baker, Able "^^xsd:string ;
obo:ARG_2000028 <http://vivo.mydomain.edu/individual/n3972> ;
obo:RO_0000053 <http://vivo.mydomain.edu/individual/n475> ,
<http://vivo.mydomain.edu/individual/n7850> ;
vitro:mostSpecificType
vivo:FacultyMember ;
vivo:freetextKeyword
"Potrezebie, Chattanooga" ;
vivo:hasCollaborator
<http://vivo.mydomain.edu/individual/n7429> ;
vivo:relatedBy <http://vivo.mydomain.edu/individual/n3401> ,
<http://vivo.mydomain.edu/individual/n5855> ,
<http://vivo.mydomain.edu/individual/n2421> ;
vivo:researchOverview
"Whatever strikes my fancy." ;
vivo:scopusId "abaker" .
<http://vivo.mydomain.edu/individual/n3972>
a vcard:Kind ,
obo:BFO_0000031 ,
owl:Thing ,
obo:ARG_2000379 ,
obo:IAO_0000030 ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
vcard:Individual ;
obo:ARG_2000029 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n475>
a owl:Thing ,
obo:BFO_0000023 ,
vivo:InvestigatorRole ,
obo:BFO_0000002 ,
obo:BFO_0000017 ,
vivo:PrincipalInvestigatorRole ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:ResearcherRole ;
obo:RO_0000052 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n7850>
a owl:Thing ,
obo:BFO_0000023 ,
obo:BFO_0000017 ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:LeaderRole ;
rdfs:label "Lead Guitarist"^^xsd:string ;
obo:RO_0000052 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n7429>
a foaf:Person ,
vivo:FacultyMember ,
foaf:Agent ,
owl:Thing ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
obo:BFO_0000004 ;
rdfs:label "Yum, Yum " .
<http://vivo.mydomain.edu/individual/n3401>
a owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Authorship ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n5855>
a vivo:FacultyPosition ,
owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Position ;
rdfs:label "Functionary"^^xsd:string ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n2421>
a owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Grant ;
rdfs:label "Cosmogenic Lassitude in Plegmatic Axolotls" ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
obo:BFO_0000001
a owl:Class ;
rdfs:label "Entity" .
obo:BFO_0000002
a owl:Class ;
rdfs:label "Continuant" .
obo:BFO_0000004
a owl:Class ;
rdfs:label "Independent Continuant"@en-US .
vivo:FacultyMember
a owl:Class ;
rdfs:label "Faculty Member"@en-US .
foaf:Person
a owl:Class ;
rdfs:label "Person"@en-US .
foaf:Agent
a owl:Class ;
rdfs:label "Agent"@en-US .
owl:Thing
a owl:Class .
<http://vivo.mydomain.edu/individual/n3639/n3639.n3>
a foaf:Document ;
rdfs:label "RDF description of Baker, Able - http://vivo.mydomain.edu/individual/n3639" ;
<http://purl.org/dc/elements/1.1/date> "2014-03-10T11:08:39"^^xsd:dateTime ;
<http://purl.org/dc/elements/1.1/publisher> <http://vivo.mydomain.edu> ;
<http://purl.org/dc/elements/1.1/rights> <http://vivo.mydomain.edu/termsOfUse> .

View file

@ -0,0 +1,503 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.individual;
import static com.hp.hpl.jena.ontology.OntModelSpec.OWL_MEM;
import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.LABEL;
import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.RDF_TYPE;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.collections.IteratorUtils;
import org.apache.log4j.Level;
import org.junit.Before;
import org.junit.Test;
import stubs.javax.servlet.ServletContextStub;
import stubs.javax.servlet.http.HttpServletRequestStub;
import stubs.javax.servlet.http.HttpSessionStub;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.policy.BasicPolicyDecision;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish.PublishDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish.PublishObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
import edu.cornell.mannlib.vitro.webapp.web.ContentType;
/**
* Start with a set of data and filter it appropriately.
*/
public class IndividualRdfAssemblerTest extends AbstractTestClass {
private static final String INDIVIDUAL_URI = "http://vivo.mydomain.edu/individual/n3639";
private static final String DOCUMENT_URI = "http://vivo.mydomain.edu/individual/n3639/n3639.n3";
/** When comparing, consider all date-stamps to be equal. */
private static final String DATE_DATA_PROPERTY = "http://purl.org/dc/elements/1.1/date";
private static final String DP1 = "http://dataPropertyUri1";
private static final String OP1 = "http://objectPropertyUri1";
private static final String C1 = "http://class1";
private static final String C2 = "http://class2";
private static final String I1 = "http://individual1";
private static final String RAW_RDF_FILENAME = "IndividualRdfAssemblerTest.rawRdf.n3";
private static final String FILTERED_RDF_FILENAME = "IndividualRdfAssemblerTest.filteredRdf.n3";
private static final String UNFILTERED_RDF_FILENAME = "IndividualRdfAssemblerTest.unfilteredRdf.n3";
private static final String[] REAL_WORLD_PROPERTIES = {
"http://vivoweb.org/ontology/core#overview",
"http://vivoweb.org/ontology/core#hasResearchArea",
"http://vivoweb.org/ontology/core#researchAreaOf" };
private OntModel rawRdf;
private OntModel expectedLod;
private OntModel actualLod;
private ServletContextStub ctx;
private HttpSessionStub session;
private HttpServletRequestStub req;
private VitroRequest vreq;
private RDFServiceModel rdfService;
private IndividualRdfAssembler ira;
@Before
public void setLoggingLevels() {
setLoggerLevel(ModelAccess.class, Level.ERROR);
// setLoggerLevel(IndividualRdfAssembler.class, Level.DEBUG);
// setLoggerLevel(RDFServiceStub.class, Level.DEBUG);
}
@Before
public void setup() throws IOException {
ctx = new ServletContextStub();
session = new HttpSessionStub();
session.setServletContext(ctx);
req = new HttpServletRequestStub();
req.setSession(session);
req.setRequestUrl(new URL(DOCUMENT_URI));
}
@Test
public void getOutgoingStatements() {
Statement s1 = dataStmt(INDIVIDUAL_URI, DP1, "value");
Statement s2 = objectStmt(INDIVIDUAL_URI, OP1, I1);
rawRdf = model(s1, s2);
expectedLod = includeDocInfo(model(s1, s2));
policyUnrestricted();
filterAndCompare("getOutgoingStatements");
}
@Test
public void filterOutgoingStatements() {
Statement s1 = dataStmt(INDIVIDUAL_URI, DP1, "value");
Statement s2 = objectStmt(INDIVIDUAL_URI, OP1, I1);
rawRdf = model(s1, s2);
expectedLod = includeDocInfo(model());
policyRestrictByPredicate(DP1, OP1);
filterAndCompare("filterOutgoingStatements");
}
@Test
public void getIncomingStatements() {
Statement s1 = objectStmt(I1, OP1, INDIVIDUAL_URI);
rawRdf = model(s1);
expectedLod = includeDocInfo(model(s1));
policyUnrestricted();
filterAndCompare("getIncomingStatements");
}
@Test
public void filterIncomingStatements() {
Statement s1 = objectStmt(I1, OP1, INDIVIDUAL_URI);
rawRdf = model(s1);
expectedLod = includeDocInfo(model());
policyRestrictByPredicate(OP1);
filterAndCompare("filterIncomingStatements");
}
@Test
public void getLabelAndTypeOfOutgoingObjects() {
Statement s1 = objectStmt(INDIVIDUAL_URI, OP1, I1);
Statement s2 = dataStmt(I1, LABEL, "silly label");
Statement s3 = objectStmt(I1, RDF_TYPE, C1);
rawRdf = model(s1, s2, s3);
expectedLod = includeDocInfo(model(s1, s2, s3));
policyUnrestricted();
filterAndCompare("getLabelAndTypeOfOutgoingObjects");
}
@Test
public void filterOrphanStatementsOfOutgoingObjects() {
Statement s1 = objectStmt(INDIVIDUAL_URI, OP1, I1);
Statement s2 = dataStmt(I1, LABEL, "silly label");
Statement s3 = objectStmt(I1, RDF_TYPE, C1);
rawRdf = model(s1, s2, s3);
expectedLod = includeDocInfo(model());
policyRestrictByPredicate(OP1);
filterAndCompare("filterOrphanStatementsOfOutgoingObjects");
}
@Test
public void getLabelAndTypeOfIncomingObjects() {
Statement s1 = objectStmt(I1, OP1, INDIVIDUAL_URI);
Statement s2 = dataStmt(I1, LABEL, "silly label");
Statement s3 = objectStmt(I1, RDF_TYPE, C1);
rawRdf = model(s1, s2, s3);
expectedLod = includeDocInfo(model(s1, s2, s3));
policyUnrestricted();
filterAndCompare("getLabelAndTypeOfIncomingObjects");
}
@Test
public void filterOrphanStatementsOfIncomingObjects() {
Statement s1 = objectStmt(I1, OP1, INDIVIDUAL_URI);
Statement s2 = dataStmt(I1, LABEL, "silly label");
Statement s3 = objectStmt(I1, RDF_TYPE, C1);
rawRdf = model(s1, s2, s3);
expectedLod = includeDocInfo(model());
policyRestrictByPredicate(OP1);
filterAndCompare("filterOrphanStatementsOfIncomingObjects");
}
@Test
public void getTypeStatements() {
Statement s1 = objectStmt(INDIVIDUAL_URI, RDF_TYPE, C1);
rawRdf = model(s1);
expectedLod = includeDocInfo(model(s1));
policyUnrestricted();
filterAndCompare("getTypeStatements");
}
@Test
public void filterTypeStatements() {
Statement s1 = objectStmt(INDIVIDUAL_URI, RDF_TYPE, C1);
rawRdf = model(s1);
expectedLod = includeDocInfo(model());
policyRestrictByClass(C1);
filterAndCompare("filterTypeStatements");
}
@Test
public void getTypeAndLabelOfType() {
Statement s1 = objectStmt(INDIVIDUAL_URI, RDF_TYPE, C1);
Statement s2 = dataStmt(C1, LABEL, "silly label");
Statement s3 = objectStmt(C1, RDF_TYPE, C2);
rawRdf = model(s1, s2, s3);
expectedLod = includeDocInfo(model(s1, s2, s3));
policyUnrestricted();
filterAndCompare("getTypeAndLabelOfType");
}
@Test
public void filterOrphanTypeAndLabelOfType() {
Statement s1 = objectStmt(INDIVIDUAL_URI, RDF_TYPE, C1);
Statement s2 = dataStmt(I1, LABEL, "silly label");
Statement s3 = objectStmt(I1, RDF_TYPE, C2);
rawRdf = model(s1, s2, s3);
expectedLod = includeDocInfo(model());
policyRestrictByClass(C1);
filterAndCompare("filterOrphanTypeAndLabelOfType");
}
@Test
public void dontGetOtherStatementsFromOutgoingObjects() {
Statement s1 = objectStmt(INDIVIDUAL_URI, OP1, I1);
Statement s2 = dataStmt(I1, DP1, "silly data property");
rawRdf = model(s1, s2);
expectedLod = includeDocInfo(model(s1));
policyUnrestricted();
filterAndCompare("dontGetOtherStatementsFromOutgoingObjects");
}
@Test
public void dontGetOtherStatementsFromIncomingObjects() {
Statement s1 = objectStmt(I1, OP1, INDIVIDUAL_URI);
Statement s2 = dataStmt(I1, DP1, "silly data property");
rawRdf = model(s1, s2);
expectedLod = includeDocInfo(model(s1));
policyUnrestricted();
filterAndCompare("dontGetOtherStatementsFromIncomingObjects");
}
@Test
public void dontGetUnrelatedStatements() {
Statement s1 = dataStmt(I1, DP1, "silly data property");
rawRdf = model(s1);
expectedLod = includeDocInfo(model());
policyUnrestricted();
filterAndCompare("dontGetUnrelatedStatements");
}
@Test
public void realWorldTestRoot() throws IOException {
rawRdf = readModelFromFile(RAW_RDF_FILENAME, "N3");
expectedLod = readModelFromFile(UNFILTERED_RDF_FILENAME, "N3");
policyUnrestricted();
filterAndCompare("real world test - root");
}
@Test
public void realWorldTestPublic() throws IOException {
rawRdf = readModelFromFile(RAW_RDF_FILENAME, "N3");
expectedLod = readModelFromFile(FILTERED_RDF_FILENAME, "N3");
policyRestrictByPredicate(REAL_WORLD_PROPERTIES);
filterAndCompare("real world test - public");
}
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
private Statement dataStmt(String subjectUri, String predicateUri,
String value) {
Resource subject = ResourceFactory.createResource(subjectUri);
Property predicate = ResourceFactory.createProperty(predicateUri);
Literal object = ResourceFactory.createPlainLiteral(value);
return ResourceFactory.createStatement(subject, predicate, object);
}
private Statement objectStmt(String subjectUri, String predicateUri,
String objectUri) {
Resource subject = ResourceFactory.createResource(subjectUri);
Property predicate = ResourceFactory.createProperty(predicateUri);
Resource object = ResourceFactory.createResource(objectUri);
return ResourceFactory.createStatement(subject, predicate, object);
}
private OntModel model(Statement... stmts) {
OntModel m = ModelFactory.createOntologyModel(OWL_MEM);
m.add(Arrays.asList(stmts));
return m;
}
private OntModel includeDocInfo(OntModel m) {
List<Statement> list = new ArrayList<>();
list.add(dataStmt(DOCUMENT_URI, LABEL, "RDF description of "
+ INDIVIDUAL_URI));
list.add(dataStmt(DOCUMENT_URI, DATE_DATA_PROPERTY, "bogusTimeStamp"));
list.add(objectStmt(DOCUMENT_URI, RDF_TYPE,
"http://xmlns.com/foaf/0.1/Document"));
list.add(objectStmt(DOCUMENT_URI,
"http://purl.org/dc/elements/1.1/publisher",
"http://vivo.mydomain.edu"));
list.add(objectStmt(DOCUMENT_URI,
"http://purl.org/dc/elements/1.1/rights",
"http://vivo.mydomain.edu/termsOfUse"));
m.add(list);
return m;
}
private void policyUnrestricted() {
ServletPolicyList.addPolicy(ctx, new UnrestrictedPolicy());
}
private void policyRestrictByPredicate(String... predicateUris) {
ServletPolicyList.addPolicy(ctx, new RestrictionsPolicy(predicateUris,
new String[0]));
}
private void policyRestrictByClass(String... classUris) {
ServletPolicyList.addPolicy(ctx, new RestrictionsPolicy(new String[0],
classUris));
}
private void filterAndCompare(String message) {
setupIndividualRdfAssembler();
actualLod = runGetRdf();
List<Statement> missing = modelDifference(expectedLod, actualLod);
List<Statement> extra = modelDifference(actualLod, expectedLod);
removeMatchingDateStatements(missing, extra);
if (missing.isEmpty() && extra.isEmpty()) {
return;
}
failComparison(message, missing, extra);
}
private void setupIndividualRdfAssembler() {
rdfService = new RDFServiceModel(rawRdf);
req.setAttribute("rdfService", rdfService);
req.setAttribute("unfilteredRDFService", rdfService);
vreq = new VitroRequest(req);
ira = new IndividualRdfAssembler(vreq, INDIVIDUAL_URI, ContentType.N3);
}
private OntModel runGetRdf() {
try {
Method m = IndividualRdfAssembler.class.getDeclaredMethod("getRdf");
m.setAccessible(true);
return (OntModel) m.invoke(ira);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private void failComparison(String message, List<Statement> missing,
List<Statement> extra) {
StringWriter sw = new StringWriter();
PrintWriter w = new PrintWriter(sw);
w.println(message);
writeStatementList("Missing statements:", missing, w);
writeStatementList("Extra statements:", extra, w);
System.err.print(sw.toString());
fail(sw.toString());
}
private void writeStatementList(String label, List<Statement> list,
PrintWriter w) {
if (list.isEmpty()) {
return;
}
w.println(label);
for (Statement s : list) {
w.println(" " + s);
}
}
private List<Statement> modelDifference(OntModel first, OntModel second) {
OntModel temp = ModelFactory.createOntologyModel(OWL_MEM);
temp.add(first);
temp.remove(statementList(second));
return statementList(temp);
}
@SuppressWarnings("unchecked")
private List<Statement> statementList(OntModel m) {
return IteratorUtils.toList(m.listStatements());
}
/**
* If two date statements have the same subject, then lets assume that their
* dates are the same. In fact, the actual date statement will have the
* current date/time.
*/
private void removeMatchingDateStatements(List<Statement> list1,
List<Statement> list2) {
for (Iterator<Statement> it1 = list1.iterator(); it1.hasNext();) {
Statement stmt1 = it1.next();
String subject1 = stmt1.getSubject().getURI();
String predicate1 = stmt1.getPredicate().getURI();
if (DATE_DATA_PROPERTY.equals(predicate1)) {
for (Iterator<Statement> it2 = list2.iterator(); it2.hasNext();) {
Statement stmt2 = it2.next();
String subject2 = stmt2.getSubject().getURI();
String predicate2 = stmt2.getPredicate().getURI();
if (predicate1.equals(predicate2)
&& subject1.equals(subject2)) {
it1.remove();
it2.remove();
}
}
}
}
}
// ----------------------------------------------------------------------
// Helper class
// ----------------------------------------------------------------------
private abstract static class AbstractTestPolicy implements PolicyIface {
@Override
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
RequestedAction whatToAuth) {
if (whatToAuth instanceof PublishDataPropertyStatement) {
return filterDataProperty((PublishDataPropertyStatement) whatToAuth);
} else if (whatToAuth instanceof PublishObjectPropertyStatement) {
return filterObjectProperty((PublishObjectPropertyStatement) whatToAuth);
} else {
return inconclusive("Bogus");
}
}
private PolicyDecision filterDataProperty(
PublishDataPropertyStatement pdps) {
return filter(pdps.getPredicateUri(), null);
}
private PolicyDecision filterObjectProperty(
PublishObjectPropertyStatement pops) {
String propertyUri = pops.getPredicateUri();
if (VitroVocabulary.RDF_TYPE.equals(propertyUri)) {
return filter(propertyUri, pops.getObjectUri());
} else {
return filter(propertyUri, null);
}
}
protected abstract PolicyDecision filter(String propertyUri,
String classUri);
protected BasicPolicyDecision authorized(String message) {
return new BasicPolicyDecision(Authorization.AUTHORIZED, message);
}
protected BasicPolicyDecision inconclusive(String message) {
return new BasicPolicyDecision(Authorization.INCONCLUSIVE, message);
}
}
private static class UnrestrictedPolicy extends AbstractTestPolicy {
@Override
protected PolicyDecision filter(String propertyUri, String classUri) {
return authorized("Totally unrestricted");
}
}
private static class RestrictionsPolicy extends AbstractTestPolicy {
private final List<String> filteredPropertyUris;
private final List<String> filteredClassUris;
public RestrictionsPolicy(String[] filteredPropertyUris,
String[] filteredClassUris) {
this.filteredPropertyUris = Arrays.asList(filteredPropertyUris);
this.filteredClassUris = Arrays.asList(filteredClassUris);
}
@Override
protected PolicyDecision filter(String propertyUri, String classUri) {
if ((propertyUri != null)
&& filteredPropertyUris.contains(propertyUri)) {
return inconclusive("Filtered property: " + propertyUri);
}
if ((classUri != null) && filteredClassUris.contains(classUri)) {
return inconclusive("Filtered class: " + classUri);
}
return authorized("Passed the filters: " + propertyUri + ","
+ classUri);
}
}
}

View file

@ -0,0 +1,163 @@
@prefix ocresd: <http://purl.org/net/OCRe/study_design.owl#> .
@prefix geo: <http://aims.fao.org/aos/geopolitical.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix scires: <http://vivoweb.org/ontology/scientific-research#> .
@prefix cito: <http://purl.org/spar/cito/> .
@prefix fabio: <http://purl.org/spar/fabio/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ocrer: <http://purl.org/net/OCRe/research.owl#> .
@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> .
@prefix event: <http://purl.org/NET/c4dm/event.owl#> .
@prefix bibo: <http://purl.org/ontology/bibo/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix c4o: <http://purl.org/spar/c4o/> .
@prefix vitro-public: <http://vitro.mannlib.cornell.edu/ns/vitro/public#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix vivo: <http://vivoweb.org/ontology/core#> .
<http://vivo.mydomain.edu/individual/n3639>
a vivo:FacultyMember ,
foaf:Person ,
owl:Thing ,
foaf:Agent ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
obo:BFO_0000004 ;
rdfs:label "Baker, Able "^^xsd:string ;
obo:ARG_2000028 <http://vivo.mydomain.edu/individual/n3972> ;
obo:RO_0000053 <http://vivo.mydomain.edu/individual/n475> ,
<http://vivo.mydomain.edu/individual/n7850> ;
vitro:mostSpecificType
vivo:FacultyMember ;
vivo:freetextKeyword
"Potrezebie, Chattanooga" ;
vivo:hasCollaborator
<http://vivo.mydomain.edu/individual/n7429> ;
vivo:hasResearchArea
<http://www.eionet.europa.eu/gemet/concept/971> ,
<http://vivo.mydomain.edu/individual/n2158> ;
vivo:overview "Just an ordinary chap of simple means and simple desires." ;
vivo:relatedBy <http://vivo.mydomain.edu/individual/n3401> ,
<http://vivo.mydomain.edu/individual/n5855> ,
<http://vivo.mydomain.edu/individual/n2421> ;
vivo:researchOverview
"Whatever strikes my fancy." ;
vivo:scopusId "abaker" .
<http://vivo.mydomain.edu/individual/n3972>
a vcard:Kind ,
obo:BFO_0000031 ,
owl:Thing ,
obo:ARG_2000379 ,
obo:IAO_0000030 ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
vcard:Individual ;
obo:ARG_2000029 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n475>
a owl:Thing ,
obo:BFO_0000023 ,
vivo:InvestigatorRole ,
obo:BFO_0000002 ,
obo:BFO_0000017 ,
vivo:PrincipalInvestigatorRole ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:ResearcherRole ;
obo:RO_0000052 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n7850>
a owl:Thing ,
obo:BFO_0000023 ,
obo:BFO_0000017 ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:LeaderRole ;
rdfs:label "Lead Guitarist"^^xsd:string ;
obo:RO_0000052 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n7429>
a foaf:Person ,
vivo:FacultyMember ,
foaf:Agent ,
owl:Thing ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
obo:BFO_0000004 ;
rdfs:label "Yum, Yum " .
<http://www.eionet.europa.eu/gemet/concept/971>
a owl:Thing ,
<http://vivo.mydomain.edu/individual/n7793> ,
skos:Concept ;
rdfs:label "botany"^^xsd:string ;
vivo:researchAreaOf <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n2158>
a owl:Thing ,
skos:Concept ;
rdfs:label "What a concept!"^^xsd:string ;
vivo:researchAreaOf <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n3401>
a owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Authorship ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n5855>
a vivo:FacultyPosition ,
owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Position ;
rdfs:label "Functionary"^^xsd:string ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n2421>
a owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Grant ;
rdfs:label "Cosmogenic Lassitude in Plegmatic Axolotls" ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
obo:BFO_0000001
a owl:Class ;
rdfs:label "Entity" .
obo:BFO_0000002
a owl:Class ;
rdfs:label "Continuant" .
obo:BFO_0000004
a owl:Class ;
rdfs:label "Independent Continuant"@en-US .
vivo:FacultyMember
a owl:Class ;
rdfs:label "Faculty Member"@en-US .
foaf:Person
a owl:Class ;
rdfs:label "Person"@en-US .
foaf:Agent
a owl:Class ;
rdfs:label "Agent"@en-US .
owl:Thing
a owl:Class .

View file

@ -0,0 +1,171 @@
@prefix ocresd: <http://purl.org/net/OCRe/study_design.owl#> .
@prefix geo: <http://aims.fao.org/aos/geopolitical.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix scires: <http://vivoweb.org/ontology/scientific-research#> .
@prefix cito: <http://purl.org/spar/cito/> .
@prefix fabio: <http://purl.org/spar/fabio/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ocrer: <http://purl.org/net/OCRe/research.owl#> .
@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> .
@prefix event: <http://purl.org/NET/c4dm/event.owl#> .
@prefix bibo: <http://purl.org/ontology/bibo/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix c4o: <http://purl.org/spar/c4o/> .
@prefix vitro-public: <http://vitro.mannlib.cornell.edu/ns/vitro/public#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix vivo: <http://vivoweb.org/ontology/core#> .
<http://vivo.mydomain.edu/individual/n3639>
a vivo:FacultyMember ,
foaf:Person ,
owl:Thing ,
foaf:Agent ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
obo:BFO_0000004 ;
rdfs:label "Baker, Able "^^xsd:string ;
obo:ARG_2000028 <http://vivo.mydomain.edu/individual/n3972> ;
obo:RO_0000053 <http://vivo.mydomain.edu/individual/n475> ,
<http://vivo.mydomain.edu/individual/n7850> ;
vitro:mostSpecificType
vivo:FacultyMember ;
vivo:freetextKeyword
"Potrezebie, Chattanooga" ;
vivo:hasCollaborator
<http://vivo.mydomain.edu/individual/n7429> ;
vivo:hasResearchArea
<http://www.eionet.europa.eu/gemet/concept/971> ,
<http://vivo.mydomain.edu/individual/n2158> ;
vivo:overview "Just an ordinary chap of simple means and simple desires." ;
vivo:relatedBy <http://vivo.mydomain.edu/individual/n3401> ,
<http://vivo.mydomain.edu/individual/n5855> ,
<http://vivo.mydomain.edu/individual/n2421> ;
vivo:researchOverview
"Whatever strikes my fancy." ;
vivo:scopusId "abaker" .
<http://vivo.mydomain.edu/individual/n3972>
a vcard:Kind ,
obo:BFO_0000031 ,
owl:Thing ,
obo:ARG_2000379 ,
obo:IAO_0000030 ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
vcard:Individual ;
obo:ARG_2000029 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n475>
a owl:Thing ,
obo:BFO_0000023 ,
vivo:InvestigatorRole ,
obo:BFO_0000002 ,
obo:BFO_0000017 ,
vivo:PrincipalInvestigatorRole ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:ResearcherRole ;
obo:RO_0000052 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n7850>
a owl:Thing ,
obo:BFO_0000023 ,
obo:BFO_0000017 ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:LeaderRole ;
rdfs:label "Lead Guitarist"^^xsd:string ;
obo:RO_0000052 <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n7429>
a foaf:Person ,
vivo:FacultyMember ,
foaf:Agent ,
owl:Thing ,
obo:BFO_0000002 ,
obo:BFO_0000001 ,
obo:BFO_0000004 ;
rdfs:label "Yum, Yum " .
<http://www.eionet.europa.eu/gemet/concept/971>
a owl:Thing ,
<http://vivo.mydomain.edu/individual/n7793> ,
skos:Concept ;
rdfs:label "botany"^^xsd:string ;
vivo:researchAreaOf <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n2158>
a owl:Thing ,
skos:Concept ;
rdfs:label "What a concept!"^^xsd:string ;
vivo:researchAreaOf <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n3401>
a owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Authorship ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n5855>
a vivo:FacultyPosition ,
owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Position ;
rdfs:label "Functionary"^^xsd:string ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
<http://vivo.mydomain.edu/individual/n2421>
a owl:Thing ,
vivo:Relationship ,
obo:BFO_0000002 ,
obo:BFO_0000020 ,
obo:BFO_0000001 ,
vivo:Grant ;
rdfs:label "Cosmogenic Lassitude in Plegmatic Axolotls" ;
vivo:relates <http://vivo.mydomain.edu/individual/n3639> .
obo:BFO_0000001
a owl:Class ;
rdfs:label "Entity" .
obo:BFO_0000002
a owl:Class ;
rdfs:label "Continuant" .
obo:BFO_0000004
a owl:Class ;
rdfs:label "Independent Continuant"@en-US .
vivo:FacultyMember
a owl:Class ;
rdfs:label "Faculty Member"@en-US .
foaf:Person
a owl:Class ;
rdfs:label "Person"@en-US .
foaf:Agent
a owl:Class ;
rdfs:label "Agent"@en-US .
owl:Thing
a owl:Class .
<http://vivo.mydomain.edu/individual/n3639/n3639.n3>
a foaf:Document ;
rdfs:label "RDF description of Baker, Able - http://vivo.mydomain.edu/individual/n3639" ;
<http://purl.org/dc/elements/1.1/date> "2014-03-10T11:08:39"^^xsd:dateTime ;
<http://purl.org/dc/elements/1.1/publisher> <http://vivo.mydomain.edu> ;
<http://purl.org/dc/elements/1.1/rights> <http://vivo.mydomain.edu/termsOfUse> .

View file

@ -75,6 +75,7 @@ public class DataPropertyDaoJenaTest extends AbstractTestClass {
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.DISPLAY_LIMIT), subModel.createTypedLiteral(5));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#curator"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#editor"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_INPROPERTYGROUPANNOT), subModel.createResource("http://thisIsTheInPropertyGroupURI"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT), subModel.createResource("http://thisIsTheCustomFormEntryURI"));

View file

@ -149,6 +149,7 @@ public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_OBJECTINDIVIDUALSORTPROPERTY), subModel.createResource("http://thisIsTheObjectIndividualSortProperty"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#curator"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#editor"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_INPROPERTYGROUPANNOT), subModel.createResource("http://thisIsTheInPropertyGroupURI"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT), subModel.createResource("http://thisIsTheCustomFormEntryURI"));
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_SELECTFROMEXISTINGANNOT), subModel.createTypedLiteral(true));

View file

@ -70,6 +70,7 @@ public class VClassDaoTest {
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.SEARCH_BOOST_ANNOT), subModel.createTypedLiteral(2.4f));
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#curator"));
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor"));
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#editor"));
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT), subModel.createTypedLiteral("this is the custom entry form annotation"));
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMDISPLAYVIEWANNOT), subModel.createTypedLiteral("this is the custom display view annotation"));
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT), subModel.createTypedLiteral("this is the custom short view annotation"));

View file

@ -92,6 +92,7 @@ public class VClassJenaTest {
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.SEARCH_BOOST_ANNOT), ontModel.createTypedLiteral(2.4f));
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT), ontModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#curator"));
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT), ontModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor"));
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT), ontModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#editor"));
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT), ontModel.createTypedLiteral("this is the custom entry form annotation"));
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMDISPLAYVIEWANNOT), ontModel.createTypedLiteral("this is the custom display view annotation"));
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT), ontModel.createTypedLiteral("this is the custom short view annotation"));
@ -126,6 +127,7 @@ public class VClassJenaTest {
Assert.assertEquals(vClassJena.getSearchBoost(), vClass.getSearchBoost());
Assert.assertEquals(vClassJena.getHiddenFromDisplayBelowRoleLevel(), vClass.getHiddenFromDisplayBelowRoleLevel());
Assert.assertEquals(vClassJena.getProhibitedFromUpdateBelowRoleLevel(), vClass.getProhibitedFromUpdateBelowRoleLevel());
Assert.assertEquals(vClassJena.getHiddenFromPublishBelowRoleLevel(), vClass.getHiddenFromPublishBelowRoleLevel());
}
@ -156,6 +158,7 @@ public class VClassJenaTest {
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMSEARCHVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMSEARCHVIEWANNOT);
protected AnnotationProperty LOCAL_HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty LOCAL_PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty LOCAL_HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty LOCAL_IN_CLASSGROUP = _constModel.createAnnotationProperty(VitroVocabulary.IN_CLASSGROUP);
@ -234,6 +237,25 @@ public class VClassJenaTest {
}
vcw.setProhibitedFromUpdateBelowRoleLevel(prohibitedRoleLevel);//this might get set to null
//There might be multiple LOCAL_HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT properties, only use the highest
it = cls.listProperties(LOCAL_HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
BaseResourceBean.RoleLevel publishRoleLevel = null;
while( it.hasNext() ){
Statement stmt = it.nextStatement();
RDFNode obj;
if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){
Resource res = (Resource)obj.as(Resource.class);
if( res != null && res.getURI() != null ){
BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI());
if( roleFromModel != null &&
(publishRoleLevel == null || roleFromModel.compareTo(publishRoleLevel) > 0 )){
publishRoleLevel = roleFromModel;
}
}
}
}
vcw.setHiddenFromPublishBelowRoleLevel(publishRoleLevel);//this might get set to null
} finally {
cls.getModel().leaveCriticalSection();
}

View file

@ -8,8 +8,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.sdb.util.Pair;
import com.hp.hpl.jena.vocabulary.OWL;
@ -27,7 +25,6 @@ public class PropertyRestrictionPolicyHelperStub extends
return getInstance(null, null);
}
/** Prohibit some namespaces. */
public static PropertyRestrictionPolicyHelperStub getInstance(
String[] restrictedNamespaces) {
@ -44,30 +41,28 @@ public class PropertyRestrictionPolicyHelperStub extends
if (restrictedNamespaces != null) {
namespaceSet.addAll(Arrays.asList(restrictedNamespaces));
}
Map<Pair<String, Pair<String,String>>, RoleLevel> thresholdMap = new HashMap<
Pair<String, Pair<String,String>>, RoleLevel>();
Map<Pair<String, Pair<String, String>>, RoleLevel> thresholdMap = new HashMap<>();
if (restrictedProperties != null) {
for (String prop : restrictedProperties) {
thresholdMap.put(
new Pair<String, Pair<String, String>>(
OWL.Thing.getURI(), new Pair<String, String>(
prop, OWL.Thing.getURI())),
RoleLevel.NOBODY);
thresholdMap.put(new Pair<String, Pair<String, String>>(
OWL.Thing.getURI(), new Pair<String, String>(prop,
OWL.Thing.getURI())), RoleLevel.NOBODY);
}
}
return new PropertyRestrictionPolicyHelperStub(namespaceSet, null,
null, thresholdMap);
null, thresholdMap, null);
}
private PropertyRestrictionPolicyHelperStub(
Set<String> modifyRestrictedNamespaces,
Set<String> modifyPermittedExceptions,
Map<Pair<String, Pair<String,String>>, RoleLevel> displayThresholds,
Map<Pair<String, Pair<String,String>>, RoleLevel> modifyThresholds) {
Map<Pair<String, Pair<String, String>>, RoleLevel> displayThresholds,
Map<Pair<String, Pair<String, String>>, RoleLevel> modifyThresholds,
Map<Pair<String, Pair<String, String>>, RoleLevel> publishThresholds) {
super(modifyRestrictedNamespaces, modifyPermittedExceptions,
displayThresholds, modifyThresholds, ModelFactory.createDefaultModel());
displayThresholds, modifyThresholds, publishThresholds);
}
}

View file

@ -81,17 +81,17 @@ public class IndividualStub implements Individual {
public String getName() {
return name;
}
@Override
@Override
public String getLabel() {
return getName();
return getName();
}
@Override
public String getPickListName() {
return getName();
return getName();
}
@Override
public List<DataPropertyStatement> getDataPropertyStatements() {
return new ArrayList<DataPropertyStatement>(dpsSet);
@ -146,7 +146,6 @@ public class IndividualStub implements Individual {
return null;
}
@Override
public boolean isVClass(String vclassUri) {
for (VClass vc : vClasses) {
@ -263,6 +262,24 @@ public class IndividualStub implements Individual {
"ResourceBean.setProhibitedFromUpdateBelowRoleLevelUsingRoleUri() not implemented.");
}
@Override
public RoleLevel getHiddenFromPublishBelowRoleLevel() {
throw new RuntimeException(
"IndividualStub.getHiddenFromPublishBelowRoleLevel() not implemented.");
}
@Override
public void setHiddenFromPublishBelowRoleLevel(RoleLevel eR) {
throw new RuntimeException(
"IndividualStub.setHiddenFromPublishBelowRoleLevel() not implemented.");
}
@Override
public void setHiddenFromPublishBelowRoleLevelUsingRoleUri(String roleUri) {
throw new RuntimeException(
"IndividualStub.setHiddenFromPublishBelowRoleLevelUsingRoleUri() not implemented.");
}
@Override
public int compareTo(Individual o) {
throw new RuntimeException(
@ -271,9 +288,10 @@ public class IndividualStub implements Individual {
@Override
public List<String> getMostSpecificTypeURIs() {
throw new RuntimeException("Individual.getMostSpecificTypeURIs() not implemented.");
throw new RuntimeException(
"Individual.getMostSpecificTypeURIs() not implemented.");
}
@Override
public String getRdfsLabel() {
throw new RuntimeException("Individual.getRdfsLabel() not implemented.");