2010-03-15 15:35:35 +00:00
|
|
|
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
|
|
|
2010-03-19 19:47:38 +00:00
|
|
|
<%@ page import="java.util.ArrayList"%>
|
|
|
|
<%@ page import="java.util.Arrays"%>
|
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
<%@ 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"%>
|
2010-03-19 15:11:10 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash"%>
|
2010-03-15 15:35:35 +00:00
|
|
|
<%@ 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" %>
|
2010-03-17 15:34:23 +00:00
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
2010-03-19 19:47:38 +00:00
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.utils.StringUtils" %>
|
2010-03-15 15:35:35 +00:00
|
|
|
|
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
2010-03-15 18:48:31 +00:00
|
|
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
2010-03-15 15:35:35 +00:00
|
|
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
|
|
|
|
|
|
<%
|
2010-03-15 18:48:31 +00:00
|
|
|
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.defaultVitroNsPropForm.jsp");
|
|
|
|
log.debug("Starting defaultVitroNsPropForm.jsp");
|
2010-03-15 15:35:35 +00:00
|
|
|
|
|
|
|
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 ) {
|
2010-03-19 21:37:09 +00:00
|
|
|
throw new Error("In defaultVitroNsPropForm.jsp, could not find subject " + subjectUri);
|
2010-03-15 15:35:35 +00:00
|
|
|
}
|
2010-03-19 15:11:10 +00:00
|
|
|
|
|
|
|
Model model = (Model)application.getAttribute("jenaOntModel");
|
|
|
|
|
2010-03-19 21:46:16 +00:00
|
|
|
String rangeDatatypeUri = dps.getDatatypeURI();
|
2010-03-19 19:47:38 +00:00
|
|
|
String rangeDatatypeUriJson = MiscWebUtils.escape(rangeDatatypeUri);
|
|
|
|
vreq.setAttribute("rangeDatatypeUriJson", rangeDatatypeUriJson);
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<String> validatorList = new ArrayList<String>();
|
|
|
|
if (predicateUri.equals(VitroVocabulary.LABEL) || predicateUri.equals(VitroVocabulary.RDF_TYPE)) {
|
|
|
|
validatorList.add("nonempty");
|
|
|
|
}
|
|
|
|
if (!rangeDatatypeUriJson.isEmpty()) {
|
|
|
|
validatorList.add("datatype:" + rangeDatatypeUriJson);
|
|
|
|
}
|
|
|
|
vreq.setAttribute("validators", StringUtils.quotedList(validatorList, ","));
|
2010-03-15 18:48:31 +00:00
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
%>
|
|
|
|
|
2010-03-15 18:48:31 +00:00
|
|
|
<c:set var="predicate" value="<%=predicateUri%>" />
|
|
|
|
<c:set var="propertyName" value="${fn:substringAfter(predicate, '#')}" />
|
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
<%-- 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 --%>
|
2010-03-15 18:48:31 +00:00
|
|
|
<v:jsonset var="dataExisting">
|
|
|
|
SELECT ?dataExisting WHERE {
|
|
|
|
?subject <${predicate}> ?dataExisting }
|
2010-03-15 15:35:35 +00:00
|
|
|
</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) --%>
|
2010-03-15 18:48:31 +00:00
|
|
|
<v:jsonset var="dataAssertion" >
|
2010-03-16 19:17:53 +00:00
|
|
|
?subject <${predicate}> ?${propertyName} .
|
2010-03-15 15:35:35 +00:00
|
|
|
</v:jsonset>
|
|
|
|
|
2010-03-19 19:47:38 +00:00
|
|
|
<%
|
2010-03-17 15:34:23 +00:00
|
|
|
|
2010-03-19 19:47:38 +00:00
|
|
|
%>
|
|
|
|
<c:if test="${propertyName == 'label' || propertyName == 'type'}">
|
|
|
|
<c:set var="validator" value="nonempty" scope="request" />
|
|
|
|
</c:if>
|
2010-03-16 19:17:53 +00:00
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
<c:set var="editjson" scope="request">
|
|
|
|
{
|
|
|
|
"formUrl" : "${formUrl}",
|
|
|
|
"editKey" : "${editKey}",
|
2010-03-15 18:48:31 +00:00
|
|
|
"datapropKey" : "<%= datapropKeyStr == null ? "" : datapropKeyStr %>",
|
2010-03-15 15:35:35 +00:00
|
|
|
"urlPatternToReturnTo" : "/entity",
|
2010-03-16 19:17:53 +00:00
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
"subject" : ["subject", "${subjectUriJson}" ],
|
|
|
|
"predicate" : ["predicate", "${predicateUriJson}" ],
|
2010-03-15 18:48:31 +00:00
|
|
|
"object" : ["${propertyName}", "", "DATAPROPHASH" ],
|
2010-03-15 15:35:35 +00:00
|
|
|
|
2010-03-15 18:48:31 +00:00
|
|
|
"n3required" : [ "${dataAssertion}" ],
|
2010-03-15 15:35:35 +00:00
|
|
|
"n3optional" : [ ],
|
|
|
|
"newResources" : { },
|
|
|
|
"urisInScope" : { },
|
|
|
|
"literalsInScope": { },
|
|
|
|
"urisOnForm" : [ ],
|
2010-03-15 18:48:31 +00:00
|
|
|
"literalsOnForm" : [ "${propertyName}" ],
|
2010-03-15 15:35:35 +00:00
|
|
|
"filesOnForm" : [ ],
|
|
|
|
"sparqlForLiterals" : { },
|
|
|
|
"sparqlForUris" : { },
|
2010-03-15 18:48:31 +00:00
|
|
|
"sparqlForExistingLiterals" : { "${propertyName}" : "${dataExisting}" },
|
2010-03-15 15:35:35 +00:00
|
|
|
"sparqlForExistingUris" : { },
|
|
|
|
"fields" : {
|
2010-03-16 19:17:53 +00:00
|
|
|
"${propertyName}" : {
|
2010-03-15 15:35:35 +00:00
|
|
|
"newResource" : "false",
|
2010-03-19 19:47:38 +00:00
|
|
|
"validators" : [ ${validators} ],
|
2010-03-15 15:35:35 +00:00
|
|
|
"optionsType" : "UNDEFINED",
|
|
|
|
"literalOptions" : [ ],
|
|
|
|
"predicateUri" : "",
|
|
|
|
"objectClassUri" : "",
|
2010-03-19 15:11:10 +00:00
|
|
|
"rangeDatatypeUri" : "${rangeDatatypeUriJson}",
|
2010-03-15 15:35:35 +00:00
|
|
|
"rangeLang" : "",
|
2010-03-15 18:48:31 +00:00
|
|
|
"assertions" : [ "${dataAssertion}" ]
|
2010-03-15 15:35:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</c:set>
|
|
|
|
|
2010-03-16 19:17:53 +00:00
|
|
|
|
2010-03-19 19:47:38 +00:00
|
|
|
|
|
|
|
<%
|
|
|
|
if( log.isDebugEnabled()) log.debug(request.getAttribute("editjson"));
|
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
|
|
if (editConfig == null) {
|
2010-03-16 19:17:53 +00:00
|
|
|
log.debug("No editConfig in session. Making new editConfig.");
|
|
|
|
log.debug(vreq.getAttribute("editjson"));
|
2010-03-15 15:35:35 +00:00
|
|
|
editConfig = new EditConfiguration((String)vreq.getAttribute("editjson"));
|
|
|
|
EditConfiguration.putConfigInSession(editConfig, session);
|
2010-03-16 19:17:53 +00:00
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( datapropKeyStr != null && datapropKeyStr.trim().length() > 0 ) {
|
|
|
|
editConfig.prepareForDataPropUpdate(model,dps);
|
|
|
|
}
|
|
|
|
|
|
|
|
%>
|
|
|
|
|
2010-03-15 18:48:31 +00:00
|
|
|
<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}:" />
|
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
<jsp:include page="${preForm}"/>
|
|
|
|
|
|
|
|
<h2>${title}</h2>
|
|
|
|
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
2010-03-16 19:17:53 +00:00
|
|
|
<v:input type="text" id="${propertyName}" size="30" />
|
2010-03-17 15:34:23 +00:00
|
|
|
<input type="hidden" name="vitroNsProp" value="true" />
|
2010-03-15 18:48:31 +00:00
|
|
|
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="${param.subjectUri}"/></p>
|
2010-03-15 15:35:35 +00:00
|
|
|
</form>
|
|
|
|
|
2010-03-16 21:04:21 +00:00
|
|
|
<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"/>
|
2010-03-17 15:34:23 +00:00
|
|
|
<input type="hidden" name="vitroNsProp" value="true" />
|
2010-03-16 21:04:21 +00:00
|
|
|
<v:input type="submit" id="delete" value="Delete" cancel="" />
|
|
|
|
</form>
|
|
|
|
</c:if>
|
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
<jsp:include page="${postForm}"/>
|
|
|
|
|