diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromDisplayBelowRoleLevelFilter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromDisplayBelowRoleLevelFilter.java index f5e54585f..08b06cbeb 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromDisplayBelowRoleLevelFilter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromDisplayBelowRoleLevelFilter.java @@ -142,18 +142,22 @@ public class HiddenFromDisplayBelowRoleLevelFilter extends VitroFiltersImpl { log.debug("checking hidden status for data property statement \"" + dPropStmt.getDatapropURI() + "\""); try { String propUri = dPropStmt.getDatapropURI(); - DataProperty prop = null; - if( dataPropertyMap.containsKey(propUri) ){ - prop = dataPropertyMap.get(propUri); - }else{ - prop = wdf.getDataPropertyDao().getDataPropertyByURI(propUri); - dataPropertyMap.put(propUri, prop); - } - if( prop == null ) { - if( ! canViewOddItems() ){ return false; } - }else{ - if( sameLevelOrHigher( prop.getHiddenFromDisplayBelowRoleLevel() ) == false) - return false; + if (propUri == null) { + if ( ! canViewOddItems() ){ return false; } + } else { + DataProperty prop = null; + if( dataPropertyMap.containsKey(propUri) ){ + prop = dataPropertyMap.get(propUri); + }else{ + prop = wdf.getDataPropertyDao().getDataPropertyByURI(propUri); + dataPropertyMap.put(propUri, prop); + } + if( prop == null ) { + if( ! canViewOddItems() ){ return false; } + }else{ + if( sameLevelOrHigher( prop.getHiddenFromDisplayBelowRoleLevel() ) == false) + return false; + } } Individual subject = dPropStmt.getIndividual(); @@ -238,7 +242,7 @@ public class HiddenFromDisplayBelowRoleLevelFilter extends VitroFiltersImpl { return false; } } else { - if (sameLevelOrHigher(subject + if (sameLevelOrHigher(object .getHiddenFromDisplayBelowRoleLevel()) == false) return false; } diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromDisplayBelowRoleLevelFilterTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromDisplayBelowRoleLevelFilterTest.java new file mode 100644 index 000000000..8a4c0ddf2 --- /dev/null +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromDisplayBelowRoleLevelFilterTest.java @@ -0,0 +1,911 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.dao.filtering.filters; + +import static edu.cornell.mannlib.vedit.beans.LoginStatusBean.CURATOR; +import static edu.cornell.mannlib.vedit.beans.LoginStatusBean.DBA; +import static edu.cornell.mannlib.vedit.beans.LoginStatusBean.EDITOR; +import static edu.cornell.mannlib.vedit.beans.LoginStatusBean.NON_EDITOR; +import static edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource.INTERNAL; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +import stubs.edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDaoStub; +import stubs.edu.cornell.mannlib.vitro.webapp.dao.IndividualDaoStub; +import stubs.edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDaoStub; +import stubs.edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryStub; +import edu.cornell.mannlib.vedit.beans.LoginStatusBean; +import edu.cornell.mannlib.vitro.testing.AbstractTestClass; +import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel; +import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; +import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; +import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl; +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; + +/** + * This test class is written to make it easy to create dozens of tests with + * minimal code duplication. That way we can test that Individual A can be + * viewed by Curators and DBAs but not by Editors or Self-Editors, etc., etc., + * ad infinitum. + * + * The class is implemented as a Parameterized JUnit test class. The parameters + * are TestData objects, and the class will invoke its single test for one. + * + * Actually, each parameter is an instance of a TestData sub-class, and the test + * method will decide how to handle the data based on the type. + * + * This gets a little clearer if you start by looking at the section labeled + * "the actual test class". + */ +@RunWith(value = Parameterized.class) +public class HiddenFromDisplayBelowRoleLevelFilterTest extends + AbstractTestClass { + private static final Log log = LogFactory + .getLog(HiddenFromDisplayBelowRoleLevelFilterTest.class); + + // ---------------------------------------------------------------------- + // the "framework" + // ---------------------------------------------------------------------- + + /** + * Each test is driven by an instance of this (actually, of a sub-class). + */ + private static abstract class TestData { + LoginStatusBean loginStatus; + + boolean expectedResult; + + public String getUsername() { + if (loginStatus == null) { + return "nobody"; + } else { + return loginStatus.getUsername(); + } + } + + public RoleLevel getRoleLevel() { + return HiddenFromDisplayBelowRoleLevelFilterTest + .getRoleLevel(loginStatus); + } + + /** A detailed description of the test in case something goes wrong. */ + public abstract String describeTest(); + } + + // ---------------------------------------------------------------------- + // data elements + // ---------------------------------------------------------------------- + + private static final String NS = "http://someDomain/individual/"; + + private static final LoginStatusBean LOGIN_NONE = null; + private static final LoginStatusBean LOGIN_SELF = new LoginStatusBean(NS + + "userSelf", "self_editor", NON_EDITOR, INTERNAL); + private static final LoginStatusBean LOGIN_EDITOR = new LoginStatusBean(NS + + "userEditor", "editor", EDITOR, INTERNAL); + private static final LoginStatusBean LOGIN_CURATOR = new LoginStatusBean(NS + + "userCurator", "curator", CURATOR, INTERNAL); + private static final LoginStatusBean LOGIN_DBA = new LoginStatusBean(NS + + "userDba", "dba", DBA, INTERNAL); + + private static final LoginStatusBean[] LOGINS = new LoginStatusBean[] { + LOGIN_NONE, LOGIN_SELF, LOGIN_EDITOR, LOGIN_CURATOR, LOGIN_DBA }; + + private static final Individual PUBLIC_INDIVIDUAL = individual( + "PUBLIC_individual", RoleLevel.PUBLIC); + private static final Individual SELF_INDIVIDUAL = individual( + "SELF_individual", RoleLevel.SELF); + private static final Individual EDITOR_INDIVIDUAL = individual( + "EDITOR_individual", RoleLevel.EDITOR); + private static final Individual CURATOR_INDIVIDUAL = individual( + "CURATOR_individual", RoleLevel.CURATOR); + private static final Individual DBA_INDIVIDUAL = individual( + "DBA_individual", RoleLevel.DB_ADMIN); + private static final Individual HIDDEN_INDIVIDUAL = individual( + "HIDDEN_individual", RoleLevel.NOBODY); + + private static final Individual[] INDIVIDUALS = new Individual[] { + PUBLIC_INDIVIDUAL, SELF_INDIVIDUAL, EDITOR_INDIVIDUAL, + CURATOR_INDIVIDUAL, DBA_INDIVIDUAL, HIDDEN_INDIVIDUAL }; + + /** Create an Individual */ + private static Individual individual(String moniker, + RoleLevel displayThreshhold) { + Individual i = new IndividualImpl(); + i.setMoniker(moniker); + i.setURI("uri:" + moniker); + i.setHiddenFromDisplayBelowRoleLevel(displayThreshhold); + return i; + } + + private static final VClass PUBLIC_VCLASS = vClass("PUBLIC_vclass", + RoleLevel.PUBLIC); + private static final VClass SELF_VCLASS = vClass("SELF_vclass", + RoleLevel.SELF); + private static final VClass EDITOR_VCLASS = vClass("EDITOR_vclass", + RoleLevel.EDITOR); + private static final VClass CURATOR_VCLASS = vClass("CURATOR_vclass", + RoleLevel.CURATOR); + private static final VClass DBA_VCLASS = vClass("DBA_vclass", + RoleLevel.DB_ADMIN); + private static final VClass HIDDEN_VCLASS = vClass("HIDDEN_vclass", + RoleLevel.NOBODY); + + /** Create a VClass */ + private static VClass vClass(String label, RoleLevel displayThreshhold) { + VClass dp = new VClass(); + dp.setName(label); + dp.setHiddenFromDisplayBelowRoleLevel(displayThreshhold); + return dp; + } + + private static final DataProperty PUBLIC_DATA_PROPERTY = dataProperty( + "PUBLIC_data_property", RoleLevel.PUBLIC); + private static final DataProperty SELF_DATA_PROPERTY = dataProperty( + "SELF_data_property", RoleLevel.SELF); + private static final DataProperty EDITOR_DATA_PROPERTY = dataProperty( + "EDITOR_data_property", RoleLevel.EDITOR); + private static final DataProperty CURATOR_DATA_PROPERTY = dataProperty( + "CURATOR_data_property", RoleLevel.CURATOR); + private static final DataProperty DBA_DATA_PROPERTY = dataProperty( + "DBA_data_property", RoleLevel.DB_ADMIN); + private static final DataProperty HIDDEN_DATA_PROPERTY = dataProperty( + "HIDDEN_data_property", RoleLevel.NOBODY); + + private static final DataProperty[] DATA_PROPERTIES = new DataProperty[] { + PUBLIC_DATA_PROPERTY, SELF_DATA_PROPERTY, EDITOR_DATA_PROPERTY, + CURATOR_DATA_PROPERTY, DBA_DATA_PROPERTY, HIDDEN_DATA_PROPERTY }; + + /** Create a DataProperty */ + private static DataProperty dataProperty(String label, + RoleLevel displayThreshhold) { + DataProperty dp = new DataProperty(); + dp.setLabel(label); + dp.setURI("uri:" + label); + dp.setHiddenFromDisplayBelowRoleLevel(displayThreshhold); + return dp; + } + + private static final ObjectProperty PUBLIC_OBJECT_PROPERTY = objectProperty( + "PUBLIC_object_property", RoleLevel.PUBLIC); + private static final ObjectProperty SELF_OBJECT_PROPERTY = objectProperty( + "SELF_object_property", RoleLevel.SELF); + private static final ObjectProperty EDITOR_OBJECT_PROPERTY = objectProperty( + "EDITOR_object_property", RoleLevel.EDITOR); + private static final ObjectProperty CURATOR_OBJECT_PROPERTY = objectProperty( + "CURATOR_object_property", RoleLevel.CURATOR); + private static final ObjectProperty DBA_OBJECT_PROPERTY = objectProperty( + "DBA_object_property", RoleLevel.DB_ADMIN); + private static final ObjectProperty HIDDEN_OBJECT_PROPERTY = objectProperty( + "HIDDEN_object_property", RoleLevel.NOBODY); + + private static final ObjectProperty[] OBJECT_PROPERTIES = new ObjectProperty[] { + PUBLIC_OBJECT_PROPERTY, SELF_OBJECT_PROPERTY, + EDITOR_OBJECT_PROPERTY, CURATOR_OBJECT_PROPERTY, + DBA_OBJECT_PROPERTY, HIDDEN_OBJECT_PROPERTY }; + + /** Create a ObjectProperty */ + private static ObjectProperty objectProperty(String label, + RoleLevel displayThreshhold) { + ObjectProperty op = new ObjectProperty(); + op.setLabel(label); + op.setURI("uri:" + label); + op.setHiddenFromDisplayBelowRoleLevel(displayThreshhold); + return op; + } + + // ---------------------------------------------------------------------- + // the "tests" + // ---------------------------------------------------------------------- + + @Parameters + public static Collection testData() { + List tests = new ArrayList(); + + /* + * tests for Individual filter + */ + // TODO: + // HiddenFromDisplayBelowRoleLevelFilter.FILTER_ON_INDIVIDUAL_VCLASSES + // is set to false. If it were true, we would need more tests: + // + // get the list of direct VClasses + // if the list is null (maybe filtered out by a previous filter) + // - test the VClass from individual.getVClassUri using the Class filter + // else + // - test each VClass from the list using the Class filter + + tests.add(testIndividual(PUBLIC_INDIVIDUAL, LOGIN_NONE, true)); + tests.add(testIndividual(PUBLIC_INDIVIDUAL, LOGIN_SELF, true)); + tests.add(testIndividual(PUBLIC_INDIVIDUAL, LOGIN_EDITOR, true)); + tests.add(testIndividual(PUBLIC_INDIVIDUAL, LOGIN_CURATOR, true)); + tests.add(testIndividual(PUBLIC_INDIVIDUAL, LOGIN_DBA, true)); + + tests.add(testIndividual(SELF_INDIVIDUAL, LOGIN_NONE, false)); + tests.add(testIndividual(SELF_INDIVIDUAL, LOGIN_SELF, true)); + tests.add(testIndividual(SELF_INDIVIDUAL, LOGIN_EDITOR, true)); + tests.add(testIndividual(SELF_INDIVIDUAL, LOGIN_CURATOR, true)); + tests.add(testIndividual(SELF_INDIVIDUAL, LOGIN_DBA, true)); + + tests.add(testIndividual(EDITOR_INDIVIDUAL, LOGIN_NONE, false)); + tests.add(testIndividual(EDITOR_INDIVIDUAL, LOGIN_SELF, false)); + tests.add(testIndividual(EDITOR_INDIVIDUAL, LOGIN_EDITOR, true)); + tests.add(testIndividual(EDITOR_INDIVIDUAL, LOGIN_CURATOR, true)); + tests.add(testIndividual(EDITOR_INDIVIDUAL, LOGIN_DBA, true)); + + tests.add(testIndividual(CURATOR_INDIVIDUAL, LOGIN_NONE, false)); + tests.add(testIndividual(CURATOR_INDIVIDUAL, LOGIN_SELF, false)); + tests.add(testIndividual(CURATOR_INDIVIDUAL, LOGIN_EDITOR, false)); + tests.add(testIndividual(CURATOR_INDIVIDUAL, LOGIN_CURATOR, true)); + tests.add(testIndividual(CURATOR_INDIVIDUAL, LOGIN_DBA, true)); + + tests.add(testIndividual(DBA_INDIVIDUAL, LOGIN_NONE, false)); + tests.add(testIndividual(DBA_INDIVIDUAL, LOGIN_SELF, false)); + tests.add(testIndividual(DBA_INDIVIDUAL, LOGIN_EDITOR, false)); + tests.add(testIndividual(DBA_INDIVIDUAL, LOGIN_CURATOR, false)); + tests.add(testIndividual(DBA_INDIVIDUAL, LOGIN_DBA, true)); + + tests.add(testIndividual(HIDDEN_INDIVIDUAL, LOGIN_NONE, false)); + tests.add(testIndividual(HIDDEN_INDIVIDUAL, LOGIN_SELF, false)); + tests.add(testIndividual(HIDDEN_INDIVIDUAL, LOGIN_EDITOR, false)); + tests.add(testIndividual(HIDDEN_INDIVIDUAL, LOGIN_CURATOR, false)); + tests.add(testIndividual(HIDDEN_INDIVIDUAL, LOGIN_DBA, false)); + + tests.add(testIndividual(null, LOGIN_NONE, false)); + tests.add(testIndividual(null, LOGIN_SELF, false)); + tests.add(testIndividual(null, LOGIN_EDITOR, false)); + tests.add(testIndividual(null, LOGIN_CURATOR, false)); + tests.add(testIndividual(null, LOGIN_DBA, true)); + + /* + * tests for Class Filter + */ + tests.add(testVClass(PUBLIC_VCLASS, LOGIN_NONE, true)); + tests.add(testVClass(PUBLIC_VCLASS, LOGIN_SELF, true)); + tests.add(testVClass(PUBLIC_VCLASS, LOGIN_EDITOR, true)); + tests.add(testVClass(PUBLIC_VCLASS, LOGIN_CURATOR, true)); + tests.add(testVClass(PUBLIC_VCLASS, LOGIN_DBA, true)); + + tests.add(testVClass(SELF_VCLASS, LOGIN_NONE, false)); + tests.add(testVClass(SELF_VCLASS, LOGIN_SELF, true)); + tests.add(testVClass(SELF_VCLASS, LOGIN_EDITOR, true)); + tests.add(testVClass(SELF_VCLASS, LOGIN_CURATOR, true)); + tests.add(testVClass(SELF_VCLASS, LOGIN_DBA, true)); + + tests.add(testVClass(EDITOR_VCLASS, LOGIN_NONE, false)); + tests.add(testVClass(EDITOR_VCLASS, LOGIN_SELF, false)); + tests.add(testVClass(EDITOR_VCLASS, LOGIN_EDITOR, true)); + tests.add(testVClass(EDITOR_VCLASS, LOGIN_CURATOR, true)); + tests.add(testVClass(EDITOR_VCLASS, LOGIN_DBA, true)); + + tests.add(testVClass(CURATOR_VCLASS, LOGIN_NONE, false)); + tests.add(testVClass(CURATOR_VCLASS, LOGIN_SELF, false)); + tests.add(testVClass(CURATOR_VCLASS, LOGIN_EDITOR, false)); + tests.add(testVClass(CURATOR_VCLASS, LOGIN_CURATOR, true)); + tests.add(testVClass(CURATOR_VCLASS, LOGIN_DBA, true)); + + tests.add(testVClass(DBA_VCLASS, LOGIN_NONE, false)); + tests.add(testVClass(DBA_VCLASS, LOGIN_SELF, false)); + tests.add(testVClass(DBA_VCLASS, LOGIN_EDITOR, false)); + tests.add(testVClass(DBA_VCLASS, LOGIN_CURATOR, false)); + tests.add(testVClass(DBA_VCLASS, LOGIN_DBA, true)); + + tests.add(testVClass(HIDDEN_VCLASS, LOGIN_NONE, false)); + tests.add(testVClass(HIDDEN_VCLASS, LOGIN_SELF, false)); + tests.add(testVClass(HIDDEN_VCLASS, LOGIN_EDITOR, false)); + tests.add(testVClass(HIDDEN_VCLASS, LOGIN_CURATOR, false)); + tests.add(testVClass(HIDDEN_VCLASS, LOGIN_DBA, false)); + + tests.add(testVClass(null, LOGIN_NONE, false)); + tests.add(testVClass(null, LOGIN_SELF, false)); + tests.add(testVClass(null, LOGIN_EDITOR, false)); + tests.add(testVClass(null, LOGIN_CURATOR, false)); + tests.add(testVClass(null, LOGIN_DBA, true)); + + /* + * tests for DataProperty filter + */ + tests.add(testDataProp(PUBLIC_DATA_PROPERTY, LOGIN_NONE, true)); + tests.add(testDataProp(PUBLIC_DATA_PROPERTY, LOGIN_SELF, true)); + tests.add(testDataProp(PUBLIC_DATA_PROPERTY, LOGIN_EDITOR, true)); + tests.add(testDataProp(PUBLIC_DATA_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testDataProp(PUBLIC_DATA_PROPERTY, LOGIN_DBA, true)); + + tests.add(testDataProp(SELF_DATA_PROPERTY, LOGIN_NONE, false)); + tests.add(testDataProp(SELF_DATA_PROPERTY, LOGIN_SELF, true)); + tests.add(testDataProp(SELF_DATA_PROPERTY, LOGIN_EDITOR, true)); + tests.add(testDataProp(SELF_DATA_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testDataProp(SELF_DATA_PROPERTY, LOGIN_DBA, true)); + + tests.add(testDataProp(EDITOR_DATA_PROPERTY, LOGIN_NONE, false)); + tests.add(testDataProp(EDITOR_DATA_PROPERTY, LOGIN_SELF, false)); + tests.add(testDataProp(EDITOR_DATA_PROPERTY, LOGIN_EDITOR, true)); + tests.add(testDataProp(EDITOR_DATA_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testDataProp(EDITOR_DATA_PROPERTY, LOGIN_DBA, true)); + + tests.add(testDataProp(CURATOR_DATA_PROPERTY, LOGIN_NONE, false)); + tests.add(testDataProp(CURATOR_DATA_PROPERTY, LOGIN_SELF, false)); + tests.add(testDataProp(CURATOR_DATA_PROPERTY, LOGIN_EDITOR, false)); + tests.add(testDataProp(CURATOR_DATA_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testDataProp(CURATOR_DATA_PROPERTY, LOGIN_DBA, true)); + + tests.add(testDataProp(DBA_DATA_PROPERTY, LOGIN_NONE, false)); + tests.add(testDataProp(DBA_DATA_PROPERTY, LOGIN_SELF, false)); + tests.add(testDataProp(DBA_DATA_PROPERTY, LOGIN_EDITOR, false)); + tests.add(testDataProp(DBA_DATA_PROPERTY, LOGIN_CURATOR, false)); + tests.add(testDataProp(DBA_DATA_PROPERTY, LOGIN_DBA, true)); + + tests.add(testDataProp(HIDDEN_DATA_PROPERTY, LOGIN_NONE, false)); + tests.add(testDataProp(HIDDEN_DATA_PROPERTY, LOGIN_SELF, false)); + tests.add(testDataProp(HIDDEN_DATA_PROPERTY, LOGIN_EDITOR, false)); + tests.add(testDataProp(HIDDEN_DATA_PROPERTY, LOGIN_CURATOR, false)); + tests.add(testDataProp(HIDDEN_DATA_PROPERTY, LOGIN_DBA, false)); + + tests.add(testDataProp(null, LOGIN_NONE, false)); + tests.add(testDataProp(null, LOGIN_SELF, false)); + tests.add(testDataProp(null, LOGIN_EDITOR, false)); + tests.add(testDataProp(null, LOGIN_CURATOR, false)); + tests.add(testDataProp(null, LOGIN_DBA, true)); + + /* + * tests for ObjectProperty filter + */ + tests.add(testObjectProp(PUBLIC_OBJECT_PROPERTY, LOGIN_NONE, true)); + tests.add(testObjectProp(PUBLIC_OBJECT_PROPERTY, LOGIN_SELF, true)); + tests.add(testObjectProp(PUBLIC_OBJECT_PROPERTY, LOGIN_EDITOR, true)); + tests.add(testObjectProp(PUBLIC_OBJECT_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testObjectProp(PUBLIC_OBJECT_PROPERTY, LOGIN_DBA, true)); + + tests.add(testObjectProp(SELF_OBJECT_PROPERTY, LOGIN_NONE, false)); + tests.add(testObjectProp(SELF_OBJECT_PROPERTY, LOGIN_SELF, true)); + tests.add(testObjectProp(SELF_OBJECT_PROPERTY, LOGIN_EDITOR, true)); + tests.add(testObjectProp(SELF_OBJECT_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testObjectProp(SELF_OBJECT_PROPERTY, LOGIN_DBA, true)); + + tests.add(testObjectProp(EDITOR_OBJECT_PROPERTY, LOGIN_NONE, false)); + tests.add(testObjectProp(EDITOR_OBJECT_PROPERTY, LOGIN_SELF, false)); + tests.add(testObjectProp(EDITOR_OBJECT_PROPERTY, LOGIN_EDITOR, true)); + tests.add(testObjectProp(EDITOR_OBJECT_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testObjectProp(EDITOR_OBJECT_PROPERTY, LOGIN_DBA, true)); + + tests.add(testObjectProp(CURATOR_OBJECT_PROPERTY, LOGIN_NONE, false)); + tests.add(testObjectProp(CURATOR_OBJECT_PROPERTY, LOGIN_SELF, false)); + tests.add(testObjectProp(CURATOR_OBJECT_PROPERTY, LOGIN_EDITOR, false)); + tests.add(testObjectProp(CURATOR_OBJECT_PROPERTY, LOGIN_CURATOR, true)); + tests.add(testObjectProp(CURATOR_OBJECT_PROPERTY, LOGIN_DBA, true)); + + tests.add(testObjectProp(DBA_OBJECT_PROPERTY, LOGIN_NONE, false)); + tests.add(testObjectProp(DBA_OBJECT_PROPERTY, LOGIN_SELF, false)); + tests.add(testObjectProp(DBA_OBJECT_PROPERTY, LOGIN_EDITOR, false)); + tests.add(testObjectProp(DBA_OBJECT_PROPERTY, LOGIN_CURATOR, false)); + tests.add(testObjectProp(DBA_OBJECT_PROPERTY, LOGIN_DBA, true)); + + tests.add(testObjectProp(HIDDEN_OBJECT_PROPERTY, LOGIN_NONE, false)); + tests.add(testObjectProp(HIDDEN_OBJECT_PROPERTY, LOGIN_SELF, false)); + tests.add(testObjectProp(HIDDEN_OBJECT_PROPERTY, LOGIN_EDITOR, false)); + tests.add(testObjectProp(HIDDEN_OBJECT_PROPERTY, LOGIN_CURATOR, false)); + tests.add(testObjectProp(HIDDEN_OBJECT_PROPERTY, LOGIN_DBA, false)); + + tests.add(testObjectProp(null, LOGIN_NONE, false)); + tests.add(testObjectProp(null, LOGIN_SELF, false)); + tests.add(testObjectProp(null, LOGIN_EDITOR, false)); + tests.add(testObjectProp(null, LOGIN_CURATOR, false)); + tests.add(testObjectProp(null, LOGIN_DBA, true)); + + /* + * tests for DataPropertyStatementFilter + * + * Generate most of these tests algorithmically. Use all combinations of + * roles for login, Individual and DataProperty. + */ + // TODO: + // HiddenFromDisplayBelowRoleLevelFilter.FILTER_ON_INDIVIDUAL_VCLASSES + // is set to false. If it were true, we would need more tests to check + // whether the VClasses of both the subject and the predicate are + // viewable. + + for (LoginStatusBean login : LOGINS) { + for (Individual subject : INDIVIDUALS) { + for (DataProperty predicate : DATA_PROPERTIES) { + tests.add(testDataPropStmt( + login, + subject, + predicate, + expectedResultForDataPropertyStatement(login, + subject, predicate))); + } + } + } + + tests.add(testDataPropStmt(LOGIN_NONE, null, PUBLIC_DATA_PROPERTY, + false)); + tests.add(testDataPropStmt(LOGIN_SELF, null, PUBLIC_DATA_PROPERTY, + false)); + tests.add(testDataPropStmt(LOGIN_EDITOR, null, PUBLIC_DATA_PROPERTY, + false)); + tests.add(testDataPropStmt(LOGIN_CURATOR, null, PUBLIC_DATA_PROPERTY, + false)); + tests.add(testDataPropStmt(LOGIN_DBA, null, PUBLIC_DATA_PROPERTY, true)); + + tests.add(testDataPropStmt(LOGIN_NONE, PUBLIC_INDIVIDUAL, null, false)); + tests.add(testDataPropStmt(LOGIN_SELF, PUBLIC_INDIVIDUAL, null, false)); + tests.add(testDataPropStmt(LOGIN_EDITOR, PUBLIC_INDIVIDUAL, null, false)); + tests.add(testDataPropStmt(LOGIN_CURATOR, PUBLIC_INDIVIDUAL, null, + false)); + tests.add(testDataPropStmt(LOGIN_DBA, PUBLIC_INDIVIDUAL, null, true)); + + /* + * tests for ObjectPropertyStatementFilter + * + * Generate most of these tests algorithmically. Use all combinations of + * roles for login, Individual (twice) and DataProperty. + */ + // TODO: + // HiddenFromDisplayBelowRoleLevelFilter.FILTER_ON_INDIVIDUAL_VCLASSES + // is set to false. If it were true, we would need more tests to check + // whether the VClasses of the subject, the predicate and the object are + // viewable. + for (LoginStatusBean login : LOGINS) { + for (Individual subject : INDIVIDUALS) { + for (Individual object : INDIVIDUALS) { + for (ObjectProperty predicate : OBJECT_PROPERTIES) { + boolean expectedResult = expectedResultForObjectPropertyStatement( + login, subject, predicate, object); + + tests.add(testObjectPropStmt(login, subject, predicate, + object, expectedResult)); + } + } + } + } + + tests.add(testObjectPropStmt(LOGIN_NONE, null, PUBLIC_OBJECT_PROPERTY, + PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_SELF, null, PUBLIC_OBJECT_PROPERTY, + PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_EDITOR, null, + PUBLIC_OBJECT_PROPERTY, PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_CURATOR, null, + PUBLIC_OBJECT_PROPERTY, PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_DBA, null, PUBLIC_OBJECT_PROPERTY, + PUBLIC_INDIVIDUAL, true)); + + tests.add(testObjectPropStmt(LOGIN_NONE, PUBLIC_INDIVIDUAL, null, + PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_SELF, PUBLIC_INDIVIDUAL, null, + PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_EDITOR, PUBLIC_INDIVIDUAL, null, + PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_CURATOR, PUBLIC_INDIVIDUAL, null, + PUBLIC_INDIVIDUAL, false)); + tests.add(testObjectPropStmt(LOGIN_DBA, PUBLIC_INDIVIDUAL, null, + PUBLIC_INDIVIDUAL, true)); + + tests.add(testObjectPropStmt(LOGIN_NONE, PUBLIC_INDIVIDUAL, + PUBLIC_OBJECT_PROPERTY, null, false)); + tests.add(testObjectPropStmt(LOGIN_SELF, PUBLIC_INDIVIDUAL, + PUBLIC_OBJECT_PROPERTY, null, false)); + tests.add(testObjectPropStmt(LOGIN_EDITOR, PUBLIC_INDIVIDUAL, + PUBLIC_OBJECT_PROPERTY, null, false)); + tests.add(testObjectPropStmt(LOGIN_CURATOR, PUBLIC_INDIVIDUAL, + PUBLIC_OBJECT_PROPERTY, null, false)); + tests.add(testObjectPropStmt(LOGIN_DBA, PUBLIC_INDIVIDUAL, + PUBLIC_OBJECT_PROPERTY, null, true)); + + return tests; + } + + /** + * Assemble the test data to test the Individual filter. + */ + private static Object[] testIndividual(Individual individual, + LoginStatusBean loginStatus, boolean expectedResult) { + IndividualTestData data = new IndividualTestData(); + data.loginStatus = loginStatus; + data.individual = individual; + data.expectedResult = expectedResult; + return new Object[] { data }; + } + + private static class IndividualTestData extends TestData { + Individual individual; + + @Override + public String describeTest() { + String message = "IndividualTest, login=" + getRoleLevel() + "(" + + getUsername() + ")"; + if (individual == null) { + message += ", individual=null"; + } else { + message += ", individual=" + individual.getMoniker(); + } + return message; + } + } + + /** + * Assemble the test data to test the VClass filter. + */ + private static Object[] testVClass(VClass dp, LoginStatusBean loginStatus, + boolean expectedResult) { + VClassTestData data = new VClassTestData(); + data.loginStatus = loginStatus; + data.vClass = dp; + data.expectedResult = expectedResult; + return new Object[] { data }; + } + + private static class VClassTestData extends TestData { + VClass vClass; + + @Override + public String describeTest() { + String message = "VClassTest, login=" + getRoleLevel() + "(" + + getUsername() + ")"; + if (vClass == null) { + message += ", vClass=null"; + } else { + message += ", vClass=" + vClass.getName(); + } + return message; + } + } + + /** + * Assemble the test data to test the DataProperty filter. + */ + private static Object[] testDataProp(DataProperty dp, + LoginStatusBean loginStatus, boolean expectedResult) { + DataPropertyTestData data = new DataPropertyTestData(); + data.loginStatus = loginStatus; + data.dataProperty = dp; + data.expectedResult = expectedResult; + return new Object[] { data }; + } + + private static class DataPropertyTestData extends TestData { + DataProperty dataProperty; + + @Override + public String describeTest() { + String message = "DataPropertyTest, login=" + getRoleLevel() + "(" + + getUsername() + ")"; + if (dataProperty == null) { + message += ", dataProperty=null"; + } else { + message += ", dataProperty=" + dataProperty.getLabel(); + } + return message; + } + } + + /** + * Assemble the test data to test the ObjectProperty filter. + */ + private static Object[] testObjectProp(ObjectProperty dp, + LoginStatusBean loginStatus, boolean expectedResult) { + ObjectPropertyTestData data = new ObjectPropertyTestData(); + data.loginStatus = loginStatus; + data.objectProperty = dp; + data.expectedResult = expectedResult; + return new Object[] { data }; + } + + private static class ObjectPropertyTestData extends TestData { + ObjectProperty objectProperty; + + @Override + public String describeTest() { + String message = "ObjectPropertyTest, login=" + getRoleLevel() + + "(" + getUsername() + ")"; + if (objectProperty == null) { + message += ", objectProperty=null"; + } else { + message += ", objectProperty=" + objectProperty.getLabel(); + } + return message; + } + } + + /** + * Assemble the test data to test the DataPropertyStatement filter. + */ + private static Object[] testDataPropStmt(LoginStatusBean login, + Individual subject, DataProperty predicate, boolean expectedResult) { + DataPropertyStatementTestData data = new DataPropertyStatementTestData(); + data.loginStatus = login; + data.subject = subject; + data.predicate = predicate; + data.expectedResult = expectedResult; + return new Object[] { data }; + } + + private static boolean expectedResultForDataPropertyStatement( + LoginStatusBean login, Individual subject, DataProperty predicate) { + RoleLevel loginRole = getRoleLevel(login); + RoleLevel subjectRole = subject.getHiddenFromDisplayBelowRoleLevel(); + RoleLevel predicateRole = predicate + .getHiddenFromDisplayBelowRoleLevel(); + + // Is the effective login role at least as high as the threshhold roles + // for both subject and predicate? + return (loginRole.compareTo(subjectRole) >= 0) + && (loginRole.compareTo(predicateRole) >= 0); + } + + private static class DataPropertyStatementTestData extends TestData { + Individual subject; + DataProperty predicate; + + @Override + public String describeTest() { + String message = "DataPropertyStatementTest, login=" + + getRoleLevel() + "(" + getUsername() + ")"; + + if (subject == null) { + message += ", subject=null"; + } else { + message += ", subject=" + subject.getMoniker(); + } + + if (predicate == null) { + message += ", predicate=null"; + } else { + message += ", predicate=" + predicate.getLabel(); + } + + return message; + } + } + + /** + * Assemble the test data to test the ObjectPropertyStatement filter. + */ + private static Object[] testObjectPropStmt(LoginStatusBean login, + Individual subject, ObjectProperty predicate, Individual object, + boolean expectedResult) { + ObjectPropertyStatementTestData data = new ObjectPropertyStatementTestData(); + data.loginStatus = login; + data.subject = subject; + data.predicate = predicate; + data.object = object; + data.expectedResult = expectedResult; + return new Object[] { data }; + } + + private static boolean expectedResultForObjectPropertyStatement( + LoginStatusBean login, Individual subject, + ObjectProperty predicate, Individual object) { + RoleLevel loginRole = getRoleLevel(login); + RoleLevel subjectRole = subject.getHiddenFromDisplayBelowRoleLevel(); + RoleLevel predicateRole = predicate + .getHiddenFromDisplayBelowRoleLevel(); + RoleLevel objectRole = object.getHiddenFromDisplayBelowRoleLevel(); + + // Is the effective login role at least as high as the threshhold roles + // for subject, object, and predicate? + return (loginRole.compareTo(subjectRole) >= 0) + && (loginRole.compareTo(objectRole) >= 0) + && (loginRole.compareTo(predicateRole) >= 0); + } + + private static class ObjectPropertyStatementTestData extends TestData { + Individual subject; + ObjectProperty predicate; + Individual object; + + @Override + public String describeTest() { + String message = "ObjectPropertyStatementTest, login=" + + getRoleLevel() + "(" + getUsername() + ")"; + + if (subject == null) { + message += ", subject=null"; + } else { + message += ", subject=" + subject.getMoniker(); + } + + if (predicate == null) { + message += ", predicate=null"; + } else { + message += ", predicate=" + predicate.getLabel(); + } + + if (object == null) { + message += ", object=null"; + } else { + message += ", object=" + object.getMoniker(); + } + + return message; + } + } + + public static RoleLevel getRoleLevel(LoginStatusBean loginStatus) { + if (loginStatus != null) { + switch (loginStatus.getSecurityLevel()) { + case LoginStatusBean.NON_EDITOR: + return RoleLevel.SELF; + case LoginStatusBean.EDITOR: + return RoleLevel.EDITOR; + case LoginStatusBean.CURATOR: + return RoleLevel.CURATOR; + case LoginStatusBean.DBA: + return RoleLevel.DB_ADMIN; + default: + break; + } + } + return RoleLevel.PUBLIC; + } + + // ---------------------------------------------------------------------- + // the actual test class + // ---------------------------------------------------------------------- + + private final TestData testData; + + private WebappDaoFactoryStub wdf; + private IndividualDaoStub indDao; + private DataPropertyDaoStub dpDao; + private ObjectPropertyDaoStub opDao; + private HiddenFromDisplayBelowRoleLevelFilter filter; + + public HiddenFromDisplayBelowRoleLevelFilterTest(TestData testData) { + this.testData = testData; + } + + @Before + public void setLoggingLevel() { + // setLoggerLevel(this.getClass(), org.apache.log4j.Level.DEBUG); + // setLoggerLevel(HiddenFromDisplayBelowRoleLevelFilter.class, + // org.apache.log4j.Level.DEBUG); + } + + @Before + public void createFilter() { + wdf = new WebappDaoFactoryStub(); + + indDao = new IndividualDaoStub(); + wdf.setIndividualDao(indDao); + + dpDao = new DataPropertyDaoStub(); + wdf.setDataPropertyDao(dpDao); + + opDao = new ObjectPropertyDaoStub(); + wdf.setObjectPropertyDao(opDao); + + filter = new HiddenFromDisplayBelowRoleLevelFilter( + this.testData.getRoleLevel(), wdf); + } + + @Test + public void runTest() throws Exception { + try { + if (testData instanceof IndividualTestData) { + runIndividualTest(); + } else if (testData instanceof VClassTestData) { + runVClassTest(); + } else if (testData instanceof DataPropertyTestData) { + runDataPropertyTest(); + } else if (testData instanceof ObjectPropertyTestData) { + runObjectPropertyTest(); + } else if (testData instanceof DataPropertyStatementTestData) { + runDataPropertyStatementTest(); + } else if (testData instanceof ObjectPropertyStatementTestData) { + runObjectPropertyStatementTest(); + } else { + fail("Unrecognized test data: " + testData); + } + } catch (Exception e) { + fail("Exception " + e + " in test: " + testData.describeTest()); + } + } + + private void runIndividualTest() { + IndividualTestData data = (IndividualTestData) this.testData; + boolean expected = data.expectedResult; + boolean actual = filter.getIndividualFilter().fn(data.individual); + + log.debug("expect '" + expected + "' for " + data.describeTest()); + assertEquals(data.describeTest(), expected, actual); + } + + private void runVClassTest() { + VClassTestData data = (VClassTestData) this.testData; + boolean expected = data.expectedResult; + boolean actual = filter.getClassFilter().fn(data.vClass); + + log.debug("expect '" + expected + "' for " + data.describeTest()); + assertEquals(data.describeTest(), expected, actual); + } + + private void runDataPropertyTest() { + DataPropertyTestData data = (DataPropertyTestData) this.testData; + boolean expected = data.expectedResult; + boolean actual = filter.getDataPropertyFilter().fn(data.dataProperty); + + log.debug("expect '" + expected + "' for " + data.describeTest()); + assertEquals(data.describeTest(), expected, actual); + } + + private void runObjectPropertyTest() { + ObjectPropertyTestData data = (ObjectPropertyTestData) this.testData; + boolean expected = data.expectedResult; + boolean actual = filter.getObjectPropertyFilter().fn( + data.objectProperty); + + log.debug("expect '" + expected + "' for " + data.describeTest()); + assertEquals(data.describeTest(), expected, actual); + } + + private void runDataPropertyStatementTest() { + DataPropertyStatementTestData data = (DataPropertyStatementTestData) this.testData; + + DataPropertyStatement dps = new DataPropertyStatementImpl(); + dps.setIndividual(data.subject); + if (data.subject != null) { + dps.setIndividualURI(data.subject.getURI()); + indDao.addIndividual(data.subject); + } + + if (data.predicate != null) { + dps.setDatapropURI(data.predicate.getURI()); + dpDao.addDataProperty(data.predicate); + } + + dps.setData("bogus data"); + + boolean expected = data.expectedResult; + boolean actual = filter.getDataPropertyStatementFilter().fn(dps); + + log.debug("expect '" + expected + "' for " + data.describeTest()); + assertEquals(data.describeTest(), expected, actual); + } + + private void runObjectPropertyStatementTest() { + ObjectPropertyStatementTestData data = (ObjectPropertyStatementTestData) this.testData; + + ObjectPropertyStatement ops = new ObjectPropertyStatementImpl(); + ops.setSubject(data.subject); + if (data.subject != null) { + ops.setSubjectURI(data.subject.getURI()); + indDao.addIndividual(data.subject); + } + + ops.setProperty(data.predicate); + if (data.predicate != null) { + ops.setPropertyURI(data.predicate.getURI()); + opDao.addObjectProperty(data.predicate); + } + + ops.setObject(data.object); + if (data.object != null) { + ops.setObjectURI(data.object.getURI()); + indDao.addIndividual(data.object); + } + + boolean expected = data.expectedResult; + boolean actual = filter.getObjectPropertyStatementFilter().fn(ops); + + log.debug("expect '" + expected + "' for " + data.describeTest()); + assertEquals(data.describeTest(), expected, actual); + } +} diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromEditRoleFilterTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromEditRoleFilterTest.java deleted file mode 100644 index 2cfbe8478..000000000 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/dao/filtering/filters/HiddenFromEditRoleFilterTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.dao.filtering.filters; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -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.beans.DataProperty; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; -import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; -import edu.cornell.mannlib.vitro.webapp.beans.VClass; -import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; - -public class HiddenFromEditRoleFilterTest { - - - OntModel testModel; - WebappDaoFactory wdf; - - @Before - public void setUp() throws Exception { - Model model = ModelFactory.createDefaultModel(); - InputStream in = HiddenFromDisplayBelowRoleLevelFilter.class.getResourceAsStream("./filtertesting.rdf"); - model.read(in,null); - testModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,model); - wdf = new WebappDaoFactoryJena(testModel,"http://example.org/test/1.0/",null,null); - - } - - @Test - public void testCuratorLevelRoleFilter(){ - HiddenFromDisplayBelowRoleLevelFilter filter = new HiddenFromDisplayBelowRoleLevelFilter(RoleLevel.CURATOR, wdf); - Assert.assertNotNull(filter); - - Individual ind = new IndividualImpl(); - - List vcs = new ArrayList(); - VClass vc = new VClass() ; - vc.setHiddenFromDisplayBelowRoleLevel(RoleLevel.PUBLIC); - vcs.add( vc ); - ind.setVClasses(vcs, true); - vc = new VClass() ; - vc.setHiddenFromDisplayBelowRoleLevel(RoleLevel.PUBLIC); - vcs.add( vc ); - ind.setVClasses(vcs, true); - - Assert.assertTrue( filter.individualFilter.fn(ind) ); - - ind.setHiddenFromDisplayBelowRoleLevel(RoleLevel.PUBLIC); - Assert.assertTrue( filter.individualFilter.fn(ind) ); - - ind.setHiddenFromDisplayBelowRoleLevel(RoleLevel.DB_ADMIN); - Assert.assertFalse( filter.individualFilter.fn(ind) ); - - - //classes can force an individual to be hidden - ind.setHiddenFromDisplayBelowRoleLevel(RoleLevel.PUBLIC); - vc.setHiddenFromDisplayBelowRoleLevel(RoleLevel.DB_ADMIN); -// Assert.assertFalse( filter.individualFilter.fn(ind) ); - - Assert.assertFalse( filter.classFilter.fn( vc ) ); - vc.setHiddenFromDisplayBelowRoleLevel(RoleLevel.CURATOR); - Assert.assertTrue( filter.classFilter.fn( vc ) ); - - DataProperty dp = new DataProperty(); - Assert.assertTrue( filter.dataPropertyFilter.fn(dp) ); - dp.setHiddenFromDisplayBelowRoleLevel(RoleLevel.PUBLIC); - Assert.assertTrue( filter.dataPropertyFilter.fn(dp) ); - dp.setHiddenFromDisplayBelowRoleLevel(RoleLevel.DB_ADMIN); - Assert.assertFalse( filter.dataPropertyFilter.fn(dp) ); - - } -} diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/DataPropertyDaoStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/DataPropertyDaoStub.java new file mode 100644 index 000000000..53faa0201 --- /dev/null +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/DataPropertyDaoStub.java @@ -0,0 +1,256 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package stubs.edu.cornell.mannlib.vitro.webapp.dao; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.Property; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.InsertException; + +/** + * A minimal implementation of the DataPropertyDao. + * + * I have only implemented the methods that I needed. Feel free to implement + * others. + */ +public class DataPropertyDaoStub implements DataPropertyDao { + // ---------------------------------------------------------------------- + // Stub infrastructure + // ---------------------------------------------------------------------- + + private final Map dpMap = new HashMap(); + + public void addDataProperty(DataProperty dataProperty) { + if (dataProperty == null) { + throw new NullPointerException("dataProperty may not be null."); + } + + String uri = dataProperty.getURI(); + if (uri == null) { + throw new NullPointerException("uri may not be null."); + } + + dpMap.put(uri, dataProperty); + } + + // ---------------------------------------------------------------------- + // Stub methods + // ---------------------------------------------------------------------- + + @Override + public DataProperty getDataPropertyByURI(String dataPropertyURI) { + return dpMap.get(dataPropertyURI); + } + + // ---------------------------------------------------------------------- + // Un-implemented methods + // ---------------------------------------------------------------------- + + @Override + public void addSuperproperty(Property property, Property superproperty) { + throw new RuntimeException( + "PropertyDao.addSuperproperty() not implemented."); + } + + @Override + public void addSuperproperty(String propertyURI, String superpropertyURI) { + throw new RuntimeException( + "PropertyDao.addSuperproperty() not implemented."); + } + + @Override + public void removeSuperproperty(Property property, Property superproperty) { + throw new RuntimeException( + "PropertyDao.removeSuperproperty() not implemented."); + } + + @Override + public void removeSuperproperty(String propertyURI, String superpropertyURI) { + throw new RuntimeException( + "PropertyDao.removeSuperproperty() not implemented."); + } + + @Override + public void addSubproperty(Property property, Property subproperty) { + throw new RuntimeException( + "PropertyDao.addSubproperty() not implemented."); + } + + @Override + public void addSubproperty(String propertyURI, String subpropertyURI) { + throw new RuntimeException( + "PropertyDao.addSubproperty() not implemented."); + } + + @Override + public void removeSubproperty(Property property, Property subproperty) { + throw new RuntimeException( + "PropertyDao.removeSubproperty() not implemented."); + } + + @Override + public void removeSubproperty(String propertyURI, String subpropertyURI) { + throw new RuntimeException( + "PropertyDao.removeSubproperty() not implemented."); + } + + @Override + public void addEquivalentProperty(String propertyURI, + String equivalentPropertyURI) { + throw new RuntimeException( + "PropertyDao.addEquivalentProperty() not implemented."); + } + + @Override + public void addEquivalentProperty(Property property, + Property equivalentProperty) { + throw new RuntimeException( + "PropertyDao.addEquivalentProperty() not implemented."); + } + + @Override + public void removeEquivalentProperty(String propertyURI, + String equivalentPropertyURI) { + throw new RuntimeException( + "PropertyDao.removeEquivalentProperty() not implemented."); + } + + @Override + public void removeEquivalentProperty(Property property, + Property equivalentProperty) { + throw new RuntimeException( + "PropertyDao.removeEquivalentProperty() not implemented."); + } + + @Override + public List getSubPropertyURIs(String propertyURI) { + throw new RuntimeException( + "PropertyDao.getSubPropertyURIs() not implemented."); + } + + @Override + public List getAllSubPropertyURIs(String propertyURI) { + throw new RuntimeException( + "PropertyDao.getAllSubPropertyURIs() not implemented."); + } + + @Override + public List getSuperPropertyURIs(String propertyURI, boolean direct) { + throw new RuntimeException( + "PropertyDao.getSuperPropertyURIs() not implemented."); + } + + @Override + public List getAllSuperPropertyURIs(String propertyURI) { + throw new RuntimeException( + "PropertyDao.getAllSuperPropertyURIs() not implemented."); + } + + @Override + public List getEquivalentPropertyURIs(String propertyURI) { + throw new RuntimeException( + "PropertyDao.getEquivalentPropertyURIs() not implemented."); + } + + @Override + public List getClassesWithRestrictionOnProperty(String propertyURI) { + throw new RuntimeException( + "PropertyDao.getClassesWithRestrictionOnProperty() not implemented."); + } + + @Override + public List getAllDataProperties() { + throw new RuntimeException( + "DataPropertyDao.getAllDataProperties() not implemented."); + } + + @Override + public List getAllExternalIdDataProperties() { + throw new RuntimeException( + "DataPropertyDao.getAllExternalIdDataProperties() not implemented."); + } + + @Override + public void fillDataPropertiesForIndividual(Individual individual) { + throw new RuntimeException( + "DataPropertyDao.fillDataPropertiesForIndividual() not implemented."); + } + + @Override + public List getDataPropertiesForVClass(String vClassURI) { + throw new RuntimeException( + "DataPropertyDao.getDataPropertiesForVClass() not implemented."); + } + + @Override + public Collection getAllPossibleDatapropsForIndividual( + String individualURI) { + throw new RuntimeException( + "DataPropertyDao.getAllPossibleDatapropsForIndividual() not implemented."); + } + + @Override + public String getRequiredDatatypeURI(Individual individual, + DataProperty dataProperty) { + throw new RuntimeException( + "DataPropertyDao.getRequiredDatatypeURI() not implemented."); + } + + @Override + public String insertDataProperty(DataProperty dataProperty) + throws InsertException { + throw new RuntimeException( + "DataPropertyDao.insertDataProperty() not implemented."); + } + + @Override + public void updateDataProperty(DataProperty dataProperty) { + throw new RuntimeException( + "DataPropertyDao.updateDataProperty() not implemented."); + } + + @Override + public void deleteDataProperty(DataProperty dataProperty) { + throw new RuntimeException( + "DataPropertyDao.deleteDataProperty() not implemented."); + } + + @Override + public void deleteDataProperty(String dataPropertyURI) { + throw new RuntimeException( + "DataPropertyDao.deleteDataProperty() not implemented."); + } + + @Override + public List getRootDataProperties() { + throw new RuntimeException( + "DataPropertyDao.getRootDataProperties() not implemented."); + } + + @Override + public boolean annotateDataPropertyAsExternalIdentifier( + String dataPropertyURI) { + throw new RuntimeException( + "DataPropertyDao.annotateDataPropertyAsExternalIdentifier() not implemented."); + } + + @Override + public List getDataPropertyList(Individual subject) { + throw new RuntimeException( + "DataPropertyDao.getDataPropertyList() not implemented."); + } + + @Override + public List getDataPropertyList(String subjectUri) { + throw new RuntimeException( + "DataPropertyDao.getDataPropertyList() not implemented."); + } + +} diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/IndividualDaoStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/IndividualDaoStub.java new file mode 100644 index 000000000..d47625f4f --- /dev/null +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/IndividualDaoStub.java @@ -0,0 +1,245 @@ +package stubs.edu.cornell.mannlib.vitro.webapp.dao; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.Keyword; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; +import edu.cornell.mannlib.vitro.webapp.dao.InsertException; + +/** + * A minimal implementation of the IndividualDao. + * + * I have only implemented the methods that I needed. Feel free to implement + * others. + */ +public class IndividualDaoStub implements IndividualDao { + // ---------------------------------------------------------------------- + // Stub infrastructure + // ---------------------------------------------------------------------- + + private final Map indMap = new HashMap(); + + public void addIndividual(Individual individual) { + if (individual == null) { + throw new NullPointerException("individual may not be null."); + } + + String uri = individual.getURI(); + if (uri == null) { + throw new NullPointerException("uri may not be null."); + } + + indMap.put(uri, individual); + } + + // ---------------------------------------------------------------------- + // Stub methods + // ---------------------------------------------------------------------- + + @Override + public Individual getIndividualByURI(String individualURI) { + return indMap.get(individualURI); + } + + // ---------------------------------------------------------------------- + // Un-implemented methods + // ---------------------------------------------------------------------- + + @Override + public Collection getExternalIds(String individualURI) { + throw new RuntimeException( + "IndividualDaoStub.getExternalIds() not implemented."); + } + + @Override + public Collection getExternalIds( + String individualURI, String dataPropertyURI) { + throw new RuntimeException( + "IndividualDaoStub.getExternalIds() not implemented."); + } + + @Override + public void addVClass(String individualURI, String vclassURI) { + throw new RuntimeException( + "IndividualDaoStub.addVClass() not implemented."); + } + + @Override + public void removeVClass(String individualURI, String vclassURI) { + throw new RuntimeException( + "IndividualDaoStub.removeVClass() not implemented."); + } + + @Override + public List getIndividualsByVClass(VClass vclass) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualsByVClass() not implemented."); + } + + @Override + public List getIndividualsByVClassURI(String vclassURI) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualsByVClassURI() not implemented."); + } + + @Override + public List getIndividualsByVClassURI(String vclassURI, + int offset, int quantity) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualsByVClassURI() not implemented."); + } + + @Override + public String insertNewIndividual(Individual individual) + throws InsertException { + throw new RuntimeException( + "IndividualDaoStub.insertNewIndividual() not implemented."); + } + + @Override + public int updateIndividual(Individual individual) { + throw new RuntimeException( + "IndividualDaoStub.updateIndividual() not implemented."); + } + + @Override + public int deleteIndividual(String individualURI) { + throw new RuntimeException( + "IndividualDaoStub.deleteIndividual() not implemented."); + } + + @Override + public int deleteIndividual(Individual individual) { + throw new RuntimeException( + "IndividualDaoStub.deleteIndividual() not implemented."); + } + + @Override + public void markModified(Individual individual) { + throw new RuntimeException( + "IndividualDaoStub.markModified() not implemented."); + } + + @Override + public Iterator getAllOfThisTypeIterator() { + throw new RuntimeException( + "IndividualDaoStub.getAllOfThisTypeIterator() not implemented."); + } + + @Override + public Iterator getAllOfThisVClassIterator(String vClassURI) { + throw new RuntimeException( + "IndividualDaoStub.getAllOfThisVClassIterator() not implemented."); + } + + @Override + public Iterator getUpdatedSinceIterator(long updatedSince) { + throw new RuntimeException( + "IndividualDaoStub.getUpdatedSinceIterator() not implemented."); + } + + @Override + public int getCountOfIndividualsInVClass(String vclassURI) { + throw new RuntimeException( + "IndividualDaoStub.getCountOfIndividualsInVClass() not implemented."); + } + + @Override + public boolean isIndividualOfClass(String vclassURI, String indURI) { + throw new RuntimeException( + "IndividualDaoStub.isIndividualOfClass() not implemented."); + } + + @Override + public List getIndividualsByDataProperty( + String dataPropertyUri, String value) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualsByDataProperty() not implemented."); + } + + @Override + public List getIndividualsByDataProperty( + String dataPropertyUri, String value, String datatypeUri, + String lang) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualsByDataProperty() not implemented."); + } + + @Override + public void fillVClassForIndividual(Individual individual) { + throw new RuntimeException( + "IndividualDaoStub.fillVClassForIndividual() not implemented."); + } + + @Override + public List monikers(String vclassURI) { + throw new RuntimeException( + "IndividualDaoStub.monikers() not implemented."); + } + + @Override + public List getKeywordsForIndividual(String individualURI) { + throw new RuntimeException( + "IndividualDaoStub.getKeywordsForIndividual() not implemented."); + } + + @Override + public List getKeywordsForIndividualByMode(String individualURI, + String modeStr) { + throw new RuntimeException( + "IndividualDaoStub.getKeywordsForIndividualByMode() not implemented."); + } + + @Override + public List getKeywordObjectsForIndividual(String individualURI) { + throw new RuntimeException( + "IndividualDaoStub.getKeywordObjectsForIndividual() not implemented."); + } + + @Override + public String getIndividualURIFromNetId(String netIdStr, + String netidMatchingPropertyUri) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualURIFromNetId() not implemented."); + } + + @Override + public String getNetId(String entityURI) { + throw new RuntimeException( + "IndividualDaoStub.getNetId() not implemented."); + } + + @Override + public String getStatus(String entityURI) { + throw new RuntimeException( + "IndividualDaoStub.getStatus() not implemented."); + } + + @Override + public String getUnusedURI(Individual individual) throws InsertException { + throw new RuntimeException( + "IndividualDaoStub.getUnusedURI() not implemented."); + } + + @Override + public Individual getIndividualByExternalId(int externalIdType, + String externalIdValue) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualByExternalId() not implemented."); + } + + @Override + public Individual getIndividualByExternalId(int externalIdType, + String externalIdValue, String vClassURI) { + throw new RuntimeException( + "IndividualDaoStub.getIndividualByExternalId() not implemented."); + } + +} diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/ObjectPropertyDaoStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/ObjectPropertyDaoStub.java new file mode 100644 index 000000000..1553cb422 --- /dev/null +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/ObjectPropertyDaoStub.java @@ -0,0 +1,248 @@ +package stubs.edu.cornell.mannlib.vitro.webapp.dao; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; +import edu.cornell.mannlib.vitro.webapp.beans.Property; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.dao.InsertException; +import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; + +/** + * A minimal implementation of the ObjectPropertyDao. + * + * I have only implemented the methods that I needed. Feel free to implement + * others. + */ +public class ObjectPropertyDaoStub implements ObjectPropertyDao { + // ---------------------------------------------------------------------- + // Stub infrastructure + // ---------------------------------------------------------------------- + + private final Map opMap = new HashMap(); + + public void addObjectProperty(ObjectProperty predicate) { + if (predicate == null) { + throw new NullPointerException("predicate may not be null."); + } + + String uri = predicate.getURI(); + if (uri == null) { + throw new NullPointerException("uri may not be null."); + } + + opMap.put(uri, predicate); + } + + // ---------------------------------------------------------------------- + // Stub methods + // ---------------------------------------------------------------------- + + @Override + public ObjectProperty getObjectPropertyByURI(String objectPropertyURI) { + return opMap.get(objectPropertyURI); + } + + // ---------------------------------------------------------------------- + // Un-implemented methods + // ---------------------------------------------------------------------- + + @Override + public void addSuperproperty(Property property, Property superproperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.addSuperproperty() not implemented."); + } + + @Override + public void addSuperproperty(String propertyURI, String superpropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.addSuperproperty() not implemented."); + } + + @Override + public void removeSuperproperty(Property property, Property superproperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.removeSuperproperty() not implemented."); + } + + @Override + public void removeSuperproperty(String propertyURI, String superpropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.removeSuperproperty() not implemented."); + } + + @Override + public void addSubproperty(Property property, Property subproperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.addSubproperty() not implemented."); + } + + @Override + public void addSubproperty(String propertyURI, String subpropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.addSubproperty() not implemented."); + } + + @Override + public void removeSubproperty(Property property, Property subproperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.removeSubproperty() not implemented."); + } + + @Override + public void removeSubproperty(String propertyURI, String subpropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.removeSubproperty() not implemented."); + } + + @Override + public void addEquivalentProperty(String propertyURI, + String equivalentPropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.addEquivalentProperty() not implemented."); + } + + @Override + public void addEquivalentProperty(Property property, + Property equivalentProperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.addEquivalentProperty() not implemented."); + } + + @Override + public void removeEquivalentProperty(String propertyURI, + String equivalentPropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.removeEquivalentProperty() not implemented."); + } + + @Override + public void removeEquivalentProperty(Property property, + Property equivalentProperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.removeEquivalentProperty() not implemented."); + } + + @Override + public List getAllSubPropertyURIs(String propertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getAllSubPropertyURIs() not implemented."); + } + + @Override + public List getAllSuperPropertyURIs(String propertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getAllSuperPropertyURIs() not implemented."); + } + + @Override + public List getEquivalentPropertyURIs(String propertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getEquivalentPropertyURIs() not implemented."); + } + + @Override + public List getClassesWithRestrictionOnProperty(String propertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getClassesWithRestrictionOnProperty() not implemented."); + } + + @Override + public List getAllObjectProperties() { + throw new RuntimeException( + "ObjectPropertyDaoStub.getAllObjectProperties() not implemented."); + } + + @Override + public List getObjectPropertiesForObjectPropertyStatements( + List objectPropertyStatements) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getObjectPropertiesForObjectPropertyStatements() not implemented."); + } + + @Override + public List getSuperPropertyURIs(String objectPropertyURI, + boolean direct) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getSuperPropertyURIs() not implemented."); + } + + @Override + public List getSubPropertyURIs(String objectPropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getSubPropertyURIs() not implemented."); + } + + @Override + public List getStatementsUsingObjectProperty( + ObjectProperty op) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getStatementsUsingObjectProperty() not implemented."); + } + + @Override + public void fillObjectPropertiesForIndividual(Individual individual) { + throw new RuntimeException( + "ObjectPropertyDaoStub.fillObjectPropertiesForIndividual() not implemented."); + } + + @Override + public int insertObjectProperty(ObjectProperty objectProperty) + throws InsertException { + throw new RuntimeException( + "ObjectPropertyDaoStub.insertObjectProperty() not implemented."); + } + + @Override + public void updateObjectProperty(ObjectProperty objectProperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.updateObjectProperty() not implemented."); + } + + @Override + public void deleteObjectProperty(String objectPropertyURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.deleteObjectProperty() not implemented."); + } + + @Override + public void deleteObjectProperty(ObjectProperty objectProperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.deleteObjectProperty() not implemented."); + } + + @Override + public boolean skipEditForm(String predicateURI) { + throw new RuntimeException( + "ObjectPropertyDaoStub.skipEditForm() not implemented."); + } + + @Override + public List getRootObjectProperties() { + throw new RuntimeException( + "ObjectPropertyDaoStub.getRootObjectProperties() not implemented."); + } + + @Override + public List getObjectPropertyList(Individual subject) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getObjectPropertyList() not implemented."); + } + + @Override + public List getObjectPropertyList(String subjectUri) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getObjectPropertyList() not implemented."); + } + + @Override + public String getCustomListViewConfigFileName(ObjectProperty objectProperty) { + throw new RuntimeException( + "ObjectPropertyDaoStub.getCustomListViewConfigFileName() not implemented."); + } + +} diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java new file mode 100644 index 000000000..b85b29dea --- /dev/null +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/WebappDaoFactoryStub.java @@ -0,0 +1,297 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package stubs.edu.cornell.mannlib.vitro.webapp.dao; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao; +import edu.cornell.mannlib.vitro.webapp.dao.Classes2ClassesDao; +import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao; +import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; +import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao; +import edu.cornell.mannlib.vitro.webapp.dao.FlagDao; +import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; +import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao; +import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao; +import edu.cornell.mannlib.vitro.webapp.dao.LinksDao; +import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao; +import edu.cornell.mannlib.vitro.webapp.dao.MenuDao; +import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao; +import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; +import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; +import edu.cornell.mannlib.vitro.webapp.dao.PageDao; +import edu.cornell.mannlib.vitro.webapp.dao.PortalDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; +import edu.cornell.mannlib.vitro.webapp.dao.TabDao; +import edu.cornell.mannlib.vitro.webapp.dao.TabIndividualRelationDao; +import edu.cornell.mannlib.vitro.webapp.dao.TabVClassRelationDao; +import edu.cornell.mannlib.vitro.webapp.dao.UserDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; +import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; +import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; + +/** + * A minimal implementation of the WebappDaoFactory. + * + * I have only implemented the methods that I needed. Feel free to implement + * others. + */ +public class WebappDaoFactoryStub implements WebappDaoFactory { + // ---------------------------------------------------------------------- + // Stub infrastructure + // ---------------------------------------------------------------------- + + private IndividualDao individualDao; + private DataPropertyDao dataPropertyDao; + private ObjectPropertyDao objectPropertyDao; + + public void setIndividualDao(IndividualDao individualDao) { + this.individualDao = individualDao; + } + + public void setDataPropertyDao(DataPropertyDao dataPropertyDao) { + this.dataPropertyDao = dataPropertyDao; + } + + public void setObjectPropertyDao(ObjectPropertyDao objectPropertyDao) { + this.objectPropertyDao = objectPropertyDao; + } + + // ---------------------------------------------------------------------- + // Stub methods + // ---------------------------------------------------------------------- + + @Override + public IndividualDao getIndividualDao() { + return this.individualDao; + } + + @Override + public DataPropertyDao getDataPropertyDao() { + return this.dataPropertyDao; + } + + @Override + public ObjectPropertyDao getObjectPropertyDao() { + return this.objectPropertyDao; + } + + // ---------------------------------------------------------------------- + // Un-implemented methods + // ---------------------------------------------------------------------- + + @Override + public Map getProperties() { + throw new RuntimeException( + "WebappDaoFactory.getProperties() not implemented."); + } + + @Override + public String checkURI(String uriStr) { + throw new RuntimeException( + "WebappDaoFactory.checkURI() not implemented."); + } + + @Override + public String checkURI(String uriStr, boolean checkUniqueness) { + throw new RuntimeException( + "WebappDaoFactory.checkURI() not implemented."); + } + + @Override + public int getLanguageProfile() { + throw new RuntimeException( + "WebappDaoFactory.getLanguageProfile() not implemented."); + } + + @Override + public String getDefaultNamespace() { + throw new RuntimeException( + "WebappDaoFactory.getDefaultNamespace() not implemented."); + } + + @Override + public Set getNonuserNamespaces() { + throw new RuntimeException( + "WebappDaoFactory.getNonuserNamespaces() not implemented."); + } + + @Override + public String[] getPreferredLanguages() { + throw new RuntimeException( + "WebappDaoFactory.getPreferredLanguages() not implemented."); + } + + @Override + public List getCommentsForResource(String resourceURI) { + throw new RuntimeException( + "WebappDaoFactory.getCommentsForResource() not implemented."); + } + + @Override + public WebappDaoFactory getUserAwareDaoFactory(String userURI) { + throw new RuntimeException( + "WebappDaoFactory.getUserAwareDaoFactory() not implemented."); + } + + @Override + public String getUserURI() { + throw new RuntimeException( + "WebappDaoFactory.getUserURI() not implemented."); + } + + @Override + public Classes2ClassesDao getClasses2ClassesDao() { + throw new RuntimeException( + "WebappDaoFactory.getClasses2ClassesDao() not implemented."); + } + + @Override + public DatatypeDao getDatatypeDao() { + throw new RuntimeException( + "WebappDaoFactory.getDatatypeDao() not implemented."); + } + + @Override + public OntologyDao getOntologyDao() { + throw new RuntimeException( + "WebappDaoFactory.getOntologyDao() not implemented."); + } + + @Override + public VClassDao getVClassDao() { + throw new RuntimeException( + "WebappDaoFactory.getVClassDao() not implemented."); + } + + @Override + public DataPropertyStatementDao getDataPropertyStatementDao() { + throw new RuntimeException( + "WebappDaoFactory.getDataPropertyStatementDao() not implemented."); + } + + @Override + public ObjectPropertyStatementDao getObjectPropertyStatementDao() { + throw new RuntimeException( + "WebappDaoFactory.getObjectPropertyStatementDao() not implemented."); + } + + @Override + public DisplayModelDao getDisplayModelDao() { + throw new RuntimeException( + "WebappDaoFactory.getDisplayModelDao() not implemented."); + } + + @Override + public ApplicationDao getApplicationDao() { + throw new RuntimeException( + "WebappDaoFactory.getApplicationDao() not implemented."); + } + + @Override + public PortalDao getPortalDao() { + throw new RuntimeException( + "WebappDaoFactory.getPortalDao() not implemented."); + } + + @Override + public TabDao getTabDao() { + throw new RuntimeException( + "WebappDaoFactory.getTabDao() not implemented."); + } + + @Override + public TabIndividualRelationDao getTabs2EntsDao() { + throw new RuntimeException( + "WebappDaoFactory.getTabs2EntsDao() not implemented."); + } + + @Override + public TabVClassRelationDao getTabs2TypesDao() { + throw new RuntimeException( + "WebappDaoFactory.getTabs2TypesDao() not implemented."); + } + + @Override + public KeywordIndividualRelationDao getKeys2EntsDao() { + throw new RuntimeException( + "WebappDaoFactory.getKeys2EntsDao() not implemented."); + } + + @Override + public KeywordDao getKeywordDao() { + throw new RuntimeException( + "WebappDaoFactory.getKeywordDao() not implemented."); + } + + @Override + public LinksDao getLinksDao() { + throw new RuntimeException( + "WebappDaoFactory.getLinksDao() not implemented."); + } + + @Override + public LinktypeDao getLinktypeDao() { + throw new RuntimeException( + "WebappDaoFactory.getLinktypeDao() not implemented."); + } + + @Override + public FlagDao getFlagDao() { + throw new RuntimeException( + "WebappDaoFactory.getFlagDao() not implemented."); + } + + @Override + public UserDao getUserDao() { + throw new RuntimeException( + "WebappDaoFactory.getUserDao() not implemented."); + } + + @Override + public VClassGroupDao getVClassGroupDao() { + throw new RuntimeException( + "WebappDaoFactory.getVClassGroupDao() not implemented."); + } + + @Override + public PropertyGroupDao getPropertyGroupDao() { + throw new RuntimeException( + "WebappDaoFactory.getPropertyGroupDao() not implemented."); + } + + @Override + public NamespaceDao getNamespaceDao() { + throw new RuntimeException( + "WebappDaoFactory.getNamespaceDao() not implemented."); + } + + @Override + public PropertyInstanceDao getPropertyInstanceDao() { + throw new RuntimeException( + "WebappDaoFactory.getPropertyInstanceDao() not implemented."); + } + + @Override + public PageDao getPageDao() { + throw new RuntimeException( + "WebappDaoFactory.getPageDao() not implemented."); + } + + @Override + public MenuDao getMenuDao() { + throw new RuntimeException( + "WebappDaoFactory.getMenuDao() not implemented."); + } + + @Override + public void close() { + throw new RuntimeException("WebappDaoFactory.close() not implemented."); + } + +}