NIHVIVO-1392 Verbose property display

This commit is contained in:
rjy7 2011-02-24 22:15:34 +00:00
parent c82314cbdb
commit faac29e6ba
10 changed files with 94 additions and 19 deletions

View file

@ -179,10 +179,9 @@ public class SiteAdminController extends FreemarkerHttpServlet {
urls.put("objectPropertyHierarchy", urlBuilder.getPortalUrl("/showObjectPropertyHierarchy", new ParamMap("iffRoot", "true")));
map.put("urls", urls);
// RY Make sure this works for true, false, and undefined values of the param
String verbose = vreq.getParameter("verbose");
boolean verbosePropertyValue = "true".equals(verbose) ? true : false;
vreq.getSession().setAttribute("verbosePropertyListing", verbosePropertyValue);
vreq.getSession().setAttribute("verbosePropertyDisplay", verbosePropertyValue);
Map<String, Object> verbosePropertyForm = new HashMap<String, Object>();
verbosePropertyForm.put("verboseFieldValue", String.valueOf(!verbosePropertyValue)); // the form toggles the current value

View file

@ -35,11 +35,13 @@ public class UrlBuilder {
AUTHENTICATE("/authenticate"),
BROWSE("/browse"),
CONTACT("/contact"),
DATA_PROPERTY_EDIT("/datapropEdit"),
INDIVIDUAL("/individual"),
INDIVIDUAL_EDIT("/entityEdit"),
INDIVIDUAL_LIST("/individuallist"),
LOGIN("/login"),
LOGOUT("/logout"),
OBJECT_PROPERTY_EDIT("/propertyEdit"),
SEARCH("/search"),
SITE_ADMIN("/siteAdmin"),
TERMS_OF_USE("/termsOfUse"),

View file

@ -15,9 +15,11 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAct
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropStmt;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
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.ParamMap;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
public class DataPropertyTemplateModel extends PropertyTemplateModel {
@ -32,8 +34,9 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
DataPropertyTemplateModel(DataProperty dp, Individual subject, VitroRequest vreq,
EditingPolicyHelper policyHelper, List<DataProperty> populatedDataPropertyList) {
super(dp, subject, policyHelper);
super(dp, subject, policyHelper, vreq);
setName(dp.getPublicName());
statements = new ArrayList<DataPropertyStatementTemplateModel>();
// If the property is populated, get the data property statements via a sparql query
@ -62,6 +65,16 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
}
}
@Override
protected Object getPropertyDisplayTier(Property p) {
return ((DataProperty)p).getDisplayTier();
}
@Override
protected Route getPropertyEditRoute() {
return Route.DATA_PROPERTY_EDIT;
}
/* Access methods for templates */
public String getType() {

View file

@ -7,6 +7,7 @@ import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyList;

View file

@ -46,7 +46,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
private static final int MAX_GROUP_DISPLAY_RANK = 99;
@SuppressWarnings("serial")
private static final List<String> VITRO_PROPS_TO_ADD_TO_LIST = new ArrayList<String>() {{
protected static final List<String> VITRO_PROPS_TO_ADD_TO_LIST = new ArrayList<String>() {{
add(VitroVocabulary.PRIMARY_LINK);
add(VitroVocabulary.ADDITIONAL_LINK);
add(VitroVocabulary.IND_MAIN_IMAGE);

View file

@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@ -23,17 +22,19 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropStmt;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
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.ParamMap;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import freemarker.cache.TemplateLoader;
@ -94,12 +95,9 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
EditingPolicyHelper policyHelper)
throws InvalidConfigurationException {
super(op, subject, policyHelper);
log.debug("Creating template model for object property " + op.getURI());
super(op, subject, policyHelper, vreq);
setName(op.getDomainPublic());
// Get the config for this object property
try {
config = new PropertyListConfig(op, vreq);
@ -120,6 +118,16 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
}
}
@Override
protected Object getPropertyDisplayTier(Property p) {
return ((ObjectProperty)p).getDomainDisplayTier();
}
@Override
protected Route getPropertyEditRoute() {
return Route.OBJECT_PROPERTY_EDIT;
}
protected ConfigError checkQuery(String queryString) {
if (StringUtils.isBlank(queryString)) {
return ConfigError.NO_SELECT_QUERY;

View file

@ -2,11 +2,18 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
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.web.templatemodels.BaseTemplateModel;
/**
@ -19,16 +26,17 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
private String name;
private String localName;
protected String propertyUri;
protected Map<String, Object> verboseDisplay = null;
// For editing
protected String subjectUri = null;
protected boolean addAccess = false;
PropertyTemplateModel(Property property, Individual subject, EditingPolicyHelper policyHelper) {
PropertyTemplateModel(Property property, Individual subject, EditingPolicyHelper policyHelper, VitroRequest vreq) {
propertyUri = property.getURI();
localName = property.getLocalName();
log.debug("Local name for property " + propertyUri + ": " + localName);
setVerboseDisplayValues(property, vreq);
// Do in subclass constructor. The label has not been set on the property, and the
// means of getting the label differs between object and data properties.
// this.name = property.getLabel();
@ -38,6 +46,35 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
}
}
protected void setVerboseDisplayValues(Property property, VitroRequest vreq) {
// No verbose display for these properties
if (GroupedPropertyList.VITRO_PROPS_TO_ADD_TO_LIST.contains(property)) {
return;
}
Boolean verboseDisplayFlag = (Boolean) vreq.getSession().getAttribute("verbosePropertyDisplay");
if ( ! Boolean.TRUE.equals(verboseDisplayFlag)) {
return;
}
LoginStatusBean loginStatusBean = LoginStatusBean.getBean(vreq);
if (! loginStatusBean.isLoggedInAtLeast(LoginStatusBean.CURATOR)) {
return;
}
verboseDisplay = new HashMap<String, Object>();
verboseDisplay.put("displayLevel", property.getHiddenFromDisplayBelowRoleLevel().getLabel());
verboseDisplay.put("updateLevel", property.getProhibitedFromUpdateBelowRoleLevel().getLabel());
verboseDisplay.put("localName", property.getLocalNameWithPrefix());
verboseDisplay.put("displayTier", getPropertyDisplayTier(property));
UrlBuilder urlBuilder = new UrlBuilder(vreq.getPortal());
String editUrl = urlBuilder.getPortalUrl(getPropertyEditRoute(), "uri", property.getURI());
verboseDisplay.put("propertyEditUrl", editUrl);
}
protected abstract Object getPropertyDisplayTier(Property p);
protected abstract Route getPropertyEditRoute();
protected void setName(String name) {
this.name = name;
}
@ -60,5 +97,9 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
}
public abstract String getAddUrl();
public Map<String, Object> getVerboseDisplay() {
return verboseDisplay;
}
}

View file

@ -23,7 +23,7 @@
<#list group.properties as property>
<article class="property" role="article">
<#-- Property display name -->
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /></h3>
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /></h3>
<#-- List the statements for each property -->
<ul class="property-list" role="list">
<#-- data property -->

View file

@ -65,7 +65,7 @@
Assumes property is non-null. -->
<#macro objectPropertyListing property editable template=property.template>
<#local localName = property.localName>
<h2 id="${localName}">${property.name?capitalize} <@addLink property editable /></h2>
<h2 id="${localName}">${property.name?capitalize} <@addLink property editable /> <@verboseDisplay property /></h2>
<ul id="individual-${localName}" role="list">
<@p.objectProperty property editable />
</ul>
@ -83,7 +83,7 @@ name will be used as the label. -->
<#macro addLinkWithLabel property editable label="${property.name?capitalize}">
<#local addLink><@addLink property editable label /></#local>
<#if addLink?has_content>
<h2 id="${property.localName}">${label} ${addLink}</h2>
<h2 id="${property.localName}">${label} ${addLink} <@verboseDisplay property /></h2>
</#if>
</#macro>
@ -97,7 +97,7 @@ name will be used as the label. -->
</#macro>
<#macro propertyLabel property label="${property.name?capitalize}">
<h2 id="${property.localName}">${label}</h2>
<h2 id="${property.localName}">${label} <@verboseDisplay property /></h2>
</#macro>
<#macro propertyListItem property statement editable>
@ -128,6 +128,19 @@ name will be used as the label. -->
</#if>
</#macro>
<#macro verboseDisplay property>
<#local verboseDisplay = property.verboseDisplay!>
<#if verboseDisplay?has_content>
<span class="verbosePropertyListing">
<a class="propertyLink" href="${verboseDisplay.propertyEditUrl}">${verboseDisplay.localName}</a>
(${property.type?lower_case} property);
display tier: ${verboseDisplay.displayTier} within group;
display level: ${verboseDisplay.displayLevel};
update level: ${verboseDisplay.updateLevel}
</span>
</#if>
</#macro>
<#-----------------------------------------------------------------------------
Macros for specific properties

View file

@ -33,14 +33,12 @@
<li><a href="${ontologyEditor.urls.propertyGroups}">Property groups</a></li>
</ul>
<#-- NIHVIVO-1590 This feature temporarily disabled in v1.2 due to time constraints.
<#assign formId = "verbosePropertyForm">
<form id="${formId}" action="${ontologyEditor.verbosePropertyForm.action}#${formId}" method="get">
<input type="hidden" name="verbose" value="${ontologyEditor.verbosePropertyForm.verboseFieldValue}" />
<span>Verbose property display for this session is <b>${ontologyEditor.verbosePropertyForm.currentValue}</b>.</span>
<input type="submit" id="submit" value="Turn ${ontologyEditor.verbosePropertyForm.newValue}" />
</form>
-->
</div>
</#if>