Fixing how shor views are found on entityMergedPropsList.jsp NIHVIVO-833

This commit is contained in:
bdc34 2010-07-16 16:35:59 +00:00
parent 0d39c89da6
commit bf7240b440
4 changed files with 69 additions and 61 deletions

View file

@ -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" %>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%><jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<%!
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.
<c:set var="opStmt" value="${objPropertyStmt}" scope="request"/>
<c:url var="propertyLink" value="/entity">
<c:param name="home" value="${portal.portalId}"/>
<c:param name="uri" value="${objPropertyStmt.object.URI}"/>
<%--
<% ObjectPropertyStatement oStmt = (ObjectPropertyStatement)request.getAttribute("opStmt");
if (oStmt!=null) {
Individual obj= (Individual)oStmt.getObject();
if (obj != null) {
if (!obj.doesFlag1Match(currentPortalId)) {%>
<c:param name="jump" value="true"/>
<% }
}
}%>
--%>
<c:param name="uri" value="${objPropertyStmt.object.URI}"/>
</c:url>
<% String customShortView = MiscWebUtils.getCustomShortView(request); %>
<c:set var="altRenderJsp" value="<%= customShortView %>" />
<c:remove var="opStmt" scope="request"/>
<c:forEach items="${objPropertyStmt.object.VClasses}" var="type">
<c:if test="${!empty type.customShortView}">
<c:set var="altRenderJsp" value="${type.customShortView}"/>
</c:if>
</c:forEach>
<c:choose>
<c:when test="${!empty altRenderJsp}">
<c:set scope="request" var="individual" value="${objPropertyStmt.object}"/>

View file

@ -39,7 +39,8 @@
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.Set"%><jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<%@page import="java.util.Set"%>
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%><jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<%!
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.
<c:param name="uri" value="${objPropertyStmt.object.URI}"/>
</c:url>
<%
String customShortView = getCustomShortView(request, vcDao);
String customShortView = MiscWebUtils.getCustomShortView(request);
%>
<c:set var="altRenderJsp" value="<%= customShortView %>" />
<c:remove var="opStmt" scope="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<VClass> vclasses = object.getVClasses(true); //get directly asserted vclasses
Set<String> superClasses = new HashSet<String>();
// 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;
}
%>