2010-01-29 22:13:57 +00:00
|
|
|
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
|
|
|
|
|
|
|
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle"%>
|
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.RoleIdentifier"%>
|
2011-05-12 16:02:37 +00:00
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils"%>
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ 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.beans.ObjectProperty"%>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Link" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.LinksDao" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
2010-03-26 18:54:33 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils" %>
|
|
|
|
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
|
2010-07-19 21:37:59 +00:00
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
2011-03-24 21:22:24 +00:00
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel" %>
|
2011-02-01 23:54:41 +00:00
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfigurationLoader"%>
|
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet"%>
|
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper"%>
|
|
|
|
|
|
|
|
<%@page import="freemarker.template.Configuration"%>
|
2010-03-26 18:54:33 +00:00
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ page import="java.util.List" %>
|
2011-02-01 23:54:41 +00:00
|
|
|
<%@ page import="java.util.Map" %>
|
|
|
|
<%@ page import="java.util.HashMap" %>
|
2010-03-26 18:54:33 +00:00
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ page import="org.apache.commons.logging.Log" %>
|
|
|
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
|
|
|
|
2010-03-26 18:54:33 +00:00
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
|
|
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
|
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jstl/functions" %>
|
2010-10-14 19:10:21 +00:00
|
|
|
|
2011-04-27 20:20:25 +00:00
|
|
|
<%@taglib prefix="vitro" uri="/WEB-INF/tlds/VitroUtils.tld" %>
|
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.UseMiscellaneousPages" %>
|
|
|
|
<% request.setAttribute("requestedActions", new UseMiscellaneousPages()); %>
|
|
|
|
<vitro:confirmAuthorization />
|
2010-03-26 18:54:33 +00:00
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%!
|
|
|
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.propDelete.jsp");
|
|
|
|
|
|
|
|
public WebappDaoFactory getUnfilteredDaoFactory() {
|
|
|
|
return (WebappDaoFactory) getServletContext().getAttribute("webappDaoFactory");
|
|
|
|
}
|
|
|
|
%>
|
|
|
|
|
|
|
|
<%-- grab the predicate URI and trim it down to get the Local Name so we can send the user back to the appropriate property --%>
|
|
|
|
<c:set var="predicateUri" value="${param.predicateUri}" />
|
|
|
|
<c:set var="localName" value="${fn:substringAfter(predicateUri, '#')}" />
|
|
|
|
<c:url var="redirectUrl" value="../entity">
|
|
|
|
<c:param name="uri" value="${param.subjectUri}"/>
|
|
|
|
</c:url>
|
|
|
|
|
|
|
|
<%
|
|
|
|
String subjectUri = request.getParameter("subjectUri");
|
|
|
|
String predicateUri = request.getParameter("predicateUri");
|
|
|
|
String objectUri = request.getParameter("objectUri");
|
|
|
|
|
|
|
|
VitroRequest vreq = new VitroRequest(request);
|
|
|
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
|
|
if( wdf == null ) {
|
|
|
|
throw new Error("could not get a WebappDaoFactory");
|
|
|
|
}
|
|
|
|
ObjectProperty prop = wdf.getObjectPropertyDao().getObjectPropertyByURI(predicateUri);
|
|
|
|
if( prop == null ) {
|
|
|
|
throw new Error("In propDelete.jsp, could not find property " + predicateUri);
|
|
|
|
}
|
2010-03-26 19:00:41 +00:00
|
|
|
request.setAttribute("propertyName",prop.getDomainPublic().toLowerCase());
|
2010-01-29 22:13:57 +00:00
|
|
|
|
|
|
|
//do the delete
|
|
|
|
if( request.getParameter("y") != null ) {
|
|
|
|
|
2011-03-11 21:39:50 +00:00
|
|
|
String editorUri = EditN3Utils.getEditorUri(request);
|
2010-01-29 22:13:57 +00:00
|
|
|
wdf = wdf.getUserAwareDaoFactory(editorUri);
|
|
|
|
|
2010-03-30 20:00:17 +00:00
|
|
|
if (prop.getStubObjectRelation()) {
|
2010-01-29 22:13:57 +00:00
|
|
|
Individual object = (Individual)request.getAttribute("object");
|
|
|
|
if (object==null) {
|
|
|
|
object = getUnfilteredDaoFactory().getIndividualDao().getIndividualByURI(objectUri);
|
|
|
|
}
|
|
|
|
if( object != null ) {
|
|
|
|
log.warn("Deleting individual "+object.getName()+" since property has been set to force range object deletion");
|
|
|
|
wdf.getIndividualDao().deleteIndividual(object);
|
|
|
|
} else {
|
|
|
|
throw new Error("Could not find object as request attribute or in model: '" + objectUri + "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement(subjectUri,predicateUri,objectUri); %>
|
|
|
|
<c:redirect url="${redirectUrl}${'#'}${localName}"/>
|
|
|
|
<% }
|
|
|
|
|
|
|
|
Individual subject = wdf.getIndividualDao().getIndividualByURI(subjectUri);
|
|
|
|
if( subject == null ) throw new Error("could not find subject " + subjectUri);
|
|
|
|
request.setAttribute("subjectName",subject.getName());
|
2010-03-26 18:54:33 +00:00
|
|
|
|
2011-02-01 23:58:08 +00:00
|
|
|
// Get the statement data to display
|
|
|
|
// rjy7 Alternative implementation: have the template put the markup into a url or form param
|
|
|
|
// which can then just be spit out here.
|
2011-02-01 23:54:41 +00:00
|
|
|
String templateName = request.getParameter("templateName");
|
|
|
|
Map params = request.getParameterMap();
|
|
|
|
Map<String, String> statement = new HashMap<String, String>();
|
|
|
|
for (Object key : params.keySet()) {
|
|
|
|
String keyString = (String) key; //key.toString()
|
|
|
|
if (keyString.startsWith("statement_")) {
|
|
|
|
keyString = keyString.replaceFirst("statement_", "");
|
|
|
|
String value = ( (String[]) params.get(key))[0];
|
|
|
|
statement.put(keyString, value);
|
2010-01-29 22:13:57 +00:00
|
|
|
}
|
2011-02-01 23:54:41 +00:00
|
|
|
}
|
|
|
|
|
2011-02-01 23:58:08 +00:00
|
|
|
// Process the statement data through the template to create the display string
|
2011-02-01 23:54:41 +00:00
|
|
|
String statementDisplay = null;
|
|
|
|
if (! statement.isEmpty()) {
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
2011-03-28 22:25:07 +00:00
|
|
|
map.put("statement", statement);
|
|
|
|
|
2011-03-24 21:22:24 +00:00
|
|
|
/* Some propStatements (propStatement-educationalTraining.ftl) make reference to the individual,
|
2011-03-28 22:25:07 +00:00
|
|
|
* but instead of adding it to the data model we'll test in the template for non-existence. If
|
2011-03-24 21:22:24 +00:00
|
|
|
* this becomes more common, add it here instead.
|
|
|
|
*/
|
|
|
|
//map.put("individual", new IndividualTemplateModel(subject, vreq));
|
2011-03-28 22:25:07 +00:00
|
|
|
|
2011-02-01 23:54:41 +00:00
|
|
|
map.putAll(FreemarkerHttpServlet.getDirectives());
|
|
|
|
map.putAll(FreemarkerHttpServlet.getMethods());
|
|
|
|
ServletContext context = getServletContext();
|
|
|
|
FreemarkerConfigurationLoader loader =
|
|
|
|
FreemarkerConfigurationLoader.getFreemarkerConfigurationLoader(context);
|
|
|
|
Configuration fmConfig = loader.getConfig(vreq);
|
|
|
|
TemplateProcessingHelper helper = new TemplateProcessingHelper(fmConfig, vreq, context);
|
|
|
|
statementDisplay = helper.processTemplateToString(templateName, map);
|
|
|
|
}
|
|
|
|
request.setAttribute("statementDisplay", statementDisplay);
|
|
|
|
%>
|
2010-01-29 22:13:57 +00:00
|
|
|
|
|
|
|
<jsp:include page="${preForm}"/>
|
|
|
|
|
|
|
|
<form action="editRequestDispatch.jsp" method="get">
|
2010-03-30 20:59:48 +00:00
|
|
|
<label for="submit"><h2>Are you sure you want to delete the following entry from <em>${propertyName}</em>?</h2></label>
|
2011-02-01 23:54:41 +00:00
|
|
|
<div class="toBeDeleted objProp">${statementDisplay}</div>
|
2010-01-29 22:13:57 +00:00
|
|
|
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
|
|
|
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
|
|
|
<input type="hidden" name="objectUri" value="${param.objectUri}"/>
|
|
|
|
<input type="hidden" name="y" value="1"/>
|
|
|
|
<input type="hidden" name="cmd" value="delete"/>
|
2010-06-17 14:26:59 +00:00
|
|
|
<p class="submit"><v:input type="submit" id="submit" value="Delete" cancel="true" /></p>
|
2010-01-29 22:13:57 +00:00
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<jsp:include page="${postForm}"/>
|