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