diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java index 82f177ddf..ba0766626 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java @@ -910,6 +910,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp " ?context config:hasConfiguration ?configuration . \n" + " ?context config:configContextFor ?property . \n" + " ?context config:qualifiedBy ?range . \n" + + " OPTIONAL { ?context config:qualifiedByDomain ?domain } \n" + " } \n" + "}"; @@ -925,14 +926,15 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp //TODO private void addPropertyClassCombinationsToListViewMap(HashMap) - // Map key is pair of object property and range class URI - // If range is unspecified, OWL.Thing.getURI() is used in the key. - Map, String> customListViewConfigFileMap = null; + // Map key is inner pair of object property and range class URI, + // with first member of outer pair being a domain class URI. + // If domain or range is unspecified, OWL.Thing.getURI() is used in the key. + Map>, String> customListViewConfigFileMap = null; @Override public String getCustomListViewConfigFileName(ObjectProperty op) { if (customListViewConfigFileMap == null) { - customListViewConfigFileMap = new HashMap, String>(); + customListViewConfigFileMap = new HashMap>, String>(); OntModel displayModel = getOntModelSelector().getDisplayModel(); //Get all property to list view config file mappings in the system QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel); @@ -945,6 +947,10 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp String rangeUri = (rangeNode != null) ? ((Resource) rangeNode).getURI() : OWL.Thing.getURI(); + RDFNode domainNode = soln.get("domain"); + String domainUri = (domainNode != null) + ? ((Resource) domainNode).getURI() + : OWL.Thing.getURI(); ObjectProperty prop = getObjectPropertyByURI(propertyUri); if (prop == null) { //This is a warning only if this property is the one for which we're searching @@ -955,17 +961,24 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp } } else { String filename = soln.getLiteral("filename").getLexicalForm(); - log.debug("putting " + prop.getURI() + " " + rangeUri + " " + filename + " into list view map"); - customListViewConfigFileMap.put(new Pair(prop, rangeUri), filename); + log.debug("putting " + domainUri + " " + prop.getURI() + " " + rangeUri + " " + filename + " into list view map"); + customListViewConfigFileMap.put( + new Pair>( + domainUri, new Pair( + prop, rangeUri)), filename); } } qexec.close(); } - String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair(op, op.getRangeVClassURI())); + String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair>(op.getDomainVClassURI(), new Pair(op, op.getRangeVClassURI()))); if (customListViewConfigFileName == null) { - log.debug("no list view found for " + op.getURI() + " qualified by " + op.getRangeVClassURI()); - customListViewConfigFileName = customListViewConfigFileMap.get(new Pair(op, OWL.Thing.getURI())); + log.debug("no list view found for " + op.getURI() + " qualified by range " + op.getRangeVClassURI() + " and domain " + op.getDomainVClassURI()); + customListViewConfigFileName = customListViewConfigFileMap.get(new Pair>(OWL.Thing.getURI(), new Pair(op, op.getRangeVClassURI()))); + } + if (customListViewConfigFileName == null) { + log.debug("no list view found for " + op.getURI() + " qualified by range " + op.getRangeVClassURI()); + customListViewConfigFileName = customListViewConfigFileMap.get(new Pair>(OWL.Thing.getURI(), new Pair(op, OWL.Thing.getURI()))); } return customListViewConfigFileName; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/ApplicationConfigurationOntologyUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/ApplicationConfigurationOntologyUtils.java index 5ba2bd600..895ad76d6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/ApplicationConfigurationOntologyUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/ApplicationConfigurationOntologyUtils.java @@ -77,8 +77,14 @@ public class ApplicationConfigurationOntologyUtils { QuerySolution qsoln = rs.nextSolution(); log.debug(qsoln); Resource domainRes = qsoln.getResource("domain"); - if(domainRes != null && !appropriateDomain(domainRes, subject, tboxModel)) { - continue; + if(domainRes != null) { + if(!appropriateDomain(domainRes, subject, tboxModel)) { + continue; + } else { + newProp.setDomainVClassURI(domainRes.getURI()); + } + } else { + newProp.setDomainVClassURI(op.getDomainVClassURI()); } Resource rangeRes = qsoln.getResource("range"); if (rangeRes != null) {