support for domain qualification in property config
This commit is contained in:
parent
43c47d0a55
commit
e3d6e37ab9
14 changed files with 129 additions and 57 deletions
|
@ -15,7 +15,7 @@ public interface ObjectPropertyDao extends PropertyDao {
|
||||||
|
|
||||||
public ObjectProperty getObjectPropertyByURI(String objectPropertyURI);
|
public ObjectProperty getObjectPropertyByURI(String objectPropertyURI);
|
||||||
|
|
||||||
public ObjectProperty getObjectPropertyByURIAndRangeURI(String objectPropertyURI, String rangeURI);
|
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI);
|
||||||
|
|
||||||
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements);
|
public List <ObjectProperty> getObjectPropertiesForObjectPropertyStatements(List /*of ObjectPropertyStatement */ objectPropertyStatements);
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ 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) {
|
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI) {
|
||||||
ObjectProperty newOprop=innerObjectPropertyDao.getObjectPropertyByURIAndRangeURI(objectPropertyURI, rangeURI);
|
ObjectProperty newOprop=innerObjectPropertyDao.getObjectPropertyByURIs(objectPropertyURI, domainURI, rangeURI);
|
||||||
return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters);
|
return (newOprop == null) ? null : new ObjectPropertyFiltering(newOprop, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,19 +284,28 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectProperty getObjectPropertyByURIAndRangeURI(String propertyURI, String rangeURI) {
|
public ObjectProperty getObjectPropertyByURIs(String propertyURI, String domainURI, String rangeURI) {
|
||||||
|
if(log.isDebugEnabled()) {
|
||||||
|
log.debug("Getting " + propertyURI + " with domain " + domainURI + " and range " + rangeURI);
|
||||||
|
}
|
||||||
ObjectProperty op = getObjectPropertyByURI(propertyURI);
|
ObjectProperty op = getObjectPropertyByURI(propertyURI);
|
||||||
if (op == null || rangeURI == null) {
|
if (op == null || rangeURI == null) {
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
op.setDomainVClassURI(domainURI);
|
||||||
op.setRangeVClassURI(rangeURI);
|
op.setRangeVClassURI(rangeURI);
|
||||||
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" +
|
||||||
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
||||||
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
||||||
"SELECT ?range ?label ?group ?customForm ?displayLevel ?updateLevel WHERE { \n" +
|
"SELECT ?range ?label ?group ?customForm ?displayLevel ?updateLevel WHERE { \n" +
|
||||||
" ?context config:configContextFor <" + propertyURI + "> . \n" +
|
" ?context config:configContextFor <" + propertyURI + "> . \n";
|
||||||
" ?context config:qualifiedBy <" + rangeURI + "> . \n" +
|
if (domainURI != null) {
|
||||||
" ?context config:hasConfiguration ?configuration . \n" +
|
propQuery += " ?context config:qualifiedByDomain <" + domainURI + "> . \n";
|
||||||
|
};
|
||||||
|
if (rangeURI != null) {
|
||||||
|
propQuery += " ?context config:qualifiedBy <" + rangeURI + "> . \n";
|
||||||
|
};
|
||||||
|
propQuery += " ?context config:hasConfiguration ?configuration . \n" +
|
||||||
" OPTIONAL { ?configuration config:propertyGroup ?group } \n" +
|
" OPTIONAL { ?configuration config:propertyGroup ?group } \n" +
|
||||||
" OPTIONAL { ?configuration config:displayName ?label } \n" +
|
" OPTIONAL { ?configuration config:displayName ?label } \n" +
|
||||||
" OPTIONAL { ?configuration vitro:customEntryFormAnnot ?customForm } \n" +
|
" OPTIONAL { ?configuration vitro:customEntryFormAnnot ?customForm } \n" +
|
||||||
|
|
|
@ -34,6 +34,7 @@ import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
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.sdb.util.Pair;
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
|
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
|
@ -52,6 +53,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||||
public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
|
|
||||||
protected static final Log log = LogFactory.getLog(PropertyDaoJena.class.getName());
|
protected static final Log log = LogFactory.getLog(PropertyDaoJena.class.getName());
|
||||||
|
protected static final String FAUX_PROPERTY_FLAG = "FAUX";
|
||||||
|
|
||||||
private static final Map<String, String> NAMESPACES = new HashMap<String, String>() {{
|
private static final Map<String, String> NAMESPACES = new HashMap<String, String>() {{
|
||||||
put("afn", VitroVocabulary.AFN);
|
put("afn", VitroVocabulary.AFN);
|
||||||
|
@ -329,7 +331,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
public List <VClass> getClassesWithRestrictionOnProperty(String propertyURI) {
|
public List <VClass> getClassesWithRestrictionOnProperty(String propertyURI) {
|
||||||
|
|
||||||
if (propertyURI == null) {
|
if (propertyURI == null) {
|
||||||
log.info("getClassesWithRestrictionOnProperty: called with null propertyURI");
|
log.warn("getClassesWithRestrictionOnProperty: called with null propertyURI");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,15 +526,8 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PropertyInstance> piList = getAllPropInstByVClasses(vclasses);
|
return getAllPropInstByVClasses(vclasses);
|
||||||
|
|
||||||
for (PropertyInstance pi : piList) {
|
|
||||||
pi.setDomainClassURI(ind.getVClassURI());
|
|
||||||
// TODO: improve. This is so the DWR property editing passes the
|
|
||||||
// individual's VClass to get the right restrictions
|
|
||||||
}
|
|
||||||
|
|
||||||
return piList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -737,12 +732,36 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
: (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));
|
Resource domainRes = op.getDomain();
|
||||||
List<String> additionalFauxSubpropertyRangeURIs = getAdditionalFauxSubpropertyRangeURIsForPropertyURI(propertyURI);
|
propInsts.add(getPropInst(
|
||||||
for (String rangeURI : additionalFauxSubpropertyRangeURIs) {
|
op, domainRes, rangeRes, applicableProperties));
|
||||||
if (rangeRes == null || getWebappDaoFactory().getVClassDao().isSubClassOf(rangeURI, rangeRes.getURI())) {
|
List<Pair<String,String>> additionalFauxSubpropertyDomainAndRangeURIs =
|
||||||
propInsts.add(getPropInstForPropertyAndRange(
|
getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(
|
||||||
op, ResourceFactory.createResource(rangeURI), applicableProperties));
|
propertyURI);
|
||||||
|
for (Pair<String,String> domainAndRangeURIs :
|
||||||
|
additionalFauxSubpropertyDomainAndRangeURIs) {
|
||||||
|
boolean applicablePropInst = false;
|
||||||
|
if (rangeRes == null ||
|
||||||
|
!getWebappDaoFactory().getVClassDao().isSubClassOf(
|
||||||
|
rangeRes.getURI(), domainAndRangeURIs.getRight())) {
|
||||||
|
if (domainAndRangeURIs.getLeft() == null) {
|
||||||
|
applicablePropInst = true;
|
||||||
|
} else {
|
||||||
|
for(VClass vclass : vclasses) {
|
||||||
|
if (vclass.getURI() != null && vclass.getURI().equals(
|
||||||
|
domainAndRangeURIs.getLeft())) {
|
||||||
|
applicablePropInst = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (applicablePropInst) {
|
||||||
|
propInsts.add(getPropInst(
|
||||||
|
op,
|
||||||
|
ResourceFactory.createResource(domainAndRangeURIs.getLeft()),
|
||||||
|
ResourceFactory.createResource(domainAndRangeURIs.getRight()),
|
||||||
|
applicableProperties));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,10 +774,16 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyInstance getPropInstForPropertyAndRange(OntProperty op, Resource rangeRes,
|
private PropertyInstance getPropInst(OntProperty op, Resource domainRes, Resource rangeRes,
|
||||||
Map<String, Resource[]> applicableProperties) {
|
Map<String, Resource[]> applicableProperties) {
|
||||||
|
if (log.isDebugEnabled() && domainRes != null && rangeRes != null) {
|
||||||
|
log.debug("getPropInst() op: " + op.getURI() + " domain: " +
|
||||||
|
domainRes.getURI() + " range: " + rangeRes.getURI());
|
||||||
|
}
|
||||||
PropertyInstance pi = new PropertyInstance();
|
PropertyInstance pi = new PropertyInstance();
|
||||||
String domainURIStr = getURIStr(op.getDomain());
|
String domainURIStr = (domainRes != null && !domainRes.isAnon()) ?
|
||||||
|
domainURIStr = domainRes.getURI()
|
||||||
|
: null;
|
||||||
if (rangeRes == null) {
|
if (rangeRes == null) {
|
||||||
pi.setRangeClassURI(OWL.Thing.getURI()); // TODO see above
|
pi.setRangeClassURI(OWL.Thing.getURI()); // TODO see above
|
||||||
} else {
|
} else {
|
||||||
|
@ -780,6 +805,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
pi.setRangeClassName(range.getName());
|
pi.setRangeClassName(range.getName());
|
||||||
}
|
}
|
||||||
pi.setDomainClassURI(domainURIStr);
|
pi.setDomainClassURI(domainURIStr);
|
||||||
|
if (domainURIStr != null) {
|
||||||
VClass domain = getWebappDaoFactory().getVClassDao()
|
VClass domain = getWebappDaoFactory().getVClassDao()
|
||||||
.getVClassByURI(domainURIStr);
|
.getVClassByURI(domainURIStr);
|
||||||
if (domain == null) {
|
if (domain == null) {
|
||||||
|
@ -788,6 +814,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
domain.setName(domain.getLocalName());
|
domain.setName(domain.getLocalName());
|
||||||
}
|
}
|
||||||
pi.setDomainClassName(domain.getName());
|
pi.setDomainClassName(domain.getName());
|
||||||
|
}
|
||||||
pi.setSubjectSide(true);
|
pi.setSubjectSide(true);
|
||||||
pi.setPropertyURI(op.getURI());
|
pi.setPropertyURI(op.getURI());
|
||||||
pi.setPropertyName(getLabelOrId(op)); // TODO
|
pi.setPropertyName(getLabelOrId(op)); // TODO
|
||||||
|
@ -796,14 +823,15 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAdditionalFauxSubpropertyRangeURIsForPropertyURI(String propertyURI) {
|
private List<Pair<String,String>> getAdditionalFauxSubpropertyDomainAndRangeURIsForPropertyURI(String propertyURI) {
|
||||||
List<String> rangeURIs = new ArrayList<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" +
|
||||||
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
|
||||||
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
||||||
"SELECT ?range WHERE { \n" +
|
"SELECT ?domain ?range WHERE { \n" +
|
||||||
" ?context config:configContextFor <" + propertyURI + "> . \n" +
|
" ?context config:configContextFor <" + propertyURI + "> . \n" +
|
||||||
" ?context config:qualifiedBy ?range . \n" +
|
" ?context config:qualifiedBy ?range . \n" +
|
||||||
|
" OPTIONAL { ?context config:qualifiedByDomain ?domain } \n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
Query q = QueryFactory.create(propQuery);
|
Query q = QueryFactory.create(propQuery);
|
||||||
|
@ -813,12 +841,18 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
while (rs.hasNext()) {
|
while (rs.hasNext()) {
|
||||||
QuerySolution qsoln = rs.nextSolution();
|
QuerySolution qsoln = rs.nextSolution();
|
||||||
Resource rangeRes = qsoln.getResource("range");
|
Resource rangeRes = qsoln.getResource("range");
|
||||||
rangeURIs.add(rangeRes.getURI());
|
String rangeURI = rangeRes.getURI();
|
||||||
|
Resource domainRes = qsoln.getResource("domain");
|
||||||
|
String domainURI = null;
|
||||||
|
if (domainRes != null && !domainRes.isAnon()) {
|
||||||
|
domainURI = domainRes.getURI();
|
||||||
|
}
|
||||||
|
domainAndRangeURIs.add(new Pair<String,String>(domainURI, rangeURI));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
qe.close();
|
qe.close();
|
||||||
}
|
}
|
||||||
return rangeURIs;
|
return domainAndRangeURIs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getURIStr(Resource res) {
|
private String getURIStr(Resource res) {
|
||||||
|
|
|
@ -1093,11 +1093,8 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
OntModel ontModel = getOntModel();
|
OntModel ontModel = getOntModel();
|
||||||
try {
|
try {
|
||||||
ontModel.enterCriticalSection(Lock.READ);
|
ontModel.enterCriticalSection(Lock.READ);
|
||||||
OntClass oc1 = getOntClass(ontModel, vclassURI1);
|
Resource oc1 = ontModel.getResource(vclassURI1);
|
||||||
OntClass oc2 = getOntClass(ontModel, vclassURI2);
|
Resource oc2 = ontModel.getResource(vclassURI2);
|
||||||
if (oc1 == null || oc2 == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return ontModel.contains(oc1, RDFS.subClassOf, oc2);
|
return ontModel.contains(oc1, RDFS.subClassOf, oc2);
|
||||||
} finally {
|
} finally {
|
||||||
ontModel.leaveCriticalSection();
|
ontModel.leaveCriticalSection();
|
||||||
|
|
|
@ -53,6 +53,10 @@ public class EditConfigurationUtils {
|
||||||
return vreq.getParameter("objectUri");
|
return vreq.getParameter("objectUri");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDomainUri(VitroRequest vreq) {
|
||||||
|
return vreq.getParameter("domainUri");
|
||||||
|
}
|
||||||
|
|
||||||
public static String getRangeUri(VitroRequest vreq) {
|
public static String getRangeUri(VitroRequest vreq) {
|
||||||
return vreq.getParameter("rangeUri");
|
return vreq.getParameter("rangeUri");
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,6 +202,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
String editConfGeneratorName = null;
|
String editConfGeneratorName = null;
|
||||||
|
|
||||||
String predicateUri = getPredicateUri(vreq);
|
String predicateUri = getPredicateUri(vreq);
|
||||||
|
String domainUri = EditConfigurationUtils.getDomainUri(vreq);
|
||||||
String rangeUri = EditConfigurationUtils.getRangeUri(vreq);
|
String rangeUri = EditConfigurationUtils.getRangeUri(vreq);
|
||||||
|
|
||||||
// *** handle the case where the form is specified as a request parameter ***
|
// *** handle the case where the form is specified as a request parameter ***
|
||||||
|
@ -218,7 +219,7 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
// *** check for a predicate URI in the request
|
// *** check for a predicate URI in the request
|
||||||
}else if( predicateUri != null && !predicateUri.isEmpty() ){
|
}else if( predicateUri != null && !predicateUri.isEmpty() ){
|
||||||
Property prop = getProperty( predicateUri, rangeUri, vreq);
|
Property prop = getProperty( predicateUri, domainUri, rangeUri, vreq);
|
||||||
if (prop != null && rangeUri != null) {
|
if (prop != null && rangeUri != null) {
|
||||||
editConfGeneratorName = getCustomEntryForm(prop);
|
editConfGeneratorName = getCustomEntryForm(prop);
|
||||||
} else if( prop != null && prop.getCustomEntryForm() != null ){
|
} else if( prop != null && prop.getCustomEntryForm() != null ){
|
||||||
|
@ -258,11 +259,11 @@ public class EditRequestDispatchController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Property getProperty(String predicateUri, String rangeUri, VitroRequest vreq) {
|
private Property getProperty(String predicateUri, String domainUri, String rangeUri, VitroRequest vreq) {
|
||||||
Property p = null;
|
Property p = null;
|
||||||
try{
|
try{
|
||||||
p = vreq.getWebappDaoFactory().getObjectPropertyDao().getObjectPropertyByURIAndRangeURI(
|
p = vreq.getWebappDaoFactory().getObjectPropertyDao().getObjectPropertyByURIs(
|
||||||
predicateUri, rangeUri);
|
predicateUri, domainUri, rangeUri);
|
||||||
if(p == null) {
|
if(p == null) {
|
||||||
p = vreq.getWebappDaoFactory().getDataPropertyDao().getDataPropertyByURI(predicateUri);
|
p = vreq.getWebappDaoFactory().getDataPropertyDao().getDataPropertyByURI(predicateUri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,6 +459,7 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
||||||
predicateUri,
|
predicateUri,
|
||||||
objectKey,
|
objectKey,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
statementDisplay,
|
statementDisplay,
|
||||||
null, vreq);
|
null, vreq);
|
||||||
ReadOnlyBeansWrapper wrapper = new ReadOnlyBeansWrapper();
|
ReadOnlyBeansWrapper wrapper = new ReadOnlyBeansWrapper();
|
||||||
|
|
|
@ -218,7 +218,7 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
}
|
}
|
||||||
|
|
||||||
listForThisSubclass.add(new ObjectPropertyStatementTemplateModel(subjectUri,
|
listForThisSubclass.add(new ObjectPropertyStatementTemplateModel(subjectUri,
|
||||||
propertyUri, rangeUri, objectKey, map, getTemplateName(), vreq));
|
propertyUri, domainUri, rangeUri, objectKey, map, getTemplateName(), vreq));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
if (pi != null) {
|
if (pi != null) {
|
||||||
if (!alreadyOnObjectPropertyList(
|
if (!alreadyOnObjectPropertyList(
|
||||||
populatedObjectPropertyList, pi)) {
|
populatedObjectPropertyList, pi)) {
|
||||||
addObjectPropertyToPropertyList(pi.getPropertyURI(), pi.getRangeClassURI(),
|
addObjectPropertyToPropertyList(pi.getPropertyURI(), pi.getDomainClassURI(), pi.getRangeClassURI(),
|
||||||
propertyList);
|
propertyList);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -206,7 +206,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, null, propertyList);
|
addObjectPropertyToPropertyList(propertyUri, null, null, propertyList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,16 +218,29 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
for (ObjectProperty op : opList) {
|
for (ObjectProperty op : opList) {
|
||||||
if (op.getURI() != null && op.getURI().equals(pi.getPropertyURI())) {
|
if (op.getURI() != null && op.getURI().equals(pi.getPropertyURI())) {
|
||||||
|
if(op.getDomainVClassURI() == null) {
|
||||||
|
if(pi.getDomainClassURI() == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else if (op.getDomainVClassURI().equals(pi.getDomainClassURI())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(op.getRangeVClassURI() == null) {
|
||||||
|
if (pi.getDomainClassURI() == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (op.getRangeVClassURI().equals(pi.getRangeClassURI())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addObjectPropertyToPropertyList(String propertyUri, String rangeUri,
|
private void addObjectPropertyToPropertyList(String propertyUri, String domainUri, String rangeUri,
|
||||||
List<Property> propertyList) {
|
List<Property> propertyList) {
|
||||||
ObjectPropertyDao opDao = wdf.getObjectPropertyDao();
|
ObjectPropertyDao opDao = wdf.getObjectPropertyDao();
|
||||||
ObjectProperty op = opDao.getObjectPropertyByURIAndRangeURI(propertyUri, rangeUri);
|
ObjectProperty op = opDao.getObjectPropertyByURIs(propertyUri, domainUri, 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) {
|
||||||
|
|
|
@ -33,6 +33,11 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
|
|
||||||
public ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String rangeUri, String objectKey,
|
public ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String rangeUri, String objectKey,
|
||||||
Map<String, String> data, String templateName, VitroRequest vreq) {
|
Map<String, String> data, String templateName, VitroRequest vreq) {
|
||||||
|
this (subjectUri, propertyUri, null, rangeUri, objectKey, data, templateName, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String domainUri, String rangeUri, String objectKey,
|
||||||
|
Map<String, String> data, String templateName, VitroRequest vreq) {
|
||||||
super(subjectUri, propertyUri, vreq);
|
super(subjectUri, propertyUri, vreq);
|
||||||
|
|
||||||
this.data = Collections.unmodifiableMap(new HashMap<String, String>(data));
|
this.data = Collections.unmodifiableMap(new HashMap<String, String>(data));
|
||||||
|
@ -45,7 +50,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
|
|
||||||
// Do delete url first, since it is used in building edit url
|
// Do delete url first, since it is used in building edit url
|
||||||
this.deleteUrl = makeDeleteUrl();
|
this.deleteUrl = makeDeleteUrl();
|
||||||
this.editUrl = makeEditUrl(ops, rangeUri);
|
this.editUrl = makeEditUrl(ops, domainUri, rangeUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeDeleteUrl() {
|
private String makeDeleteUrl() {
|
||||||
|
@ -90,7 +95,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
return UrlBuilder.getUrl(EDIT_PATH, params);
|
return UrlBuilder.getUrl(EDIT_PATH, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeEditUrl(ObjectPropertyStatement ops, String rangeUri) {
|
private String makeEditUrl(ObjectPropertyStatement ops, String domainUri, String rangeUri) {
|
||||||
// Is the edit link suppressed for this property?
|
// Is the edit link suppressed for this property?
|
||||||
if (new EditLinkSuppressor(vreq).isEditLinkSuppressed(propertyUri)) {
|
if (new EditLinkSuppressor(vreq).isEditLinkSuppressed(propertyUri)) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -115,6 +120,9 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
params.put("deleteProhibited", "prohibited");
|
params.put("deleteProhibited", "prohibited");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (domainUri != null) {
|
||||||
|
params.put("domainUri", rangeUri);
|
||||||
|
}
|
||||||
if (rangeUri != null) {
|
if (rangeUri != null) {
|
||||||
params.put("rangeUri", rangeUri);
|
params.put("rangeUri", rangeUri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
setName(op.getDomainPublic());
|
setName(op.getDomainPublic());
|
||||||
|
|
||||||
sortDirection = op.getDomainEntitySortDirection();
|
sortDirection = op.getDomainEntitySortDirection();
|
||||||
|
domainUri = op.getDomainVClassURI();
|
||||||
rangeUri = op.getRangeVClassURI();
|
rangeUri = op.getRangeVClassURI();
|
||||||
|
|
||||||
// Get the config for this object property
|
// Get the config for this object property
|
||||||
|
@ -132,6 +133,9 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
"subjectUri", subjectUri,
|
"subjectUri", subjectUri,
|
||||||
"predicateUri", propertyUri);
|
"predicateUri", propertyUri);
|
||||||
|
|
||||||
|
if (domainUri != null) {
|
||||||
|
params.put("domainUri", domainUri);
|
||||||
|
}
|
||||||
if (rangeUri != null) {
|
if (rangeUri != null) {
|
||||||
params.put("rangeUri", rangeUri);
|
params.put("rangeUri", rangeUri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
|
||||||
protected final VitroRequest vreq;
|
protected final VitroRequest vreq;
|
||||||
protected final String subjectUri;
|
protected final String subjectUri;
|
||||||
protected final String propertyUri;
|
protected final String propertyUri;
|
||||||
|
protected String domainUri;
|
||||||
protected String rangeUri;
|
protected String rangeUri;
|
||||||
private final String localName;
|
private final String localName;
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ObjectPropertyDaoStub implements ObjectPropertyDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectProperty getObjectPropertyByURIAndRangeURI(String objectPropertyURI, String rangeURI) {
|
public ObjectProperty getObjectPropertyByURIs(String objectPropertyURI, String domainURI, String rangeURI) {
|
||||||
return getObjectPropertyByURI(objectPropertyURI);
|
return getObjectPropertyByURI(objectPropertyURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue