Updates for terminology annotation, sending submission URL from jsp to javascript instead of hard-coding. Also including some basic validation by preventing submission when no terms are selected.

This commit is contained in:
hjkhjk54 2011-08-16 17:00:01 +00:00
parent 5e60e05812
commit dd44eeb314
4 changed files with 22 additions and 13 deletions

View file

@ -31,12 +31,8 @@ var addTerminologyForm = {
mixIn: function() {
// Mix in the custom form utility methods
$.extend(this, vitro.customFormUtils);
// Get the custom form data from the page
$.extend(this, customFormData);
//test
alert(addTerminologyForm.UMLSCUIURL);
alert(addTerminologyForm.dataServiceUri);
},
// On page load, create references for easy access to form elements.
initObjects: function() {
@ -58,6 +54,7 @@ var addTerminologyForm = {
this.termLabel = $('#termLabel');
this.termType = $('#termType');
this.removeTermLinks = $('a.remove');
this.errors = $('#errors');
},
initPage: function() {
@ -68,6 +65,7 @@ var addTerminologyForm = {
bindEventListeners: function() {
this.searchSubmit.click(function() {
addTerminologyForm.submitSearchTerm();
addTerminologyForm.clearErrors();
return false;
});
@ -111,6 +109,9 @@ var addTerminologyForm = {
clearSearchResults:function() {
$('#selectedTerm').empty();
},
clearErrors:function() {
addTerminologyForm.errors.empty();
},
showTermListOnlyView: function() {
this.hideForm();
this.showFormButtonWrapper.show();
@ -159,6 +160,9 @@ var addTerminologyForm = {
},
prepareSubmit:function() {
var checkedElements = $("#CUI:checked");
if(!addTerminologyForm.validateTermSelection(checkedElements)) {
return false;
}
var i;
var len = checkedElements.length;
var checkedTerm, checkedTermElement, termLabel, termType;
@ -190,6 +194,13 @@ var addTerminologyForm = {
"</div>" +
"</li>";
return htmlAdd;
}, validateTermSelection:function(checkedElements) {
var numberElements = checkedElements.length;
if(numberElements < 1) {
addTerminologyForm.errors.html("<p class='validationError'>Please select at least one term from search results to add or click cancel.</p>");
return false;
}
return true;
}, removeExistingTerm: function(link) {
var removeLast = false,
message = 'Are you sure you want to remove this term?';
@ -227,7 +238,7 @@ var addTerminologyForm = {
});
} else {
alert('Error processing request: author not removed');
alert('Error processing request: term not removed');
}
}
});

View file

@ -61,7 +61,7 @@ SPARQL queries for existing values. --%>
</v:jsonset>
<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" />
<c:set var="submitSearchUrl" value="/UMLSTermsRetrieval"/>
<c:url var="submitSearchUrl" value="/UMLSTermsRetrieval"/>
<c:url var="UMLSCUIURL" value="http://link.informatics.stonybrook.edu/umls/CUI/" />
<c:set var="editjson" scope="request">
{
@ -246,10 +246,7 @@ SPARQL queries for existing values. --%>
</div>
<form id="addTerminologyForm" class="customForm" action="<c:url value="/edit/processTerminologyAnnotation"/>" >
<h3>Search UMLS Terms</h3>
<p class="inline"><v:input type="text" id="searchTerm" label="Search UMLS" cssClass="acSelector" size="35" />
<p class="inline"><v:input type="text" id="searchTerm" label="Search UMLS Terms" cssClass="acSelector" size="35" />
<input type="button" id="searchButton" name="searchButton" value="Search"/>
</p>
<input type="hidden" id="entryTerm" name="entryTerm" value="" /> <!-- Field value populated by JavaScript -->
@ -267,7 +264,7 @@ SPARQL queries for existing values. --%>
<!-- Field value populated by JavaScript -->
</div>
<div id="errors" name="errors"></div>
<p class="submit"><v:input type="submit" id="submit" name="submit" value="Add Term" cancel="true" /></p>

View file

@ -53,6 +53,7 @@ public class ProcessTerminologyController extends VitroHttpServlet {
}
int numberTerms = termsArray.length;
log.debug("Number of terms included is " + numberTerms);
//if multiple values then need to process this differently by adding additional
//fields, assertions, etc. as well as changing the URL slightly
String url = "/edit/processRdfForm2.jsp?" + vreq.getQueryString();
@ -68,7 +69,7 @@ public class ProcessTerminologyController extends VitroHttpServlet {
//Generate new url which will map input fields to value
url = generateUrl(editConfig, vreq);
}
log.debug("Submitting to url using the following parameters " + url);
RequestDispatcher dispatcher = req.getRequestDispatcher(url);
dispatcher.forward(req, resp);

View file

@ -47,7 +47,7 @@ public class UMLSTerminologyAnnotation extends VitroHttpServlet {
try{
//Get parameter
String entryText = vreq.getParameter("searchTerm");
System.out.println("Entry text is " + entryText);
log.debug("Executing UMLS term retrieval using " + entryText);
//TODO: Find a non-deprecated mechanism to do so
String dataUrl = submissionUrl + "textToProcess=" + URLEncoder.encode(entryText) + "&format=json";
try{