NIHVIVO-646 More work on addAuthorsToInformationResource custom form. Create edit submission preprocessing mechanism to make automated modifications to the form submission (e.g., creating a label from first, last, and middle name entries).
This commit is contained in:
parent
ab3e088cdf
commit
8570254efb
4 changed files with 64 additions and 37 deletions
|
@ -30,6 +30,7 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual"%>
|
<%@ 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.dao.VitroVocabulary"%>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.CreateLabelFromNameFields"%>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory"%>
|
<%@ 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.controller.VitroRequest"%>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
||||||
|
@ -71,26 +72,22 @@ SPARQL queries for existing values. --%>
|
||||||
<%-- Data properties --%>
|
<%-- Data properties --%>
|
||||||
|
|
||||||
<v:jsonset var="newPersonFirstNameAssertion">
|
<v:jsonset var="newPersonFirstNameAssertion">
|
||||||
@prefix foaf: <${foaf}> .
|
@prefix foaf: <${foaf}> .
|
||||||
|
|
||||||
?newPerson foaf:firstName ?firstName .
|
?newPerson foaf:firstName ?firstName .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="newPersonMiddleNameAssertion">
|
<v:jsonset var="newPersonMiddleNameAssertion">
|
||||||
@prefix core: <${vivoCore}> .
|
@prefix core: <${vivoCore}> .
|
||||||
|
|
||||||
?newPerson core:middleName ?middleName .
|
?newPerson core:middleName ?middleName .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="newPersonLastNameAssertion">
|
<v:jsonset var="newPersonLastNameAssertion">
|
||||||
@prefix foaf: <${foaf}> .
|
@prefix foaf: <${foaf}> .
|
||||||
|
|
||||||
?newPerson foaf:lastName ?lastName .
|
?newPerson foaf:lastName ?lastName .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="authorshipRankAssertion">
|
<v:jsonset var="authorshipRankAssertion">
|
||||||
@prefix core: <${vivoCore}> .
|
@prefix core: <${vivoCore}> .
|
||||||
|
|
||||||
?authorshipUri core:authorRank ?rank .
|
?authorshipUri core:authorRank ?rank .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
|
@ -99,16 +96,17 @@ SPARQL queries for existing values. --%>
|
||||||
@prefix core: <${vivoCore}> .
|
@prefix core: <${vivoCore}> .
|
||||||
|
|
||||||
?authorshipUri a core:Authorship ,
|
?authorshipUri a core:Authorship ,
|
||||||
<${flagURI}> ;
|
<${flagUri}> ;
|
||||||
core:linkedInformationResource ?infoResource .
|
core:linkedInformationResource ?infoResource ;
|
||||||
|
core:authorRank ?rank .
|
||||||
|
|
||||||
?infoResource core:informationResourceInAuthorship ?authorshipUri .
|
?infoResource core:informationResourceInAuthorship ?authorshipUri .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForExistingPerson">
|
<v:jsonset var="n3ForExistingPerson">
|
||||||
@prefix core: <${vivoCore}> .
|
@prefix core: <${vivoCore}> .
|
||||||
?authorshipUri core:linkedAuthor ?personUri
|
?authorshipUri core:linkedAuthor ?personUri .
|
||||||
?personUri core:authorInAuthorship ?authorshipUri
|
?personUri core:authorInAuthorship ?authorshipUri .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForNewPerson">
|
<v:jsonset var="n3ForNewPerson">
|
||||||
|
@ -116,13 +114,11 @@ SPARQL queries for existing values. --%>
|
||||||
@prefix core: <${vivoCore}> .
|
@prefix core: <${vivoCore}> .
|
||||||
|
|
||||||
?newPerson a foaf:Person ,
|
?newPerson a foaf:Person ,
|
||||||
<${flagURI}> ;
|
<${flagUri}> ;
|
||||||
core:firstName ?firstName ;
|
<${label}> ?label .
|
||||||
core:middleName ?middleName ;
|
|
||||||
core:lastName ?lastName .
|
|
||||||
|
|
||||||
?authorshipUri core:linkedAuthor ?newPerson
|
?authorshipUri core:linkedAuthor ?newPerson .
|
||||||
?newPerson core:authorInAuthorship ?authorshipUri
|
?newPerson core:authorInAuthorship ?authorshipUri .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
<c:set var="editjson" scope="request">
|
||||||
|
@ -147,13 +143,24 @@ SPARQL queries for existing values. --%>
|
||||||
"urisInScope" : { },
|
"urisInScope" : { },
|
||||||
"literalsInScope": { },
|
"literalsInScope": { },
|
||||||
"urisOnForm" : [ "authorshipUri", "personUri" ],
|
"urisOnForm" : [ "authorshipUri", "personUri" ],
|
||||||
"literalsOnForm" : [ "firstName", "middleName", "lastName", "rank" ],
|
"literalsOnForm" : [ "firstName", "middleName", "lastName", "rank", "label" ],
|
||||||
"filesOnForm" : [ ],
|
"filesOnForm" : [ ],
|
||||||
"sparqlForLiterals" : { },
|
"sparqlForLiterals" : { },
|
||||||
"sparqlForUris" : { },
|
"sparqlForUris" : { },
|
||||||
"sparqlForExistingLiterals" : { },
|
"sparqlForExistingLiterals" : { },
|
||||||
"sparqlForExistingUris" : { },
|
"sparqlForExistingUris" : { },
|
||||||
"fields" : {
|
"fields" : {
|
||||||
|
"label" : {
|
||||||
|
"newResource" : "false",
|
||||||
|
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
|
||||||
|
"optionsType" : "UNDEFINED",
|
||||||
|
"literalOptions" : [ ],
|
||||||
|
"predicateUri" : "",
|
||||||
|
"objectClassUri" : "",
|
||||||
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
||||||
|
"rangeLang" : "",
|
||||||
|
"assertions" : [ "${n3ForNewPerson}" ]
|
||||||
|
},
|
||||||
"firstName" : {
|
"firstName" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
"validators" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ],
|
"validators" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ],
|
||||||
|
@ -203,7 +210,6 @@ SPARQL queries for existing values. --%>
|
||||||
</c:set>
|
</c:set>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
|
|
||||||
log.debug(request.getAttribute("editjson"));
|
log.debug(request.getAttribute("editjson"));
|
||||||
|
|
||||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
||||||
|
@ -212,6 +218,11 @@ SPARQL queries for existing values. --%>
|
||||||
EditConfiguration.putConfigInSession(editConfig,session);
|
EditConfiguration.putConfigInSession(editConfig,session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For now the field names in CreateLabelFromFieldNames.processEditSubmission() are
|
||||||
|
// hard-coded. If we want the flexibility in naming them, we can pass in a map of
|
||||||
|
// the field names when creating the preprocessor.
|
||||||
|
editConfig.addEditSubmissionPreprocessor(new CreateLabelFromNameFields(editConfig));
|
||||||
|
|
||||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
Model model = (Model) application.getAttribute("jenaOntModel");
|
||||||
String objectUri = (String) request.getAttribute("objectUri");
|
String objectUri = (String) request.getAttribute("objectUri");
|
||||||
editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing
|
editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing
|
||||||
|
@ -220,6 +231,7 @@ SPARQL queries for existing values. --%>
|
||||||
String predicateUri = vreq.getParameter("predicateUri");
|
String predicateUri = vreq.getParameter("predicateUri");
|
||||||
Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
|
||||||
List<Individual> authorships = infoResource.getRelatedIndividuals(predicateUri);
|
List<Individual> authorships = infoResource.getRelatedIndividuals(predicateUri);
|
||||||
|
|
||||||
vreq.setAttribute("infoResourceName", infoResource.getName());
|
vreq.setAttribute("infoResourceName", infoResource.getName());
|
||||||
vreq.setAttribute("rank", authorships.size()+1); // new author ranked last when added
|
vreq.setAttribute("rank", authorships.size()+1); // new author ranked last when added
|
||||||
|
|
||||||
|
@ -252,11 +264,11 @@ SPARQL queries for existing values. --%>
|
||||||
if ( author != null ) {
|
if ( author != null ) {
|
||||||
request.setAttribute("author", author);
|
request.setAttribute("author", author);
|
||||||
%>
|
%>
|
||||||
<%-- RY Should use author short view here? --%>
|
<%-- RY Should use author short view here instead? --%>
|
||||||
<c:url var="authorHref" value="/individual">
|
<c:url var="authorHref" value="/individual">
|
||||||
<c:param name="uri" value="${author.URI}"/>
|
<c:param name="uri" value="${author.URI}"/>
|
||||||
</c:url>
|
</c:url>
|
||||||
<li><a href="${authorHref}" class="authorName"><%= getAuthorName(author) %></a><a href="" class="remove">Remove</a></li>
|
<li><a href="${authorHref}" class="authorName">${author.name}</a><a href="" class="remove">Remove</a></li>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
|
@ -266,7 +278,7 @@ SPARQL queries for existing values. --%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id="showAddForm">
|
<div id="showAddForm">
|
||||||
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="${param.subjectUri}" cancelLabel="Done" />
|
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="${param.subjectUri}" cancelLabel="Return to Publication" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,7 +288,10 @@ SPARQL queries for existing values. --%>
|
||||||
<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="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>
|
<p class="inline"><v:input type="text" id="middleName" label="Middle name" size="20" />${initialHint}</p>
|
||||||
|
|
||||||
<input type="hidden" name="personUri" value="" />
|
<%-- These fields will have values populated/modified by JavaScript --%>
|
||||||
|
<%-- <p class="inline"><v:input type="text" id="label" label="Label" size="20" />${initialHint}</p>--%>
|
||||||
|
|
||||||
|
<input type="hidden" name="personUri" value="" />
|
||||||
<input type="hidden" name="rank" value="${rank}" />
|
<input type="hidden" name="rank" value="${rank}" />
|
||||||
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="${param.subjectUri}" /></p>
|
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="${param.subjectUri}" /></p>
|
||||||
|
@ -287,6 +302,10 @@ SPARQL queries for existing values. --%>
|
||||||
<jsp:include page="${postForm}"/>
|
<jsp:include page="${postForm}"/>
|
||||||
|
|
||||||
<%!
|
<%!
|
||||||
|
// We'll just rely on rdfs:label for now. In future, the label will be created by the app from
|
||||||
|
// last name, first name, and middle name fields, so we don't have to worry about inconsistent
|
||||||
|
// ordering.
|
||||||
|
/*
|
||||||
public String getAuthorName(Individual author) {
|
public String getAuthorName(Individual author) {
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
@ -305,5 +324,5 @@ public String getAuthorName(Individual author) {
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
%>
|
%>
|
||||||
|
|
|
@ -20,6 +20,14 @@ a.remove {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#showAddForm span.or {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#showAddForm a.cancel {
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
form a:link.cancel, form a:visited.cancel,
|
form a:link.cancel, form a:visited.cancel,
|
||||||
#authors a:link.remove, #authors a:visited.remove,
|
#authors a:link.remove, #authors a:visited.remove,
|
||||||
#showAddForm a:link.cancel, #showAddForm a:visited.cancel {
|
#showAddForm a:link.cancel, #showAddForm a:visited.cancel {
|
||||||
|
|
|
@ -58,13 +58,13 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
||||||
|
|
||||||
String flagURI = null;
|
String flagUri = null;
|
||||||
if (wdf.getApplicationDao().isFlag1Active()) {
|
if (wdf.getApplicationDao().isFlag1Active()) {
|
||||||
flagURI = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing";
|
flagUri = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing";
|
||||||
} else {
|
} else {
|
||||||
flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering
|
flagUri = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering
|
||||||
}
|
}
|
||||||
vreq.setAttribute("flagURI",flagURI);
|
vreq.setAttribute("flagUri",flagUri);
|
||||||
|
|
||||||
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||||
request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
|
request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
|
||||||
|
@ -182,13 +182,13 @@ the org type still gets asserted. --%>
|
||||||
|
|
||||||
?edAttainmentUri core:educationalBackgroundOf ?person ;
|
?edAttainmentUri core:educationalBackgroundOf ?person ;
|
||||||
a core:EducationalAttainment ,
|
a core:EducationalAttainment ,
|
||||||
<${flagURI}> .
|
<${flagUri}> .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForNewOrg">
|
<v:jsonset var="n3ForNewOrg">
|
||||||
?newOrg <${label}> ?newOrgName ;
|
?newOrg <${label}> ?newOrgName ;
|
||||||
a ?newOrgType ,
|
a ?newOrgType ,
|
||||||
<${flagURI}> .
|
<${flagUri}> .
|
||||||
|
|
||||||
?edAttainmentUri <${orgGrantingDegree}> ?newOrg .
|
?edAttainmentUri <${orgGrantingDegree}> ?newOrg .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
|
@ -31,13 +31,13 @@
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
||||||
|
|
||||||
String flagURI = null;
|
String flagUri = null;
|
||||||
if (vreq.getAppBean().isFlag1Active()) {
|
if (vreq.getAppBean().isFlag1Active()) {
|
||||||
flagURI = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing";
|
flagUri = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing";
|
||||||
} else {
|
} else {
|
||||||
flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering
|
flagUri = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering
|
||||||
}
|
}
|
||||||
vreq.setAttribute("flagURI",flagURI);
|
vreq.setAttribute("flagUri",flagUri);
|
||||||
|
|
||||||
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||||
request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
|
request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
|
|
||||||
?positionUri core:positionForPerson ?person ;
|
?positionUri core:positionForPerson ?person ;
|
||||||
a ?positionType ,
|
a ?positionType ,
|
||||||
<${flagURI}> .
|
<${flagUri}> .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForNewOrg">
|
<v:jsonset var="n3ForNewOrg">
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
|
|
||||||
?newOrg <${label}> ?newOrgName ;
|
?newOrg <${label}> ?newOrgName ;
|
||||||
a ?newOrgType ,
|
a ?newOrgType ,
|
||||||
<${flagURI}> ;
|
<${flagUri}> ;
|
||||||
<${orgForPositionPred}> ?positionUri .
|
<${orgForPositionPred}> ?positionUri .
|
||||||
|
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue