From 3cb92fac0c7dc420ce35162a81706f631efbea86 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Thu, 1 Apr 2010 05:44:08 +0000 Subject: [PATCH] NIHVIVO-193 Fixed custom short view bug: new code that looks for superclass custom short views was neglecting to look for the subclass's custom short view first. --- .../entity/entityMergedPropsListUngrouped.jsp | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp b/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp index 2abbe5d51..636def1c6 100644 --- a/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp +++ b/webapp/web/templates/entity/entityMergedPropsListUngrouped.jsp @@ -190,27 +190,11 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. - <% - // Make this a method of some object: Individual or ...? - String customShortView = null; - Individual object = ((ObjectPropertyStatement)request.getAttribute("opStmt")).getObject(); - List vclasses = object.getVClasses(); - - vclassLoop: for (VClass vclass : vclasses) { - String vclassUri = vclass.getURI(); - List superClassUris = vcDao.getAllSuperClassURIs(vclassUri); - for (String superClassUri : superClassUris) { - VClass cl = vcDao.getVClassByURI(superClassUri); - customShortView = cl.getCustomShortView(); - if (customShortView != null) { - break vclassLoop; - } - } - } + String customShortView = getCustomShortView(request, vcDao); %> - + @@ -359,3 +343,33 @@ 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(); + + vclassLoop: for (VClass vclass : vclasses) { + // Use this class's custom short view, if there is one + customShortView = vclass.getCustomShortView(); + if (customShortView != null) { + break; + } + // Otherwise, check for superclass 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; + } + } + } + return customShortView; +} +%>