From 418fc432e06ed3ce191a2f16ffd0939d4c609c4f Mon Sep 17 00:00:00 2001 From: bdc34 Date: Wed, 14 Jul 2010 00:09:47 +0000 Subject: [PATCH] Changing entityMergedPropList so that it will look for customShortViews on all directly asserted classes before checking any super classes. NIHVIVO-629 NIHVIVO-630 --- .../entity/entityMergedPropsListUngrouped.jsp | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp b/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp index c2c377164..9a13b8f3b 100644 --- a/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp +++ b/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp @@ -37,7 +37,9 @@ <%@ page import="org.apache.commons.logging.Log" %> <%@ page import="org.apache.commons.logging.LogFactory" %> - + +<%@page import="java.util.LinkedList"%> +<%@page import="java.util.Set"%> <%! public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.templates.entity.entityMergedPropsList.jsp"); %> @@ -354,25 +356,32 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. private String getCustomShortView(HttpServletRequest request, VClassDao vcDao) { String customShortView = null; Individual object = ((ObjectPropertyStatement)request.getAttribute("opStmt")).getObject(); - List vclasses = object.getVClasses(); - + 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) { - break; + return customShortView; } - // Otherwise, check for superclass custom short views + // Otherwise, add superclass to list of vclasses to check for custom short views String vclassUri = vclass.getURI(); - List superClassUris = vcDao.getAllSuperClassURIs(vclassUri); - for (String superClassUri : superClassUris) { - VClass vc = vcDao.getVClassByURI(superClassUri); - customShortView = vc.getCustomShortView(); - if (customShortView != null) { - break vclassLoop; - } + 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 customShortView; + } + + return null; } %>