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.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 edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
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.DESCRIPTION,
|
||||
VitroVocabulary.IMAGETHUMB,
|
||||
|
@ -22,7 +28,8 @@ public class FrontEndEditingUtils {
|
|||
// 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
|
||||
);
|
||||
|
||||
|
@ -45,5 +52,48 @@ public class FrontEndEditingUtils {
|
|||
// 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 boolean isVitroNsObjProp(String propertyUri) {
|
||||
return VITRO_NS_OBJECT_PROPS.contains(propertyUri);
|
||||
}
|
||||
|
||||
public static String getVitroNsObjDisplayName(String predicateUri, Individual object, Model model) {
|
||||
|
||||
String displayName = null;
|
||||
|
||||
// These are the only Vitro namespace object properties that are editable on the front end at this point.
|
||||
if (StringUtils.equalsOneOf(predicateUri, VitroVocabulary.PRIMARY_LINK, VitroVocabulary.ADDITIONAL_LINK)) {
|
||||
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) {
|
||||
String predicateUri = (String) item;
|
||||
String subjectUri = entity.getURI();
|
||||
if (isVitroNsDataProp(predicateUri)) {
|
||||
if (FrontEndEditingUtils.isVitroNsDataProp(predicateUri)) {
|
||||
if (data == null) { // link to add a new value
|
||||
links = doVitroNsDataProp( subjectUri, predicateUri, policyToAccess(ids, policy, subjectUri, predicateUri), contextPath );
|
||||
} else { // links to edit or delete an existing value
|
||||
DataPropertyStatement dps = (DataPropertyStatement) new DataPropertyStatementImpl(subjectUri, predicateUri, data);
|
||||
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
|
||||
links = doObjProp( subjectUri, predicateUri, policyToAccess(ids, policy, subjectUri, predicateUri), contextPath );
|
||||
} else { // links to edit or delete an existing value
|
||||
|
@ -640,15 +640,6 @@ public class PropertyEditLinks extends TagSupport{
|
|||
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) {
|
||||
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"%>
|
||||
<%@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" %>
|
||||
<%@ 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.vitro.webapp.edit.n3editing.EditN3Utils"%>
|
||||
<%@ 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.ObjectPropertyStatement"%>
|
||||
|
@ -21,10 +19,18 @@
|
|||
<%@ 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" %>
|
||||
<%@ 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="org.apache.commons.logging.Log" %>
|
||||
<%@ 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");
|
||||
|
||||
|
@ -94,9 +100,15 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
|||
String customShortView = null;
|
||||
String shortViewPrefix = "/templates/entity/";
|
||||
Individual object = getUnfilteredDaoFactory().getIndividualDao().getIndividualByURI(objectUri);
|
||||
|
||||
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)");
|
||||
} 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(true)) { // direct VClasses, not inferred, and not including Vitro namespace
|
||||
request.setAttribute("rangeClassName", clas.getName());
|
||||
|
@ -130,7 +142,7 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
|||
<jsp:include page="${preForm}"/>
|
||||
|
||||
<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">
|
||||
<c:choose>
|
||||
<c:when test="${!empty customShortView}">
|
||||
|
|
Loading…
Add table
Reference in a new issue