NIHVIVO-725 Initial work on autocomplete filter for existing publications for the author
This commit is contained in:
parent
67a3e7a86c
commit
d1c8d701c2
3 changed files with 53 additions and 17 deletions
|
@ -47,14 +47,24 @@ core:informationResourceInAuthorship (InformationResource : Authorship) - invers
|
||||||
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 subjectUri = vreq.getParameter("subjectUri");
|
||||||
|
String predicateUri = vreq.getParameter("predicateUri");
|
||||||
|
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
||||||
|
vreq.setAttribute("subjectUriJson", MiscWebUtils.escape(subjectUri));
|
||||||
|
|
||||||
|
String vivoOnt = "http://vivoweb.org/ontology";
|
||||||
|
String vivoCore = vivoOnt + "/core#";
|
||||||
|
vreq.setAttribute("vivoOnt", vivoOnt);
|
||||||
|
vreq.setAttribute("vivoCore", vivoCore);
|
||||||
|
vreq.setAttribute("vivoCoreJson", MiscWebUtils.escape(vivoCore));
|
||||||
|
|
||||||
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||||
|
|
||||||
String intDatatypeUri = XSD.xint.toString();
|
String intDatatypeUri = XSD.xint.toString();
|
||||||
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
||||||
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
|
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
|
||||||
%>
|
%>
|
||||||
<c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
|
|
||||||
<c:set var="vivoCore" value="${vivoOnt}/core#" />
|
|
||||||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
||||||
<c:set var="label" value="${rdfs}label" />
|
<c:set var="label" value="${rdfs}label" />
|
||||||
<c:set var="infoResourceClassUri" value="${vivoCore}InformationResource" />
|
<c:set var="infoResourceClassUri" value="${vivoCore}InformationResource" />
|
||||||
|
@ -97,7 +107,11 @@ SPARQL queries for existing values. --%>
|
||||||
?newPub core:informationResourceInAuthorship ?authorshipUri .
|
?newPub core:informationResourceInAuthorship ?authorshipUri .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<%-- <v:jsonset var="infoResourceClassUriJson">${infoResourceClassUri}</v:jsonset> --%>
|
<%-- Must be all one line for JavaScript. --%>
|
||||||
|
<c:set var="sparqlForAcFilter">
|
||||||
|
PREFIX core: <${vivoCore}> SELECT ?pubUri WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri .?authorshipUri core:linkedInformationResource ?pubUri .}
|
||||||
|
</c:set>
|
||||||
|
|
||||||
<c:set var="publicationsClassGroupUri" value="${vivoOnt}#vitroClassGrouppublications" />
|
<c:set var="publicationsClassGroupUri" value="${vivoOnt}#vitroClassGrouppublications" />
|
||||||
<v:jsonset var="publicationsClassGroupUriJson">${publicationsClassGroupUri}</v:jsonset>
|
<v:jsonset var="publicationsClassGroupUriJson">${publicationsClassGroupUri}</v:jsonset>
|
||||||
|
|
||||||
|
@ -180,15 +194,11 @@ SPARQL queries for existing values. --%>
|
||||||
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
|
||||||
|
|
||||||
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(),
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
||||||
JavaScript.UTILS.path(),
|
JavaScript.UTILS.path(),
|
||||||
JavaScript.CUSTOM_FORM_UTILS.path(),
|
JavaScript.CUSTOM_FORM_UTILS.path(),
|
||||||
"/edit/forms/js/customFormWithAdvanceTypeSelection.js"
|
"/edit/forms/js/customFormWithAdvanceTypeSelection.js"
|
||||||
));
|
));
|
||||||
request.setAttribute("customJs", customJs);
|
request.setAttribute("customJs", customJs);
|
||||||
|
|
||||||
|
@ -202,15 +212,21 @@ SPARQL queries for existing values. --%>
|
||||||
|
|
||||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||||
|
|
||||||
|
<c:url var="acUrl" value="/autocomplete?stem=true" />
|
||||||
|
<c:url var="sparqlQueryUrl" value="/admin/sparqlquery" />
|
||||||
<jsp:include page="${preForm}" />
|
<jsp:include page="${preForm}" />
|
||||||
|
<script>
|
||||||
|
var customFormData = {
|
||||||
|
sparqlForAcFilter: '${sparqlForAcFilter}',
|
||||||
|
sparqlQueryUrl: '${sparqlQueryUrl}',
|
||||||
|
acUrl: '${acUrl}'
|
||||||
|
}
|
||||||
|
//var sparqlForAcFilter = "${sparqlForAcFilter}";
|
||||||
|
</script>
|
||||||
<h2>Create a new publication entry for <%= subjectName %></h2>
|
<h2>Create a new publication entry for <%= subjectName %></h2>
|
||||||
|
|
||||||
<form id="addPublicationForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
<form id="addPublicationForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||||
|
|
||||||
<div id="infoForJs">
|
|
||||||
<span class="acUrl" id="<c:url value="/autocomplete?stem=true" />"></span>
|
|
||||||
</div>
|
|
||||||
<p class="inline"><v:input type="select" label="Publication Type ${requiredHint}" name="pubType" id="typeSelector" /></p>
|
<p class="inline"><v:input type="select" label="Publication Type ${requiredHint}" name="pubType" id="typeSelector" /></p>
|
||||||
|
|
||||||
<div id="fullViewOnly">
|
<div id="fullViewOnly">
|
||||||
|
|
|
@ -178,7 +178,7 @@ var addAuthorForm = {
|
||||||
url: addAuthorForm.acUrl,
|
url: addAuthorForm.acUrl,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: request,
|
data: request,
|
||||||
complete: function(xhr) {
|
complete: function(xhr, status) {
|
||||||
// Not sure why, but we need an explicit json parse here. jQuery
|
// Not sure why, but we need an explicit json parse here. jQuery
|
||||||
// should parse the response text and return a json object.
|
// should parse the response text and return a json object.
|
||||||
var results = jQuery.parseJSON(xhr.responseText);
|
var results = jQuery.parseJSON(xhr.responseText);
|
||||||
|
|
|
@ -102,9 +102,11 @@ var customForm = {
|
||||||
},
|
},
|
||||||
|
|
||||||
initAutocomplete: function() {
|
initAutocomplete: function() {
|
||||||
|
|
||||||
|
var acFilter = this.getAcFilter();
|
||||||
|
|
||||||
this.acCache = {};
|
this.acCache = {};
|
||||||
this.baseAcUrl = $('.acUrl').attr('id');
|
this.baseAcUrl = customFormData.acUrl;
|
||||||
|
|
||||||
this.acSelector.autocomplete({
|
this.acSelector.autocomplete({
|
||||||
minLength: 3,
|
minLength: 3,
|
||||||
|
@ -120,11 +122,13 @@ var customForm = {
|
||||||
url: customForm.acUrl,
|
url: customForm.acUrl,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: request,
|
data: request,
|
||||||
complete: function(xhr) {
|
complete: function(xhr, status) {
|
||||||
// Not sure why, but we need an explicit json parse here. jQuery
|
// Not sure why, but we need an explicit json parse here. jQuery
|
||||||
// should parse the response text and return a json object.
|
// should parse the response text and return a json object.
|
||||||
var results = jQuery.parseJSON(xhr.responseText);
|
var results = jQuery.parseJSON(xhr.responseText);
|
||||||
customForm.acCache[request.term] = results;
|
|
||||||
|
customForm.acCache[request.term] = results;
|
||||||
|
|
||||||
response(results);
|
response(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +141,22 @@ var customForm = {
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getAcFilter: function() {
|
||||||
|
// RY This gets put on the page for now. May want to put into a js file instead.
|
||||||
|
var url = $('.sparqlQueryUrl').attr('id');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: customFormData.sparqlQueryUrl,
|
||||||
|
data: {
|
||||||
|
resultFormat: 'RS_JSON',
|
||||||
|
query: customFormData.sparqlForAcFilter
|
||||||
|
},
|
||||||
|
success: function(data, status, xhr) {
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// Reset some autocomplete values after type is changed
|
// Reset some autocomplete values after type is changed
|
||||||
resetAutocomplete: function(typeVal) {
|
resetAutocomplete: function(typeVal) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue