support for domain qualification in list views

This commit is contained in:
brianjlowe 2013-08-26 16:13:35 -04:00
parent 528283ab16
commit 6869cda316
2 changed files with 30 additions and 11 deletions

View file

@ -910,6 +910,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
" ?context config:hasConfiguration ?configuration . \n" + " ?context config:hasConfiguration ?configuration . \n" +
" ?context config:configContextFor ?property . \n" + " ?context config:configContextFor ?property . \n" +
" ?context config:qualifiedBy ?range . \n" + " ?context config:qualifiedBy ?range . \n" +
" OPTIONAL { ?context config:qualifiedByDomain ?domain } \n" +
" } \n" + " } \n" +
"}"; "}";
@ -925,14 +926,15 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
//TODO private void addPropertyClassCombinationsToListViewMap(HashMap) //TODO private void addPropertyClassCombinationsToListViewMap(HashMap)
// Map key is pair of object property and range class URI // Map key is inner pair of object property and range class URI,
// If range is unspecified, OWL.Thing.getURI() is used in the key. // with first member of outer pair being a domain class URI.
Map<Pair<ObjectProperty, String>, String> customListViewConfigFileMap = null; // If domain or range is unspecified, OWL.Thing.getURI() is used in the key.
Map<Pair<String,Pair<ObjectProperty, String>>, String> customListViewConfigFileMap = null;
@Override @Override
public String getCustomListViewConfigFileName(ObjectProperty op) { public String getCustomListViewConfigFileName(ObjectProperty op) {
if (customListViewConfigFileMap == null) { if (customListViewConfigFileMap == null) {
customListViewConfigFileMap = new HashMap<Pair<ObjectProperty, String>, String>(); customListViewConfigFileMap = new HashMap<Pair<String,Pair<ObjectProperty, String>>, String>();
OntModel displayModel = getOntModelSelector().getDisplayModel(); OntModel displayModel = getOntModelSelector().getDisplayModel();
//Get all property to list view config file mappings in the system //Get all property to list view config file mappings in the system
QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel); QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel);
@ -945,6 +947,10 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
String rangeUri = (rangeNode != null) String rangeUri = (rangeNode != null)
? ((Resource) rangeNode).getURI() ? ((Resource) rangeNode).getURI()
: OWL.Thing.getURI(); : OWL.Thing.getURI();
RDFNode domainNode = soln.get("domain");
String domainUri = (domainNode != null)
? ((Resource) domainNode).getURI()
: OWL.Thing.getURI();
ObjectProperty prop = getObjectPropertyByURI(propertyUri); ObjectProperty prop = getObjectPropertyByURI(propertyUri);
if (prop == null) { if (prop == null) {
//This is a warning only if this property is the one for which we're searching //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 { } else {
String filename = soln.getLiteral("filename").getLexicalForm(); String filename = soln.getLiteral("filename").getLexicalForm();
log.debug("putting " + prop.getURI() + " " + rangeUri + " " + filename + " into list view map"); log.debug("putting " + domainUri + " " + prop.getURI() + " " + rangeUri + " " + filename + " into list view map");
customListViewConfigFileMap.put(new Pair<ObjectProperty, String>(prop, rangeUri), filename); customListViewConfigFileMap.put(
new Pair<String,Pair<ObjectProperty,String>>(
domainUri, new Pair<ObjectProperty, String>(
prop, rangeUri)), filename);
} }
} }
qexec.close(); qexec.close();
} }
String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<ObjectProperty, String>(op, op.getRangeVClassURI())); String customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<String, Pair<ObjectProperty, String>>(op.getDomainVClassURI(), new Pair<ObjectProperty,String>(op, op.getRangeVClassURI())));
if (customListViewConfigFileName == null) { if (customListViewConfigFileName == null) {
log.debug("no list view found for " + op.getURI() + " qualified by " + op.getRangeVClassURI()); log.debug("no list view found for " + op.getURI() + " qualified by range " + op.getRangeVClassURI() + " and domain " + op.getDomainVClassURI());
customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<ObjectProperty, String>(op, OWL.Thing.getURI())); customListViewConfigFileName = customListViewConfigFileMap.get(new Pair<String, Pair<ObjectProperty, String>>(OWL.Thing.getURI(), new Pair<ObjectProperty,String>(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<String, Pair<ObjectProperty, String>>(OWL.Thing.getURI(), new Pair<ObjectProperty,String>(op, OWL.Thing.getURI())));
} }
return customListViewConfigFileName; return customListViewConfigFileName;

View file

@ -77,8 +77,14 @@ public class ApplicationConfigurationOntologyUtils {
QuerySolution qsoln = rs.nextSolution(); QuerySolution qsoln = rs.nextSolution();
log.debug(qsoln); log.debug(qsoln);
Resource domainRes = qsoln.getResource("domain"); Resource domainRes = qsoln.getResource("domain");
if(domainRes != null && !appropriateDomain(domainRes, subject, tboxModel)) { if(domainRes != null) {
continue; if(!appropriateDomain(domainRes, subject, tboxModel)) {
continue;
} else {
newProp.setDomainVClassURI(domainRes.getURI());
}
} else {
newProp.setDomainVClassURI(op.getDomainVClassURI());
} }
Resource rangeRes = qsoln.getResource("range"); Resource rangeRes = qsoln.getResource("range");
if (rangeRes != null) { if (rangeRes != null) {