From 012be3fdabafab9212943ba39586e57f33577e7d Mon Sep 17 00:00:00 2001 From: bdc34 Date: Wed, 21 Jul 2010 22:16:46 +0000 Subject: [PATCH] Merge to trunk: Adding custom form that redirects to publication instead of editing. NIHVIVO-912 --- .../edit/forms/redirectToPublication.jsp | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 productMods/edit/forms/redirectToPublication.jsp diff --git a/productMods/edit/forms/redirectToPublication.jsp b/productMods/edit/forms/redirectToPublication.jsp new file mode 100644 index 00000000..ccf5545b --- /dev/null +++ b/productMods/edit/forms/redirectToPublication.jsp @@ -0,0 +1,70 @@ +<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> + +<%-- +This form will not allow an edit but will redirect to the publication. +This can be used to skip over an authorship context node. + +What does this do on an add? +It shouldn't encounter an add, it will redirect to the subject. Hide the add with in a policy. + +What about the delete link? +The delete link will not go to this form. You should hide the delete link with the policy. +--%> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.util.Arrays" %> + +<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils" %> + +<%@ page import="org.apache.commons.logging.Log" %> +<%@ page import="org.apache.commons.logging.LogFactory" %> + +<%! + public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.redirectToObject.jsp"); + public static String nodeToPubProp = "http://vivoweb.org/ontology/core#linkedInformationResource"; +%> +<% + VitroRequest vreq = new VitroRequest(request); + WebappDaoFactory wdf = vreq.getWebappDaoFactory(); + + Individual subject = (Individual) request.getAttribute("subject"); + Individual obj = (Individual) request.getAttribute("object"); + + if( obj == null ){ + log.warn("this custom form is intended to redirect to the object but none was found."); + %> + + + + <% + }else{ + List stmts = obj.getObjectPropertyStatements( nodeToPubProp ); + if( stmts == null || stmts.size() == 0 ){ + %> + + + + <% + } else { + ObjectPropertyStatement ops = stmts.get(0); + String pubUri = ops.getObjectURI(); + if( pubUri != null ){ + %> + + + + <% + } else{ + %> + + + + <% } + } + } +%> + \ No newline at end of file