Browse Source

ECL Playground: Load from existing WU.

Post pending ?wuid=XXX to the playground URL will open the nominated WU
in the playground.

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
Gordon Smith 13 years ago
parent
commit
0d48ea5660
2 changed files with 80 additions and 29 deletions
  1. 35 0
      esp/files/ECLPlayground.js
  2. 45 29
      esp/files/scripts/ESPWorkunit.js

+ 35 - 0
esp/files/ECLPlayground.js

@@ -41,6 +41,10 @@ define([
 				//  ActiveX will flicker if created before initial layout
 				setTimeout(function(){
 					initGraph();
+					var wuid = dojo.queryToObject(dojo.doc.location.search.substr((dojo.doc.location.search[0] === "?" ? 1 : 0)))["wuid"];
+					if (wuid) {
+						doLoad(wuid);
+					}
 				}, 1);
 			},
 
@@ -109,6 +113,37 @@ define([
 				resultsControl.clear();
 			},
 
+			doLoad = function (wuid) {
+				wu = new Workunit({
+					wuid: wuid,
+
+					onMonitor: function () {
+						dom.byId("status").innerHTML = wu.state;
+						if (wu.isComplete())
+							wu.getInfo();
+					},
+					onGetText: function () {
+						editorControl.setText(wu.getText());
+					},
+					onGetInfo: function () {
+						if (wu.errors.length) {
+							editorControl.setErrors(wu.errors);
+							resultsControl.addExceptionTab(wu.errors);
+						}
+						wu.getResults();
+						wu.getGraphs();
+					},
+					onGetGraph: function (idx) {
+						graphControl.loadXGMML(wu.graphs[idx].xgmml, true);
+					},
+					onGetResult: function (idx) {
+						resultsControl.addDatasetTab(wu.results[idx].dataset);
+					}
+				});
+				wu.getText();
+				wu.monitor();
+			},
+
 			doSubmit = function(evt) {
 				resetPage();
 				wu = new Workunit({

+ 45 - 29
esp/files/scripts/ESPWorkunit.js

@@ -21,9 +21,12 @@ define([
 	"hpcc/ESPBase"], function(baseConfig, declare, baseXhr, ESPBase) {
 	return declare(ESPBase, {
 		wuid : "",
+
 		stateID : 0,
 		state : "",
 
+		text: "",
+
 		resultCount : 0,
 		results : [],
 
@@ -44,6 +47,8 @@ define([
 		},
 		onComplete : function() {
 		},
+		onGetText: function () {
+		},
 		onGetInfo : function() {
 		},
 		onGetGraph : function(name) {
@@ -150,43 +155,54 @@ define([
 				}
 			});
 		},
-		getInfo : function(_sync) {
+		getInfoEx: function (_sync, func, IncludeExceptions, IncludeGraphs, IncludeSourceFiles, IncludeResults, IncludeResultsViewNames, IncludeVariables, IncludeTimers, IncludeDebugValues, IncludeApplicationValues, IncludeWorkflows, IncludeResultSchemas) {
 			var request = {};
 			request['Wuid'] = this.wuid;
-			request['IncludeExceptions'] = true;
-			request['IncludeGraphs'] = true;
-			request['IncludeSourceFiles'] = false;
-			request['IncludeResults'] = true;
-			request['IncludeResultsViewNames'] = false;
-			request['IncludeVariables'] = false;
-			request['IncludeTimers'] = true;
-			request['IncludeDebugValues'] = false;
-			request['IncludeApplicationValues'] = false;
-			request['IncludeWorkflows'] = false;
-			request['SuppressResultSchemas'] = true;
+			request['IncludeExceptions'] = IncludeExceptions;
+			request['IncludeGraphs'] = IncludeGraphs;
+			request['IncludeSourceFiles'] = IncludeSourceFiles;
+			request['IncludeResults'] = IncludeResults;
+			request['IncludeResultsViewNames'] = IncludeResultsViewNames;
+			request['IncludeVariables'] = IncludeVariables;
+			request['IncludeTimers'] = IncludeTimers;
+			request['IncludeDebugValues'] = IncludeDebugValues;
+			request['IncludeApplicationValues'] = IncludeApplicationValues;
+			request['IncludeWorkflows'] = IncludeWorkflows;
+			request['SuppressResultSchemas'] = !IncludeResultSchemas;
 			request['rawxml_'] = "1";
 
-			var context = this;
 			baseXhr.post({
-				url : this.getBaseURL() + "/WUInfo",
-				handleAs : "xml",
-				content : request,
-				sync : _sync,
-				load : function(xmlDom) {
-					context.exceptions = context.parseRows(xmlDom, "Exception");
-					context.errors = context.parseRows(xmlDom, "ECLException");
-					context.timers = context.parseRows(xmlDom, "ECLTimer");
-					context.graphs = context.parseRows(xmlDom, "ECLGraph");
-					for(var i = 0; i < context.graphs.length; ++i) {
-						context.graphNameIndex[context.graphs[i].Name] = i;						
-					}
-					context.results = context.parseRows(xmlDom, "ECLResult");
-					context.onGetInfo();
-				},
-				error : function() {
+				url: this.getBaseURL() + "/WUInfo",
+				handleAs: "xml",
+				content: request,
+				sync: _sync,
+				load: func,
+				error: function () {
 				}
 			});
 		},
+		getText: function () {
+			var context = this;
+			this.getInfoEx(false, function (xmlDom) {
+				context.text = context.parseKeyValue(xmlDom, "Text");
+				context.onGetText();
+			});
+			return wu.text;
+		},
+		getInfo: function (_sync) {
+			var context = this;
+			this.getInfoEx(_sync, function (xmlDom) {
+				context.exceptions = context.parseRows(xmlDom, "Exception");
+				context.errors = context.parseRows(xmlDom, "ECLException");
+				context.timers = context.parseRows(xmlDom, "ECLTimer");
+				context.graphs = context.parseRows(xmlDom, "ECLGraph");
+				for (var i = 0; i < context.graphs.length; ++i) {
+					context.graphNameIndex[context.graphs[i].Name] = i;
+				}
+				context.results = context.parseRows(xmlDom, "ECLResult");
+				context.onGetInfo();
+			}, true, true, false, true, false, false, true, false, false, false, false);
+		},
 		getGraphs : function() {
 			for(var i = 0; i < this.graphs.length; ++i) {
 				this.getGraph(i);