diff --git a/productMods/edit/forms/addPublicationToAuthor.jsp b/productMods/edit/forms/addPublicationToAuthor.jsp index 421e7f53..0b465618 100644 --- a/productMods/edit/forms/addPublicationToAuthor.jsp +++ b/productMods/edit/forms/addPublicationToAuthor.jsp @@ -47,14 +47,24 @@ core:informationResourceInAuthorship (InformationResource : Authorship) - invers WebappDaoFactory wdf = vreq.getWebappDaoFactory(); 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())); String intDatatypeUri = XSD.xint.toString(); vreq.setAttribute("intDatatypeUri", intDatatypeUri); vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri)); %> - - + @@ -97,7 +107,11 @@ SPARQL queries for existing values. --%> ?newPub core:informationResourceInAuthorship ?authorshipUri . -<%-- ${infoResourceClassUri} --%> +<%-- Must be all one line for JavaScript. --%> + +PREFIX core: <${vivoCore}> SELECT ?pubUri WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri .?authorshipUri core:linkedInformationResource ?pubUri .} + + ${publicationsClassGroupUri} @@ -180,15 +194,11 @@ SPARQL queries for existing values. --%> Model model = (Model) application.getAttribute("jenaOntModel"); String objectUri = (String) request.getAttribute("objectUri"); 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 customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), JavaScript.UTILS.path(), JavaScript.CUSTOM_FORM_UTILS.path(), - "/edit/forms/js/customFormWithAdvanceTypeSelection.js" + "/edit/forms/js/customFormWithAdvanceTypeSelection.js" )); request.setAttribute("customJs", customJs); @@ -202,15 +212,21 @@ SPARQL queries for existing values. --%> + + - +

Create a new publication entry for <%= subjectName %>

" > -
- "> -

diff --git a/productMods/edit/forms/js/addAuthorsToInformationResource.js b/productMods/edit/forms/js/addAuthorsToInformationResource.js index bb490fcb..8b5ffdbf 100644 --- a/productMods/edit/forms/js/addAuthorsToInformationResource.js +++ b/productMods/edit/forms/js/addAuthorsToInformationResource.js @@ -178,7 +178,7 @@ var addAuthorForm = { url: addAuthorForm.acUrl, dataType: 'json', data: request, - complete: function(xhr) { + complete: function(xhr, status) { // Not sure why, but we need an explicit json parse here. jQuery // should parse the response text and return a json object. var results = jQuery.parseJSON(xhr.responseText); diff --git a/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js b/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js index fd60ea91..e8efcc86 100644 --- a/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js +++ b/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js @@ -102,9 +102,11 @@ var customForm = { }, initAutocomplete: function() { - + + var acFilter = this.getAcFilter(); + this.acCache = {}; - this.baseAcUrl = $('.acUrl').attr('id'); + this.baseAcUrl = customFormData.acUrl; this.acSelector.autocomplete({ minLength: 3, @@ -120,11 +122,13 @@ var customForm = { url: customForm.acUrl, dataType: 'json', data: request, - complete: function(xhr) { + complete: function(xhr, status) { // Not sure why, but we need an explicit json parse here. jQuery // should parse the response text and return a json object. var results = jQuery.parseJSON(xhr.responseText); - customForm.acCache[request.term] = results; + + customForm.acCache[request.term] = 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 resetAutocomplete: function(typeVal) {