modifications for NIHVIVO-246.

changed the getSuperPropertyURIs and getSuperClassURIs methods in the property and class DaoJenas (and the interfaces that they implement, and the filtering code) to take an additional boolean argument named direct and to pass it to the Jena call.

changed the edit controllers to invoke the above methods with direct=false.

changed the recursive methods within the daos to invoke the above methods with direct=true
This commit is contained in:
sjm222 2010-05-14 20:40:19 +00:00
parent 3105e29bca
commit 8d538b5fc6
11 changed files with 20 additions and 19 deletions

View file

@ -138,7 +138,7 @@ public class DatapropEditController extends BaseEditController {
? getAssertionsWebappDaoFactory().getDataPropertyDao() ? getAssertionsWebappDaoFactory().getDataPropertyDao()
: getWebappDaoFactory().getDataPropertyDao(); : getWebappDaoFactory().getDataPropertyDao();
List superURIs = assertionsDpDao.getSuperPropertyURIs(dp.getURI()); List superURIs = assertionsDpDao.getSuperPropertyURIs(dp.getURI(),false);
List superProperties = new ArrayList(); List superProperties = new ArrayList();
Iterator superURIit = superURIs.iterator(); Iterator superURIit = superURIs.iterator();
while (superURIit.hasNext()) { while (superURIit.hasNext()) {

View file

@ -171,7 +171,7 @@ public class PropertyEditController extends BaseEditController {
} else { } else {
opDao = getWebappDaoFactory().getObjectPropertyDao(); opDao = getWebappDaoFactory().getObjectPropertyDao();
} }
List superURIs = opDao.getSuperPropertyURIs(p.getURI()); List superURIs = opDao.getSuperPropertyURIs(p.getURI(),false);
List superProperties = new ArrayList(); List superProperties = new ArrayList();
Iterator superURIit = superURIs.iterator(); Iterator superURIit = superURIs.iterator();
while (superURIit.hasNext()) { while (superURIit.hasNext()) {

View file

@ -150,7 +150,7 @@ public class VclassEditController extends BaseEditController {
} else { } else {
vcDao = getWebappDaoFactory().getVClassDao(); vcDao = getWebappDaoFactory().getVClassDao();
} }
List superURIs = vcDao.getSuperClassURIs(vcl.getURI()); List superURIs = vcDao.getSuperClassURIs(vcl.getURI(),false);
List superVClasses = new ArrayList(); List superVClasses = new ArrayList();
Iterator superURIit = superURIs.iterator(); Iterator superURIit = superURIs.iterator();
while (superURIit.hasNext()) { while (superURIit.hasNext()) {

View file

@ -17,7 +17,7 @@ public interface ObjectPropertyDao extends PropertyDao {
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements); public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements);
public List<String> getSuperPropertyURIs(String objectPropertyURI); public List<String> getSuperPropertyURIs(String objectPropertyURI, boolean direct);
public List<String> getSubPropertyURIs(String objectPropertyURI); public List<String> getSubPropertyURIs(String objectPropertyURI);

View file

@ -37,7 +37,7 @@ public interface PropertyDao {
List <String> getAllSubPropertyURIs(String propertyURI); List <String> getAllSubPropertyURIs(String propertyURI);
List <String> getSuperPropertyURIs(String propertyURI); List <String> getSuperPropertyURIs(String propertyURI, boolean direct);
List <String> getAllSuperPropertyURIs(String propertyURI); List <String> getAllSuperPropertyURIs(String propertyURI);

View file

@ -48,7 +48,7 @@ public interface VClassDao {
List <String> getAllSubClassURIs(String classURI); List <String> getAllSubClassURIs(String classURI);
List <String> getSuperClassURIs(String classURI); List <String> getSuperClassURIs(String classURI, boolean direct);
List <String> getAllSuperClassURIs(String classURI); List <String> getAllSuperClassURIs(String classURI);

View file

@ -133,8 +133,8 @@ class DataPropertyDaoFiltering extends BaseFiltering implements DataPropertyDao{
return innerDataPropertyDao.getAllSubPropertyURIs(propertyURI); return innerDataPropertyDao.getAllSubPropertyURIs(propertyURI);
} }
public List <String> getSuperPropertyURIs(String propertyURI) { public List <String> getSuperPropertyURIs(String propertyURI, boolean direct) {
return innerDataPropertyDao.getSuperPropertyURIs(propertyURI); return innerDataPropertyDao.getSuperPropertyURIs(propertyURI, direct);
} }
public List <String> getAllSuperPropertyURIs(String propertyURI) { public List <String> getAllSuperPropertyURIs(String propertyURI) {

View file

@ -120,8 +120,8 @@ class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectProperty
return innerObjectPropertyDao.getAllSubPropertyURIs(propertyURI); return innerObjectPropertyDao.getAllSubPropertyURIs(propertyURI);
} }
public List <String> getSuperPropertyURIs(String propertyURI) { public List <String> getSuperPropertyURIs(String propertyURI, boolean direct) {
return innerObjectPropertyDao.getSuperPropertyURIs(propertyURI); return innerObjectPropertyDao.getSuperPropertyURIs(propertyURI, direct);
} }
public List <String> getAllSuperPropertyURIs(String propertyURI) { public List <String> getAllSuperPropertyURIs(String propertyURI) {

View file

@ -132,8 +132,8 @@ public class VClassDaoFiltering extends BaseFiltering implements VClassDao{
return innerVClassDao.getSubClassURIs(classURI); return innerVClassDao.getSubClassURIs(classURI);
} }
public List<String> getSuperClassURIs(String classURI) { public List<String> getSuperClassURIs(String classURI, boolean direct) {
return innerVClassDao.getSuperClassURIs(classURI); return innerVClassDao.getSuperClassURIs(classURI, direct);
} }
public VClass getVClassByURI(String URI) { public VClass getVClassByURI(String URI) {

View file

@ -127,11 +127,11 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
return outputList; return outputList;
} }
public List <String> getSuperPropertyURIs(String propertyURI) { public List <String> getSuperPropertyURIs(String propertyURI, boolean direct) {
List<String> supURIs = new LinkedList<String>(); List<String> supURIs = new LinkedList<String>();
getOntModel().enterCriticalSection(Lock.READ); getOntModel().enterCriticalSection(Lock.READ);
try { try {
Iterator supIt = getOntModel().getOntProperty(propertyURI).listSuperProperties(true); Iterator supIt = getOntModel().getOntProperty(propertyURI).listSuperProperties(direct);
while (supIt.hasNext()) { while (supIt.hasNext()) {
try { try {
OntProperty prop = (OntProperty) supIt.next(); OntProperty prop = (OntProperty) supIt.next();
@ -147,7 +147,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
} }
private void getAllSuperPropertyURIs(String propertyURI, HashSet<String> subtree){ private void getAllSuperPropertyURIs(String propertyURI, HashSet<String> subtree){
List<String> directSuperproperties = getSuperPropertyURIs(propertyURI); List<String> directSuperproperties = getSuperPropertyURIs(propertyURI,true);
Iterator<String> it=directSuperproperties.iterator(); Iterator<String> it=directSuperproperties.iterator();
while(it.hasNext()){ while(it.hasNext()){
String uri = (String)it.next(); String uri = (String)it.next();

View file

@ -417,7 +417,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
} }
public void getAllSuperClassURIs(String classURI, HashSet<String> subtree){ public void getAllSuperClassURIs(String classURI, HashSet<String> subtree){
List<String> directSuperclasses = getSuperClassURIs(classURI); List<String> directSuperclasses = getSuperClassURIs(classURI, true);
Iterator<String> it=directSuperclasses.iterator(); Iterator<String> it=directSuperclasses.iterator();
while(it.hasNext()){ while(it.hasNext()){
String uri = (String)it.next(); String uri = (String)it.next();
@ -607,16 +607,17 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
return subURIs; return subURIs;
} }
public List <String> getSuperClassURIs(String classURI) { public List <String> getSuperClassURIs(String classURI, boolean direct) {
List supURIs = new ArrayList(); List supURIs = new ArrayList();
OntClass subClass = getOntClass(getOntModel(), classURI); OntClass subClass = getOntClass(getOntModel(), classURI);
try { try {
Iterator supIt = subClass.listSuperClasses(true); Iterator supIt = subClass.listSuperClasses(direct);
while (supIt.hasNext()) { while (supIt.hasNext()) {
OntClass cls = (OntClass) supIt.next(); OntClass cls = (OntClass) supIt.next();
supURIs.add(getClassURIStr(cls)); supURIs.add(getClassURIStr(cls));
} }
} catch (Exception e) { } catch (Exception e) {
//TODO make this attempt respect the direct argument
// we'll try this again using a different method that doesn't try to convert to OntClass // we'll try this again using a different method that doesn't try to convert to OntClass
List<Resource> supList = this.listDirectObjectPropertyValues(getOntModel().getResource(classURI), RDFS.subClassOf); List<Resource> supList = this.listDirectObjectPropertyValues(getOntModel().getResource(classURI), RDFS.subClassOf);
for (Resource res : supList) { for (Resource res : supList) {
@ -691,7 +692,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
OntResource superclass = null; OntResource superclass = null;
if (vclassURI != null) { if (vclassURI != null) {
// TODO need a getAllSuperPropertyURIs method in ObjectPropertyDao // TODO need a getAllSuperPropertyURIs method in ObjectPropertyDao
List<String> superproperties = getWebappDaoFactory().getObjectPropertyDao().getSuperPropertyURIs(propertyURI); List<String> superproperties = getWebappDaoFactory().getObjectPropertyDao().getSuperPropertyURIs(propertyURI,false);
superproperties.add(propertyURI); superproperties.add(propertyURI);
HashSet<String> subjSuperclasses = new HashSet<String>(getAllSuperClassURIs(vclassURI)); HashSet<String> subjSuperclasses = new HashSet<String>(getAllSuperClassURIs(vclassURI));
subjSuperclasses.add(vclassURI); subjSuperclasses.add(vclassURI);