NIHVIVO-149 An individual's name can now be edited from the front end.

This commit is contained in:
rjy7 2010-03-15 15:35:35 +00:00
parent e06c6d0cba
commit f8726e8356
13 changed files with 287 additions and 94 deletions

View file

@ -38,6 +38,11 @@
<required>false</required> <required>false</required>
<rtexprvalue>true</rtexprvalue> <rtexprvalue>true</rtexprvalue>
</attribute> </attribute>
<attribute>
<name>data</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag> </tag>
</taglib> </taglib>

View file

@ -18,13 +18,6 @@ public class EditDataPropStmt implements RequestedAction {
this.dataPropStmt = dps; this.dataPropStmt = dps;
} }
public EditDataPropStmt(String subjectUri, String predicateUri, String data) {
dataPropStmt = new DataPropertyStatementImpl();
dataPropStmt.setIndividualURI(subjectUri);
dataPropStmt.setDatapropURI(predicateUri);
dataPropStmt.setData(data);
}
public PolicyDecision accept(VisitingPolicyIface policy, IdentifierBundle whoToAuth) { public PolicyDecision accept(VisitingPolicyIface policy, IdentifierBundle whoToAuth) {
return policy.visit(whoToAuth,this); return policy.visit(whoToAuth,this);
} }

View file

@ -4,8 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date; import java.util.Date;
import com.hp.hpl.jena.rdf.model.Property;
/** /**
* a class representing an particular instance of a data property * a class representing a particular instance of a data property
* *
*/ */
public interface DataPropertyStatement { public interface DataPropertyStatement {
@ -20,7 +22,7 @@ public interface DataPropertyStatement {
public String getDatapropURI(); public String getDatapropURI();
public void setDatapropURI(String datapropURI); public void setDatapropURI(String propertyURI);
public String getDatatypeURI(); public String getDatatypeURI();

View file

@ -29,6 +29,12 @@ public class DataPropertyStatementImpl implements VitroTimeWindowedResource, Dat
} }
} }
public DataPropertyStatementImpl(String individualUri, String propertyUri, String data){
individualURI = individualUri;
datapropURI = propertyUri;
this.data = data;
}
public String getIndividualURI() { public String getIndividualURI() {
return individualURI; return individualURI;
} }

View file

@ -18,7 +18,6 @@ public class VitroVocabulary {
*/ */
public static final String PSEUDO_BNODE_NS = "http://vitro.mannlib.cornell.edu/ns/bnode#"; public static final String PSEUDO_BNODE_NS = "http://vitro.mannlib.cornell.edu/ns/bnode#";
public static final String RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; public static final String RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
public static final String RDFS = "http://www.w3.org/2000/01/rdf-schema#"; public static final String RDFS = "http://www.w3.org/2000/01/rdf-schema#";
public static final String RDF_TYPE = RDF+"type"; public static final String RDF_TYPE = RDF+"type";

View file

@ -5,12 +5,18 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
import java.util.List; import java.util.List;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.web.jsptags.InputElementFormattingTag;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
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;
public class RdfLiteralHash { public class RdfLiteralHash {
private static final Log log = LogFactory.getLog(RdfLiteralHash.class.getName()); private static final Log log = LogFactory.getLog(RdfLiteralHash.class.getName());
@ -87,4 +93,38 @@ public class RdfLiteralHash {
return null; return null;
} }
public static DataPropertyStatement getVitroNsPropertyStmtByHash(Individual ind, Model model, int hash) {
if (ind == null || model == null || hash == 0) {
return null;
}
DataPropertyStatement dps = null;
StmtIterator stmts = model.listStatements(model.createResource(ind.getURI()), null, (RDFNode)null);
try {
while (stmts.hasNext()) {
Statement stmt = stmts.nextStatement();
RDFNode node = stmt.getObject();
if ( node.isLiteral() ){
Literal lit = (Literal)node.as(Literal.class);
String value = lit.getLexicalForm();
String lang = lit.getLanguage();
String datatypeURI = lit.getDatatypeURI();
dps = new DataPropertyStatementImpl();
dps.setDatatypeURI(datatypeURI);
dps.setLanguage(lang);
dps.setData(value);
dps.setDatapropURI(stmt.getPredicate().toString());
if (doesStmtMatchHash(dps, hash)) {
break;
}
}
}
//} catch {
} finally{
stmts.close();
}
return dps;
}
} }

