NIHVIVO-646 add authors to publications custom form
This commit is contained in:
parent
f80e1d301c
commit
6f5636a9c5
6 changed files with 300 additions and 52 deletions
142
productMods/edit/forms/addAuthorsToInformationResource.jsp
Normal file
142
productMods/edit/forms/addAuthorsToInformationResource.jsp
Normal file
|
@ -0,0 +1,142 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%-- Custom form for adding authors to information resources
|
||||
|
||||
Classes:
|
||||
core:InformationResource - the information resource being edited
|
||||
core:Authorship - primary new individual being created
|
||||
foaf:Person - new or existing individual
|
||||
|
||||
Data properties of Authorship:
|
||||
core:authorRank
|
||||
|
||||
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
|
||||
|
||||
--%>
|
||||
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="java.util.Arrays" %>
|
||||
|
||||
<%@ 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.dao.VitroVocabulary"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
|
||||
<%@ 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="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 subjectUri = vreq.getParameter("subjectUri");
|
||||
String predicateUri = vreq.getParameter("predicateUri");
|
||||
Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
||||
List<Individual> authorships = infoResource.getRelatedIndividuals(predicateUri);
|
||||
vreq.setAttribute("infoResourceName", infoResource.getName());
|
||||
|
||||
String linkedAuthorProperty = "http://vivoweb.org/ontology/core#linkedAuthor";
|
||||
|
||||
List<String> customJs = new ArrayList<String>(Arrays.asList("forms/js/addAuthorsToInformationResource.js"));
|
||||
request.setAttribute("customJs", customJs);
|
||||
|
||||
List<String> customCss = new ArrayList<String>(Arrays.asList("forms/css/customForm.css",
|
||||
"forms/css/addAuthorsToInformationResource.css"
|
||||
));
|
||||
request.setAttribute("customCss", customCss);
|
||||
%>
|
||||
|
||||
<c:set var="title" value="Manage authors of <em>${infoResourceName}</em>" />
|
||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||
<c:set var="initialHint" value="<span class='hint'>initial okay</span>" />
|
||||
|
||||
<jsp:include page="${preForm}" />
|
||||
|
||||
<h2>${title}</h2>
|
||||
|
||||
<ul class="authors">
|
||||
<%
|
||||
for ( Individual authorship : authorships ) {
|
||||
List<Individual> authors = authorship.getRelatedIndividuals(linkedAuthorProperty);
|
||||
if ( !authors.isEmpty() ) {
|
||||
Individual author = authors.get(0);
|
||||
String authorName = getAuthorName(author);
|
||||
%>
|
||||
|
||||
<li><span class="authorName"><%= authorName %></span><a href="" class="remove">Remove</a></li>
|
||||
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
</ul>
|
||||
|
||||
<input type="button" value="Add Author" id="showAddForm" />
|
||||
|
||||
<form id="addAuthorForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
|
||||
<p class="inline"><v:input type="text" id="lastName" label="Last name ${requiredHint}" size="30" /></p>
|
||||
<p class="inline"><v:input type="text" id="firstName" label="First name ${requiredHint}" size="20" />${initialHint}</p>
|
||||
<p class="inline"><v:input type="text" id="middleName" label="Middle name" size="20" />${initialHint}</p>
|
||||
|
||||
<input type="hidden" name="newAuthor" value="true" />
|
||||
|
||||
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="${param.subjectUri}"/></p>
|
||||
|
||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||
</form>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
||||
<%!
|
||||
public String getAuthorName(Individual author) {
|
||||
String name;
|
||||
|
||||
String lastName = author.getDataValue("http://xmlns.com/foaf/0.1/lastName");
|
||||
String firstName = author.getDataValue("http://xmlns.com/foaf/0.1/firstName");
|
||||
|
||||
if (lastName != null && firstName != null) {
|
||||
name = lastName + ", " + firstName;
|
||||
String middleName = author.getDataValue("http://vivoweb.org/ontology/core#middleName");
|
||||
if (middleName != null) {
|
||||
name += " " + middleName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
name = author.getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
%>
|
|
@ -0,0 +1,47 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
ul.authors {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
ul.authors li {
|
||||
list-style: none;
|
||||
margin-bottom: .75em;
|
||||
}
|
||||
|
||||
ul.authors span.authorName {
|
||||
display: inline-block;
|
||||
width: 15em;
|
||||
}
|
||||
|
||||
/* Hide elements not used in non-JS version of form */
|
||||
#showFormButton,
|
||||
a.remove {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#content form p.inline {
|
||||
clear: left;
|
||||
margin-bottom: 0;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
#content form p.inline input,
|
||||
#content form p.inline label {
|
||||
float: left;
|
||||
clear: none;
|
||||
}
|
||||
|
||||
#content form p.inline label {
|
||||
width: 10em;
|
||||
margin-top: 0;
|
||||
|
||||
}
|
||||
|
||||
#content form p.inline input {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#content form p.inline span.hint {
|
||||
margin-left: .5em;
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
#content form {
|
||||
/* width: 50%;*/
|
||||
}
|
||||
|
||||
#content form div {
|
||||
clear: left;
|
||||
}
|
||||
|
|
49
productMods/edit/forms/js/addAuthorsToInformationResource.js
Normal file
49
productMods/edit/forms/js/addAuthorsToInformationResource.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
var addAuthorForm = {
|
||||
|
||||
onLoad: function() {
|
||||
|
||||
this.initObjects();
|
||||
this.adjustForJs();
|
||||
this.initForm();
|
||||
},
|
||||
|
||||
|
||||
// On page load, create references within the customForm scope to DOM elements.
|
||||
// NB These must be assigned after the elements have been loaded onto the page.
|
||||
initObjects: function() {
|
||||
|
||||
this.form = $('#addAuthorForm');
|
||||
this.showFormButton = $('#showAddForm');
|
||||
this.removeLinks = $('a.remove');
|
||||
},
|
||||
|
||||
// On page load, make changes to the non-Javascript version for the Javascript version.
|
||||
// These are features that will NOT CHANGE throughout the workflow of the Javascript version.
|
||||
adjustForJs: function() {
|
||||
|
||||
// Show elements that are hidden by css on load since not used in non-JS version
|
||||
this.showFormButton.show();
|
||||
this.removeLinks.show();
|
||||
|
||||
this.form.hide();
|
||||
},
|
||||
|
||||
initForm: function() {
|
||||
|
||||
this.showFormButton.bind('click', function() {
|
||||
$(this).hide();
|
||||
addAuthorForm.form.show();
|
||||
});
|
||||
},
|
||||
|
||||
toggleRemoveLink: function() {
|
||||
// when clicking remove: remove the author, and change link text to "undo"
|
||||
// when clicking undo: add the author back, and change link text to "remove"
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
addAuthorForm.onLoad();
|
||||
});
|
|
@ -479,6 +479,6 @@ var customForm = {
|
|||
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function() {
|
||||
customForm.onLoad();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,34 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%-- Custom form for adding an educational attainment to an individual
|
||||
|
||||
Classes:
|
||||
core:EducationalAttainment - 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 EducationalAttainment:
|
||||
core:majorField
|
||||
core:departmentOrSchool
|
||||
core:supplementalInformation
|
||||
|
||||
Object properties (domain : range)
|
||||
|
||||
core:educationalBackground (Person : EducationalAttainment) - inverse of educationalBackgroundOf
|
||||
core:educationalBackgroundOf (EducationalAttainment : Person) - inverse of educationalBackground
|
||||
|
||||
core:degreeTypeAwarded (EducationalAttainment : AcademicDegree) - inverse of awardedTo
|
||||
core:awardedTo (AcademicDegree : EducationalAttainment) - inverse of degreeTypeAwarded
|
||||
|
||||
core:organizationGrantingDegree (EducationalAttainment : Organization) - no inverse
|
||||
|
||||
core:dateTimeValue (EducationalAttainment : DateTimeValue)
|
||||
core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
||||
--%>
|
||||
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="java.util.Arrays" %>
|
||||
|
@ -42,34 +71,11 @@
|
|||
%>
|
||||
|
||||
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
||||
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
|
||||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
||||
<c:set var="label" value="${rdfs}label" />
|
||||
<c:set var="edBackgroundClass" value="${vivoCore}EducationalAttainment" />
|
||||
<c:set var="edAttainmentClass" value="${vivoCore}EducationalAttainment" />
|
||||
<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" />
|
||||
<c:set var="degreeClass" value="${vivoCore}AcademicDegree" />
|
||||
<%--
|
||||
Classes:
|
||||
core:EducationalAttainment - primary new individual being created
|
||||
foaf:Person - existing individual
|
||||
foaf:Organization - new or existing individual
|
||||
core:AcademicDegree - existing individual
|
||||
|
||||
Data properties of EducationalAttainment:
|
||||
core:majorField
|
||||
core:year
|
||||
core:departmentOrSchool
|
||||
core:supplementalInformation
|
||||
|
||||
Object properties (domain : range)
|
||||
|
||||
core:educationalBackground (Person : EducationalAttainment) - inverse of educationalBackgroundOf
|
||||
core:educationalBackgroundOf (EducationalAttainment : Person) - inverse of educationalBackground
|
||||
|
||||
core:degreeTypeAwarded (EducationalAttainment : AcademicDegree) - inverse of awardedTo
|
||||
core:awardedTo (AcademicDegree : EducationalAttainment) - inverse of degreeTypeAwarded
|
||||
|
||||
core:organizationGrantingDegree (EducationalAttainment : Organization) - no inverse
|
||||
|
||||
<%-- Data properties --%>
|
||||
<%-- Then enter a SPARQL query for each field, by convention concatenating the field id with "Existing"
|
||||
|
@ -79,41 +85,49 @@ core:organizationGrantingDegree (EducationalAttainment : Organization) - no inve
|
|||
<c:set var="majorFieldPred" value="${vivoCore}majorField" />
|
||||
<v:jsonset var="majorFieldExisting" >
|
||||
SELECT ?majorFieldExisting WHERE {
|
||||
?edBackgroundUri <${majorFieldPred}> ?majorFieldExisting }
|
||||
?edAttainmentUri <${majorFieldPred}> ?majorFieldExisting }
|
||||
</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="majorFieldAssertion" >
|
||||
?edBackgroundUri <${majorFieldPred}> ?majorField .
|
||||
?edAttainmentUri <${majorFieldPred}> ?majorField .
|
||||
</v:jsonset>
|
||||
|
||||
<c:set var="yearPred" value="${vivoCore}year" />
|
||||
<c:set var="dateTimeValue" value="${vivoCore}DateTimeValue" />
|
||||
<c:set var="hasDateTimeValue" value="${vivoCore}dateTimeValue" />
|
||||
<c:set var="precisionValue" value="${vivoCore}YearPrecision" />
|
||||
<c:set var="hasPrecision" value="${vivoCore}dateTimePrecision" />
|
||||
|
||||
<v:jsonset var="yearExisting" >
|
||||
SELECT ?existingYear WHERE {
|
||||
?edBackgroundUri <${yearPred}> ?existingYear }
|
||||
?edAttainmentUri <${hasDateTimeValue}> ?existingYear }
|
||||
</v:jsonset>
|
||||
<v:jsonset var="yearAssertion" >
|
||||
?edBackgroundUri <${yearPred}> ?year .
|
||||
@prefix core: <${vivoCore}> .
|
||||
?dateTime a core:DateTimeValue ;
|
||||
core:dateTime ?year ;
|
||||
core:dateTimeValuePrecision core:YearPrecision .
|
||||
?edAttainmentUri core:dateTimeValue ?dateTime .
|
||||
</v:jsonset>
|
||||
|
||||
<c:set var="deptPred" value="${vivoCore}departmentOrSchool" />
|
||||
<v:jsonset var="deptExisting" >
|
||||
SELECT ?existingDept WHERE {
|
||||
?edBackgroundUri <${deptPred}> ?existingDept }
|
||||
?edAttainmentUri <${deptPred}> ?existingDept }
|
||||
</v:jsonset>
|
||||
<v:jsonset var="deptAssertion" >
|
||||
?edBackgroundUri <${deptPred}> ?dept .
|
||||
?edAttainmentUri <${deptPred}> ?dept .
|
||||
</v:jsonset>
|
||||
|
||||
<c:set var="infoPred" value="${vivoCore}supplementalInformation" />
|
||||
<v:jsonset var="infoExisting" >
|
||||
SELECT ?existingInfo WHERE {
|
||||
?edBackgroundUri <${infoPred}> ?existingInfo }
|
||||
?edAttainmentUri <${infoPred}> ?existingInfo }
|
||||
</v:jsonset>
|
||||
<v:jsonset var="infoAssertion" >
|
||||
?edBackgroundUri <${infoPred}> ?info .
|
||||
?edAttainmentUri <${infoPred}> ?info .
|
||||
</v:jsonset>
|
||||
|
||||
<%-- Object properties --%>
|
||||
|
@ -124,21 +138,21 @@ core:organizationGrantingDegree (EducationalAttainment : Organization) - no inve
|
|||
<c:set var="degreeFor" value="${vivoCore}awardedTo" />
|
||||
<v:jsonset var="degreeExisting" >
|
||||
SELECT ?existingDegreeUri WHERE {
|
||||
?edBackgroundUri <${hasDegree}> ?existingDegreeUri }
|
||||
?edAttainmentUri <${hasDegree}> ?existingDegreeUri }
|
||||
</v:jsonset>
|
||||
<v:jsonset var="degreeAssertion" >
|
||||
?edBackgroundUri <${hasDegree}> ?degreeUri .
|
||||
?degreeUri <${degreeFor}> ?edBackgroundUri .
|
||||
?edAttainmentUri <${hasDegree}> ?degreeUri .
|
||||
?degreeUri <${degreeFor}> ?edAttainmentUri .
|
||||
</v:jsonset>
|
||||
|
||||
<c:set var="orgGrantingDegree" value="${vivoCore}organizationGrantingDegree" />
|
||||
<%-- This property has no inverse --%>
|
||||
<v:jsonset var="organizationUriExisting" >
|
||||
SELECT ?existingOrgUri WHERE {
|
||||
?edBackgroundUri <${orgGrantingDegree}> ?existingOrgUri }
|
||||
?edAttainmentUri <${orgGrantingDegree}> ?existingOrgUri }
|
||||
</v:jsonset>
|
||||
<v:jsonset var="organizationUriAssertion" >
|
||||
?edBackgroundUri <${orgGrantingDegree}> ?organizationUri .
|
||||
?edAttainmentUri <${orgGrantingDegree}> ?organizationUri .
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="newOrgNameAssertion">
|
||||
|
@ -153,9 +167,9 @@ the org type still gets asserted. --%>
|
|||
<v:jsonset var="n3ForStmtToPerson">
|
||||
@prefix core: <${vivoCore}> .
|
||||
|
||||
?person core:educationalBackground ?edBackgroundUri .
|
||||
?person core:educationalBackground ?edAttainmentUri .
|
||||
|
||||
?edBackgroundUri core:educationalBackgroundOf ?person ;
|
||||
?edAttainmentUri core:educationalBackgroundOf ?person ;
|
||||
a core:EducationalAttainment ,
|
||||
<${flagURI}> .
|
||||
</v:jsonset>
|
||||
|
@ -165,10 +179,10 @@ the org type still gets asserted. --%>
|
|||
a ?newOrgType ,
|
||||
<${flagURI}> .
|
||||
|
||||
?edBackgroundUri <${orgGrantingDegree}> ?newOrg .
|
||||
?edAttainmentUri <${orgGrantingDegree}> ?newOrg .
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="edBackgroundClassUriJson">${edBackgroundClass}</v:jsonset>
|
||||
<v:jsonset var="edAttainmentClassUriJson">${edAttainmentClass}</v:jsonset>
|
||||
<v:jsonset var="orgClassUriJson">${orgClass}</v:jsonset>
|
||||
<v:jsonset var="degreeClassUriJson">${degreeClass}</v:jsonset>
|
||||
|
||||
|
@ -180,7 +194,7 @@ the org type still gets asserted. --%>
|
|||
|
||||
"subject" : ["person", "${subjectUriJson}" ],
|
||||
"predicate" : ["predicate", "${predicateUriJson}" ],
|
||||
"object" : ["edBackgroundUri", "${objectUriJson}", "URI" ],
|
||||
"object" : ["edAttainmentUri", "${objectUriJson}", "URI" ],
|
||||
|
||||
"n3required" : [ "${n3ForStmtToPerson}", "${degreeAssertion}", "${majorFieldAssertion}", "${yearAssertion}" ],
|
||||
|
||||
|
@ -188,7 +202,7 @@ the org type still gets asserted. --%>
|
|||
"${n3ForNewOrg}", "${newOrgNameAssertion}", "${newOrgTypeAssertion}",
|
||||
"${deptAssertion}", "${infoAssertion}" ],
|
||||
|
||||
"newResources" : { "edBackgroundUri" : "${defaultNamespace}",
|
||||
"newResources" : { "edAttainmentUri" : "${defaultNamespace}",
|
||||
"newOrg" : "${defaultNamespace}" },
|
||||
|
||||
"urisInScope" : { },
|
||||
|
@ -233,12 +247,12 @@ the org type still gets asserted. --%>
|
|||
},
|
||||
"year" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "nonempty", "datatype:${gYearDatatypeUriJson}" ],
|
||||
"validators" : [ "nonempty" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "${gYearDatatypeUriJson}",
|
||||
"rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#dateTime",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${yearAssertion}"]
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue