diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/MiscWebUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/MiscWebUtils.java index 77a969ad7..7b577df7d 100755 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/MiscWebUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/MiscWebUtils.java @@ -3,7 +3,10 @@ package edu.cornell.mannlib.vitro.webapp.web; import java.util.Enumeration; +import java.util.HashSet; +import java.util.List; import java.util.Properties; +import java.util.Set; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; @@ -15,6 +18,12 @@ import org.apache.commons.logging.LogFactory; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.impl.ModelCom; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; public class MiscWebUtils { /** @@ -51,7 +60,7 @@ public class MiscWebUtils { } return current; } - + /** * Gets an attribute from the request, if it is not null, and of Class String * print it to req.out, otherwise throw an exception. @@ -70,7 +79,54 @@ public class MiscWebUtils { } return (String) contentObj; } - + + // Get custom short view from either the object's class or one of its + // superclasses. + // This is needed because the inference update happens asynchronously, so + // when a new + // property has been added and the page is reloaded, the custom short view + // from a + // superclass may not have been inferred yet. + public static String getCustomShortView(HttpServletRequest request) { + VitroRequest vreq = new VitroRequest(request); + VClassDao vcDao = vreq.getWebappDaoFactory().getVClassDao(); + + String customShortView = null; + Individual object = ((ObjectPropertyStatement) request + .getAttribute("opStmt")).getObject(); + List vclasses = object.getVClasses(true); // get directly + // asserted vclasses + Set superClasses = new HashSet(); + + // First try directly asserted classes, there is no useful decision + // mechanism for + // the case where two directly asserted classes have a custom short + // view. + for (VClass vclass : vclasses) { + // Use this class's custom short view, if there is one + customShortView = vclass.getCustomShortView(); + if (customShortView != null) { + return customShortView; + } + // Otherwise, add superclass to list of vclasses to check for custom + // short views + String vclassUri = vclass.getURI(); + superClasses.addAll(vcDao.getAllSuperClassURIs(vclassUri)); + } + + // Next try super classes. There is no useful decision mechanism for + // the case where two super classes have a custom short view. + for (String superClassUri : superClasses) { + VClass vc = vcDao.getVClassByURI(superClassUri); + customShortView = vc.getCustomShortView(); + if (customShortView != null) { + return customShortView; + } + } + + return null; + } + /** * returns a table of the req attributes * @param req diff --git a/webapp/web/templates/edit/specific/user_edit.jsp b/webapp/web/templates/edit/specific/user_edit.jsp index 5e1b4f279..16de14ab5 100644 --- a/webapp/web/templates/edit/specific/user_edit.jsp +++ b/webapp/web/templates/edit/specific/user_edit.jsp @@ -45,7 +45,7 @@ - +

Associate user account with a person

diff --git a/webapp/web/templates/entity/entityMergedPropsList.jsp b/webapp/web/templates/entity/entityMergedPropsList.jsp index 9cc360ddc..9cde91e52 100644 --- a/webapp/web/templates/entity/entityMergedPropsList.jsp +++ b/webapp/web/templates/entity/entityMergedPropsList.jsp @@ -32,7 +32,8 @@ <%@ page import="org.apache.commons.logging.LogFactory" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %> <%@ page import="edu.cornell.mannlib.vedit.beans.LoginFormBean" %> - + +<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> <%! public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.templates.entity.entityMergedPropsList.jsp"); %> @@ -161,25 +162,13 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. - - <%-- -<% ObjectPropertyStatement oStmt = (ObjectPropertyStatement)request.getAttribute("opStmt"); - if (oStmt!=null) { - Individual obj= (Individual)oStmt.getObject(); - if (obj != null) { - if (!obj.doesFlag1Match(currentPortalId)) {%> - -<% } - } - }%> - --%> + + + <% String customShortView = MiscWebUtils.getCustomShortView(request); %> + - - - - - + diff --git a/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp b/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp index 9a13b8f3b..c711629c6 100644 --- a/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp +++ b/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp @@ -39,7 +39,8 @@ <%@ page import="org.apache.commons.logging.LogFactory" %> <%@page import="java.util.LinkedList"%> -<%@page import="java.util.Set"%> +<%@page import="java.util.Set"%> +<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> <%! public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.templates.entity.entityMergedPropsList.jsp"); %> @@ -191,7 +192,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. <% - String customShortView = getCustomShortView(request, vcDao); + String customShortView = MiscWebUtils.getCustomShortView(request); %> @@ -347,41 +348,3 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. } } // end for (Property p : g.getPropertyList() %> - -<%! -// Get custom short view from either the object's class or one of its superclasses. -// This is needed because the inference update happens asynchronously, so when a new -// property has been added and the page is reloaded, the custom short view from a -// superclass may not have been inferred yet. -private String getCustomShortView(HttpServletRequest request, VClassDao vcDao) { - String customShortView = null; - Individual object = ((ObjectPropertyStatement)request.getAttribute("opStmt")).getObject(); - List vclasses = object.getVClasses(true); //get directly asserted vclasses - Set superClasses = new HashSet(); - - // First try directly asserted classes, there is no useful decision mechanism for - // the case where two directly asserted classes have a custom short view. - vclassLoop: for (VClass vclass : vclasses) { - // Use this class's custom short view, if there is one - customShortView = vclass.getCustomShortView(); - if (customShortView != null) { - return customShortView; - } - // Otherwise, add superclass to list of vclasses to check for custom short views - String vclassUri = vclass.getURI(); - superClasses.addAll( vcDao.getAllSuperClassURIs(vclassUri) ); - } - - // Next try super classes. There is no useful decision mechanism for - // the case where two super classes have a custom short view. - for (String superClassUri : superClasses) { - VClass vc = vcDao.getVClassByURI(superClassUri); - customShortView = vc.getCustomShortView(); - if (customShortView != null) { - return customShortView; - } - } - - return null; -} -%>