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:
|
||||
core:InformationResource - the information resource being edited
|
||||
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:
|
||||
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.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.dao.VitroVocabulary" %>
|
||||
<%@ 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);
|
||||
List<Individual> authorships = infoResource.getRelatedIndividuals(predicateUri);
|
||||
String rankPredicateUri = "http://vivoweb.org/ontology/core#authorRank";
|
||||
DataPropertyComparator comp = new DataPropertyComparator(rankPredicateUri);
|
||||
Collections.sort(authorships, comp);
|
||||
|
||||
vreq.setAttribute("infoResourceName", infoResource.getName());
|
||||
|
||||
|
@ -301,32 +300,38 @@ SPARQL queries for existing values. --%>
|
|||
<ul id="authorships" <%= ulClass %>>
|
||||
<%
|
||||
|
||||
int rank = 0;
|
||||
int index = 0;
|
||||
// RY Should get authorRank properties rather than Authorship individuals; then can use
|
||||
// existing PropertyRanker
|
||||
DataPropertyComparator comp = new DataPropertyComparator(rankPredicateUri);
|
||||
Collections.sort(authorships, comp);
|
||||
|
||||
int maxRank = 0;
|
||||
int position = 0;
|
||||
|
||||
for ( Individual authorship : authorships ) {
|
||||
String rankDatatypeUri = "";
|
||||
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
|
||||
if (rankStmt != null) {
|
||||
rank = Integer.valueOf(rankStmt.getData());
|
||||
rankDatatypeUri = rankStmt.getDatatypeURI();
|
||||
}
|
||||
|
||||
Individual author = authorship.getRelatedIndividual(linkedAuthorProperty);
|
||||
if ( author != null ) {
|
||||
index++;
|
||||
position++;
|
||||
String rankValue = "";
|
||||
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
|
||||
if (rankStmt != null) {
|
||||
rankValue = rankStmt.getData();
|
||||
maxRank = Integer.valueOf(rankValue);
|
||||
String rankDatatypeUri = rankStmt.getDatatypeURI();
|
||||
if ( !StringUtils.isEmpty(rankDatatypeUri) ) {
|
||||
rankValue += "_" + rankDatatypeUri;
|
||||
}
|
||||
}
|
||||
request.setAttribute("rankValue", rankValue);
|
||||
request.setAttribute("authorName", author.getName());
|
||||
// Doesn't seem to need urlencoding to add as id attribute value
|
||||
//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);
|
||||
// It's not the same as rank, because ranks may have gaps.
|
||||
request.setAttribute("position", position);
|
||||
|
||||
%>
|
||||
<c:url var="authorHref" value="/individual">
|
||||
|
@ -349,7 +354,7 @@ SPARQL queries for existing values. --%>
|
|||
}
|
||||
// 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", rank + 1);
|
||||
request.setAttribute("newRank", maxRank + 1);
|
||||
request.setAttribute("rankPred", rankPredicateUri);
|
||||
%>
|
||||
|
||||
|
|
|
@ -265,15 +265,18 @@ var addAuthorForm = {
|
|||
oldRankForN3,
|
||||
rankVals;
|
||||
|
||||
rankVals = oldRankVal.split('_'); // e.g., 1_http://www.w3.org/2001/XMLSchema#int
|
||||
if (oldRankVal) {
|
||||
// e.g., 1_http://www.w3.org/2001/XMLSchema#int
|
||||
// We handle typeless values formatted as either "1" or "1_".
|
||||
rankVals = oldRankVal.split('_');
|
||||
oldRank = rankVals[0];
|
||||
oldRankType = rankVals[1];
|
||||
oldRankType = rankVals.length > 1 ? rankVals[1] : '';
|
||||
oldRankForN3 = addAuthorForm.makeRankDataPropVal(oldRank, oldRankType);
|
||||
retractions += subjectUri + ' ' + predicateUri + ' ' + oldRankForN3 + ' .';
|
||||
}
|
||||
|
||||
newRankForN3 = addAuthorForm.makeRankDataPropVal(newRank, rankXsdType);
|
||||
|
||||
additions += subjectUri + ' ' + predicateUri + ' ' + newRankForN3 + ' .';
|
||||
retractions += subjectUri + ' ' + predicateUri + ' ' + oldRankForN3 + ' .';
|
||||
|
||||
// This data will be used to modify the page after successful completion
|
||||
// of the Ajax request.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue