NIHVIVO-746 Handle unranked authorships in add authors to publication form.
This commit is contained in:
parent
e041eda21c
commit
26f86e9bfe
2 changed files with 66 additions and 58 deletions
|
@ -5,7 +5,7 @@
|
||||||
Classes:
|
Classes:
|
||||||
core:InformationResource - the information resource being edited
|
core:InformationResource - the information resource being edited
|
||||||
core:Authorship - primary new individual being created
|
core:Authorship - primary new individual being created
|
||||||
foaf:Person - new or existing individual
|
foaf:Person - new or existing individual being linked to
|
||||||
|
|
||||||
Data properties of Authorship:
|
Data properties of Authorship:
|
||||||
core:authorRank
|
core:authorRank
|
||||||
|
@ -31,6 +31,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.beans.DataPropertyComparator" %>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator" %>
|
||||||
|
<%-- <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.EntityMergedPropertyListController.PropertyRanker" %> --%>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
<%@ 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.dao.VitroVocabulary" %>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
||||||
|
@ -256,8 +257,6 @@ SPARQL queries for existing values. --%>
|
||||||
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);
|
||||||
String rankPredicateUri = "http://vivoweb.org/ontology/core#authorRank";
|
String rankPredicateUri = "http://vivoweb.org/ontology/core#authorRank";
|
||||||
DataPropertyComparator comp = new DataPropertyComparator(rankPredicateUri);
|
|
||||||
Collections.sort(authorships, comp);
|
|
||||||
|
|
||||||
vreq.setAttribute("infoResourceName", infoResource.getName());
|
vreq.setAttribute("infoResourceName", infoResource.getName());
|
||||||
|
|
||||||
|
@ -299,59 +298,65 @@ SPARQL queries for existing values. --%>
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
|
|
||||||
<ul id="authorships" <%= ulClass %>>
|
<ul id="authorships" <%= ulClass %>>
|
||||||
<%
|
<%
|
||||||
|
|
||||||
int rank = 0;
|
// RY Should get authorRank properties rather than Authorship individuals; then can use
|
||||||
int index = 0;
|
// existing PropertyRanker
|
||||||
|
DataPropertyComparator comp = new DataPropertyComparator(rankPredicateUri);
|
||||||
|
Collections.sort(authorships, comp);
|
||||||
|
|
||||||
for ( Individual authorship : authorships ) {
|
int maxRank = 0;
|
||||||
String rankDatatypeUri = "";
|
int position = 0;
|
||||||
|
|
||||||
|
for ( Individual authorship : authorships ) {
|
||||||
|
Individual author = authorship.getRelatedIndividual(linkedAuthorProperty);
|
||||||
|
if ( author != null ) {
|
||||||
|
position++;
|
||||||
|
String rankValue = "";
|
||||||
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
|
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
|
||||||
if (rankStmt != null) {
|
if (rankStmt != null) {
|
||||||
rank = Integer.valueOf(rankStmt.getData());
|
rankValue = rankStmt.getData();
|
||||||
rankDatatypeUri = rankStmt.getDatatypeURI();
|
maxRank = Integer.valueOf(rankValue);
|
||||||
|
String rankDatatypeUri = rankStmt.getDatatypeURI();
|
||||||
|
if ( !StringUtils.isEmpty(rankDatatypeUri) ) {
|
||||||
|
rankValue += "_" + rankDatatypeUri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
request.setAttribute("rankValue", rankValue);
|
||||||
Individual author = authorship.getRelatedIndividual(linkedAuthorProperty);
|
request.setAttribute("authorName", author.getName());
|
||||||
if ( author != null ) {
|
// Doesn't seem to need urlencoding to add as id attribute value
|
||||||
index++;
|
//request.setAttribute("authorUri", URLEncoder.encode(author.getURI(), "UTF-8"));
|
||||||
request.setAttribute("authorName", author.getName());
|
request.setAttribute("authorUri", author.getURI());
|
||||||
// Doesn't seem to need urlencoding to add as id attribute value
|
request.setAttribute("authorshipUri", authorship.getURI());
|
||||||
//request.setAttribute("authorUri", URLEncoder.encode(author.getURI(), "UTF-8"));
|
|
||||||
request.setAttribute("authorUri", author.getURI());
|
|
||||||
request.setAttribute("authorshipUri", authorship.getURI());
|
|
||||||
request.setAttribute("rankValue", rank + "_" + rankDatatypeUri);
|
|
||||||
request.setAttribute("rank", rank);
|
|
||||||
|
|
||||||
// This value is used to replace a moved element after a failed reorder.
|
|
||||||
// It's not the same as rank, because ranks may have gaps. It's easier to
|
|
||||||
// reposition the element using ordering.
|
|
||||||
request.setAttribute("position", index);
|
|
||||||
|
|
||||||
%>
|
// This value is used to replace a moved element after a failed reorder.
|
||||||
<c:url var="authorHref" value="/individual">
|
// It's not the same as rank, because ranks may have gaps.
|
||||||
<c:param name="uri" value="${authorUri}"/>
|
request.setAttribute("position", position);
|
||||||
</c:url>
|
|
||||||
<c:url var="deleteAuthorshipHref" value="/edit/primitiveDelete" />
|
|
||||||
|
|
||||||
<li class="authorship" id="${authorshipUri}">
|
|
||||||
<span class="rank" id="${rankValue}"></span>
|
|
||||||
<span class="position" id="${position}"></span>
|
|
||||||
<%-- This span will be used in the next phase, when we display a message that the author has been
|
|
||||||
removed. That text will replace the a.authorLink, which will be removed. --%>
|
|
||||||
<span class="author"><a href="${authorHref}" id="${authorUri}" class="authorLink">${authorName}</a>
|
|
||||||
<a href="${deleteAuthorshipHref}" class="remove">Remove</a>
|
|
||||||
<%-- <a href="${undoHref}" class="undo">Undo</a> --%></span>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<%
|
%>
|
||||||
}
|
<c:url var="authorHref" value="/individual">
|
||||||
}
|
<c:param name="uri" value="${authorUri}"/>
|
||||||
// A new author will be ranked last when added.
|
</c:url>
|
||||||
// This wouldn't handle gaps in the ranking: vreq.setAttribute("rank", authorships.size()+1);
|
<c:url var="deleteAuthorshipHref" value="/edit/primitiveDelete" />
|
||||||
request.setAttribute("newRank", rank + 1);
|
|
||||||
request.setAttribute("rankPred", rankPredicateUri);
|
<li class="authorship" id="${authorshipUri}">
|
||||||
%>
|
<span class="rank" id="${rankValue}"></span>
|
||||||
|
<span class="position" id="${position}"></span>
|
||||||
|
<%-- This span will be used in the next phase, when we display a message that the author has been
|
||||||
|
removed. That text will replace the a.authorLink, which will be removed. --%>
|
||||||
|
<span class="author"><a href="${authorHref}" id="${authorUri}" class="authorLink">${authorName}</a>
|
||||||
|
<a href="${deleteAuthorshipHref}" class="remove">Remove</a>
|
||||||
|
<%-- <a href="${undoHref}" class="undo">Undo</a> --%></span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// A new author will be ranked last when added.
|
||||||
|
// This wouldn't handle gaps in the ranking: vreq.setAttribute("rank", authorships.size()+1);
|
||||||
|
request.setAttribute("newRank", maxRank + 1);
|
||||||
|
request.setAttribute("rankPred", rankPredicateUri);
|
||||||
|
%>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -265,16 +265,19 @@ var addAuthorForm = {
|
||||||
oldRankForN3,
|
oldRankForN3,
|
||||||
rankVals;
|
rankVals;
|
||||||
|
|
||||||
rankVals = oldRankVal.split('_'); // e.g., 1_http://www.w3.org/2001/XMLSchema#int
|
if (oldRankVal) {
|
||||||
oldRank = rankVals[0];
|
// e.g., 1_http://www.w3.org/2001/XMLSchema#int
|
||||||
oldRankType = rankVals[1];
|
// We handle typeless values formatted as either "1" or "1_".
|
||||||
oldRankForN3 = addAuthorForm.makeRankDataPropVal(oldRank, oldRankType);
|
rankVals = oldRankVal.split('_');
|
||||||
|
oldRank = rankVals[0];
|
||||||
|
oldRankType = rankVals.length > 1 ? rankVals[1] : '';
|
||||||
|
oldRankForN3 = addAuthorForm.makeRankDataPropVal(oldRank, oldRankType);
|
||||||
|
retractions += subjectUri + ' ' + predicateUri + ' ' + oldRankForN3 + ' .';
|
||||||
|
}
|
||||||
|
|
||||||
newRankForN3 = addAuthorForm.makeRankDataPropVal(newRank, rankXsdType);
|
newRankForN3 = addAuthorForm.makeRankDataPropVal(newRank, rankXsdType);
|
||||||
|
|
||||||
additions += subjectUri + ' ' + predicateUri + ' ' + newRankForN3 + ' .';
|
additions += subjectUri + ' ' + predicateUri + ' ' + newRankForN3 + ' .';
|
||||||
retractions += subjectUri + ' ' + predicateUri + ' ' + oldRankForN3 + ' .';
|
|
||||||
|
|
||||||
// This data will be used to modify the page after successful completion
|
// This data will be used to modify the page after successful completion
|
||||||
// of the Ajax request.
|
// of the Ajax request.
|
||||||
authorship = {
|
authorship = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue