NIHVIVO-142 Generalize the vitro namespace name editing form to apply to all vitro namespace properties.
This commit is contained in:
parent
f8726e8356
commit
619f0dc646
3 changed files with 52 additions and 59 deletions
|
@ -159,9 +159,9 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
return SKIP_BODY;
|
return SKIP_BODY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNameFromUri(String predicateUri) {
|
// private String getNameFromUri(String predicateUri) {
|
||||||
return predicateUri.substring(predicateUri.lastIndexOf('#')+1);
|
// 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 ) {
|
||||||
|
@ -329,8 +329,8 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
String dpropHash = String.valueOf(RdfLiteralHash.makeRdfLiteralHash( dpropStmt ));
|
String dpropHash = String.valueOf(RdfLiteralHash.makeRdfLiteralHash( dpropStmt ));
|
||||||
String dispatchUrl = contextPath + "edit/editDatapropStmtRequestDispatch.jsp";
|
String dispatchUrl = contextPath + "edit/editDatapropStmtRequestDispatch.jsp";
|
||||||
|
|
||||||
String propName = getNameFromUri(predicateUri);
|
//String propName = getNameFromUri(predicateUri);
|
||||||
String editForm = "vitroNsEdit" + StringUtils.capitalize(propName) + "Form.jsp";
|
//String editForm = "defaultVitroNsPropForm.jsp";
|
||||||
|
|
||||||
LinkStruct ls = new LinkStruct();
|
LinkStruct ls = new LinkStruct();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -341,11 +341,11 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
"subjectUri", subjectUri,
|
"subjectUri", subjectUri,
|
||||||
"predicateUri", predicateUri,
|
"predicateUri", predicateUri,
|
||||||
"datapropKey", dpropHash,
|
"datapropKey", dpropHash,
|
||||||
"vitroNsProp", "true",
|
"vitroNsProp", "true");
|
||||||
// RY If we use a single vitro ns form for all vitro ns props, we won't need the editForm param.
|
// 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
|
// 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.
|
// 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");
|
||||||
ls.setMouseoverText("edit this property");
|
ls.setMouseoverText("edit this property");
|
||||||
|
@ -364,7 +364,8 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
"subjectUri", subjectUri,
|
"subjectUri", subjectUri,
|
||||||
"predicateUri", predicateUri,
|
"predicateUri", predicateUri,
|
||||||
"datapropKey", dpropHash,
|
"datapropKey", dpropHash,
|
||||||
"editForm", editForm);
|
"vitroNsProp", "true");
|
||||||
|
//"editForm", editForm);
|
||||||
ls.setHref(url);
|
ls.setHref(url);
|
||||||
ls.setType("delete");
|
ls.setType("delete");
|
||||||
ls.setMouseoverText("delete this property");
|
ls.setMouseoverText("delete this property");
|
||||||
|
@ -429,25 +430,6 @@ public class PropertyEditLinks extends TagSupport{
|
||||||
return element + "</a>\n";
|
return element + "</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// protected Map<Property,EditLinkAccess[]> getAccess(){
|
|
||||||
// //right now we return an all access, all the time hashmap.
|
|
||||||
// return new HashMap<Property,EditLinkAccess[]>(){
|
|
||||||
//
|
|
||||||
// public boolean containsKey(Object key) { return true; }
|
|
||||||
//
|
|
||||||
// public EditLinkAccess[] get(Object key) {
|
|
||||||
// EditLinkAccess[] ela = { EditLinkAccess.MODIFY,
|
|
||||||
// EditLinkAccess.DELETE, EditLinkAccess.ADDNEW,
|
|
||||||
// EditLinkAccess.INFO, EditLinkAccess.ADMIN };
|
|
||||||
// return ela;
|
|
||||||
// }
|
|
||||||
// public boolean isEmpty() { return false; }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
public static final EditLinkAccess[] NO_ACCESS = {};
|
public static final EditLinkAccess[] NO_ACCESS = {};
|
||||||
public static final EditLinkAccess[] ACCESS_TEMPLATE = {};
|
public static final EditLinkAccess[] ACCESS_TEMPLATE = {};
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
************************************** */
|
************************************** */
|
||||||
|
|
||||||
final String DEFAULT_DATA_FORM = "defaultDatapropForm.jsp";
|
final String DEFAULT_DATA_FORM = "defaultDatapropForm.jsp";
|
||||||
final String DEFAULT_ERROR_FORM = "error.jsp";
|
|
||||||
final String DEFAULT_VITRO_NS_FORM = "defaultVitroNsPropForm.jsp";
|
final String DEFAULT_VITRO_NS_FORM = "defaultVitroNsPropForm.jsp";
|
||||||
|
final String DEFAULT_ERROR_FORM = "error.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 %>" /> <%
|
||||||
|
@ -51,7 +51,8 @@
|
||||||
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;
|
String vitroNsProp = vreq.getParameter("vitroNsProp");
|
||||||
|
boolean isVitroNsProp = vitroNsProp != null && 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");
|
||||||
|
@ -105,10 +106,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (isVitroNsProp) {
|
||||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||||
|
@ -150,19 +147,26 @@
|
||||||
<% return;
|
<% return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( formParam == null ){
|
String form = null;
|
||||||
String form = dataproperty.getCustomEntryForm();
|
if (formParam != null) {
|
||||||
|
form = formParam;
|
||||||
|
}
|
||||||
|
else if (isVitroNsProp) { // dataproperty is null here
|
||||||
|
form = DEFAULT_VITRO_NS_FORM;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
form = dataproperty.getCustomEntryForm();
|
||||||
if (form != null && form.length()>0) {
|
if (form != null && form.length()>0) {
|
||||||
log.warn("have a custom form for this data property: "+form);
|
log.warn("have a custom form for this data property: "+form);
|
||||||
vreq.setAttribute("hasCustomForm","true");
|
vreq.setAttribute("hasCustomForm","true");
|
||||||
} else {
|
} else {
|
||||||
form = DEFAULT_DATA_FORM;
|
form = DEFAULT_DATA_FORM;
|
||||||
}
|
}
|
||||||
vreq.setAttribute("form", form);
|
|
||||||
} else {
|
|
||||||
vreq.setAttribute("form", formParam);
|
|
||||||
}
|
}
|
||||||
if( session.getAttribute("requestedFromEntity") == null )
|
vreq.setAttribute("form", form);
|
||||||
|
|
||||||
|
if( session.getAttribute("requestedFromEntity") == null ) {
|
||||||
session.setAttribute("requestedFromEntity", subjectUri );
|
session.setAttribute("requestedFromEntity", subjectUri );
|
||||||
|
}
|
||||||
%>
|
%>
|
||||||
<jsp:forward page="/edit/forms/${form}" />
|
<jsp:forward page="/edit/forms/${form}" />
|
||||||
|
|
|
@ -11,11 +11,12 @@
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
||||||
|
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||||||
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
<%@ 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");
|
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.defaultVitroNsPropForm.jsp");
|
||||||
log.debug("Starting vitroNsEditLabelForm.jsp");
|
log.debug("Starting defaultVitroNsPropForm.jsp");
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
if( subject == null ) {
|
if( subject == null ) {
|
||||||
throw new Error("In vitroNsEditLabelForm.jsp, could not find subject " + subjectUri);
|
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.
|
<%-- RY Once this is working, change to just one vitroNsEditForm for all vitro ns props, by parameterizing the predicate.
|
||||||
|
@ -42,44 +44,50 @@ Not sure sparqlForExistingLiterals is needed: see defaultDatapropForm - doesn't
|
||||||
so it can be more easily copied to another form.
|
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 --%>
|
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, '#')}" />
|
||||||
|
|
||||||
<%-- Then enter a SPARQL query for the field, by convention concatenating the field id with "Existing"
|
<%-- 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.
|
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
|
This must then be referenced in the sparqlForExistingLiterals section of the JSON block below
|
||||||
and in the literalsOnForm --%>
|
and in the literalsOnForm --%>
|
||||||
<v:jsonset var="labelExisting">
|
<v:jsonset var="dataExisting">
|
||||||
SELECT ?labelExisting WHERE {
|
SELECT ?dataExisting WHERE {
|
||||||
?subject <http://www.w3.org/2000/01/rdf-schema#label> ?labelExisting }
|
?subject <${predicate}> ?dataExisting }
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<%-- Pair the "existing" query with the skeleton of what will be asserted for a new statement involving this field.
|
<%-- 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.
|
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) --%>
|
NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%>
|
||||||
<v:jsonset var="labelAssertion" >
|
<v:jsonset var="dataAssertion" >
|
||||||
?subject <http://www.w3.org/2000/01/rdf-schema#label> ?label .
|
?subject <${predicate}> ?label .
|
||||||
</v:jsonset>
|
</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" />
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
<c:set var="editjson" scope="request">
|
||||||
{
|
{
|
||||||
"formUrl" : "${formUrl}",
|
"formUrl" : "${formUrl}",
|
||||||
"editKey" : "${editKey}",
|
"editKey" : "${editKey}",
|
||||||
"datapropKey" : "<%=datapropKeyStr==null?"":datapropKeyStr%>",
|
"datapropKey" : "<%= datapropKeyStr == null ? "" : datapropKeyStr %>",
|
||||||
"urlPatternToReturnTo" : "/entity",
|
"urlPatternToReturnTo" : "/entity",
|
||||||
|
|
||||||
"subject" : ["subject", "${subjectUriJson}" ],
|
"subject" : ["subject", "${subjectUriJson}" ],
|
||||||
"predicate" : ["predicate", "${predicateUriJson}" ],
|
"predicate" : ["predicate", "${predicateUriJson}" ],
|
||||||
"object" : ["label", "", "DATAPROPHASH" ],
|
"object" : ["${propertyName}", "", "DATAPROPHASH" ],
|
||||||
|
|
||||||
"n3required" : [ "${labelAssertion}" ],
|
"n3required" : [ "${dataAssertion}" ],
|
||||||
"n3optional" : [ ],
|
"n3optional" : [ ],
|
||||||
"newResources" : { },
|
"newResources" : { },
|
||||||
"urisInScope" : { },
|
"urisInScope" : { },
|
||||||
"literalsInScope": { },
|
"literalsInScope": { },
|
||||||
"urisOnForm" : [ ],
|
"urisOnForm" : [ ],
|
||||||
"literalsOnForm" : [ "label" ],
|
"literalsOnForm" : [ "${propertyName}" ],
|
||||||
"filesOnForm" : [ ],
|
"filesOnForm" : [ ],
|
||||||
"sparqlForLiterals" : { },
|
"sparqlForLiterals" : { },
|
||||||
"sparqlForUris" : { },
|
"sparqlForUris" : { },
|
||||||
"sparqlForExistingLiterals" : { "label" : "${labelExisting}" },
|
"sparqlForExistingLiterals" : { "${propertyName}" : "${dataExisting}" },
|
||||||
"sparqlForExistingUris" : { },
|
"sparqlForExistingUris" : { },
|
||||||
"fields" : {
|
"fields" : {
|
||||||
"label" : {
|
"label" : {
|
||||||
|
@ -89,9 +97,9 @@ Also change hard-coded predicate to ?predicate, so it will be picked up from the
|
||||||
"literalOptions" : [ ],
|
"literalOptions" : [ ],
|
||||||
"predicateUri" : "",
|
"predicateUri" : "",
|
||||||
"objectClassUri" : "",
|
"objectClassUri" : "",
|
||||||
"rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#string",
|
"rangeDatatypeUri" : "${rangeDatatypeUri}",
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${labelAssertion}" ]
|
"assertions" : [ "${dataAssertion}" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,19 +117,18 @@ Also change hard-coded predicate to ?predicate, so it will be picked up from the
|
||||||
editConfig.prepareForDataPropUpdate(model,dps);
|
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() + ":");
|
|
||||||
|
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
<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}:" />
|
||||||
|
|
||||||
<jsp:include page="${preForm}"/>
|
<jsp:include page="${preForm}"/>
|
||||||
|
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
||||||
<v:input type="text" id="label" size="30" />
|
<v:input type="text" id="label" size="30" />
|
||||||
<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>
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
<jsp:include page="${postForm}"/>
|
Loading…
Add table
Reference in a new issue