VIVO-774 Fix display of unpopulated properties

Unpopulated properties with no domain URI were not recognized as faux properties
Use the faux property display name instead of the base property name.
This commit is contained in:
Jim Blake 2014-11-19 15:55:56 -05:00
parent dfb9b7517e
commit 474b0abb44
4 changed files with 14 additions and 18 deletions

View file

@ -26,6 +26,7 @@ import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ResIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
@ -273,9 +274,11 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
private static final String VCARD_KIND_URI = "http://www.w3.org/2006/vcard/ns#Kind";
private static final String VCARD_NAMESPACE = "http://www.w3.org/2006/vcard/ns#";
private void storeQualifiedByRoot(OntResource context, String rangeURI) {
if (rangeURI.startsWith(VCARD_NAMESPACE)) {
updatePropertyResourceURIValue(context, QUALIFIED_BY_ROOT, VCARD_KIND_URI);
updatePropertyResourceURIValue(context, QUALIFIED_BY_ROOT,
VCARD_KIND_URI);
} else {
updatePropertyResourceURIValue(context, QUALIFIED_BY_ROOT, null);
}
@ -504,8 +507,6 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
+ " :hasConfiguration ?config . \n" //
+ "} \n"; //
// TODO Add a filter that will reject solutions that include
// qualifiedByDomain
private static final String QUERY_LOCATE_CONFIG_CONTEXT_WITH_NO_DOMAIN = "" //
+ "PREFIX : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" //
+ "\n" //
@ -515,6 +516,9 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
+ " :configContextFor ?baseUri ; \n" //
+ " :qualifiedBy ?rangeUri ; \n" //
+ " :hasConfiguration ?config . \n" //
+ " FILTER NOT EXISTS { \n" //
+ " ?context :qualifiedByDomain ?domainUri \n" //
+ " } \n" //
+ "} \n"; //
private static class ParserLocateConfigContext extends
@ -558,7 +562,8 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
String baseUri, String rangeUri) {
try (LockedOntModel displayModel = lockableDisplayModel.read()) {
String queryString;
if (domainUri == null || domainUri.trim().isEmpty()) {
if (domainUri == null || domainUri.trim().isEmpty()
|| domainUri.equals(OWL.Thing.getURI())) {
queryString = bindValues(
QUERY_LOCATE_CONFIG_CONTEXT_WITH_NO_DOMAIN,
uriValue("baseUri", baseUri),

View file

@ -69,8 +69,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
DataPropertyTemplateModel(DataProperty dp, Individual subject, VitroRequest vreq,
boolean editing, List<DataProperty> populatedDataPropertyList) {
super(dp, subject, vreq);
setName(dp.getPublicName());
super(dp, subject, vreq, dp.getPublicName());
// Get the config for this data property
try {

View file

@ -86,8 +86,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
boolean editing)
throws InvalidConfigurationException {
super(op, subject, vreq);
setName(op.getDomainPublic());
super(op, subject, vreq, op.getDomainPublic());
sortDirection = op.getDomainEntitySortDirection();
domainUri = op.getDomainVClassURI();
@ -232,7 +231,6 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
public static ObjectPropertyTemplateModel getObjectPropertyTemplateModel(ObjectProperty op,
Individual subject, VitroRequest vreq, boolean editing,
List<ObjectProperty> populatedObjectPropertyList) {
if (op.getCollateBySubclass()) {
try {
return new CollatedObjectPropertyTemplateModel(op, subject, vreq, editing, populatedObjectPropertyList);

View file

@ -13,13 +13,11 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
import edu.cornell.mannlib.vitro.webapp.dao.FauxPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
@ -42,15 +40,14 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
protected String addUrl;
private String name;
PropertyTemplateModel(Property property, Individual subject, VitroRequest vreq) {
PropertyTemplateModel(Property property, Individual subject, VitroRequest vreq, String name) {
this.vreq = vreq;
subjectUri = subject.getURI();
this.property = property;
propertyUri = property.getURI();
localName = property.getLocalName();
this.name = name;
setVerboseDisplayValues(property);
addUrl = "";
@ -106,6 +103,7 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
FauxProperty fauxProperty = isFauxProperty(property);
if (fauxProperty != null) {
verboseDisplay.put("fauxProperty", assembleFauxPropertyValues(fauxProperty));
this.name = fauxProperty.getDisplayName();
}
}
@ -129,10 +127,6 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
protected abstract int getPropertyDisplayTier(Property p);
protected abstract Route getPropertyEditRoute();
protected void setName(String name) {
this.name = name;
}
public String toString() {
return String.format("%s on %s",
propertyUri != null ? propertyUri : "null Prop URI",