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"%>
|
2011-04-25 17:27:05 +00:00
|
|
|
<%@ page import="com.hp.hpl.jena.vocabulary.XSD"%>
|
2010-03-15 15:35:35 +00:00
|
|
|
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual"%>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
|
2011-05-12 16:02:37 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration"%>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.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-24 16:04:54 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
2011-04-05 16:58:27 +00:00
|
|
|
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
2010-03-24 16:04:54 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils" %>
|
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" %>
|
|
|
|
|
|
|
|
<%
|
2011-06-03 21:44:15 +00:00
|
|
|
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.rdfLabelForm.jsp");
|
2011-04-05 20:18:11 +00:00
|
|
|
|
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");
|
2011-04-05 20:18:11 +00:00
|
|
|
|
2011-06-03 21:44:15 +00:00
|
|
|
log.debug("Starting rdfsLabelForm.jsp");
|
2011-04-05 20:18:11 +00:00
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
DataPropertyStatement dps = (DataPropertyStatement)vreq.getAttribute("dataprop");
|
|
|
|
|
|
|
|
String datapropKeyStr = vreq.getParameter("datapropKey");
|
|
|
|
|
|
|
|
Individual subject = (Individual)vreq.getAttribute("subject");
|
|
|
|
if( subject == null ) {
|
2011-04-25 17:27:05 +00:00
|
|
|
throw new Error("In rdfsLabelForm.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-22 23:17:22 +00:00
|
|
|
// Get datatype and language for the data property statement
|
|
|
|
String rangeDatatypeUri = null,
|
|
|
|
rangeLang = null;
|
2010-03-19 19:47:38 +00:00
|
|
|
|
2010-03-22 23:17:22 +00:00
|
|
|
if (dps != null) {
|
|
|
|
|
|
|
|
rangeDatatypeUri = dps.getDatatypeURI();
|
|
|
|
if (rangeDatatypeUri == null) {
|
2011-04-25 17:27:05 +00:00
|
|
|
log.debug("no range datatype uri set on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
2010-03-22 23:17:22 +00:00
|
|
|
} else {
|
2011-04-25 17:27:05 +00:00
|
|
|
log.debug("range datatype uri of [" + rangeDatatypeUri + "] on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
2010-03-22 23:17:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rangeLang = dps.getLanguage();
|
|
|
|
if( rangeLang == null ) {
|
2011-04-25 17:27:05 +00:00
|
|
|
log.debug("no language attribute on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
2010-03-22 23:17:22 +00:00
|
|
|
rangeLang = "";
|
|
|
|
} else {
|
2011-04-25 17:27:05 +00:00
|
|
|
log.debug("language attribute of ["+rangeLang+"] on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
2010-03-22 23:17:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2011-04-25 17:27:05 +00:00
|
|
|
log.debug("No incoming rdfs:label statement for property "+predicateUri+"; adding a new statement");
|
|
|
|
rangeDatatypeUri = XSD.xstring.getURI();
|
2010-03-22 23:17:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String rangeDatatypeUriJson = rangeDatatypeUri == null ? "" : MiscWebUtils.escape(rangeDatatypeUri);
|
|
|
|
|
|
|
|
vreq.setAttribute("rangeDatatypeUriJson", rangeDatatypeUriJson);
|
|
|
|
vreq.setAttribute("rangeLangJson", rangeLang);
|
2010-03-19 19:47:38 +00:00
|
|
|
|
2010-03-22 23:17:22 +00:00
|
|
|
// Create list of validators
|
2010-03-19 19:47:38 +00:00
|
|
|
ArrayList<String> validatorList = new ArrayList<String>();
|
|
|
|
if (predicateUri.equals(VitroVocabulary.LABEL) || predicateUri.equals(VitroVocabulary.RDF_TYPE)) {
|
2011-04-05 16:58:27 +00:00
|
|
|
validatorList.add("\"nonempty\"");
|
2010-03-19 19:47:38 +00:00
|
|
|
}
|
2010-03-22 23:17:22 +00:00
|
|
|
if (!StringUtils.isEmpty(rangeDatatypeUriJson)) {
|
2011-04-05 16:58:27 +00:00
|
|
|
validatorList.add("\"datatype:" + rangeDatatypeUriJson + "\"");
|
2010-03-19 19:47:38 +00:00
|
|
|
}
|
2011-04-05 16:58:27 +00:00
|
|
|
vreq.setAttribute("validators", StringUtils.join(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%>" />
|
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
<%-- 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" >
|
2011-06-03 21:44:15 +00:00
|
|
|
?subject <${predicate}> ?label .
|
2010-03-15 15:35:35 +00:00
|
|
|
</v:jsonset>
|
|
|
|
|
|
|
|
<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}" ],
|
2011-06-03 21:44:15 +00:00
|
|
|
"object" : ["label", "", "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" : [ ],
|
2011-06-03 21:44:15 +00:00
|
|
|
"literalsOnForm" : [ "label" ],
|
2010-03-15 15:35:35 +00:00
|
|
|
"filesOnForm" : [ ],
|
|
|
|
"sparqlForLiterals" : { },
|
|
|
|
"sparqlForUris" : { },
|
2011-06-03 21:44:15 +00:00
|
|
|
"sparqlForExistingLiterals" : { },
|
2010-03-15 15:35:35 +00:00
|
|
|
"sparqlForExistingUris" : { },
|
|
|
|
"fields" : {
|
2011-06-03 21:44:15 +00:00
|
|
|
"label" : {
|
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-22 23:17:22 +00:00
|
|
|
"rangeLang" : "${rangeLangJson}",
|
2010-03-15 18:48:31 +00:00
|
|
|
"assertions" : [ "${dataAssertion}" ]
|
2010-03-15 15:35:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</c:set>
|
|
|
|
|
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-23 17:28:11 +00:00
|
|
|
// Configure form
|
2010-03-22 23:17:22 +00:00
|
|
|
String actionText = dps == null ? "Add new " : "Edit ";
|
2011-06-03 21:44:15 +00:00
|
|
|
String submitLabel = actionText + "label";
|
|
|
|
String title = actionText + "<em>label</em> for " + subject.getName();
|
2010-03-22 23:17:22 +00:00
|
|
|
|
2010-03-15 15:35:35 +00:00
|
|
|
%>
|
|
|
|
|
2010-03-23 17:28:11 +00:00
|
|
|
<jsp:include page="${preForm}">
|
2011-06-03 21:44:15 +00:00
|
|
|
<jsp:param name="useTinyMCE" value="false"/>
|
2010-03-23 17:28:11 +00:00
|
|
|
</jsp:include>
|
2010-03-15 15:35:35 +00:00
|
|
|
|
2010-03-22 23:17:22 +00:00
|
|
|
<h2><%= title %></h2>
|
2010-03-15 15:35:35 +00:00
|
|
|
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
2011-06-03 21:44:15 +00:00
|
|
|
<v:input type="text" id="label" size="30" />
|
2010-03-17 15:34:23 +00:00
|
|
|
<input type="hidden" name="vitroNsProp" value="true" />
|
2010-06-17 14:26:59 +00:00
|
|
|
<p class="submit"><v:input type="submit" id="submit" value="<%= submitLabel %>" cancel="true"/></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}"/>
|
|
|
|
|
2010-03-22 23:17:22 +00:00
|
|
|
|