NIHVIVO-725 Initial work on addPublicationToAuthor custom form

This commit is contained in:
rjy7 2010-07-06 22:48:04 +00:00
parent 0dd620d70c
commit 98543e75e0
9 changed files with 275 additions and 42 deletions

View file

@ -3310,7 +3310,7 @@ display level </vitro:publicDescriptionAnnot>
<vitro:hiddenFromDisplayBelowRoleLevelAnnot rdf:resource="http://vitro.mannlib.cornell.edu/ns/vitro/role#public"/>
</rdf:Description>
<rdf:Description rdf:about="http://vivoweb.org/ontology/core#authorInAuthorship">
<vitro:customEntryFormAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">addInformationResourceToAuthor.jsp</vitro:customEntryFormAnnot>
<vitro:customEntryFormAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">addPublicationToAuthor.jsp</vitro:customEntryFormAnnot>
<vitro:offerCreateNewOptionAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</vitro:offerCreateNewOptionAnnot>
<vitro:inPropertyGroupAnnot rdf:resource="http://vivoweb.org/ontology#vitroPropertyGroupbibliographic"/>
<vitro:forceStubDeletionAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</vitro:forceStubDeletionAnnot>

View file

@ -102,7 +102,7 @@ SPARQL queries for existing values. --%>
?authorshipUri core:authorRank ?rank .
</v:jsonset>
<%-- This applies to both new and existing person --%>
<%-- This applies to both a new and an existing person --%>
<v:jsonset var="n3ForNewAuthorship">
@prefix core: <${vivoCore}> .
@ -157,7 +157,7 @@ SPARQL queries for existing values. --%>
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ "authorshipUri", "personUri" ],
"urisOnForm" : [ "personUri" ],
"literalsOnForm" : [ "firstName", "middleName", "lastName", "rank", "label" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
@ -253,15 +253,14 @@ SPARQL queries for existing values. --%>
String subjectUri = vreq.getParameter("subjectUri");
String predicateUri = vreq.getParameter("predicateUri");
Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
String vivoCore = "http://vivoweb.org/ontology/core#";
List<Individual> authorships = infoResource.getRelatedIndividuals(predicateUri);
// We could do this instead, then iterate through the statements, but we still can't use PropertyRanker because
// it compares Property objects rather than statements.
// List<ObjectPropertyStatement> authorshipStmts = infoResource.getObjectPropertyStatements(vivoCore + "informationResourceInAuthorship");
//Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
Individual infoResource = ((Individual) request.getAttribute("subject"));
vreq.setAttribute("infoResourceName", infoResource.getName());
List<Individual> authorships = infoResource.getRelatedIndividuals(predicateUri);
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.UTILS.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
@ -271,6 +270,7 @@ SPARQL queries for existing values. --%>
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/autocomplete.css",
"/edit/forms/css/addAuthorsToInformationResource.css"
));
request.setAttribute("customCss", customCss);
@ -398,14 +398,14 @@ SPARQL queries for existing values. --%>
<h3>Add an Author</h3>
<p class="inline"><v:input type="text" id="lastName" label="Name ${requiredHint}" size="30" /></p>
<p class="inline"><v:input type="text" id="lastName" label="Name ${requiredHint}" cssClass="acInput" size="30" /></p>
<p class="inline"><v:input type="text" id="firstName" label="First name ${requiredHint} ${initialHint}" size="20" /></p>
<p class="inline"><v:input type="text" id="middleName" label="Middle name ${initialHint}" size="20" /></p>
<input type="hidden" id="label" name="label" value="" /> <!-- Field value populated by JavaScript -->
<div id="selectedAuthor">
<div id="selectedAuthor" class="acSelection">
<%-- RY maybe make this a label and input field. See what looks best. --%>
<p class="inline"><label>Selected author: </label><span id="selectedAuthorName"></span></p>
<p class="inline"><label>Selected author: </label><span class="acSelectionName" id="selectedAuthorName"></span></p>
<input type="hidden" id="personUri" name="personUri" value="" /> <!-- Field value populated by JavaScript -->
</div>

View file

@ -1,18 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding an information resource to an author
Classes:
foaf:Person - the individual being edited
core:Authorship - primary new individual being created
core:InformationResource - new or existing individual being linked to
Object properties (domain : range)
core:informationResourceInAuthorship (InformationResource : Authorship)
core:linkedInformationResource (Authorship : InformationResource) - inverse of informationResourceInAuthorship
core:linkedAuthor (Authorship : Person)
core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor
--%>

View file

@ -0,0 +1,236 @@
<%-- $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
String flagUri = null;
if (wdf.getApplicationDao().isFlag1Active()) {
flagUri = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing";
} else {
flagUri = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering
}
vreq.setAttribute("flagUri",flagUri);
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="vivoCore" value="http://vivoweb.org/ontology/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 ,
<${flagUri}> ;
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 ,
<${flagUri}> ;
<${label}> ?title .
?authorshipUri core:linkedInformationResource ?newPub .
?newPub core:informationResourceInAuthorship ?authorshipUri .
</v:jsonset>
<v:jsonset var="infoResourceClassUriJson">${infoResourceClassUri}</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" : "CHILD_VCLASSES",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${infoResourceClassUriJson}",
"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" id="pubType" />
<v:input type="text" id="title" label="title" cssClass="acInput" 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" 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}"/>

View file

@ -94,19 +94,13 @@ form a:hover.cancel,
width: 10em;
}
#selectedAuthorName {
background-color: #d9d9d9;
padding: .5em 1em;
}
#content form p.submit {
margin-top: 3em;
}
/* Disabling undo links for the present. Add back later. */
/*
a.undo,
#selectedAuthor {
a.undo {
display: none;
}
*/
@ -116,8 +110,7 @@ a.undo,
/*
#showAddForm,
a.remove,
a.undo,
#selectedAuthor {
a.undo {
display: none;
}
*/

View file

@ -0,0 +1,10 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
.acSelection {
display: none;
}
.acSelectionName {
background-color: #d9d9d9;
padding: .5em 1em;
}

View file

@ -0,0 +1,5 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
#selectedResource {
display:none;
}

View file

@ -0,0 +1,3 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$('#pubUri').attr('disabled', 'disabled');

View file

@ -7,8 +7,6 @@ core:EducationalTraining - primary new individual being created
foaf:Person - existing individual
foaf:Organization - new or existing individual
core:AcademicDegree - existing individual
core:DateTimeValue
core:DateTimeValuePrecision
Data properties of EducationalTraining:
core:majorField
@ -25,6 +23,12 @@ core:degreeOutcomeOf (AcademicDegree : EducationalTraining) - inverse of degreeE
core:organizationGrantingDegree (EducationalTraining : Organization) - no inverse
Future version
--------------
Classes:
core:DateTimeValue
core:DateTimeValuePrecision
Object properties:
core:dateTimeValue (EducationalTraining : DateTimeValue)
core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
--%>