NIHVIVO-143 Fix to previous commit: took isVitroNsProp value out of the EditConfiguration and put it in the request.
This commit is contained in:
parent
1de471536a
commit
014d9a3762
8 changed files with 75 additions and 57 deletions
|
@ -87,7 +87,6 @@ public class EditConfiguration {
|
|||
String entityToReturnTo;
|
||||
String formUrl;
|
||||
String editKey;
|
||||
boolean isVitroNsProp;
|
||||
|
||||
EditN3Generator n3generator;
|
||||
private String originalJson;
|
||||
|
@ -170,9 +169,6 @@ public class EditConfiguration {
|
|||
|
||||
urlPatternToReturnTo = obj.getString("urlPatternToReturnTo");
|
||||
|
||||
String vitroNsPropParam = obj.getString("isVitroNsProp");
|
||||
isVitroNsProp = vitroNsPropParam != null && vitroNsPropParam.equalsIgnoreCase("true");
|
||||
|
||||
JSONArray predicate = obj.getJSONArray("predicate");
|
||||
if( predicate.length() != 2 )
|
||||
throw new Error("EditConfiguration predicate field must be an array with two items: [varnameForPredicate, predicateUri]");
|
||||
|
@ -515,14 +511,6 @@ public class EditConfiguration {
|
|||
urlPatternToReturnTo = s;
|
||||
}
|
||||
|
||||
public boolean isVitroNsProp() {
|
||||
return isVitroNsProp;
|
||||
}
|
||||
|
||||
public void setIsVitroNsProp(boolean b) {
|
||||
isVitroNsProp = b;
|
||||
}
|
||||
|
||||
/** return a copy of the value so that the configuration is not modified by external code.
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -327,14 +327,25 @@ public class PropertyEditLinks extends TagSupport{
|
|||
|
||||
int index = 0;
|
||||
|
||||
boolean deleteAllowed = ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) &&
|
||||
!( predicateUri.endsWith("#label") || predicateUri.endsWith("#type") ) );
|
||||
|
||||
if( contains( allowedAccessTypeArray, EditLinkAccess.MODIFY ) ){
|
||||
log.debug("Permission found to UPDATE vitro namespace property " + predicateUri);
|
||||
log.debug("permission found to UPDATE vitro namepsace property statement "+ predicateUri);
|
||||
LinkStruct ls = new LinkStruct();
|
||||
String url = makeRelativeHref(dispatchUrl,
|
||||
String url = deleteAllowed
|
||||
? makeRelativeHref(dispatchUrl,
|
||||
"subjectUri", subjectUri,
|
||||
"predicateUri", predicateUri,
|
||||
"datapropKey", dpropHash,
|
||||
"vitroNsProp", "true");
|
||||
"vitroNsProp", "true")
|
||||
: makeRelativeHref(dispatchUrl,
|
||||
"subjectUri", subjectUri,
|
||||
"predicateUri", predicateUri,
|
||||
"datapropKey", dpropHash,
|
||||
"vitroNsProp", "true",
|
||||
"deleteProhibited", "prohibited");
|
||||
|
||||
ls.setHref(url);
|
||||
ls.setType("edit");
|
||||
ls.setMouseoverText("edit this text");
|
||||
|
@ -346,8 +357,7 @@ public class PropertyEditLinks extends TagSupport{
|
|||
}
|
||||
|
||||
// Name and type can be edited but not deleted
|
||||
if ( !( predicateUri.endsWith("#label") || predicateUri.endsWith("#type") ) ) {
|
||||
if ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) ){
|
||||
if ( deleteAllowed ) {
|
||||
LinkStruct ls = new LinkStruct();
|
||||
log.debug("Permission found to DELETE vitro namespace property " + predicateUri);
|
||||
String url = makeRelativeHref(dispatchUrl,
|
||||
|
@ -364,7 +374,6 @@ public class PropertyEditLinks extends TagSupport{
|
|||
else {
|
||||
log.debug("NO permission found to DELETE vitro namespace property " + predicateUri);
|
||||
}
|
||||
}
|
||||
|
||||
return links;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
<%@ page import="java.util.HashMap" %>
|
||||
<%@ page import="org.apache.commons.logging.Log" %>
|
||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
||||
|
||||
<%
|
||||
//org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.editDatapropStmtRequestDispatch.jsp");
|
||||
final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.editDatapropStmtRequestDispatch.jsp");
|
||||
|
@ -64,12 +67,14 @@
|
|||
log.error("required subjectUri parameter missing");
|
||||
throw new Error("predicateUri was empty, it is required by editDatapropStmtRequestDispatch");
|
||||
}
|
||||
|
||||
/* since we have the URIs let's put the individual, data property, and optional data property statement in the request */
|
||||
|
||||
vreq.setAttribute("subjectUri", subjectUri);
|
||||
vreq.setAttribute("subjectUriJson", MiscWebUtils.escape(subjectUri));
|
||||
vreq.setAttribute("predicateUri", predicateUri);
|
||||
vreq.setAttribute("predicateUriJson", MiscWebUtils.escape(predicateUri));
|
||||
|
||||
/* since we have the URIs let's put the individual, data property, and optional data property statement in the request */
|
||||
vreq.setAttribute("vitroNsProp", vitroNsProp);
|
||||
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
|
||||
|
@ -82,7 +87,7 @@
|
|||
|
||||
DataProperty dataproperty = wdf.getDataPropertyDao().getDataPropertyByURI( predicateUri );
|
||||
if( dataproperty == null) {
|
||||
// No dataproperty will be returned for a vitro ns prop
|
||||
// No dataproperty will be returned for a vitro ns prop, but we shouldn't throw an error.
|
||||
if (!isVitroNsProp) {
|
||||
log.error("Could not find data property '"+predicateUri+"' in model");
|
||||
throw new Error("editDatapropStmtRequest.jsp: Could not find DataProperty in model: " + predicateUri);
|
||||
|
@ -112,7 +117,6 @@
|
|||
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||
dps = RdfLiteralHash.getPropertyStmtByHash(subject, dataHash, model, isVitroNsProp);
|
||||
|
||||
|
||||
if (dps==null) {
|
||||
log.error("No match to existing data property \""+predicateUri+"\" statement for subject \""+subjectUri+"\" via key "+datapropKeyStr);
|
||||
%><jsp:forward page="/edit/messages/dataPropertyStatementMissing.jsp"></jsp:forward> <%
|
||||
|
@ -126,7 +130,7 @@
|
|||
log.debug("predicate for DataProperty from request is " + dataproperty.getURI() + " with rangeDatatypeUri of '" + dataproperty.getRangeDatatypeURI() + "'");
|
||||
}
|
||||
if( dps == null )
|
||||
log.debug("no existng DataPropertyStatement statement was found, making a new statemet");
|
||||
log.debug("no existing DataPropertyStatement statement was found, making a new statemet");
|
||||
else{
|
||||
log.debug("Found an existing DataPropertyStatement");
|
||||
String msg = "existing datapropstmt: ";
|
||||
|
@ -134,9 +138,7 @@
|
|||
msg += " prop uri: <"+dps.getDatapropURI() + ">\n";
|
||||
msg += " prop data: \"" + dps.getData() + "\"\n";
|
||||
msg += " datatype: <" + dps.getDatatypeURI() + ">\n";
|
||||
//if (!isVitroNsProp) {
|
||||
msg += " hash of this stmt: " + RdfLiteralHash.makeRdfLiteralHash(dps);
|
||||
//}
|
||||
log.debug(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
|
||||
|
||||
<%@ page import="edu.cornell.mannlib.vedit.beans.LoginFormBean" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataProperty" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
||||
|
@ -51,7 +53,13 @@
|
|||
|
||||
String dataValue=null;
|
||||
// DataPropertyStatement dps=EditConfiguration.findDataPropertyStatementViaHashcode(subject,predicateUri,dataHash);
|
||||
DataPropertyStatement dps= RdfLiteralHash.getDataPropertyStmtByHash(subject,dataHash);
|
||||
//DataPropertyStatement dps= RdfLiteralHash.getDataPropertyStmtByHash(subject,dataHash);
|
||||
|
||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||
String vitroNsProp = vreq.getParameter("vitroNsProp");
|
||||
boolean isVitroNsProp = vitroNsProp != null && vitroNsProp.equals("true") ? true : false;
|
||||
DataPropertyStatement dps = RdfLiteralHash.getPropertyStmtByHash(subject, dataHash, model, isVitroNsProp);
|
||||
|
||||
if( log.isDebugEnabled() ){
|
||||
log.debug("attempting to delete dataPropertyStatement: subjectURI <" + dps.getIndividualURI() +">");
|
||||
log.debug( "predicateURI <" + dps.getDatapropURI() + ">");
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
"editKey" : "${editKey}",
|
||||
"datapropKey" : "<%= datapropKeyStr == null ? "" : datapropKeyStr %>",
|
||||
"urlPatternToReturnTo" : "/entity",
|
||||
"isVitroNsProp" : "true",
|
||||
|
||||
"subject" : ["subject", "${subjectUriJson}" ],
|
||||
"predicate" : ["predicate", "${predicateUriJson}" ],
|
||||
|
@ -127,6 +126,7 @@
|
|||
<c:set var="propertyLabel" value="${propertyName == 'label' ? 'name' : propertyName}" />
|
||||
<c:set var="submitLabel" value="Edit ${propertyLabel}" />
|
||||
<c:set var="title" scope="request" value="Edit the ${propertyLabel} of ${subject.name}:" />
|
||||
<c:set var="vitroNsProp" scope="request" value="true" />
|
||||
|
||||
<jsp:include page="${preForm}"/>
|
||||
|
||||
|
@ -136,5 +136,16 @@
|
|||
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="${param.subjectUri}"/></p>
|
||||
</form>
|
||||
|
||||
<c:if test="${ (!empty param.datapropKey) && (empty param.deleteProhibited) }">
|
||||
<form class="deleteForm" action="editDatapropStmtRequestDispatch.jsp" method="post">
|
||||
<label for="delete"><h3>Delete this entry?</h3></label>
|
||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
||||
<input type="hidden" name="datapropKey" value="${param.datapropKey}"/>
|
||||
<input type="hidden" name="cmd" value="delete"/>
|
||||
<v:input type="submit" id="delete" value="Delete" cancel="" />
|
||||
</form>
|
||||
</c:if>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ if( vreq.getParameter("subjectUri") != null ){
|
|||
Individual individual = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(vreq.getParameter("subjectUri"));
|
||||
String name = "the individual you were trying to edit.";
|
||||
if( individual != null && individual.getName() != null ){
|
||||
name = individual.getName() + ".";
|
||||
name = individual.getName();
|
||||
} %>
|
||||
<c:url value="/entity" var="entityPage">
|
||||
<c:param name="uri"><%=vreq.getParameter("subjectUri")%></c:param>
|
||||
|
|
|
@ -39,7 +39,6 @@ and set a flag in the request to indicate "back button confusion"
|
|||
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.datapropertyBackButtonProblems.jsp");
|
||||
%>
|
||||
<%
|
||||
System.out.println("IN BACK BUTTON JSP");
|
||||
log.debug("Starting datapropertyBackButtonProblems.jsp");
|
||||
|
||||
if( session == null)
|
||||
|
|
|
@ -132,7 +132,7 @@ and set a flag in the request to indicate "back button confusion"
|
|||
throw new Error("In processDatapropRdfForm.jsp, could not find subject Individual via uri " + subjectUri);
|
||||
}
|
||||
|
||||
boolean backButtonProblems = checkForBackButtonConfusion(application, submission, editConfig, subject, wdf);
|
||||
boolean backButtonProblems = checkForBackButtonConfusion(vreq, application, submission, editConfig, subject, wdf);
|
||||
if( backButtonProblems ){
|
||||
%><jsp:forward page="/edit/messages/datapropertyBackButtonProblems.jsp"/><%
|
||||
return;
|
||||
|
@ -369,7 +369,7 @@ and set a flag in the request to indicate "back button confusion"
|
|||
return fieldChanged;
|
||||
}
|
||||
|
||||
private boolean checkForBackButtonConfusion(ServletContext application, EditSubmission submission,
|
||||
private boolean checkForBackButtonConfusion(VitroRequest vreq, ServletContext application, EditSubmission submission,
|
||||
EditConfiguration editConfig, Individual subject,
|
||||
WebappDaoFactory wdf) {
|
||||
if (editConfig.getDatapropKey() == null
|
||||
|
@ -378,7 +378,8 @@ and set a flag in the request to indicate "back button confusion"
|
|||
|
||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||
int dpropHash = Integer.parseInt(editConfig.getDatapropKey());
|
||||
boolean isVitroNsProp = editConfig.isVitroNsProp();
|
||||
String vitroNsProp = vreq.getParameter("vitroNsProp");
|
||||
boolean isVitroNsProp = vitroNsProp != null && vitroNsProp.equals("true");
|
||||
DataPropertyStatement dps = RdfLiteralHash.getPropertyStmtByHash(subject, dpropHash, model, isVitroNsProp);
|
||||
|
||||
if (dps != null)
|
||||
|
|
Loading…
Add table
Reference in a new issue