NIHVIVO-143 Front end editing of moniker

This commit is contained in:
rjy7 2010-03-16 19:17:53 +00:00
parent 1af92dc350
commit 1de471536a
9 changed files with 87 additions and 54 deletions

View file

@ -14,9 +14,11 @@
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%
org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.editDatapropStmtRequestDispatch");
//Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.editDatapropStmtRequestDispatch");
//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");
%>
<%
// Decide which form to forward to, set subjectUri, subjectUriJson, predicateUri, predicateUriJson in request
@ -107,13 +109,9 @@
DataPropertyStatement dps = null;
if( dataHash != 0) {
if (isVitroNsProp) {
Model model = (Model)application.getAttribute("jenaOntModel");
dps = RdfLiteralHash.getVitroNsPropertyStmtByHash(subject, model, dataHash);
}
else {
dps = RdfLiteralHash.getDataPropertyStmtByHash(subject, dataHash);
}
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);
@ -124,7 +122,9 @@
}
if( log.isDebugEnabled() ){
log.debug("predicate for DataProperty from request is " + dataproperty.getURI() + " with rangeDatatypeUri of '" + dataproperty.getRangeDatatypeURI() + "'");
if (dataproperty != null) {
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");
else{
@ -134,7 +134,9 @@
msg += " prop uri: <"+dps.getDatapropURI() + ">\n";
msg += " prop data: \"" + dps.getData() + "\"\n";
msg += " datatype: <" + dps.getDatatypeURI() + ">\n";
msg += " hash of this stmt: " + RdfLiteralHash.makeRdfLiteralHash(dps);
//if (!isVitroNsProp) {
msg += " hash of this stmt: " + RdfLiteralHash.makeRdfLiteralHash(dps);
//}
log.debug(msg);
}
}

View file

@ -126,7 +126,6 @@
</c:set>
<%
System.out.println(request.getAttribute("editjson"));
if( log.isDebugEnabled()) log.debug(request.getAttribute("editjson"));
EditConfiguration editConfig = new EditConfiguration((String)vreq.getAttribute("editjson"));

View file

@ -36,14 +36,6 @@
%>
<%-- RY Once this is working, change to just one vitroNsEditForm for all vitro ns props, by parameterizing the predicate.
The title and submit button text will need to be customized.
Not sure sparqlForExistingLiterals is needed: see defaultDatapropForm - doesn't use it.
--%>
<%-- RY Change labelExisting, label, and labelAssertion to variables once this is working,
so it can be more easily copied to another form.
Also change hard-coded predicate to ?predicate, so it will be picked up from the editConfig predicate --%>
<c:set var="predicate" value="<%=predicateUri%>" />
<c:set var="propertyName" value="${fn:substringAfter(predicate, '#')}" />
@ -60,19 +52,28 @@ Also change hard-coded predicate to ?predicate, so it will be picked up from the
The actual assertion inserted in the model will be created via string substitution into the ? variables.
NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%>
<v:jsonset var="dataAssertion" >
?subject <${predicate}> ?label .
?subject <${predicate}> ?${propertyName} .
</v:jsonset>
<%-- RY This will be the default, but base it on propertyName --%>
<c:set var="rangeDatatypeUri" value="http://www.w3.org/2001/XMLSchema#string" />
<%-- RY Add other validation cases here. --%>
<c:choose>
<c:when test="${propertyName == 'label' || propertyName == 'type'}">
<c:set var="validator" value="nonempty" />
</c:when>
</c:choose>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"datapropKey" : "<%= datapropKeyStr == null ? "" : datapropKeyStr %>",
"urlPatternToReturnTo" : "/entity",
"isVitroNsProp" : "true",
"subject" : ["subject", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["${propertyName}", "", "DATAPROPHASH" ],
@ -90,9 +91,9 @@ Also change hard-coded predicate to ?predicate, so it will be picked up from the
"sparqlForExistingLiterals" : { "${propertyName}" : "${dataExisting}" },
"sparqlForExistingUris" : { },
"fields" : {
"label" : {
"${propertyName}" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"validators" : [ <c:if test="${!empty validator}">"${validator}"</c:if> ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
@ -106,10 +107,14 @@ Also change hard-coded predicate to ?predicate, so it will be picked up from the
</c:set>
<%
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
log.debug("No editConfig in session. Making new editConfig.");
log.debug(vreq.getAttribute("editjson"));
editConfig = new EditConfiguration((String)vreq.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig, session);
}
if ( datapropKeyStr != null && datapropKeyStr.trim().length() > 0 ) {
@ -127,7 +132,7 @@ Also change hard-coded predicate to ?predicate, so it will be picked up from the
<h2>${title}</h2>
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
<v:input type="text" id="label" size="30" />
<v:input type="text" id="${propertyName}" size="30" />
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="${param.subjectUri}"/></p>
</form>

View file

@ -39,7 +39,7 @@ 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)
@ -57,7 +57,7 @@ and set a flag in the request to indicate "back button confusion"
VitroRequest vreq = new VitroRequest(request);
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,vreq);
EditSubmission submission = new EditSubmission(vreq, vreq.getParameterMap(), editConfig);
EditSubmission submission = new EditSubmission(vreq.getParameterMap(), editConfig);
EditN3Generator n3Subber = editConfig.getN3Generator();
List<String> n3Required = editConfig.getN3Required();
@ -182,13 +182,13 @@ and set a flag in the request to indicate "back button confusion"
jenaOntModel.remove( model );
}
}catch(Throwable t){
errorMessages.add("In processDatapropRdfForm.jsp, error adding edit change n3required model to in memory model \n"+ t.getMessage() );
errorMessages.add("In datapropertyBackButtonProblems.jsp, error adding edit change n3required model to in memory model \n"+ t.getMessage() );
}finally{
lock.leaveCriticalSection();
}
%>
<jsp:forward page="postEditCleanUp.jsp"/>
<jsp:forward page="../postEditCleanUp.jsp"/>
<%!

View file

@ -62,15 +62,15 @@ 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.processDatapropRdfForm.jsp");
final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.processDatapropRdfForm.jsp");
%>
<%
log.debug("Starting processDatapropRdfForm.jsp");
if( session == null)
throw new Error("need to have session");
%>
<%
boolean selfEditing = VitroRequestPrep.isSelfEditing(request);
if (!selfEditing && !LoginFormBean.loggedIn(request, LoginFormBean.NON_EDITOR)) {
%><c:redirect url="<%= Controllers.LOGIN %>" /><%
@ -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( submission, editConfig, subject, wdf);
boolean backButtonProblems = checkForBackButtonConfusion(application, submission, editConfig, subject, wdf);
if( backButtonProblems ){
%><jsp:forward page="/edit/messages/datapropertyBackButtonProblems.jsp"/><%
return;
@ -369,14 +369,18 @@ and set a flag in the request to indicate "back button confusion"
return fieldChanged;
}
private boolean checkForBackButtonConfusion(EditSubmission submission,
private boolean checkForBackButtonConfusion(ServletContext application, EditSubmission submission,
EditConfiguration editConfig, Individual subject,
WebappDaoFactory wdf) {
if (editConfig.getDatapropKey() == null
|| editConfig.getDatapropKey().length() == 0)
return false;
DataPropertyStatement dps = RdfLiteralHash.getDataPropertyStmtByHash(
subject, Integer.parseInt(editConfig.getDatapropKey()));
Model model = (Model)application.getAttribute("jenaOntModel");
int dpropHash = Integer.parseInt(editConfig.getDatapropKey());
boolean isVitroNsProp = editConfig.isVitroNsProp();
DataPropertyStatement dps = RdfLiteralHash.getPropertyStmtByHash(subject, dpropHash, model, isVitroNsProp);
if (dps != null)
return false;
DataProperty dp = wdf.getDataPropertyDao().getDataPropertyByURI(