continuing work on VIVO-60 application ontology support for property/class combinations
This commit is contained in:
parent
4341d72ec4
commit
e3fe0ac52b
7 changed files with 167 additions and 54 deletions
|
@ -15,6 +15,8 @@ public interface ObjectPropertyDao extends PropertyDao {
|
||||||
|
|
||||||
public ObjectProperty getObjectPropertyByURI(String objectPropertyURI);
|
public ObjectProperty getObjectPropertyByURI(String objectPropertyURI);
|
||||||
|
|
||||||
|
public ObjectProperty getObjectPropertyByURIAndRangeURI(String objectPropertyURI, String rangeURI);
|
||||||
|
|
||||||
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements);
|
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements);
|
||||||
|
|
||||||
public List<String> getSuperPropertyURIs(String objectPropertyURI, boolean direct);
|
public List<String> getSuperPropertyURIs(String objectPropertyURI, boolean direct);
|
||||||
|
|
|
@ -49,6 +49,11 @@ class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectProperty
|
||||||
return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters);
|
return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObjectProperty getObjectPropertyByURIAndRangeURI(String objectPropertyURI, String rangeURI) {
|
||||||
|
ObjectProperty newOprop=innerObjectPropertyDao.getObjectPropertyByURIAndRangeURI(objectPropertyURI, rangeURI);
|
||||||
|
return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters);
|
||||||
|
}
|
||||||
|
|
||||||
public List<ObjectPropertyStatement> getStatementsUsingObjectProperty(ObjectProperty op) {
|
public List<ObjectPropertyStatement> getStatementsUsingObjectProperty(ObjectProperty op) {
|
||||||
return ObjectPropertyStatementDaoFiltering.filterAndWrapList(innerObjectPropertyDao.getStatementsUsingObjectProperty(op),filters);
|
return ObjectPropertyStatementDaoFiltering.filterAndWrapList(innerObjectPropertyDao.getStatementsUsingObjectProperty(op),filters);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.Property;
|
import com.hp.hpl.jena.rdf.model.Property;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
@ -282,6 +284,65 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObjectProperty getObjectPropertyByURIAndRangeURI(String propertyURI, String rangeURI) {
|
||||||
|
ObjectProperty op = getObjectPropertyByURI(propertyURI);
|
||||||
|
if (op == null) {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
op.setRangeVClassURI(rangeURI);
|
||||||
|
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 ?range ?label ?group ?customForm ?displayLevel ?updateLevel WHERE { \n" +
|
||||||
|
" ?context config:configContextFor <" + propertyURI + "> . \n" +
|
||||||
|
" ?context config:qualifiedBy <" + rangeURI + "> . \n" +
|
||||||
|
" ?context config:hasConfiguration ?configuration . \n" +
|
||||||
|
" OPTIONAL { ?configuration config:propertyGroup ?group } \n" +
|
||||||
|
" OPTIONAL { ?configuration config:displayName ?label } \n" +
|
||||||
|
" OPTIONAL { ?configuration vitro:customEntryFormAnnot ?customForm } \n" +
|
||||||
|
" OPTIONAL { ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel } \n" +
|
||||||
|
" OPTIONAL { ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } \n" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
Query q = QueryFactory.create(propQuery);
|
||||||
|
QueryExecution qe = QueryExecutionFactory.create(q, getOntModelSelector().getDisplayModel());
|
||||||
|
try {
|
||||||
|
ResultSet rs = qe.execSelect();
|
||||||
|
if (rs.hasNext()) {
|
||||||
|
QuerySolution qsoln = rs.nextSolution();
|
||||||
|
log.debug(qsoln);
|
||||||
|
Resource groupRes = qsoln.getResource("group");
|
||||||
|
if (groupRes != null) {
|
||||||
|
op.setGroupURI(groupRes.getURI());
|
||||||
|
}
|
||||||
|
Resource displayLevelRes = qsoln.getResource("displayLevel");
|
||||||
|
if (displayLevelRes != null) {
|
||||||
|
op.setHiddenFromDisplayBelowRoleLevel(
|
||||||
|
BaseResourceBean.RoleLevel.getRoleByUri(
|
||||||
|
displayLevelRes.getURI()));
|
||||||
|
}
|
||||||
|
Resource updateLevelRes = qsoln.getResource("updateLevel");
|
||||||
|
if (updateLevelRes != null) {
|
||||||
|
op.setProhibitedFromUpdateBelowRoleLevel(
|
||||||
|
BaseResourceBean.RoleLevel.getRoleByUri(
|
||||||
|
updateLevelRes.getURI()));
|
||||||
|
}
|
||||||
|
Literal labelLit = qsoln.getLiteral("label");
|
||||||
|
if (labelLit != null) {
|
||||||
|
op.setDomainPublic(labelLit.getLexicalForm());
|
||||||
|
}
|
||||||
|
Literal customFormLit = qsoln.getLiteral("customForm");
|
||||||
|
if (customFormLit != null) {
|
||||||
|
op.setCustomEntryForm(customFormLit.getLexicalForm());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
qe.close();
|
||||||
|
}
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List objPropertyStmts) {
|
public List<ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List objPropertyStmts) {
|
||||||
if( objPropertyStmts == null || objPropertyStmts.size() < 1) return new ArrayList();
|
if( objPropertyStmts == null || objPropertyStmts.size() < 1) return new ArrayList();
|
||||||
HashMap<String,ObjectProperty> hash = new HashMap<String,ObjectProperty>();
|
HashMap<String,ObjectProperty> hash = new HashMap<String,ObjectProperty>();
|
||||||
|
|
|
@ -30,6 +30,7 @@ import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.Statement;
|
import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
|
@ -711,14 +712,34 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
if (op == null) {
|
if (op == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String domainURIStr = getURIStr(op.getDomain());
|
|
||||||
Resource[] foundRanges = applicableProperties.get(propertyURI);
|
Resource[] foundRanges = applicableProperties.get(propertyURI);
|
||||||
Resource rangeRes = (foundRanges[0] != null)
|
Resource rangeRes = (foundRanges[0] != null)
|
||||||
? foundRanges[0]
|
? foundRanges[0]
|
||||||
: (op.getRange() == null && foundRanges[1] != null)
|
: (op.getRange() == null && foundRanges[1] != null)
|
||||||
? foundRanges[1]
|
? foundRanges[1]
|
||||||
: op.getRange();
|
: op.getRange();
|
||||||
|
propInsts.add(getPropInstForPropertyAndRange(op, rangeRes, applicableProperties));
|
||||||
|
List<String> additionalFauxSubpropertyRangeURIs = getAdditionalFauxSubpropertyRangeURIsForPropertyURI(propertyURI);
|
||||||
|
for (String rangeURI : additionalFauxSubpropertyRangeURIs) {
|
||||||
|
if (getWebappDaoFactory().getVClassDao().isSubClassOf(rangeURI, rangeRes.getURI())) {
|
||||||
|
propInsts.add(getPropInstForPropertyAndRange(
|
||||||
|
op, ResourceFactory.createResource(rangeURI), applicableProperties));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
ontModel.leaveCriticalSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
return propInsts;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PropertyInstance getPropInstForPropertyAndRange(OntProperty op, Resource rangeRes,
|
||||||
|
Map<String, Resource[]> applicableProperties) {
|
||||||
PropertyInstance pi = new PropertyInstance();
|
PropertyInstance pi = new PropertyInstance();
|
||||||
|
String domainURIStr = getURIStr(op.getDomain());
|
||||||
if (rangeRes != null) {
|
if (rangeRes != null) {
|
||||||
String rangeClassURI;
|
String rangeClassURI;
|
||||||
if (rangeRes.isAnon()) {
|
if (rangeRes.isAnon()) {
|
||||||
|
@ -753,14 +774,32 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
pi.setPropertyName(getLabelOrId(op)); // TODO
|
pi.setPropertyName(getLabelOrId(op)); // TODO
|
||||||
pi.setRangePublic(getLabelOrId(op));
|
pi.setRangePublic(getLabelOrId(op));
|
||||||
pi.setDomainPublic(getLabelOrId(op));
|
pi.setDomainPublic(getLabelOrId(op));
|
||||||
propInsts.add(pi);
|
return pi;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getAdditionalFauxSubpropertyRangeURIsForPropertyURI(String propertyURI) {
|
||||||
|
List<String> rangeURIs = new ArrayList<String>();
|
||||||
|
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 ?range WHERE { \n" +
|
||||||
|
" ?context config:configContextFor <" + propertyURI + "> . \n" +
|
||||||
|
" ?context config:qualifiedBy ?range . \n" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
Query q = QueryFactory.create(propQuery);
|
||||||
|
QueryExecution qe = QueryExecutionFactory.create(q, getOntModelSelector().getDisplayModel());
|
||||||
|
try {
|
||||||
|
ResultSet rs = qe.execSelect();
|
||||||
|
while (rs.hasNext()) {
|
||||||
|
QuerySolution qsoln = rs.nextSolution();
|
||||||
|
Resource rangeRes = qsoln.getResource("range");
|
||||||
|
rangeURIs.add(rangeRes.getURI());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
ontModel.leaveCriticalSection();
|
qe.close();
|
||||||
}
|
}
|
||||||
|
return rangeURIs;
|
||||||
return propInsts;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getURIStr(Resource res) {
|
private String getURIStr(Resource res) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class SimpleOntModelSelector implements OntModelSelector {
|
||||||
this.applicationMetadataModel = ontModel;
|
this.applicationMetadataModel = ontModel;
|
||||||
this.tboxModel = ontModel;
|
this.tboxModel = ontModel;
|
||||||
this.userAccountsModel = ontModel;
|
this.userAccountsModel = ontModel;
|
||||||
|
this.displayModel = ontModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setABoxModel(OntModel m) {
|
public void setABoxModel(OntModel m) {
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
if (pi != null) {
|
if (pi != null) {
|
||||||
if (!alreadyOnObjectPropertyList(
|
if (!alreadyOnObjectPropertyList(
|
||||||
populatedObjectPropertyList, pi)) {
|
populatedObjectPropertyList, pi)) {
|
||||||
addObjectPropertyToPropertyList(pi.getPropertyURI(),
|
addObjectPropertyToPropertyList(pi.getPropertyURI(), pi.getRangeClassURI(),
|
||||||
propertyList);
|
propertyList);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,7 +199,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
// constitute a special case (i.e., included in piDao.getAllPossiblePropInstForIndividual()).
|
// constitute a special case (i.e., included in piDao.getAllPossiblePropInstForIndividual()).
|
||||||
for (String propertyUri : VITRO_PROPS_TO_ADD_TO_LIST) {
|
for (String propertyUri : VITRO_PROPS_TO_ADD_TO_LIST) {
|
||||||
if (!alreadyOnPropertyList(propertyList, propertyUri)) {
|
if (!alreadyOnPropertyList(propertyList, propertyUri)) {
|
||||||
addObjectPropertyToPropertyList(propertyUri, propertyList);
|
addObjectPropertyToPropertyList(propertyUri, null, propertyList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,10 +217,10 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addObjectPropertyToPropertyList(String propertyUri,
|
private void addObjectPropertyToPropertyList(String propertyUri, String rangeUri,
|
||||||
List<Property> propertyList) {
|
List<Property> propertyList) {
|
||||||
ObjectPropertyDao opDao = wdf.getObjectPropertyDao();
|
ObjectPropertyDao opDao = wdf.getObjectPropertyDao();
|
||||||
ObjectProperty op = opDao.getObjectPropertyByURI(propertyUri);
|
ObjectProperty op = opDao.getObjectPropertyByURIAndRangeURI(propertyUri, rangeUri);
|
||||||
if (op == null) {
|
if (op == null) {
|
||||||
log.error("ObjectProperty op returned null from opDao.getObjectPropertyByURI(" + propertyUri + ")");
|
log.error("ObjectProperty op returned null from opDao.getObjectPropertyByURI(" + propertyUri + ")");
|
||||||
} else if (op.getURI() == null) {
|
} else if (op.getURI() == null) {
|
||||||
|
|
|
@ -66,6 +66,11 @@ public class ObjectPropertyDaoStub implements ObjectPropertyDao {
|
||||||
return opMap.get(objectPropertyURI);
|
return opMap.get(objectPropertyURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectProperty getObjectPropertyByURIAndRangeURI(String objectPropertyURI, String rangeURI) {
|
||||||
|
return getObjectPropertyByURI(objectPropertyURI);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCustomListViewConfigFileName(ObjectProperty objectProperty) {
|
public String getCustomListViewConfigFileName(ObjectProperty objectProperty) {
|
||||||
if (objectProperty == null) {
|
if (objectProperty == null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue