This commit is contained in:
rjy7 2010-07-19 21:37:59 +00:00
parent ddae9bb311
commit a5f60a9f7f
5 changed files with 60 additions and 55 deletions

View file

@ -80,51 +80,55 @@ 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<VClass> vclasses = object.getVClasses(true); // get directly
// asserted vclasses
Set<String> superClasses = new HashSet<String>();
return getCustomShortView(object, request);
}
// 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));
}
// 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.
// 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;
}
}
public static String getCustomShortView(Individual individual, HttpServletRequest request) {
VitroRequest vreq = new VitroRequest(request);
VClassDao vcDao = vreq.getWebappDaoFactory().getVClassDao();
String customShortView = null;
List<VClass> vclasses = individual.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.
// RY If we're getting the custom short view with reference to an object property.
// should we use the property's getRangeVClass() method instead?
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;
return null;
}
/**

View file

@ -432,6 +432,12 @@ public class InputElementFormattingTag extends TagSupport {
out.print("<input "+classStr+" "+sizeStr+" type=\"text\" id=\""+getId()+"\" name=\""+getName()+"\" value=\""+valueStr+"\" />");
if (definitionTags) { out.print("</dd>"); }
out.println();
} else if( getType().equalsIgnoreCase("hidden")) {
String valueStr = doValue(editConfig, editSub);
if (definitionTags) { out.print("<dd>"); }
out.print("<input "+classStr+ "type=\"hidden\" id=\""+getId()+"\" name=\""+getName()+"\" value=\""+valueStr+"\" />");
if (definitionTags) { out.print("</dd>"); }
out.println();
} else if (getType().equalsIgnoreCase("textarea")) {
String valueStr = doValue(editConfig, editSub);
String rowStr = doRows();

View file

@ -21,6 +21,7 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils" %>
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
<%@ page import="java.util.List" %>
@ -104,25 +105,18 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
if( object == null ) {
//log.warn("Could not find object individual "+objectUri+" via wdf.getIndividualDao().getIndividualByURI(objectUri)");
request.setAttribute("objectName","(name unspecified)");
} else if (FrontEndEditingUtils.isVitroNsObjProp(predicateUri)) {
} else if (FrontEndEditingUtils.isVitroNsObjProp(predicateUri)) {
Model model = (Model)application.getAttribute("jenaOntModel");
request.setAttribute("individual", object);
request.setAttribute("objectName", FrontEndEditingUtils.getVitroNsObjDisplayName(predicateUri, object, model));
log.debug("setting object name " + (String)request.getAttribute("objectName") + " for vitro namespace object property " + predicateUri);
} else {
for (VClass clas : object.getVClasses()) {
request.setAttribute("rangeClassName", clas.getName());
customShortView = MiscWebUtils.getCustomShortView(object, request);
if (customShortView != null) {
foundClass = true;
customShortView = clas.getCustomShortView();
if (customShortView != null && customShortView.trim().length()>0) {
log.debug("setting object name from VClass custom short view");
request.setAttribute("customShortView",shortViewPrefix + customShortView.trim());
request.setAttribute("individual",object);
} else {
log.debug("No custom short view for class, so setting object name from object individual name");
request.setAttribute("objectName",object.getName());
}
log.debug("setting object name from VClass custom short view");
request.setAttribute("customShortView",shortViewPrefix + customShortView.trim());
request.setAttribute("individual",object);
}
if (!foundClass) {
VClass clas = prop.getRangeVClass();

View file

@ -13,7 +13,6 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditN3Generator" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmissionPreprocessor" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field" %>
<%@ page import="java.io.StringReader" %>
<%@ page import="java.util.*" %>

View file

@ -26,6 +26,7 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %>
<%@ 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"%>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Collections" %>
@ -34,13 +35,14 @@
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.HashSet" %>
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.Set"%>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@page import="java.util.LinkedList"%>
<%@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" />
<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");
%>