
Removed flag1value1 stuff from all vivo custom forms, since no longer needed. Initial setup for publication form javascript.
227 lines
No EOL
9.6 KiB
Text
227 lines
No EOL
9.6 KiB
Text
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
|
|
<%-- Custom form for adding a publication to an author
|
|
|
|
Classes:
|
|
foaf:Person - the individual being edited
|
|
core:Authorship - primary new individual being created
|
|
|
|
Object properties (domain : range):
|
|
|
|
core:authorInAuthorship (Person : Authorship)
|
|
core:linkedAuthor (Authorship : Person) - inverse of authorInAuthorship
|
|
|
|
core:linkedInformationResource (Authorship : InformationResource)
|
|
core:informationResourceInAuthorship (InformationResource : Authorship) - inverse of linkedInformationResource
|
|
|
|
--%>
|
|
|
|
<%@ page import="java.util.List" %>
|
|
<%@ page import="java.util.ArrayList" %>
|
|
<%@ page import="java.util.Arrays" %>
|
|
<%@ page import="java.util.Collections" %>
|
|
<%@ page import="java.net.URLEncoder" %>
|
|
|
|
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
|
|
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
|
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator" %>
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
|
<%@ 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.edit.n3editing.PublicationHasAuthorValidator" %>
|
|
<%@ 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.web.MiscWebUtils" %>
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.StringUtils" %>
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
|
|
|
|
<%@ page import="org.apache.commons.logging.Log" %>
|
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
|
|
<%!
|
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.addAuthorsToInformationResource.jsp");
|
|
%>
|
|
<%
|
|
VitroRequest vreq = new VitroRequest(request);
|
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
|
|
|
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
|
|
|
String intDatatypeUri = XSD.xint.toString();
|
|
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
|
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
|
|
%>
|
|
<c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
|
|
<c:set var="vivoCore" value="${vivoOnt}/core#" />
|
|
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
|
<c:set var="label" value="${rdfs}label" />
|
|
<c:set var="infoResourceClassUri" value="${vivoCore}InformationResource" />
|
|
|
|
<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no
|
|
SPARQL queries for existing values. --%>
|
|
|
|
<v:jsonset var="newPubTypeAssertion">
|
|
?newPub a ?pubType .
|
|
</v:jsonset>
|
|
|
|
<v:jsonset var="newPubNameAssertion">
|
|
?newPub <${label}> ?title .
|
|
</v:jsonset>
|
|
|
|
<%-- This applies to both a new and an existing publication --%>
|
|
<v:jsonset var="n3ForNewAuthorship">
|
|
@prefix core: <${vivoCore}> .
|
|
|
|
?authorshipUri a core:Authorship ;
|
|
core:linkedAuthor ?person .
|
|
|
|
?person core:authorInAuthorship ?authorshipUri .
|
|
</v:jsonset>
|
|
|
|
<v:jsonset var="n3ForExistingPub">
|
|
@prefix core: <${vivoCore}> .
|
|
|
|
?authorshipUri core:linkedInformationResource ?pubUri .
|
|
?pubUri core:informationResourceInAuthorship ?authorshipUri .
|
|
</v:jsonset>
|
|
|
|
<v:jsonset var="n3ForNewPub">
|
|
@prefix core: <${vivoCore}> .
|
|
|
|
?newPub a ?pubType ;
|
|
<${label}> ?title .
|
|
|
|
?authorshipUri core:linkedInformationResource ?newPub .
|
|
?newPub core:informationResourceInAuthorship ?authorshipUri .
|
|
</v:jsonset>
|
|
|
|
<%-- <v:jsonset var="infoResourceClassUriJson">${infoResourceClassUri}</v:jsonset> --%>
|
|
<c:set var="publicationsClassGroupUri" value="${vivoOnt}#vitroClassGrouppublications" />
|
|
<v:jsonset var="publicationsClassGroupUriJson">${publicationsClassGroupUri}</v:jsonset>
|
|
|
|
<c:set var="editjson" scope="request">
|
|
{
|
|
"formUrl" : "${formUrl}",
|
|
"editKey" : "${editKey}",
|
|
"urlPatternToReturnTo" : "", // this will be a problem in the case of a new infoResource - we don't have the uri yet
|
|
|
|
"subject" : ["person", "${subjectUriJson}" ],
|
|
"predicate" : ["predicate", "${predicateUriJson}" ],
|
|
"object" : ["authorshipUri", "${objectUriJson}", "URI" ],
|
|
|
|
"n3required" : [ "${n3ForNewAuthorship}" ],
|
|
|
|
"n3optional" : [ "${n3ForExistingPub}", "${n3ForNewPub}",
|
|
"${newPubNameAssertion}", "${newPubTypeAssertion}" ],
|
|
|
|
"newResources" : { "authorshipUri" : "${defaultNamespace}",
|
|
"newPub" : "${defaultNamespace}" },
|
|
|
|
"urisInScope" : { },
|
|
"literalsInScope": { },
|
|
"urisOnForm" : [ "pubUri", "pubType" ],
|
|
"literalsOnForm" : [ "title" ],
|
|
"filesOnForm" : [ ],
|
|
"sparqlForLiterals" : { },
|
|
"sparqlForUris" : { },
|
|
"sparqlForExistingLiterals" : { },
|
|
"sparqlForExistingUris" : { },
|
|
"fields" : {
|
|
"title" : {
|
|
"newResource" : "false",
|
|
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
|
|
"optionsType" : "UNDEFINED",
|
|
"literalOptions" : [ ],
|
|
"predicateUri" : "",
|
|
"objectClassUri" : "",
|
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
|
"rangeLang" : "",
|
|
"assertions" : [ "${n3ForNewPub}" ]
|
|
},
|
|
"pubType" : {
|
|
"newResource" : "false",
|
|
"validators" : [ ],
|
|
"optionsType" : "VCLASSGROUP",
|
|
"literalOptions" : [ "Select one" ],
|
|
"predicateUri" : "",
|
|
"objectClassUri" : "${publicationsClassGroupUriJson}",
|
|
"rangeDatatypeUri" : "",
|
|
"rangeLang" : "",
|
|
"assertions" : [ "${newPubTypeAssertion}" ]
|
|
},
|
|
"pubUri" : {
|
|
"newResource" : "false",
|
|
"validators" : [ ],
|
|
"optionsType" : "UNDEFINED",
|
|
"literalOptions" : [ ],
|
|
"predicateUri" : "",
|
|
"objectClassUri" : "${personClassUriJson}",
|
|
"rangeDatatypeUri" : "",
|
|
"rangeLang" : "",
|
|
"assertions" : ["${n3ForExistingPub}"]
|
|
}
|
|
}
|
|
}
|
|
</c:set>
|
|
|
|
<%
|
|
log.debug(request.getAttribute("editjson"));
|
|
|
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
if (editConfig == null) {
|
|
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
|
|
EditConfiguration.putConfigInSession(editConfig,session);
|
|
}
|
|
|
|
Model model = (Model) application.getAttribute("jenaOntModel");
|
|
String objectUri = (String) request.getAttribute("objectUri");
|
|
editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing
|
|
|
|
String subjectUri = vreq.getParameter("subjectUri");
|
|
String predicateUri = vreq.getParameter("predicateUri");
|
|
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
|
|
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
|
JavaScript.UTILS.path(),
|
|
JavaScript.CUSTOM_FORM_UTILS.path(),
|
|
"/edit/forms/js/customFormWithAdvanceTypeSelection.js"
|
|
));
|
|
request.setAttribute("customJs", customJs);
|
|
|
|
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
|
Css.CUSTOM_FORM.path(),
|
|
"/edit/forms/css/autocomplete.css",
|
|
"/edit/forms/css/customFormWithAdvanceTypeSelection.css"
|
|
));
|
|
request.setAttribute("customCss", customCss);
|
|
%>
|
|
|
|
<jsp:include page="${preForm}" />
|
|
|
|
<h2>Create a new publication entry for <%= subjectName %></h2>
|
|
|
|
<form id="addPublicationForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
|
|
<v:input type="select" label="Publication type" name="pubType" id="typeSelector" />
|
|
|
|
<v:input type="text" id="title" label="title" cssClass="acInput newIndLabel" size="50" />
|
|
|
|
<div class="acSelection">
|
|
<%-- RY maybe make this a label and input field. See what looks best. --%>
|
|
<p class="inline"><label>Selected :</label><span class="acSelectionName"></span></p>
|
|
<input type="hidden" id="pubUri" name="pubUri" cssClass="existingIndUri" value="" /> <!-- Field value populated by JavaScript -->
|
|
</div>
|
|
|
|
<p class="submit"><v:input type="submit" id="submit" value="Create Publication" cancel="true" /></p>
|
|
|
|
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
|
</form>
|
|
|
|
<jsp:include page="${postForm}"/> |