Add dependent resources annotation to back end editing for object properties. NIHVIVO-212

This commit is contained in:
bdc34 2010-03-30 20:00:17 +00:00
parent 2ff288b4b1
commit e50a1bc6f5
13 changed files with 73 additions and 32 deletions

View file

@ -18,10 +18,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
public class DependentResourceDeleteJenaTest {
String isDependentRelation =
" <"+VitroVocabulary.PROPERTY_DEPENDENCYPROPERTYANNOT+"> \"true\"^^xsd:boolean .\n" ;
" <"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> \"true\"^^xsd:boolean .\n" ;
String nosePropIsDependentRel =
"<"+VitroVocabulary.PROPERTY_DEPENDENCYPROPERTYANNOT+"> rdf:type owl:AnnotationProperty .\n" +
"<"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> rdf:type owl:AnnotationProperty .\n" +
" ex:hasNose " + isDependentRelation;
String prefixesN3 =

View file

@ -33,10 +33,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
public class JenaBaseDaoTest {
String isDependentRelation =
" <"+VitroVocabulary.PROPERTY_DEPENDENCYPROPERTYANNOT+"> \"true\"^^xsd:boolean .\n" ;
" <"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> \"true\"^^xsd:boolean .\n" ;
String nosePropIsDependentRel =
"<"+VitroVocabulary.PROPERTY_DEPENDENCYPROPERTYANNOT+"> rdf:type owl:AnnotationProperty .\n" +
"<"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> rdf:type owl:AnnotationProperty .\n" +
" ex:hasNose " + isDependentRelation;
String prefixesN3 =
@ -104,7 +104,7 @@ public class JenaBaseDaoTest {
"<http://example.com/prop1> " +
" a owl:ObjectProperty ; " +
" rdfs:label \"Prop 1 Dependent Relation\" ; " +
" <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#dependencyPropertyAnnot> \"true\"^^xsd:boolean ." ;
isDependentRelation ;
Model expectedModel = (ModelFactory.createOntologyModel()).read(new StringReader(expected), "", "N3");
@ -185,7 +185,7 @@ public class JenaBaseDaoTest {
"<http://example.com/prop1> " +
" a owl:ObjectProperty ; " +
" rdfs:label \"Prop 1 Dependent Relation\" ; " +
" <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#dependencyPropertyAnnot> \"true\"^^xsd:boolean ." ;
isDependentRelation ;
Model expectedModel = (ModelFactory.createOntologyModel()).read(new StringReader(expected), "", "N3");
@ -193,6 +193,11 @@ public class JenaBaseDaoTest {
wipeOutModTime(expectedModel);
wipeOutModTime(model);
System.out.println("expected Model" );
expectedModel.write(System.out,"N3");
System.out.println("result model");
model.write(System.out,"N3");
Assert.assertTrue( model.isIsomorphicWith(expectedModel));
}

View file

@ -49,4 +49,39 @@ public class ObjectPropertyDaoJenaTest {
Assert.fail(e.getMessage());
}
}
@Test
public void testStubObjectProperty(){
/* Check that we can save collateBySubclass */
OntModel model = ModelFactory.createOntologyModel();
WebappDaoFactory wdf = new WebappDaoFactoryJena(model);
ObjectProperty op1 = new ObjectProperty();
String propURI = "http://example.com/testObjectProp" ;
op1.setURI(propURI);
Assert.assertFalse(op1.getStubObjectRelation());
try {
wdf.getObjectPropertyDao().insertObjectProperty(op1);
ObjectProperty op2 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
Assert.assertNotNull(op2);
Assert.assertFalse(op2.getStubObjectRelation());
op2.setStubObjectRelation(true);
wdf.getObjectPropertyDao().updateObjectProperty(op2);
ObjectProperty op3 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
Assert.assertNotNull(op3);
Assert.assertTrue(op3.getStubObjectRelation());
op3.setStubObjectRelation(false);
wdf.getObjectPropertyDao().updateObjectProperty(op3);
ObjectProperty op4 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
Assert.assertNotNull(op4);
Assert.assertFalse(op4.getStubObjectRelation());
} catch (InsertException e) {
Assert.fail(e.getMessage());
}
}
}