View file

@ -38,6 +38,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActio
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
@ -58,6 +59,7 @@ public class PropertyEditLinks extends TagSupport{
Object item; Object item;
String var; String var;
String icons; String icons;
String data;
private static final Log log = LogFactory.getLog(PropertyEditLinks.class.getName()); private static final Log log = LogFactory.getLog(PropertyEditLinks.class.getName());
@ -72,6 +74,9 @@ public class PropertyEditLinks extends TagSupport{
public void setIcons(String ic){ icons = ic; } public void setIcons(String ic){ icons = ic; }
public String getIcons(){ return icons; } public String getIcons(){ return icons; }
public void setData(String data){ this.data = data; }
public String getData(){ return data; }
@Override @Override
public int doStartTag() throws JspException { public int doStartTag() throws JspException {
if( item == null ) { if( item == null ) {
@ -126,9 +131,9 @@ public class PropertyEditLinks extends TagSupport{
} else if( item instanceof DataProperty ){ } else if( item instanceof DataProperty ){
DataProperty prop = (DataProperty)item; // a DataProperty populated for this subject individual DataProperty prop = (DataProperty)item; // a DataProperty populated for this subject individual
links = doDataProp( prop, entity, themeDir,policyToAccess(ids, policy, entity.getURI(), prop), contextPath ) ; links = doDataProp( prop, entity, themeDir,policyToAccess(ids, policy, entity.getURI(), prop), contextPath ) ;
} else if (item instanceof String) { } else if (item instanceof String && data != null) {
String predicateUri = (String) item; DataPropertyStatement dps = (DataPropertyStatement) new DataPropertyStatementImpl(entity.getURI(), (String)item, data);
links = doVitroNamespaceProp( predicateUri, entity, themeDir, policyToAccess(ids, policy, entity.getURI(), predicateUri), contextPath ); links = doVitroNamespaceProp( dps, themeDir, policyToAccess(ids, policy, dps), contextPath );
} else { } else {
log.error("PropertyEditLinks cannot make links for an object of type "+item.getClass().getName()); log.error("PropertyEditLinks cannot make links for an object of type "+item.getClass().getName());
return SKIP_BODY; return SKIP_BODY;
@ -154,6 +159,10 @@ public class PropertyEditLinks extends TagSupport{
return SKIP_BODY; return SKIP_BODY;
} }
private String getNameFromUri(String predicateUri) {
return predicateUri.substring(predicateUri.lastIndexOf('#')+1);
}
protected LinkStruct[] doDataProp(DataProperty dprop, Individual entity, String themeDir, EditLinkAccess[] allowedAccessTypeArray, String contextPath) { protected LinkStruct[] doDataProp(DataProperty dprop, Individual entity, String themeDir, EditLinkAccess[] allowedAccessTypeArray, String contextPath) {
if( allowedAccessTypeArray == null || dprop == null || allowedAccessTypeArray.length == 0 ) { if( allowedAccessTypeArray == null || dprop == null || allowedAccessTypeArray.length == 0 ) {
log.debug("null or empty access type array in doDataProp for dprop "+dprop.getPublicName()+"; most likely just a property prohibited from editing"); log.debug("null or empty access type array in doDataProp for dprop "+dprop.getPublicName()+"; most likely just a property prohibited from editing");
@ -230,11 +239,6 @@ public class PropertyEditLinks extends TagSupport{
ls.setMouseoverText("edit this text"); ls.setMouseoverText("edit this text");
links[index] = ls; index++; links[index] = ls; index++;
// String imgUrl = makeRelativeHref( themeDir + "site_icons/pencil.gif");
// str += "<a class\"edit image\" href=" + url + " title=\"edit\">" +
// "<img src=" + imgUrl + " alt=\"(edit)\"/></a>\n";
} else { } else {
log.debug("NO permission to UPDATE this data property statement ("+dpropStmt.getDatapropURI()+") found in policy"); log.debug("NO permission to UPDATE this data property statement ("+dpropStmt.getDatapropURI()+") found in policy");
} }
@ -251,10 +255,6 @@ public class PropertyEditLinks extends TagSupport{
ls.setMouseoverText("delete this text"); ls.setMouseoverText("delete this text");
links[index] = ls; index++; links[index] = ls; index++;
// String imgUrl = makeRelativeHref( themeDir + "site_icons/trashcan.gif");
// str += "<a class\"delete image\" href=" + url + " title=\"delete\">" +
// "<img src=" + imgUrl + " alt=\"(delete)\"/></a>\n";
} else { } else {
log.debug("NO permission to DELETE this data property statement ("+dpropStmt.getDatapropURI()+") found in policy"); log.debug("NO permission to DELETE this data property statement ("+dpropStmt.getDatapropURI()+") found in policy");
} }
@ -288,10 +288,6 @@ public class PropertyEditLinks extends TagSupport{
ls.setMouseoverText("change this relationship"); ls.setMouseoverText("change this relationship");
links[index] = ls; index++; links[index] = ls; index++;
// String imgUrl = makeRelativeHref( themeDir + "site_icons/pencil.gif");
// str += "<a class\"edit image\" href=" + url + " title=\"edit\">" +
// "<img src=" + imgUrl + " alt=\"(edit)\"/></a>\n";
} else { } else {
log.debug("NO permission to UPDATE this object property statement ("+opropStmt.getPropertyURI()+") found in policy"); log.debug("NO permission to UPDATE this object property statement ("+opropStmt.getPropertyURI()+") found in policy");
} }
@ -318,28 +314,37 @@ public class PropertyEditLinks extends TagSupport{
return links; return links;
} }
protected LinkStruct[] doVitroNamespaceProp(String predicateUri, Individual entity, String themeDir, EditLinkAccess[] allowedAccessTypeArray, String contextPath) { protected LinkStruct[] doVitroNamespaceProp(DataPropertyStatement dpropStmt, String themeDir, EditLinkAccess[] allowedAccessTypeArray, String contextPath) {
LinkStruct[] links = new LinkStruct[2]; if( allowedAccessTypeArray == null || dpropStmt == null || allowedAccessTypeArray.length == 0 ) {
log.debug("Null or empty access type array for vitro namespace property " + dpropStmt.getDatapropURI());
if( allowedAccessTypeArray == null || predicateUri == null || allowedAccessTypeArray.length == 0 ) {
log.debug("Null or empty access type array for vitro namespace property " + predicateUri);
return empty_array; return empty_array;
} }
int index = 0; LinkStruct[] links = new LinkStruct[2];
LinkStruct ls = new LinkStruct();
String subjectUri = dpropStmt.getIndividualURI();
String predicateUri = dpropStmt.getDatapropURI();
String dpropHash = String.valueOf(RdfLiteralHash.makeRdfLiteralHash( dpropStmt ));
String dispatchUrl = contextPath + "edit/editDatapropStmtRequestDispatch.jsp"; String dispatchUrl = contextPath + "edit/editDatapropStmtRequestDispatch.jsp";
String propName = predicateUri.substring(predicateUri.lastIndexOf('#')+1); String propName = getNameFromUri(predicateUri);
String editForm = "vitroNs" + StringUtils.capitalize(propName) + "Form.jsp"; String editForm = "vitroNsEdit" + StringUtils.capitalize(propName) + "Form.jsp";
LinkStruct ls = new LinkStruct();
int index = 0;
if ( contains( allowedAccessTypeArray, EditLinkAccess.MODIFY ) ){ if ( contains( allowedAccessTypeArray, EditLinkAccess.MODIFY ) ){
log.debug("Permission found to UPDATE vitro namespace property " + predicateUri); log.debug("Permission found to UPDATE vitro namespace property " + predicateUri);
String url = makeRelativeHref(dispatchUrl, String url = makeRelativeHref(dispatchUrl,
"subjectUri", entity.getURI(), "subjectUri", subjectUri,
"predicateUri", predicateUri, "predicateUri", predicateUri,
"datapropKey", dpropHash,
"vitroNsProp", "true",
// RY If we use a single vitro ns form for all vitro ns props, we won't need the editForm param.
// See if they can reasonably be combined into a single form, then have
// editDatapropStmtRequestDispatch use a default vitro ns form if no custom form is specified.
"editForm", editForm); "editForm", editForm);
ls.setHref(url); ls.setHref(url);
ls.setType("edit"); ls.setType("edit");
@ -356,8 +361,10 @@ public class PropertyEditLinks extends TagSupport{
if ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) ){ if ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) ){
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", entity.getURI(), "subjectUri", subjectUri,
"predicateUri", predicateUri); "predicateUri", predicateUri,
"datapropKey", dpropHash,
"editForm", editForm);
ls.setHref(url); ls.setHref(url);
ls.setType("delete"); ls.setType("delete");
ls.setMouseoverText("delete this property"); ls.setMouseoverText("delete this property");
@ -508,24 +515,24 @@ public class PropertyEditLinks extends TagSupport{
return access; return access;
} }
protected EditLinkAccess[] policyToAccess( IdentifierBundle ids, PolicyIface policy, String subjectUri, String propertyUri) { // protected EditLinkAccess[] policyToAccess( IdentifierBundle ids, PolicyIface policy, String subjectUri, String propertyUri) {
//
ArrayList<EditLinkAccess> list = new ArrayList<EditLinkAccess>(2); // ArrayList<EditLinkAccess> list = new ArrayList<EditLinkAccess>(2);
//
RequestedAction action = new EditDataPropStmt(subjectUri, propertyUri, (String) null); // RequestedAction action = new EditDataPropStmt(subjectUri, propertyUri, (String) null);
PolicyDecision dec = policy.isAuthorized(ids, action); // PolicyDecision dec = policy.isAuthorized(ids, action);
if ( dec != null && dec.getAuthorized() == Authorization.AUTHORIZED ){ // if ( dec != null && dec.getAuthorized() == Authorization.AUTHORIZED ){
list.add( EditLinkAccess.MODIFY); // list.add( EditLinkAccess.MODIFY);
} // }
//
action = new DropDataPropStmt(subjectUri, propertyUri, (String) null); // action = new DropDataPropStmt(subjectUri, propertyUri, (String) null);
dec = policy.isAuthorized(ids, action); // dec = policy.isAuthorized(ids, action);
if( dec != null && dec.getAuthorized() == Authorization.AUTHORIZED ){ // if( dec != null && dec.getAuthorized() == Authorization.AUTHORIZED ){
list.add( EditLinkAccess.DELETE ); // list.add( EditLinkAccess.DELETE );
} // }
//
return list.toArray(ACCESS_TEMPLATE); // return list.toArray(ACCESS_TEMPLATE);
} // }
public enum EditLinkAccess{ MODIFY, DELETE, ADDNEW, INFO, ADMIN }; public enum EditLinkAccess{ MODIFY, DELETE, ADDNEW, INFO, ADMIN };

View file

@ -1,5 +1,6 @@
<%-- $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.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" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
@ -33,6 +34,7 @@
final String DEFAULT_DATA_FORM = "defaultDatapropForm.jsp"; final String DEFAULT_DATA_FORM = "defaultDatapropForm.jsp";
final String DEFAULT_ERROR_FORM = "error.jsp"; final String DEFAULT_ERROR_FORM = "error.jsp";
final String DEFAULT_VITRO_NS_FORM = "defaultVitroNsPropForm.jsp";
if (!VitroRequestPrep.isSelfEditing(request) && !LoginFormBean.loggedIn(request, LoginFormBean.NON_EDITOR)) { if (!VitroRequestPrep.isSelfEditing(request) && !LoginFormBean.loggedIn(request, LoginFormBean.NON_EDITOR)) {
%> <c:redirect url="<%= Controllers.LOGIN %>" /> <% %> <c:redirect url="<%= Controllers.LOGIN %>" /> <%
@ -49,6 +51,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");
boolean isVitroNsProp = vreq.getParameter("vitroNsProp").equals("true") ? true : false;
if( subjectUri == null || subjectUri.trim().length() == 0 ) { if( subjectUri == null || subjectUri.trim().length() == 0 ) {
log.error("required subjectUri parameter missing"); log.error("required subjectUri parameter missing");
@ -76,9 +79,8 @@
DataProperty dataproperty = wdf.getDataPropertyDao().getDataPropertyByURI( predicateUri ); DataProperty dataproperty = wdf.getDataPropertyDao().getDataPropertyByURI( predicateUri );
if( dataproperty == null) { if( dataproperty == null) {
// We must have either a dataproperty or a custom form // No dataproperty will be returned for a vitro ns prop
// A custom form is used for a vitro namespace property if (!isVitroNsProp) {
if (formParam == null) {
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);
} }
@ -103,8 +105,18 @@
} }
DataPropertyStatement dps = null; DataPropertyStatement dps = null;
// We don't need a dataprop statement in the request if we're using a custom form
// RY But we need the dps to call the edit config's prepareForDataPropUpdate.
// So we can either create the dps here, or in the custom form, or change
// prepareForDataPropUpdate to use the datahash to get the dps
if( dataHash != 0) { if( dataHash != 0) {
if (isVitroNsProp) {
Model model = (Model)application.getAttribute("jenaOntModel");
dps = RdfLiteralHash.getVitroNsPropertyStmtByHash(subject, model, dataHash);
}
else {
dps = RdfLiteralHash.getDataPropertyStmtByHash(subject, dataHash); dps = RdfLiteralHash.getDataPropertyStmtByHash(subject, dataHash);
}
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);

View file

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

View file

@ -0,0 +1,128 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
<%@ page import="com.hp.hpl.jena.rdf.model.Model"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
<%
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.vitroNsEditLabelForm.jsp");
log.debug("Starting vitroNsEditLabelForm.jsp");
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
String subjectUri = vreq.getParameter("subjectUri");
String predicateUri = vreq.getParameter("predicateUri");
DataPropertyStatement dps = (DataPropertyStatement)vreq.getAttribute("dataprop");
String datapropKeyStr = vreq.getParameter("datapropKey");
Individual subject = (Individual)vreq.getAttribute("subject");
if( subject == null ) {
throw new Error("In vitroNsEditLabelForm.jsp, could not find subject " + subjectUri);
}
%>
<%-- 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 --%>
<%-- Then enter a SPARQL query for the field, by convention concatenating the field id with "Existing"
to convey that the expression is used to retrieve any existing value for the field in an existing individual.
This must then be referenced in the sparqlForExistingLiterals section of the JSON block below
and in the literalsOnForm --%>
<v:jsonset var="labelExisting">
SELECT ?labelExisting WHERE {
?subject <http://www.w3.org/2000/01/rdf-schema#label> ?labelExisting }
</v:jsonset>
<%-- Pair the "existing" query with the skeleton of what will be asserted for a new statement involving this field.
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="labelAssertion" >
?subject <http://www.w3.org/2000/01/rdf-schema#label> ?label .
</v:jsonset>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"datapropKey" : "<%=datapropKeyStr==null?"":datapropKeyStr%>",
"urlPatternToReturnTo" : "/entity",
"subject" : ["subject", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["label", "", "DATAPROPHASH" ],
"n3required" : [ "${labelAssertion}" ],
"n3optional" : [ ],
"newResources" : { },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ ],
"literalsOnForm" : [ "label" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : { "label" : "${labelExisting}" },
"sparqlForExistingUris" : { },
"fields" : {
"label" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#string",
"rangeLang" : "",
"assertions" : [ "${labelAssertion}" ]
}
}
}
</c:set>
<%
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
editConfig = new EditConfiguration((String)vreq.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig, session);
}
if ( datapropKeyStr != null && datapropKeyStr.trim().length() > 0 ) {
Model model = (Model)application.getAttribute("jenaOntModel");
editConfig.prepareForDataPropUpdate(model,dps);
}
/* prepare the <title> and text for the submit button */
// RY Generalize this if we use the same form for all vitro ns props
String submitLabel = "Edit name";
request.setAttribute("title", "Edit the name of " + subject.getName() + ":");
%>
<jsp:include page="${preForm}"/>
<h2>${title}</h2>
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
<v:input type="text" id="label" size="30" />
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/></p>
</form>
<jsp:include page="${postForm}"/>

View file

@ -1 +0,0 @@
In vitroNsLabelForm

View file

@ -104,10 +104,11 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
<div class="statementWrap"> <div class="statementWrap">
<h2><p:process>${entity.name}</p:process></h2> <h2><p:process>${entity.name}</p:process></h2>
<c:if test="${showEdits}"> <c:if test="${showEdits}">
<c:set var="editLinks"><edLnk:editLinks item="${labelUri}" icons="false"/></c:set> <c:set var="editLinks"><edLnk:editLinks item="${labelUri}" data="${entity.name}" icons="false"/></c:set>
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if> <c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
</c:if> </c:if>
</div></div> </div>
</div>
<c:if test="${!empty entity.moniker}"> <c:if test="${!empty entity.moniker}">
<p:process><em class="moniker">${entity.moniker}</em></p:process> <p:process><em class="moniker">${entity.moniker}</em></p:process>
</c:if> </c:if>