enabling display of faux subproperties without visible "parents"
This commit is contained in:
parent
be4f867f1f
commit
1999537379
2 changed files with 79 additions and 8 deletions
|
@ -44,6 +44,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
|
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
@ -761,8 +762,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
? foundRanges[1]
|
? foundRanges[1]
|
||||||
: op.getRange();
|
: op.getRange();
|
||||||
Resource domainRes = op.getDomain();
|
Resource domainRes = op.getDomain();
|
||||||
propInsts.add(getPropInst(
|
propInsts.add(getPropInst(op, domainRes, rangeRes));
|
||||||
op, domainRes, rangeRes, applicableProperties));
|
|
||||||
List<Pair<String,String>> additionalFauxSubpropertyDomainAndRangeURIs =
|
List<Pair<String,String>> additionalFauxSubpropertyDomainAndRangeURIs =
|
||||||
getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(
|
getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(
|
||||||
propertyURI);
|
propertyURI);
|
||||||
|
@ -787,8 +787,8 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
propInsts.add(getPropInst(
|
propInsts.add(getPropInst(
|
||||||
op,
|
op,
|
||||||
ResourceFactory.createResource(domainAndRangeURIs.getLeft()),
|
ResourceFactory.createResource(domainAndRangeURIs.getLeft()),
|
||||||
ResourceFactory.createResource(domainAndRangeURIs.getRight()),
|
ResourceFactory.createResource(domainAndRangeURIs.getRight())
|
||||||
applicableProperties));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -798,12 +798,31 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
ontModel.leaveCriticalSection();
|
ontModel.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add any faux properties with applicable domain where the predicate URI
|
||||||
|
// is not already on the list
|
||||||
|
List<ObjectProperty> stragglers = getAdditionalFauxSubpropertiesForVClasses(
|
||||||
|
vclasses, propInsts);
|
||||||
|
for (ObjectProperty op : stragglers) {
|
||||||
|
propInsts.add(makePropInst(op));
|
||||||
|
}
|
||||||
|
|
||||||
return propInsts;
|
return propInsts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyInstance getPropInst(OntProperty op, Resource domainRes, Resource rangeRes,
|
private PropertyInstance makePropInst(ObjectProperty op) {
|
||||||
Map<String, Resource[]> applicableProperties) {
|
PropertyInstance pi = new PropertyInstance();
|
||||||
|
pi.setDomainClassURI(op.getDomainVClassURI());
|
||||||
|
pi.setRangeClassURI(op.getRangeVClassURI());
|
||||||
|
pi.setSubjectSide(true);
|
||||||
|
pi.setPropertyURI(op.getURI());
|
||||||
|
pi.setPropertyName(op.getLabel());
|
||||||
|
pi.setDomainPublic(op.getDomainPublic());
|
||||||
|
return pi;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PropertyInstance getPropInst(OntProperty op, Resource domainRes,
|
||||||
|
Resource rangeRes) {
|
||||||
if (log.isDebugEnabled() && domainRes != null && rangeRes != null) {
|
if (log.isDebugEnabled() && domainRes != null && rangeRes != null) {
|
||||||
log.debug("getPropInst() op: " + op.getURI() + " domain: " +
|
log.debug("getPropInst() op: " + op.getURI() + " domain: " +
|
||||||
domainRes.getURI() + " range: " + rangeRes.getURI());
|
domainRes.getURI() + " range: " + rangeRes.getURI());
|
||||||
|
@ -851,6 +870,58 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ObjectProperty> getAdditionalFauxSubpropertiesForVClasses(
|
||||||
|
List<VClass> vclasses, List<PropertyInstance> propInsts) {
|
||||||
|
|
||||||
|
List<ObjectProperty> opList = new ArrayList<ObjectProperty>();
|
||||||
|
if (vclasses.size() == 0) {
|
||||||
|
return opList;
|
||||||
|
}
|
||||||
|
ObjectPropertyDao opDao = getWebappDaoFactory().getObjectPropertyDao();
|
||||||
|
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
|
||||||
|
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
||||||
|
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
||||||
|
"SELECT ?property ?domain ?range WHERE { \n" +
|
||||||
|
" ?context config:configContextFor ?property . \n" +
|
||||||
|
" ?context config:qualifiedByDomain ?domain . \n" +
|
||||||
|
" ?context config:qualifiedBy ?range . \n";
|
||||||
|
for(PropertyInstance propInst : propInsts) {
|
||||||
|
propQuery += " FILTER (?property != <" + propInst.getPropertyURI() + "> ) \n";
|
||||||
|
}
|
||||||
|
Iterator<VClass> classIt = vclasses.iterator();
|
||||||
|
if(classIt.hasNext()) {
|
||||||
|
propQuery += " FILTER ( \n";
|
||||||
|
propQuery += " (?domain = <" + OWL.Thing.getURI() + "> )\n";
|
||||||
|
while (classIt.hasNext()) {
|
||||||
|
VClass vclass = classIt.next();
|
||||||
|
if(vclass.isAnonymous()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
propQuery += " || (?domain = <" + vclass.getURI() + "> ) \n";
|
||||||
|
}
|
||||||
|
propQuery += ") \n";
|
||||||
|
}
|
||||||
|
propQuery += "} \n";
|
||||||
|
log.debug(propQuery);
|
||||||
|
Query q = QueryFactory.create(propQuery);
|
||||||
|
QueryExecution qe = QueryExecutionFactory.create(
|
||||||
|
q, getOntModelSelector().getDisplayModel());
|
||||||
|
try {
|
||||||
|
ResultSet rs = qe.execSelect();
|
||||||
|
while (rs.hasNext()) {
|
||||||
|
QuerySolution qsoln = rs.nextSolution();
|
||||||
|
String propertyURI = qsoln.getResource("property").getURI();
|
||||||
|
String domainURI = qsoln.getResource("domain").getURI();
|
||||||
|
String rangeURI = qsoln.getResource("range").getURI();
|
||||||
|
opList.add(opDao.getObjectPropertyByURIs(
|
||||||
|
propertyURI, domainURI, rangeURI, null));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
qe.close();
|
||||||
|
}
|
||||||
|
return opList;
|
||||||
|
}
|
||||||
|
|
||||||
private List<Pair<String,String>> getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(String propertyURI) {
|
private List<Pair<String,String>> getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(String propertyURI) {
|
||||||
List<Pair<String,String>> domainAndRangeURIs = new ArrayList<Pair<String,String>>();
|
List<Pair<String,String>> domainAndRangeURIs = new ArrayList<Pair<String,String>>();
|
||||||
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
|
String propQuery = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class FileGraphSetup implements ServletContextListener {
|
||||||
* base model.
|
* base model.
|
||||||
*/
|
*/
|
||||||
public boolean readGraphs(Set<Path> pathSet, RDFServiceModelMaker dataset, String type, OntModel baseModel) {
|
public boolean readGraphs(Set<Path> pathSet, RDFServiceModelMaker dataset, String type, OntModel baseModel) {
|
||||||
return readGraphs(pathSet, dataset, type, baseModel, false);
|
return readGraphs(pathSet, dataset, type, baseModel, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue