2010-01-29 22:13:57 +00:00
|
|
|
<%-- $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" %>
|
2010-03-25 21:30:45 +00:00
|
|
|
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
|
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataProperty" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao" %>
|
2010-03-24 21:41:33 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
|
2010-03-25 21:30:45 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
2010-03-24 21:41:33 +00:00
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ page import="java.util.List" %>
|
2010-03-24 21:41:33 +00:00
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ page import="org.apache.commons.logging.Log" %>
|
|
|
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
2010-03-24 21:41:33 +00:00
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
|
|
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
|
|
<%!
|
2010-03-24 21:41:33 +00:00
|
|
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.defaultLinkForm.jsp");
|
|
|
|
%>
|
|
|
|
<%
|
2010-03-25 19:01:03 +00:00
|
|
|
VitroRequest vreq = new VitroRequest(request);
|
|
|
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
|
|
vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
|
|
|
|
|
|
|
|
String propertyUri = (String) request.getAttribute("predicateUri");
|
2010-03-25 21:30:45 +00:00
|
|
|
String objectUri = (String) request.getAttribute("objectUri");
|
|
|
|
|
|
|
|
String stringDatatypeUriJson = MiscWebUtils.escape(XSD.xstring.toString());
|
|
|
|
String uriDatatypeUriJson = MiscWebUtils.escape(XSD.anyURI.toString());
|
2010-01-29 22:13:57 +00:00
|
|
|
%>
|
2010-03-24 21:41:33 +00:00
|
|
|
|
2010-03-25 21:30:45 +00:00
|
|
|
<c:set var="stringDatatypeUriJson" value="<%= stringDatatypeUriJson %>" />
|
|
|
|
<c:set var="uriDatatypeUriJson" value="<%= uriDatatypeUriJson %>" />
|
|
|
|
|
2010-03-24 21:41:33 +00:00
|
|
|
<c:set var="rdfUri" value="<%= VitroVocabulary.RDF %>" />
|
2010-03-25 21:30:45 +00:00
|
|
|
<c:set var="vitroUri" value="<%= VitroVocabulary.vitroURI %>" />
|
|
|
|
<c:set var="linkUrl" value="<%= VitroVocabulary.LINK_URL %>" />
|
|
|
|
<c:set var="linkAnchor" value="<%= VitroVocabulary.LINK_ANCHOR %>" />
|
|
|
|
<c:set var="linkDisplayRank" value="<%= VitroVocabulary.LINK_DISPLAYRANK_URL %>" />
|
2010-03-24 21:41:33 +00:00
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
<%-- Enter here any class names to be used for constructing INDIVIDUALS_VIA_VCLASS pick lists
|
|
|
|
These are then referenced in the field's ObjectClassUri but not elsewhere.
|
|
|
|
NOTE that this class may not exist in the model, in which the only choice of type
|
|
|
|
that will show up is "web page", which will insert no new statements and just create
|
|
|
|
links of type vitro:Link --%>
|
|
|
|
|
|
|
|
<%-- Then enter a SPARQL query for each 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.
|
|
|
|
Each of these must then be referenced in the sparqlForExistingLiterals section of the JSON block below
|
|
|
|
and in the literalsOnForm --%>
|
|
|
|
<v:jsonset var="urlExisting" >
|
|
|
|
SELECT ?urlExisting
|
2010-03-25 21:30:45 +00:00
|
|
|
WHERE { ?link <${linkUrl}> ?urlExisting }
|
2010-01-29 22:13:57 +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) --%>
|
|
|
|
<v:jsonset var="urlAssertion" >
|
2010-03-25 21:30:45 +00:00
|
|
|
?link <${linkUrl}> ?url .
|
2010-01-29 22:13:57 +00:00
|
|
|
</v:jsonset>
|
|
|
|
|
|
|
|
<v:jsonset var="anchorExisting" >
|
|
|
|
SELECT ?anchorExisting
|
2010-03-25 21:30:45 +00:00
|
|
|
WHERE { ?link <${linkAnchor}> ?anchorExisting }
|
2010-01-29 22:13:57 +00:00
|
|
|
</v:jsonset>
|
|
|
|
<v:jsonset var="anchorAssertion" >
|
2010-03-25 21:30:45 +00:00
|
|
|
?link <${linkAnchor}> ?anchor .
|
|
|
|
</v:jsonset>
|
|
|
|
|
|
|
|
<%-- RY Currently display rank is always hard-coded to -1, but later we may want to enable sorting. --%>
|
|
|
|
<v:jsonset var="displayRankExisting" >
|
|
|
|
SELECT ?displayRankExisting
|
|
|
|
WHERE { ?link <${linkDisplayRank}> ?displayRankExisting }
|
|
|
|
</v:jsonset>
|
|
|
|
<v:jsonset var="displayRankAssertion" >
|
|
|
|
?link <${linkDisplayRank}> ?displayRank .
|
2010-01-29 22:13:57 +00:00
|
|
|
</v:jsonset>
|
|
|
|
|
|
|
|
<%-- When not retrieving a literal via a datatype property, put the SPARQL statement into
|
|
|
|
the SparqlForExistingUris --%>
|
|
|
|
|
|
|
|
<v:jsonset var="n3ForEdit">
|
2010-03-24 21:41:33 +00:00
|
|
|
@prefix rdf: <${rdfUri}> .
|
|
|
|
@prefix vitro: <${vitroUri}> .
|
2010-01-29 22:13:57 +00:00
|
|
|
|
2010-03-25 19:01:03 +00:00
|
|
|
?subject ?predicate ?link .
|
2010-01-29 22:13:57 +00:00
|
|
|
|
|
|
|
?link rdf:type vitro:Link .
|
|
|
|
|
|
|
|
?link
|
2010-03-25 21:30:45 +00:00
|
|
|
<${linkUrl}> ?url ;
|
|
|
|
<${linkAnchor}> ?anchor ;
|
|
|
|
<${linkDisplayRank}> ?displayRank .
|
2010-01-29 22:13:57 +00:00
|
|
|
|
|
|
|
</v:jsonset>
|
|
|
|
|
|
|
|
|
|
|
|
<c:set var="editjson" scope="request">
|
|
|
|
{
|
|
|
|
"formUrl" : "${formUrl}",
|
|
|
|
"editKey" : "${editKey}",
|
|
|
|
"urlPatternToReturnTo" : "/entity",
|
|
|
|
|
|
|
|
"subject" : ["subject", "${subjectUriJson}" ],
|
|
|
|
"predicate" : ["predicate", "${predicateUriJson}" ],
|
|
|
|
"object" : ["link", "${objectUriJson}", "URI" ],
|
|
|
|
|
|
|
|
"n3required" : [ "${n3ForEdit}" ],
|
2010-03-25 21:30:45 +00:00
|
|
|
"n3optional" : [ ],
|
2010-03-25 19:01:03 +00:00
|
|
|
"newResources" : { "link" : "${defaultNamespace}" },
|
2010-01-29 22:13:57 +00:00
|
|
|
"urisInScope" : { },
|
|
|
|
"literalsInScope" : { },
|
|
|
|
"urisOnForm" : [ ],
|
2010-03-25 21:30:45 +00:00
|
|
|
"literalsOnForm" : [ "url", "anchor", "displayRank" ],
|
2010-01-29 22:13:57 +00:00
|
|
|
"filesOnForm" : [ ],
|
|
|
|
"sparqlForLiterals" : { },
|
|
|
|
"sparqlForUris" : { },
|
|
|
|
"sparqlForExistingLiterals" : {
|
|
|
|
"url" : "${urlExisting}",
|
2010-03-25 21:30:45 +00:00
|
|
|
"anchor" : "${anchorExisting}",
|
|
|
|
"displayRank" : "${displayRankExisting}"
|
2010-01-29 22:13:57 +00:00
|
|
|
},
|
|
|
|
"sparqlForExistingUris" : { },
|
|
|
|
"fields" : {
|
|
|
|
"url" : {
|
|
|
|
"newResource" : "false",
|
2010-03-25 21:30:45 +00:00
|
|
|
"validators" : [ "nonempty", "datatype:${uriDatatypeUriJson}" ],
|
2010-01-29 22:13:57 +00:00
|
|
|
"optionsType" : "UNDEFINED",
|
|
|
|
"literalOptions" : [ ],
|
|
|
|
"predicateUri" : "",
|
|
|
|
"objectClassUri" : "",
|
2010-03-25 21:30:45 +00:00
|
|
|
"rangeDatatypeUri" : "${uriDatatypeUriJson}",
|
2010-01-29 22:13:57 +00:00
|
|
|
"rangeLang" : "",
|
|
|
|
"assertions" : [ "${urlAssertion}" ]
|
|
|
|
},
|
|
|
|
"anchor" : {
|
|
|
|
"newResource" : "false",
|
2010-03-25 21:30:45 +00:00
|
|
|
"validators" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ],
|
2010-01-29 22:13:57 +00:00
|
|
|
"optionsType" : "UNDEFINED",
|
|
|
|
"literalOptions" : [ ],
|
|
|
|
"predicateUri" : "",
|
|
|
|
"objectClassUri" : "",
|
2010-03-25 21:30:45 +00:00
|
|
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
2010-01-29 22:13:57 +00:00
|
|
|
"rangeLang" : "",
|
|
|
|
"assertions" : [ "${anchorAssertion}" ]
|
2010-03-25 21:30:45 +00:00
|
|
|
},
|
|
|
|
"displayRank" : {
|
|
|
|
"newResource" : "false",
|
|
|
|
"validators" : [ ],
|
|
|
|
"optionsType" : "UNDEFINED",
|
|
|
|
"literalOptions" : [ ],
|
|
|
|
"predicateUri" : "",
|
|
|
|
"objectClassUri" : "",
|
|
|
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
|
|
|
"rangeLang" : "",
|
|
|
|
"assertions" : [ "${displayRankAssertion}" ]
|
2010-01-29 22:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</c:set>
|
|
|
|
<%
|
2010-03-24 21:41:33 +00:00
|
|
|
log.debug(request.getAttribute("editjson"));
|
|
|
|
|
2010-01-29 22:13:57 +00:00
|
|
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
|
|
if( editConfig == null ){
|
|
|
|
editConfig = new EditConfiguration((String)request.getAttribute("editjson"));
|
|
|
|
EditConfiguration.putConfigInSession(editConfig, session);
|
|
|
|
}
|
|
|
|
|
2010-03-25 19:01:03 +00:00
|
|
|
Model model = (Model)application.getAttribute("jenaOntModel");
|
2010-01-29 22:13:57 +00:00
|
|
|
if( objectUri != null ){
|
|
|
|
editConfig.prepareForObjPropUpdate(model);
|
|
|
|
}else{
|
|
|
|
editConfig.prepareForNonUpdate(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get some data to make the form more useful */
|
2010-03-25 21:30:45 +00:00
|
|
|
String subjectName = ((Individual)request.getAttribute("subject")).getName();
|
2010-01-29 22:13:57 +00:00
|
|
|
|
2010-03-24 21:41:33 +00:00
|
|
|
String submitLabel="";
|
|
|
|
String title="";
|
2010-03-25 21:30:45 +00:00
|
|
|
String linkCategory = propertyUri.equals(VitroVocabulary.PRIMARY_LINK) ? "primary" : "additional";
|
2010-01-29 22:13:57 +00:00
|
|
|
if (objectUri != null) {
|
2010-03-25 21:30:45 +00:00
|
|
|
title = "Edit <em>" + linkCategory + " link</em> for " + subjectName;
|
2010-01-29 22:13:57 +00:00
|
|
|
submitLabel = "Save changes";
|
|
|
|
} else {
|
2010-03-25 21:30:45 +00:00
|
|
|
title = "Create a new <em>" + linkCategory + " link</em> for " + subjectName;
|
2010-01-29 22:13:57 +00:00
|
|
|
submitLabel = "Create new link";
|
|
|
|
}
|
|
|
|
|
|
|
|
%>
|
|
|
|
|
|
|
|
<jsp:include page="${preForm}"/>
|
|
|
|
|
2010-03-24 21:41:33 +00:00
|
|
|
<h2><%= title %></h2>
|
2010-01-29 22:13:57 +00:00
|
|
|
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
|
|
<v:input type="text" label="URL" id="url" size="70"/>
|
2010-03-25 19:01:03 +00:00
|
|
|
<v:input type="text" label="Link anchor text" id="anchor" size="70"/>
|
2010-03-25 21:30:45 +00:00
|
|
|
<input type="hidden" name="displayRank" value="-1" />
|
2010-06-17 14:26:59 +00:00
|
|
|
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/></p>
|
2010-01-29 22:13:57 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<jsp:include page="${postForm}"/>
|