NIHVIVO-144 Show the link on the delete confirmation screen when deleting a primary or additional link for an individual from the front end.
This commit is contained in:
parent
732266d962
commit
f96eb9722d
3 changed files with 86 additions and 33 deletions
|
@ -5,14 +5,20 @@ package edu.cornell.mannlib.vitro.webapp.utils;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
//import com.hp.hpl.jena.rdf.model.Resource;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
|
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||||
import com.hp.hpl.jena.vocabulary.XSD;
|
import com.hp.hpl.jena.vocabulary.XSD;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
public class FrontEndEditingUtils {
|
public class FrontEndEditingUtils {
|
||||||
|
|
||||||
public static final List<String> VITRO_NS_DATA_PROPS = Arrays.asList(VitroVocabulary.BLURB,
|
// NB List includes only those properties currently editable from the front end.
|
||||||
|
private static final List<String> VITRO_NS_DATA_PROPS = Arrays.asList(VitroVocabulary.BLURB,
|
||||||
VitroVocabulary.CITATION,
|
VitroVocabulary.CITATION,
|
||||||
VitroVocabulary.DESCRIPTION,
|
VitroVocabulary.DESCRIPTION,
|
||||||
VitroVocabulary.IMAGETHUMB,
|
VitroVocabulary.IMAGETHUMB,
|
||||||
|
@ -22,7 +28,8 @@ public class FrontEndEditingUtils {
|
||||||
// VitroVocabulary.TIMEKEY
|
// VitroVocabulary.TIMEKEY
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final List<String> VITRO_NS_OBJECT_PROPS = Arrays.asList(VitroVocabulary.ADDITIONAL_LINK,
|
// NB List includes only those properties currently editable from the front end.
|
||||||
|
private static final List<String> VITRO_NS_OBJECT_PROPS = Arrays.asList(VitroVocabulary.ADDITIONAL_LINK,
|
||||||
VitroVocabulary.PRIMARY_LINK
|
VitroVocabulary.PRIMARY_LINK
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -32,18 +39,61 @@ public class FrontEndEditingUtils {
|
||||||
//return datatype.getURI();
|
//return datatype.getURI();
|
||||||
return XSD.xstring.getURI();
|
return XSD.xstring.getURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static final Map<String, String> VITRO_NS_PROPERTIES = new HashMap<String, String>() {
|
||||||
|
// {
|
||||||
|
// put(BLURB, XSD.xstring.getURI());
|
||||||
|
// put(CITATION, XSD.xstring.getURI());
|
||||||
|
// put(DESCRIPTION, XSD.xstring.getURI());
|
||||||
|
// put(LABEL, XSD.xstring.getURI());
|
||||||
|
// put(LINK_ANCHOR, XSD.xstring.getURI());
|
||||||
|
// put(MONIKER, XSD.xstring.getURI());
|
||||||
|
// put(PRIMARY_LINK, XSD.xstring.getURI());
|
||||||
|
// put(RDF_TYPE, XSD.xstring.getURI());
|
||||||
|
// put(TIMEKEY, XSD.dateTime.getURI());
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
|
||||||
|
public static boolean isVitroNsDataProp(String propertyUri) {
|
||||||
|
return VITRO_NS_DATA_PROPS.contains(propertyUri);
|
||||||
|
}
|
||||||
|
|
||||||
// public static final Map<String, String> VITRO_NS_PROPERTIES = new HashMap<String, String>() {
|
public static boolean isVitroNsObjProp(String propertyUri) {
|
||||||
// {
|
return VITRO_NS_OBJECT_PROPS.contains(propertyUri);
|
||||||
// put(BLURB, XSD.xstring.getURI());
|
}
|
||||||
// put(CITATION, XSD.xstring.getURI());
|
|
||||||
// put(DESCRIPTION, XSD.xstring.getURI());
|
public static String getVitroNsObjDisplayName(String predicateUri, Individual object, Model model) {
|
||||||
// put(LABEL, XSD.xstring.getURI());
|
|
||||||
// put(LINK_ANCHOR, XSD.xstring.getURI());
|
String displayName = null;
|
||||||
// put(MONIKER, XSD.xstring.getURI());
|
|
||||||
// put(PRIMARY_LINK, XSD.xstring.getURI());
|
// These are the only Vitro namespace object properties that are editable on the front end at this point.
|
||||||
// put(RDF_TYPE, XSD.xstring.getURI());
|
if (StringUtils.equalsOneOf(predicateUri, VitroVocabulary.PRIMARY_LINK, VitroVocabulary.ADDITIONAL_LINK)) {
|
||||||
// put(TIMEKEY, XSD.dateTime.getURI());
|
String linkAnchor = getLiteralValue(model, object, VitroVocabulary.LINK_ANCHOR);
|
||||||
// }
|
String linkUrl = getLiteralValue(model, object, VitroVocabulary.LINK_URL);
|
||||||
// };
|
displayName = "<a href='" + linkUrl + "'>" + linkAnchor + "</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return displayName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getLiteralValue(Model model, Individual ind, String predicateUri) {
|
||||||
|
|
||||||
|
String value = null;
|
||||||
|
StmtIterator stmts = model.listStatements(model.createResource(ind.getURI()),
|
||||||
|
model.getProperty(predicateUri),
|
||||||
|
(RDFNode)null);
|
||||||
|
while (stmts.hasNext()) {
|
||||||
|
Statement stmt = stmts.nextStatement();
|
||||||
|
RDFNode node = stmt.getObject();
|
||||||
|
if (node.isLiteral()) {
|
||||||
|
Literal lit = (Literal) node.as(Literal.class);
|
||||||
|
value = lit.getLexicalForm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,14 +141,14 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
} else if (item instanceof String) {
|
} else if (item instanceof String) {
|
||||||
String predicateUri = (String) item;
|
String predicateUri = (String) item;
|
||||||
String subjectUri = entity.getURI();
|
String subjectUri = entity.getURI();
|
||||||
if (isVitroNsDataProp(predicateUri)) {
|
if (FrontEndEditingUtils.isVitroNsDataProp(predicateUri)) {
|
||||||
if (data == null) { // link to add a new value
|
if (data == null) { // link to add a new value
|
||||||
links = doVitroNsDataProp( subjectUri, predicateUri, policyToAccess(ids, policy, subjectUri, predicateUri), contextPath );
|
links = doVitroNsDataProp( subjectUri, predicateUri, policyToAccess(ids, policy, subjectUri, predicateUri), contextPath );
|
||||||
} else { // links to edit or delete an existing value
|
} else { // links to edit or delete an existing value
|
||||||
DataPropertyStatement dps = (DataPropertyStatement) new DataPropertyStatementImpl(subjectUri, predicateUri, data);
|
DataPropertyStatement dps = (DataPropertyStatement) new DataPropertyStatementImpl(subjectUri, predicateUri, data);
|
||||||
links = doVitroNsDataPropStmt( dps, entity, policyToAccess(ids, policy, dps), contextPath );
|
links = doVitroNsDataPropStmt( dps, entity, policyToAccess(ids, policy, dps), contextPath );
|
||||||
}
|
}
|
||||||
} else if (isVitroNsObjProp(predicateUri)) {
|
} else if (FrontEndEditingUtils.isVitroNsObjProp(predicateUri)) {
|
||||||
if (data == null) { // link to add a new value
|
if (data == null) { // link to add a new value
|
||||||
links = doObjProp( subjectUri, predicateUri, policyToAccess(ids, policy, subjectUri, predicateUri), contextPath );
|
links = doObjProp( subjectUri, predicateUri, policyToAccess(ids, policy, subjectUri, predicateUri), contextPath );
|
||||||
} else { // links to edit or delete an existing value
|
} else { // links to edit or delete an existing value
|
||||||
|
@ -640,15 +640,6 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
return ls;
|
return ls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isVitroNsDataProp(String predicateUri) {
|
|
||||||
return FrontEndEditingUtils.VITRO_NS_DATA_PROPS.contains(predicateUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isVitroNsObjProp(String predicateUri) {
|
|
||||||
return FrontEndEditingUtils.VITRO_NS_OBJECT_PROPS.contains(predicateUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getObjPropMouseoverLabel(String propertyUri) {
|
private String getObjPropMouseoverLabel(String propertyUri) {
|
||||||
String mouseoverText = "relationship"; // default
|
String mouseoverText = "relationship"; // default
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory.SelfEditing"%>
|
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory.SelfEditing"%>
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory"%>
|
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory"%>
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.RoleIdentifier"%>
|
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.RoleIdentifier"%>
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditN3Utils"%><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditN3Utils"%>
|
||||||
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jstl/functions" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginFormBean" %>
|
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginFormBean" %>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
<%@ 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.ObjectPropertyStatement"%>
|
||||||
|
@ -21,10 +19,18 @@
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.LinksDao" %>
|
<%@ 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.filters.VitroRequestPrep" %>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
<%@ 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="java.util.List" %>
|
<%@ page import="java.util.List" %>
|
||||||
|
|
||||||
<%@ page import="org.apache.commons.logging.Log" %>
|
<%@ page import="org.apache.commons.logging.Log" %>
|
||||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||||
|
|
||||||
|
<%@ 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" %>
|
||||||
|
|
||||||
<%!
|
<%!
|
||||||
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.propDelete.jsp");
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.propDelete.jsp");
|
||||||
|
|
||||||
|
@ -46,7 +52,7 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
||||||
}
|
}
|
||||||
boolean selfEditing = VitroRequestPrep.isSelfEditing(request);
|
boolean selfEditing = VitroRequestPrep.isSelfEditing(request);
|
||||||
if (!selfEditing && !LoginFormBean.loggedIn(request, LoginFormBean.NON_EDITOR)) {%>
|
if (!selfEditing && !LoginFormBean.loggedIn(request, LoginFormBean.NON_EDITOR)) {%>
|
||||||
<c:redirect url="<%= Controllers.LOGIN %>" />
|
<c:redirect url="<%= Controllers.LOGIN %>" />
|
||||||
<% }
|
<% }
|
||||||
|
|
||||||
String subjectUri = request.getParameter("subjectUri");
|
String subjectUri = request.getParameter("subjectUri");
|
||||||
|
@ -94,9 +100,15 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
||||||
String customShortView = null;
|
String customShortView = null;
|
||||||
String shortViewPrefix = "/templates/entity/";
|
String shortViewPrefix = "/templates/entity/";
|
||||||
Individual object = getUnfilteredDaoFactory().getIndividualDao().getIndividualByURI(objectUri);
|
Individual object = getUnfilteredDaoFactory().getIndividualDao().getIndividualByURI(objectUri);
|
||||||
|
|
||||||
if( object == null ) {
|
if( object == null ) {
|
||||||
log.warn("Could not find object individual "+objectUri+" via wdf.getIndividualDao().getIndividualByURI(objectUri)");
|
//log.warn("Could not find object individual "+objectUri+" via wdf.getIndividualDao().getIndividualByURI(objectUri)");
|
||||||
request.setAttribute("objectName","(name unspecified)");
|
request.setAttribute("objectName","(name unspecified)");
|
||||||
|
} 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 {
|
} else {
|
||||||
for (VClass clas : object.getVClasses(true)) { // direct VClasses, not inferred, and not including Vitro namespace
|
for (VClass clas : object.getVClasses(true)) { // direct VClasses, not inferred, and not including Vitro namespace
|
||||||
request.setAttribute("rangeClassName", clas.getName());
|
request.setAttribute("rangeClassName", clas.getName());
|
||||||
|
@ -130,7 +142,7 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
||||||
<jsp:include page="${preForm}"/>
|
<jsp:include page="${preForm}"/>
|
||||||
|
|
||||||
<form action="editRequestDispatch.jsp" method="get">
|
<form action="editRequestDispatch.jsp" method="get">
|
||||||
<label for="submit"><h2>Are you sure you want to delete the following entry from <em>${propertyName}</em>?</h2></label>
|
<label for="submit"><h2>Are you sure you want to delete the following entry for <em>${propertyName}</em>?</h2></label>
|
||||||
<div class="toBeDeleted objProp">
|
<div class="toBeDeleted objProp">
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${!empty customShortView}">
|
<c:when test="${!empty customShortView}">
|
||||||
|
|
Loading…
Add table
Reference in a new issue