diff --git a/Geoweaver.war b/Geoweaver.war new file mode 100644 index 000000000..964fd8b79 Binary files /dev/null and b/Geoweaver.war differ diff --git a/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.js b/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.js index 8ba3a8461..b007fd2af 100644 --- a/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.js +++ b/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.js @@ -18,7 +18,7 @@ edu = { sponsor: "ESIPLab incubator project", - version: "0.7.8", + version: "0.7.9", author: "Ziheng Sun", diff --git a/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js b/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js index 583a4056b..91b9aa9d8 100644 --- a/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js +++ b/WebContent/geoweaver/js/edu.gmu.csiss.geoweaver.process.js @@ -16,6 +16,8 @@ edu.gmu.csiss.geoweaver.process = { envlist: {}, + cmid: null, //the id used to differentiate the dialogs + builtin_processes: [ {"operation":"ShowResultMap", "params":[{"name":"resultfile", "min_occurs": 1, "max_occurs": 1}]}, //multiple occurs are something for later @@ -84,7 +86,7 @@ edu.gmu.csiss.geoweaver.process = { var valid = false; - if($("#processname").val()){ + if($("#processname-"+edu.gmu.csiss.geoweaver.process.cmid).val()){ // &&this.editor.getValue()){ @@ -96,56 +98,33 @@ edu.gmu.csiss.geoweaver.process = { }, - showShell: function(code){ + showShell: function(code, cmid){ - $("#codearea").append(''); + $("#codearea-"+edu.gmu.csiss.geoweaver.process.cmid).append(''); //initiate the code editor - edu.gmu.csiss.geoweaver.process.editor = CodeMirror.fromTextArea(document.getElementById("codeeditor"), { + edu.gmu.csiss.geoweaver.process.editor = CodeMirror.fromTextArea(document.getElementById("codeeditor-" + cmid), { + + lineNumbers: true, - lineNumbers: true, - - lineWrapping: true, - - extraKeys: { - - "Ctrl-S": function(instance) { - - edu.gmu.csiss.geoweaver.process.update(edu.gmu.csiss.geoweaver.process.current_pid); - - } - } - - }); + lineWrapping: true, + + extraKeys: { + + "Ctrl-S": function(instance) { + + edu.gmu.csiss.geoweaver.process.update(edu.gmu.csiss.geoweaver.process.current_pid, cmid); + + } + } + + }); $(".CodeMirror").css('font-size',"10pt"); edu.gmu.csiss.geoweaver.process.editor.setSize(null, 360); -// var cmds = CodeMirror.commands; -// -// cmds.saveCode = function(cm){ -// -// console.log("save code is triggered"); -//// edu.gmu.csiss.geoweaver.process.update(edu.gmu.csiss.geoweaver.process.current_id); -// -// } -// -// var keyMap = CodeMirror.keyMap; -// -// keyMap.macSublime = { -// "Cmd-S": "saveCode", -// }; -// -// CodeMirror.normalizeKeyMap(keyMap.macSublime); -// -// keyMap.pcSublime = { -// "Ctrl-S": "saveCode", -// }; -// -// CodeMirror.normalizeKeyMap(keyMap.pcSublime); - if(code!=null){ edu.gmu.csiss.geoweaver.process.editor.setValue(edu.gmu.csiss.geoweaver.process.unescape(code)); @@ -222,28 +201,30 @@ edu.gmu.csiss.geoweaver.process = { }, - showPython: function(code){ - - $("#codearea").append(''); - - //initiate the code editor - - edu.gmu.csiss.geoweaver.process.editor = CodeMirror.fromTextArea(document.getElementById("codeeditor"), { - - lineNumbers: true, - - lineWrapping: true, - - extraKeys: { - - "Ctrl-S": function(instance) { - - edu.gmu.csiss.geoweaver.process.update(edu.gmu.csiss.geoweaver.process.current_pid); - - } - } - - }); + showPython: function(code, cmid){ + +// var cmid = Math.floor(Math.random() * 100); + + $("#codearea-"+cmid).append(''); + + //initiate the code editor + + edu.gmu.csiss.geoweaver.process.editor = CodeMirror.fromTextArea(document.getElementById("codeeditor-" + cmid), { + + lineNumbers: true, + + lineWrapping: true, + + extraKeys: { + + "Ctrl-S": function(instance) { + + edu.gmu.csiss.geoweaver.process.update(edu.gmu.csiss.geoweaver.process.current_pid, cmid); + + } + } + + }); $(".CodeMirror").css('font-size',"10pt"); @@ -261,7 +242,7 @@ edu.gmu.csiss.geoweaver.process = { }, - showJupyter: function(code){ + showJupyter: function(code, cmid){ var cont = '
* This panel is for importing and editing jupyter notebooks. The execution is by nbconvert.
'+ '
'+ @@ -271,29 +252,27 @@ edu.gmu.csiss.geoweaver.process = { '
'+ ' '+ '
'+ - '
'; + '
'; - $("#codearea").append(cont); + $("#codearea-"+cmid).append(cont); this.load_jupyter(); if(code!=null && typeof code != 'undefined'){ - if(typeof code != 'object'){ code = $.parseJSON(code); } var notebook = nb.parse(code); var rendered = notebook.render(); - $("#jupyter_area").append(rendered); - + $("#jupyter_area-"+cmid).append(rendered); } }, - showBuiltinProcess: function(code){ + showBuiltinProcess: function(code, cmid){ var cont = ' '+ - '
'; for(var i=0;i'; content += ''; var width = 720; var height = 640; @@ -424,58 +404,50 @@ edu.gmu.csiss.geoweaver.process = { }); - frame.on('#history-process-d', 'click', (_frame, evt) => { - edu.gmu.csiss.geoweaver.process.recent(20); - _frame.closeFrame(); - }); - - frame.on('#history-workflow-d', 'click', (_frame, evt) => { - edu.gmu.csiss.geoweaver.workflow.recent(20); - _frame.closeFrame(); - }); - //Show the window frame.show(); frame.setPosition((window.innerWidth - width) / 2, (window.innerHeight -height) / 2, 'LEFT_TOP'); - edu.gmu.csiss.geoweaver.process.showShell(); + edu.gmu.csiss.geoweaver.process.showShell(null, edu.gmu.csiss.geoweaver.process.cmid); - $("#processcategory").on('change', function() { + $("#processcategory-"+edu.gmu.csiss.geoweaver.process.cmid).on('change', function() { - $("#codearea").empty(); + console.log(this.id); + + $("#codearea-"+edu.gmu.csiss.geoweaver.process.cmid).empty(); if( this.value == "shell"){ - edu.gmu.csiss.geoweaver.process.showShell(); + edu.gmu.csiss.geoweaver.process.showShell(null,edu.gmu.csiss.geoweaver.process.cmid); }else if(this.value == "builtin"){ - edu.gmu.csiss.geoweaver.process.showBuiltinProcess(); + edu.gmu.csiss.geoweaver.process.showBuiltinProcess(null,edu.gmu.csiss.geoweaver.process.cmid); }else if(this.value == "jupyter"){ - edu.gmu.csiss.geoweaver.process.showJupyter(edu.gmu.csiss.geoweaver.process.jupytercode); + edu.gmu.csiss.geoweaver.process.showJupyter(null, edu.gmu.csiss.geoweaver.process.jupytercode,edu.gmu.csiss.geoweaver.process.cmid); }else if(this.value == "python"){ - edu.gmu.csiss.geoweaver.process.showPython(); + edu.gmu.csiss.geoweaver.process.showPython(null, edu.gmu.csiss.geoweaver.process.cmid); } }); - $("#add-process").click(function(){ + $("#add-process-" + edu.gmu.csiss.geoweaver.process.cmid).click(function(){ - edu.gmu.csiss.geoweaver.process.add(false); + edu.gmu.csiss.geoweaver.process.add(false,edu.gmu.csiss.geoweaver.process.cmid); frame.close(); }); - $("#run-process").click(function(){ + $("#run-process-" + edu.gmu.csiss.geoweaver.process.cmid).click(function(){ - edu.gmu.csiss.geoweaver.process.add(true); + edu.gmu.csiss.geoweaver.process.add(true,edu.gmu.csiss.geoweaver.process.cmid); frame.close(); @@ -899,6 +871,14 @@ edu.gmu.csiss.geoweaver.process = { }).done(function(msg){ + if(msg==""){ + + alert("Cannot find the process history in the database."); + + return; + + } + msg = $.parseJSON(msg); var output = msg.output; @@ -1088,11 +1068,13 @@ edu.gmu.csiss.geoweaver.process = { getProcessDialogTemplate: function(){ + edu.gmu.csiss.geoweaver.process.cmid = Math.floor(Math.random() * 1000); + var content = '
'+ '
'+ ' '+ '
'+ - ' '+ ' '+ ' '+ ' '+ @@ -1106,11 +1088,11 @@ edu.gmu.csiss.geoweaver.process = { // '
'+ ' '+ '
'+ - ' '+ + ' '+ '
'+ '
'+ - '
'+ + '
'+ '

Ctrl+S to save edits.

'+ '
'; @@ -1139,8 +1121,8 @@ edu.gmu.csiss.geoweaver.process = { edu.gmu.csiss.geoweaver.process.getProcessDialogTemplate() + '
'; content += ''; var width = 720; var height = 640; @@ -1177,16 +1159,6 @@ edu.gmu.csiss.geoweaver.process = { }); - frame.on('#history-process-d', 'click', (_frame, evt) => { - edu.gmu.csiss.geoweaver.process.recent(20); - _frame.closeFrame(); - }); - - frame.on('#history-workflow-d', 'click', (_frame, evt) => { - edu.gmu.csiss.geoweaver.workflow.recent(20); - _frame.closeFrame(); - }); - //Show the window frame.show(); @@ -1198,33 +1170,33 @@ edu.gmu.csiss.geoweaver.process = { var old_code = msg.code; - $("#processcategory").val(old_lang); + $("#processcategory-"+edu.gmu.csiss.geoweaver.process.cmid).val(old_lang); - $("#processname").val(msg.name); + $("#processname-"+edu.gmu.csiss.geoweaver.process.cmid).val(msg.name); - $("#codearea").empty(); + $("#codearea-"+edu.gmu.csiss.geoweaver.process.cmid).empty(); if( old_lang == "shell"){ - edu.gmu.csiss.geoweaver.process.showShell(old_code); + edu.gmu.csiss.geoweaver.process.showShell(old_code, edu.gmu.csiss.geoweaver.process.cmid); }else if(old_lang == "builtin"){ - edu.gmu.csiss.geoweaver.process.showBuiltinProcess(old_code); + edu.gmu.csiss.geoweaver.process.showBuiltinProcess(old_code, edu.gmu.csiss.geoweaver.process.cmid); }else if(old_lang == "jupyter"){ - edu.gmu.csiss.geoweaver.process.showJupyter(old_code); + edu.gmu.csiss.geoweaver.process.showJupyter(old_code, edu.gmu.csiss.geoweaver.process.cmid); }else if(old_lang == "python"){ - edu.gmu.csiss.geoweaver.process.showPython(old_code); + edu.gmu.csiss.geoweaver.process.showPython(old_code, edu.gmu.csiss.geoweaver.process.cmid); } - $("#processcategory").on('change', function() { + $("#processcategory-"+edu.gmu.csiss.geoweaver.process.cmid).on('change', function() { - $("#codearea").empty(); + $("#codearea-"+edu.gmu.csiss.geoweaver.process.cmid).empty(); var old_code_new = null; @@ -1236,31 +1208,31 @@ edu.gmu.csiss.geoweaver.process = { if( this.value == "shell"){ - edu.gmu.csiss.geoweaver.process.showShell(old_code_new); + edu.gmu.csiss.geoweaver.process.showShell(old_code_new, edu.gmu.csiss.geoweaver.process.cmid); }else if(this.value == "builtin"){ - edu.gmu.csiss.geoweaver.process.showBuiltinProcess(old_code_new); + edu.gmu.csiss.geoweaver.process.showBuiltinProcess(old_code_new, edu.gmu.csiss.geoweaver.process.cmid); }else if(this.value == "jupyter"){ - edu.gmu.csiss.geoweaver.process.showJupyter(old_code_new); + edu.gmu.csiss.geoweaver.process.showJupyter(old_code_new, edu.gmu.csiss.geoweaver.process.cmid); }else if(this.value == "python"){ - edu.gmu.csiss.geoweaver.process.showPython(old_code_new); + edu.gmu.csiss.geoweaver.process.showPython(old_code_new, edu.gmu.csiss.geoweaver.process.cmid); } }); - $("#edit-save-process").click(function(){ + $("#edit-save-process-"+edu.gmu.csiss.geoweaver.process.cmid).click(function(){ - edu.gmu.csiss.geoweaver.process.update(msg.id); + edu.gmu.csiss.geoweaver.process.update(msg.id, edu.gmu.csiss.geoweaver.process.cmid); }); - $("#edit-run-process").click(function(){ + $("#edit-run-process-"+edu.gmu.csiss.geoweaver.process.cmid).click(function(){ //not finished yet @@ -1454,7 +1426,7 @@ edu.gmu.csiss.geoweaver.process = { }, - update: function(pid){ + update: function(pid, cmid){ console.log("update process id: " + pid); @@ -1462,15 +1434,15 @@ edu.gmu.csiss.geoweaver.process = { var req = { - type: "process", lang: $("#processcategory").val(), + type: "process", lang: $("#processcategory-"+cmid).val(), - desc: $("#processcategory").val(), //use the description column to store the process type + desc: $("#processcategory-"+cmid).val(), //use the description column to store the process type - name: $("#processname").val(), + name: $("#processname-"+cmid).val(), id: pid, - code: edu.gmu.csiss.geoweaver.process.getCode() + code: edu.gmu.csiss.geoweaver.process.getCode(cmid) }; @@ -1511,7 +1483,7 @@ edu.gmu.csiss.geoweaver.process = { } }, - add: function(run){ + add: function(run, cmid){ this.current_pid = null; @@ -1521,42 +1493,42 @@ edu.gmu.csiss.geoweaver.process = { type: "process", - lang: $("#processcategory").val(), + lang: $("#processcategory-"+cmid).val(), - desc: $("#processcategory").val(), //use the description column to store the process type + desc: $("#processcategory-"+cmid).val(), //use the description column to store the process type - name: $("#processname").val(), + name: $("#processname-"+cmid).val(), - code: edu.gmu.csiss.geoweaver.process.getCode() + code: edu.gmu.csiss.geoweaver.process.getCode(cmid) }; - $.ajax({ - - url: "add", - - method: "POST", - - data: req - - }).done(function(msg){ - - msg = $.parseJSON(msg); - - msg.desc = req.desc; - - edu.gmu.csiss.geoweaver.process.addMenuItem(msg, req.desc); - - if(run) - - edu.gmu.csiss.geoweaver.process.runProcess(msg.id, msg.name, $("#processcategory").val()); - - - }).fail(function(jqXHR, textStatus){ - - alert("Fail to add the process."); - - }); + $.ajax({ + + url: "add", + + method: "POST", + + data: req + + }).done(function(msg){ + + msg = $.parseJSON(msg); + + msg.desc = req.desc; + + edu.gmu.csiss.geoweaver.process.addMenuItem(msg, req.desc); + + if(run) + + edu.gmu.csiss.geoweaver.process.runProcess(msg.id, msg.name, $("#processcategory-"+cmid).val()); + + + }).fail(function(jqXHR, textStatus){ + + alert("Fail to add the process."); + + }); }else{ diff --git a/docs/newlook.gif b/docs/newlook.gif new file mode 100644 index 000000000..06509ffa2 Binary files /dev/null and b/docs/newlook.gif differ diff --git a/install-windows.bat b/install-windows.bat index 01dafe347..2bcad71b5 100755 --- a/install-windows.bat +++ b/install-windows.bat @@ -18,25 +18,31 @@ cd install echo current directory is %CD% -if EXIST "openjdk-12.0.2_windows-x64_bin_1.zip" ( +if exist "openjdk-12.0.2_windows-x64_bin.zip" ( echo ++++++++++++++++ found openjdk-12.0.2_windows-x64_bin.zip ) else ( - echo -e Download OpenJDK + echo -e "Download OpenJDK" - curl https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_windows-x64_bin.zip -o openjdk-12.0.2_windows-x64_bin.zip + curl -L "https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_windows-x64_bin.zip" -o "openjdk-12.0.2_windows-x64_bin.zip" rem tar -zxvf openjdk-12.0.2_linux-x64_bin.tar.gz - echo "Expand-Archive" %CD%\openjdk-12.0.2_windows-x64_bin.zip %CD%\ - powershell -Command "Expand-Archive %CD%\openjdk-12.0.2_windows-x64_bin.zip %CD%\ " ) -if EXIST "apache-tomcat-9.0.22-windows-x64_1.zip" ( +if not exist "jdk-12.0.2" ( + + echo "Expand-Archive" %CD%\openjdk-12.0.2_windows-x64_bin.zip %CD%\ + + powershell -Command "Expand-Archive -Path '%CD%\openjdk-12.0.2_windows-x64_bin.zip' -DestinationPath '%CD%\' " + +) + +if exist "apache-tomcat-9.0.22-windows-x64.zip" ( echo ++++++++++++++++ found apache-tomcat-9.0.22.tar.gz @@ -44,65 +50,80 @@ if EXIST "apache-tomcat-9.0.22-windows-x64_1.zip" ( echo "Download Tomcat" - curl https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.22/bin/apache-tomcat-9.0.22-windows-x64.zip -o apache-tomcat-9.0.22-windows-x64.zip + curl -L "https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.22/bin/apache-tomcat-9.0.22-windows-x64.zip" -o "apache-tomcat-9.0.22-windows-x64.zip" - rem tar -zxvf apache-tomcat-9.0.24-windows-x64.zip - - powershell -Command "Expand-Archive %CD%\apache-tomcat-9.0.22-windows-x64.zip %CD%\ " ) -echo change the default jdk to the downloaded jdk - - - -for /f "tokens=*" %%a in (apache-tomcat-9.0.22/bin/catalina.bat) do ( +if not exist "apache-tomcat-9.0.22" ( - echo %%a >> temp.txt + rem tar -zxvf apache-tomcat-9.0.24-windows-x64.zip - rem if "%%a" == "" ( ) else ( echo %%a >> temp.txt ) - - if "%%a" == "setlocal" ( + powershell -Command "Expand-Archive -Path '%CD%\apache-tomcat-9.0.22-windows-x64.zip' -DestinationPath '%CD%\' " - rem echo this is the position should the new line being inserted >> temp.txt + echo "change the default jdk to the downloaded jdk" + + del "temp.txt" + + for /f "tokens=*" %%a in (apache-tomcat-9.0.22\bin\startup.bat) do ( - echo set JAVA_HOME=%CD%\jdk-12.0.2\ >> temp.txt - + rem if "%%a" == "" ( ) else ( echo %%a >> temp.txt ) + + if "%%a" == "setlocal" ( + + rem echo this is the position should the new line being inserted >> temp.txt + + echo set CATALINA_HOME=%CD%\apache-tomcat-9.0.22>> "temp.txt" + + echo set JAVA_HOME=%CD%\jdk-12.0.2>> "temp.txt" + + echo set JRE_HOME=%CD%\jdk-12.0.2>> "temp.txt" + + ) + + echo %%a >> temp.txt ) - + ) + rem echo ***New bottom line*** >> temp.txt -echo y|del apache-tomcat-9.0.22/bin/catalina.bat +rem echo y|del "apache-tomcat-9.0.2F2\bin\catalina.bat" -rename temp.txt apache-tomcat-9.0.22/bin/catalina.bat +rem rename "temp.txt" "apache-tomcat-9.0.22\bin\catalina.bat" + +copy "temp.txt" "apache-tomcat-9.0.22\bin\startup.bat" rem echo JAVA_HOME='$PWD'/jdk-12.0.2/ 109 >> apache-tomcat-9.0.22/bin/catalina.sh echo download Geoweaver into Apache Tomcat Webapp Folder -curl https://github.com/ESIPFed/Geoweaver/releases/download/latest/Geoweaver.war -o Geoweaver.war +del "Geoweaver.war" + +curl -L "https://github.com/ESIPFed/Geoweaver/releases/download/latest/Geoweaver.war" -o "Geoweaver.war" -mv Geoweaver.war apache-tomcat-9.0.22/webapps/ +copy "Geoweaver.war" "apache-tomcat-9.0.22\webapps\" echo Move database in place -cp ../db/geoweaver* ~/ +copy "..\db\geoweaver.mv.db" "C:%HOMEPATH%\" + +copy "..\db\geoweaver.trace.db" "C:%HOMEPATH%\" echo start the tomcat.. -chmod 755 apache-tomcat-9.0.22/bin/catalina.sh +rem chmod 755 apache-tomcat-9.0.22/bin/catalina.sh -chmod 755 apache-tomcat-9.0.22/bin/startup.sh +rem chmod 755 apache-tomcat-9.0.22/bin/startup.sh -./apache-tomcat-9.0.22/bin/startup.sh +apache-tomcat-9.0.22\bin\startup.bat -sleep 3 +SLEEP 3 echo modify the Geoweaver configuration - there is no need to do this +rem there is no need to do this echo Geoweaver is successfully installed! diff --git a/pom.xml b/pom.xml index 083fe266e..5501e3ba8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 Geoweaver - 0.7.8 + 0.7.9 war Geoweaver ESIPLab incubator project @@ -66,6 +66,11 @@ system ${basedir}/WebContent/WEB-INF/lib/aopalliance-1.0.jar + commons-codec commons-codec diff --git a/src/edu/gmu/csiss/earthcube/cyberconnector/database/DataBaseOperation.java b/src/edu/gmu/csiss/earthcube/cyberconnector/database/DataBaseOperation.java index 459088a06..032bd5751 100644 --- a/src/edu/gmu/csiss/earthcube/cyberconnector/database/DataBaseOperation.java +++ b/src/edu/gmu/csiss/earthcube/cyberconnector/database/DataBaseOperation.java @@ -12,6 +12,8 @@ import java.sql.SQLException; import java.sql.SQLTimeoutException; import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import org.apache.log4j.Logger; @@ -30,7 +32,95 @@ public class DataBaseOperation { private final static Logger logger = Logger.getLogger(DataBaseOperation.class); - private static Connection q_conn, e_conn,u_conn; +// private static Connection q_conn, e_conn,u_conn; + + private static List conn_pool = new ArrayList(); //maximum 5 connections + + static int maximum_connection = 10; + + static void addNewConnection(Connection newcon) { + + if(conn_pool.size()>=maximum_connection) { + + //close the oldest connections + + try { + + conn_pool.get(0).close(); + + conn_pool.remove(0); + + } catch (SQLException e) { + + e.printStackTrace(); + + } + + } + + conn_pool.add(newcon); + + } + + static synchronized Connection getLiveConnection() { + + Connection con = null; + + try { + + for(int i=0;i