NIHVIVO-1392 Verbose property display
This commit is contained in:
parent
c82314cbdb
commit
faac29e6ba
10 changed files with 94 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue