From 1a292d80111112fbfc7a3d234662ede7a489b120 Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Fri, 16 Dec 2016 18:47:17 +0000 Subject: [PATCH] [VIVO-1309] [VIVO-1307] Update DWR to version 3.0.2 and remove dom4j --- dependencies/pom.xml | 8 +- webapp/src/main/webapp/WEB-INF/dwr.xml | 2 + webapp/src/main/webapp/WEB-INF/web.xml | 2 +- webapp/src/main/webapp/js/edit/entityRetry.js | 6 +- webapp/src/main/webapp/js/ents_edit.js | 95 ++++++++++--------- webapp/src/main/webapp/js/ents_retry.js | 6 +- webapp/src/main/webapp/js/vitro.js | 26 ++--- .../edit/specific/ents_edit_head.jsp | 10 +- 8 files changed, 81 insertions(+), 74 deletions(-) diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 1246f2f0e..9742a0fdf 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -56,12 +56,12 @@ cxf-xjc-ts 2.6.2 - - + + @@ -202,7 +202,7 @@ org.directwebremoting dwr - 2.0.M2.8 + 3.0.2-RELEASE org.freemarker diff --git a/webapp/src/main/webapp/WEB-INF/dwr.xml b/webapp/src/main/webapp/WEB-INF/dwr.xml index 21fd9445c..b17f2de58 100755 --- a/webapp/src/main/webapp/WEB-INF/dwr.xml +++ b/webapp/src/main/webapp/WEB-INF/dwr.xml @@ -48,6 +48,8 @@ + + diff --git a/webapp/src/main/webapp/WEB-INF/web.xml b/webapp/src/main/webapp/WEB-INF/web.xml index 04ee7bc23..1eb6dd626 100644 --- a/webapp/src/main/webapp/WEB-INF/web.xml +++ b/webapp/src/main/webapp/WEB-INF/web.xml @@ -939,7 +939,7 @@ dwr-invoker - uk.ltd.getahead.dwr.DWRServlet + org.directwebremoting.servlet.DwrServlet debug true diff --git a/webapp/src/main/webapp/js/edit/entityRetry.js b/webapp/src/main/webapp/js/edit/entityRetry.js index 3087d9090..a2be916b8 100644 --- a/webapp/src/main/webapp/js/edit/entityRetry.js +++ b/webapp/src/main/webapp/js/edit/entityRetry.js @@ -42,7 +42,7 @@ function monikerInit(){ function update(){ //updates moniker list when type is changed - DWRUtil.useLoadingMessage(); + dwr.util.useLoadingMessage(); EntityDWR.monikers(createList, document.getElementById("VClassURI").value ); @@ -62,7 +62,7 @@ function createList(data) { //puts options in moniker select list var opt = new Option("[new moniker]",""); ele.options[ele.options.length] = opt; - DWRUtil.setValue("Moniker",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp + dwr.util.setValue("Moniker",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp checkMonikers(); } @@ -111,7 +111,7 @@ function fillList(id, data, selectedtext) { for (var i = 0; i < data.length; i++) { - var text = DWRUtil.toDescriptiveString(data[i]); + var text = dwr.util.toDescriptiveString(data[i]); var value = text; diff --git a/webapp/src/main/webapp/js/ents_edit.js b/webapp/src/main/webapp/js/ents_edit.js index 04ef980de..7bed21719 100644 --- a/webapp/src/main/webapp/js/ents_edit.js +++ b/webapp/src/main/webapp/js/ents_edit.js @@ -1,15 +1,15 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* this code uses: - dwrutil in util.js + dwr.util in util.js vitro.js detect.js */ dojo.require("dojo.io.*"); dojo.require("dojo.event.*"); -//DWREngine.setErrorHandler(function(data){alert("DWREngine error: " + data);}); -//DWREngine.setWarningHandler(function(data){alert("DWREngine warning: " + data);}); +//dwr.engine.setErrorHandler(function(data){alert("dwr.engine error: " + data);}); +//dwr.engine.setWarningHandler(function(data){alert("dwr.engine warning: " + data);}); /* ents_edit.js has several tasks: @@ -68,7 +68,7 @@ function update( ) { clearProp(); updateTable(); updateEntityAndPropHash(); - var but = $("newPropButton"); + var but = dwr.util.byId("newPropButton"); if( but ) { but.disabled = false; } } @@ -78,11 +78,11 @@ function clearProp() { var clearMap={sunrise:"",sunset: ""}; editingNewProp = false; gVClassUri = null; - DWRUtil.setValues( clearMap ); - clear($("propertyList")); - clear($("vClassList")); + dwr.util.setValues( clearMap ); + clear(dwr.util.byId("propertyList")); + clear(dwr.util.byId("vClassList")); - var ele = $("entitiesList"); + var ele = dwr.util.byId("entitiesList"); while( ele != null && ele.length > 0){ ele.remove(0); } @@ -102,7 +102,7 @@ function updateEntityAndPropHash(){ //once we set the gEntity we can get the ents2ents properties. //PropertyDWR.getAllPropInstByVClass(setPropertyHash, entityObj.VClassURI ); if( entityObj != null && 'URI' in entityObj ) - PropertyDWR.getAllPossiblePropInstForIndividual(setPropertyHash, entityObj.URI); + PropertyDWR.getAllPossiblePropInstForIndividual(entityObj.URI, { callback:setPropertyHash }); //else //alert("could not find an individual, usually this means that there is no type for the URI"); }; @@ -126,7 +126,7 @@ function updateEntityAndPropHash(){ }; //get the gEntity and then build the gPropertyHash - EntityDWR.entityByURI(setGEntity, gEntityURI); + EntityDWR.entityByURI(gEntityURI, { callback:setGEntity }); } /***************************************************************** @@ -139,7 +139,7 @@ function doNoPropsWarning(){ "The button you have clicked adds a new object property statement relating this individual " + "to another individual. If you are looking to add new object properties to the " + "system, look under the 'About' menu."); - var but = $("newPropButton"); + var but = dwr.util.byId("newPropButton"); if( but ) { but.disabled = true; } } @@ -149,18 +149,18 @@ because dwr calls are async we have a callback function updateTable(callback) { var cb = callback; function fillTable(props) { - DWRUtil.removeAllRows("propbody"); + dwr.util.removeAllRows("propbody"); /* This makes the row that gets added to the ents_edit form for each ents2ents object. */ - addRows($("propbody"), props, + addRows(dwr.util.byId("propbody"), props, [getDomain, getProperty, getRange, getEdit, getDelete], makeTr); - var newPropTr = $("justwritenTr"); + var newPropTr = dwr.util.byId("justwritenTr"); if( newPropTr != null ){ Fat.fade_element( "justwritenTr" ); } if(cb !== undefined && cb !== null ) { cb(); } } - PropertyDWR.getExistingProperties(fillTable,gEntityURI); + PropertyDWR.getExistingProperties(gEntityURI, { callback: fillTable }); } /**************************************************************************/ @@ -252,7 +252,7 @@ var makeTr = (function(){ /* outer func */ /* called when Edit button is clicked */ function editTable(inputElement, subjectURI, predicateURI, objectURI){ var rowIndex = inputElement.parentNode.parentNode.rowIndex-1 ; - var table = $("propbody"); + var table = dwr.util.byId("propbody"); table.deleteRow( rowIndex ); table.insertRow(rowIndex); table.rows[rowIndex].insertCell(0); @@ -261,7 +261,7 @@ function editTable(inputElement, subjectURI, predicateURI, objectURI){ table.rows[rowIndex].cells[0].colSpan = tableMaxColspan( table ); vform.style.display="block"; - PropertyDWR.getProperty(fillForm, subjectURI, predicateURI, objectURI); + PropertyDWR.getProperty(subjectURI, predicateURI, objectURI, { callback: fillForm }); inputElement.parentNode.parentNode.style.display="none"; } @@ -270,7 +270,7 @@ function deleteProp( subjectURI, predicateURI, objectURI, objectName, predicateN if( PropertyDWR.deleteProp ){ if (confirm("Are you sure you want to delete the property\n" + objectName + " " + predicateName + "?")) { - PropertyDWR.deleteProp(update, subjectURI, predicateURI, objectURI); + PropertyDWR.deleteProp(subjectURI, predicateURI, objectURI, { callback:update }); } } else { alert("Deletion of object property statements is disabled."); @@ -312,7 +312,7 @@ function newProp() { fillForm( newP ); editingNewProp = true; fillRangeVClassList(); - var table = $("propbody"); + var table = dwr.util.byId("propbody"); var tr = table.insertRow(0); tr.id = "newrow"; appendPropForm( tr, tableMaxColspan( table ) ); @@ -331,7 +331,7 @@ function fillForm(aprop) { gProperty = aprop; var vclass = gProperty.domainClass; - DWRUtil.setValues(gProperty); + dwr.util.setValues(gProperty); toggleDisabled("newPropButton"); @@ -346,7 +346,7 @@ function fillPropList(classId) { /* This function fills up the form's select list with options Notice that the option id is the propertyid + 'D' or 'R' so that domain and range properties can be distinguished */ - var propList = $("propertyList"); + var propList = dwr.util.byId("propertyList"); clear(propList); //add properties as options @@ -383,10 +383,10 @@ function fillPropList(classId) { *****************************************************************/ function fillRangeVClassList( propId ){ //If propId is null then the one on the property select list will be used - if( propId == null ) { propId = DWRUtil.getValue("propertyList");} + if( propId == null ) { propId = dwr.util.getValue("propertyList");} //clear the list and put the loading message up - var vclassListEle = $("vClassList"); + var vclassListEle = dwr.util.byId("vClassList"); clear(vclassListEle); vclassListEle.options[vclassListEle.options.length] = new Option("Loading...",-10); //vclassListEle.options[0].selected = true; @@ -394,11 +394,11 @@ function fillRangeVClassList( propId ){ var prop = gPropertyHash[propId]; - VClassDWR.getVClasses( - function(vclasses){ - addVClassOptions( vclasses ); - }, - prop.domainClassURI, prop.propertyURI, prop.subjectSide); + VClassDWR.getVClasses(prop.domainClassURI, prop.propertyURI, prop.subjectSide, + function(vclasses){ + addVClassOptions( vclasses ); + } + ); } /**************************************************************** @@ -406,14 +406,14 @@ function fillRangeVClassList( propId ){ the entitiesList. ****************************************************************/ function addVClassOptions( vclassArray ){ - // DWRUtil.addOptions("entitiesList",null); - var vclassEle = $("vClassList"); + // dwr.util.addOptions("entitiesList",null); + var vclassEle = dwr.util.byId("vClassList"); clear( vclassEle ); vclassEle.disabled = false; if( vclassArray == null || vclassArray.length < 1){ vclassEle.disabled = true; - entsEle = $("entitiesList"); + entsEle = dwr.util.byId("entitiesList"); clear(entsEle); var msg="There are no entities defined yet that could fill this role"; var opt = new Option(msg,-1); @@ -435,15 +435,15 @@ function addVClassOptions( vclassArray ){ //attempt to set the selected option to the current vclass var vclassURI = null; - var prop = gPropertyHash[ DWRUtil.getValue("propertyList") ]; + var prop = gPropertyHash[ dwr.util.getValue("propertyList") ]; if( gProperty.propertyURI == prop.propertyURI ){ vclassURI = gProperty.rangeClassURI; - DWRUtil.setValue(vclassEle, vclassURI ); + dwr.util.setValue(vclassEle, vclassURI ); //here we were unable to set the vclass select option to the vclassid //of the entity. this means that the vclass of the entity is not one that //is permited by the PropertyInheritance and other restrictions. - if( DWRUtil.getValue(vclassEle) != vclassURI){ + if( dwr.util.getValue(vclassEle) != vclassURI){ alert("This entity's class does not match the class of this property. This is usually the "+ "result of the class of the entity having been changed. Properties that were added when " + "this entity had the old class still reflect that value.\n" + @@ -461,15 +461,15 @@ function addVClassOptions( vclassArray ){ *****************************************************************/ function fillEntsList( vclassEle ){ if( vclassEle == null ) - vclassEle = $("vClassList"); - var vclassUri = DWRUtil.getValue( vclassEle ); + vclassEle = dwr.util.byId("vClassList"); + var vclassUri = dwr.util.getValue( vclassEle ); if( vclassUri == gVClassUri ) return; else gVClassUri = vclassUri; - var entsListEle = $("entitiesList"); + var entsListEle = dwr.util.byId("entitiesList"); clear(entsListEle); entityOptToSelect = null; @@ -494,7 +494,7 @@ function fillEntsList( vclassEle ){ }, load: function(type, data, evt){ //clear here since we will be using addEntOptions for multiple adds -// var entsListEle = $("entitiesList"); +// var entsListEle = dwr.util.byId("entitiesList"); // clear(entsListEle); addEntOptions(data, -1); }, @@ -509,7 +509,7 @@ function fillEntsList( vclassEle ){ /** add entities in entArray as options elements to select element "Individual" */ function addEntOptions( entArray ){ - var entsListEle = $("entitiesList"); + var entsListEle = dwr.util.byId("entitiesList"); if( entArray == null || entArray.length == 0){ clear(entsListEle); @@ -623,12 +623,12 @@ function writeProp() { return; } if( !validateForm() ) { return; } - var prop = gPropertyHash[DWRUtil.getValue("propertyList")]; + var prop = gPropertyHash[dwr.util.getValue("propertyList")]; var newP = {}; var oldP = gProperty; newP.propertyURI = prop.propertyURI; - var selected = DWRUtil.getValue("entitiesList"); + var selected = dwr.util.getValue("entitiesList"); newP.subjectEntURI= gEntity.URI; newP.objectEntURI = selected ; @@ -639,16 +639,17 @@ function writeProp() { if( editingNewProp ){ newP.ents2entsId = -1; - PropertyDWR.insertProp(callback, newP ); + PropertyDWR.insertProp(newP, { callback:callback } ); } else { var afterDelete= function(result){ - PropertyDWR.insertProp(callback, newP); + PropertyDWR.insertProp(newP, { callback:callback }); }; - PropertyDWR.deleteProp(afterDelete, + PropertyDWR.deleteProp( gProperty.subjectEntURI, gProperty.propertyURI, - gProperty.objectEntURI); + gProperty.objectEntURI, + { callback:afterDelete }); } } @@ -657,10 +658,10 @@ addEvent(window, 'load', update); /********************* some utilities ***********************************/ /* this clones the property edit from a div on the ents_edit.jsp */ -function getForm(){ return $("propeditdiv").cloneNode(true); } +function getForm(){ return dwr.util.byId("propeditdiv").cloneNode(true); } /* a function to display a lot of info about an object */ -function disy( obj, note ){ alert( (note!==null?note:"") + DWRUtil.toDescriptiveString(obj, 3));} +function disy( obj, note ){ alert( (note!==null?note:"") + dwr.util.toDescriptiveString(obj, 3));} /* attempts to get the URI of the entity being edited */ function getEntityUriFromPage(){ diff --git a/webapp/src/main/webapp/js/ents_retry.js b/webapp/src/main/webapp/js/ents_retry.js index d0aa8def9..d4cecd0ac 100644 --- a/webapp/src/main/webapp/js/ents_retry.js +++ b/webapp/src/main/webapp/js/ents_retry.js @@ -30,7 +30,7 @@ function init(){ function update(){ //updates moniker list when type is changed - DWRUtil.useLoadingMessage(); + dwr.util.useLoadingMessage(); EntityDWR.monikers(createList, document.getElementById("field2Value").value ); @@ -50,7 +50,7 @@ function createList(data) { //puts options in moniker select list var opt = new Option("[new moniker]",""); ele.options[ele.options.length] = opt; - DWRUtil.setValue("monikerSelect",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp + dwr.util.setValue("monikerSelect",getCurrentMoniker()); // getCurrentMoniker() is defined on jsp checkMonikers(); } @@ -96,7 +96,7 @@ function fillList(id, data, selectedtext) { for (var i = 0; i < data.length; i++) { - var text = DWRUtil.toDescriptiveString(data[i]); + var text = dwr.util.toDescriptiveString(data[i]); var value = text; diff --git a/webapp/src/main/webapp/js/vitro.js b/webapp/src/main/webapp/js/vitro.js index e57e85ce2..5625840f3 100755 --- a/webapp/src/main/webapp/js/vitro.js +++ b/webapp/src/main/webapp/js/vitro.js @@ -54,7 +54,7 @@ function encodeUrl(pstrString) { */ function addRows(ele, data, cellFuncs, rowFunc) { var frag = document.createDocumentFragment(); - if (DWRUtil._isArray(data)) { + if (dwr.util._isArray(data)) { for (var i = 0; i < data.length; i++) { frag.appendChild( makeRow( data[i], cellFuncs, rowFunc) ); } @@ -77,9 +77,9 @@ function makeRow( row, cellFuncs, rowFunc){ var func = cellFuncs[j] var td var reply = func(row) - if (DWRUtil._isHTMLElement(reply, "td")) { + if (dwr.util._isHTMLElement(reply, "td")) { td = reply; - } else if (DWRUtil._isHTMLElement(reply, "a")) { + } else if (dwr.util._isHTMLElement(reply, "a")) { td = document.createElement("td"); td.appendChild( reply ); } else { @@ -91,7 +91,7 @@ function makeRow( row, cellFuncs, rowFunc){ return tr; } -/** added this from the DWRUtil.js */ +/** added this from the dwr.util.js */ isDate = function(data) { return (data && data.toUTCString) ? true : false; }; @@ -147,8 +147,8 @@ function date2iso8601( jdate ){ function setDateValue(ele, date, date2StrFunc){ if( date == null || ! isDate(date)) { return; } if( date2StrFunc == null ) { date2StrFunc = date2iso8601; } - ele = $(ele); - DWRUtil.setValue(ele, date2StrFunc( date )); + ele = dwr.util.byId(ele); + dwr.util.setValue(ele, date2StrFunc( date )); } /* removes all children and if it can, removes options */ @@ -160,7 +160,7 @@ function clear(ele){ } function hideElementById(eleId){ - var ele = $(eleId); + var ele = dwr.util.byId(eleId); if( ele != null ){ ele.style.display="none"; } } @@ -168,7 +168,7 @@ function makeEntLinkElement(entityURI, text){ link = document.createElement("a"); link.href = "entityEdit?uri=" + encodeUrl(entityURI); link.innerHTML = text; - //DWRUtil.setValue(link, "test" + text); + //dwr.util.setValue(link, "test" + text); return link; } @@ -375,7 +375,7 @@ function adjustIFrameSize(id) { } function toggleDisabled(ele){ - ele = $(ele); + ele = dwr.util.byId(ele); if(ele == null) {return;} ele.disabled = !ele.disabled ; } @@ -403,16 +403,16 @@ and returns a value for use in the select option value. textFun is a function that takes one parameter, an object, and returns a value for use in the select option text. -This is based on the code in DWRUtil but lacks the error checking. +This is based on the code in dwr.util but lacks the error checking. */ addOptions = function(ele, data, valueFunc, textFunc) { var orig = ele; - ele = $(ele); + ele = dwr.util.byId(ele); if (ele == null) { - DWRUtil.debug("addOptions() can't find an element with id: " + orig + "."); + dwr.util.debug("addOptions() can't find an element with id: " + orig + "."); return; } - var useOptions = DWRUtil._isHTMLElement(ele, "select"); + var useOptions = dwr.util._isHTMLElement(ele, "select"); if (data == null) return; var text; diff --git a/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp b/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp index 31bf303fb..2f226cac1 100644 --- a/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp +++ b/webapp/src/main/webapp/templates/edit/specific/ents_edit_head.jsp @@ -12,19 +12,23 @@ String context = request.getContextPath(); if (!(Boolean)request.getAttribute("dwrDisabled")) { %> + + - -