Workaround for asynchronous json bug
diff --git a/asterix-app/src/main/resources/sdk/static/cherry/examples/cherry.html b/asterix-app/src/main/resources/sdk/static/cherry/examples/cherry.html
index 7059e24..f620df7 100755
--- a/asterix-app/src/main/resources/sdk/static/cherry/examples/cherry.html
+++ b/asterix-app/src/main/resources/sdk/static/cherry/examples/cherry.html
@@ -124,8 +124,8 @@
<button id="submit-button">Submit</button>
<button id="clear-button">Clear</button>
<button id="show-query-button">Show Query</button><br />
- <input type="checkbox" value="Submit Asynchronously" name="async" id="asbox" />
- Submit asynchronously?
+ <!-- <input type="checkbox" value="Submit Asynchronously" name="async" id="asbox" />
+ Submit asynchronously?-->
</div>
</div><!-- end #submit-query -->
diff --git a/asterix-app/src/main/resources/sdk/static/cherry/img/hyrax.png b/asterix-app/src/main/resources/sdk/static/cherry/img/hyrax.png
new file mode 100644
index 0000000..645b7c1
--- /dev/null
+++ b/asterix-app/src/main/resources/sdk/static/cherry/img/hyrax.png
Binary files differ
diff --git a/asterix-app/src/main/resources/sdk/static/cherry/js/cherry.js b/asterix-app/src/main/resources/sdk/static/cherry/js/cherry.js
index b3be8ec..4fe4da5 100755
--- a/asterix-app/src/main/resources/sdk/static/cherry/js/cherry.js
+++ b/asterix-app/src/main/resources/sdk/static/cherry/js/cherry.js
@@ -252,7 +252,7 @@
"http://localhost:19002/query",
{
"query" : "use dataverse twitter;\n" + f.val(),
- "mode" : build_cherry_mode
+ "mode" : "synchronous"//build_cherry_mode
},
{
"sync" : cherryQuerySyncCallback,
@@ -311,6 +311,9 @@
* @param {object} extra_info, containing the asynchronous handle's id
*/
function asynchronousQueryAPIStatusReceived (res, extra_info) {
+
+ alert("Status: " + res);
+
var handle_outcome = $.parseJSON(res[0]);
var handle_id = extra_info["handle_id"];
if (handle_outcome["status"] == "SUCCESS") {
@@ -330,12 +333,20 @@
* @param {number} handle_id, the integer ID parsed from the handle object
*/
function asynchronousQueryGetAPIQueryStatus (handle, handle_id) {
- var apiQueryStatus = new AsterixCoreAPI()
- .dataverse("twitter")
- .handle(handle)
- .success(asynchronousQueryAPIStatusReceived, true)
- .add_extra("handle_id", handle_id)
- .api_core_query_status();
+
+ var a = new AExpression();
+ a.run(
+ "http://localhost:19002/query/status",
+ {
+ "handle" : handle
+ },
+ {
+ "sync" : asynchronousQueryAPIStatusReceived
+ },
+ {
+ "handle_id" : handle_id
+ }
+ )
}
/**
@@ -354,7 +365,8 @@
asyncQueryManager[handle_id] = {
"handle" : handle,
"query" : handle_query,
- "data" : extra["payload"]
+ "data" : extra["payload"],
+ "ready" : true
};
$('#review-handles-dropdown').append('<a href="#" class="holdmenu"><span class="label" id="handle_' + handle_id + '">Handle ' + handle_id + '</span></a>');
@@ -383,13 +395,21 @@
$('#dialog').html(APIqueryTracker["query"]);
// Generate new Asterix Core API Query
- var asyncResultQuery = new AsterixCoreAPI()
- .dataverse("twitter")
- .handle(asyncQueryManager[handle_id]["handle"])
- .success(cherryQuerySyncCallback, true)
- .add_extra("payload", asyncQueryManager[handle_id]["data"]) // Legacy
- .add_extra("query_string", asyncQueryManager[handle_id]["query"]) // Legacy
- .api_core_query_result();
+ var ah = new AExpression();
+ ah.run(
+ "http://localhost:19002/query/result",
+ {
+ "handle" : asyncQueryManager[handle_id]["handle"],
+ },
+ {
+ "sync" : function () { alert("hello world"); },
+ },
+ {
+ "payload" : asyncQueryManager[handle_id]["data"],
+ "query_string" : asyncQueryManager[handle_id]["query"]
+ }
+ );
+
}
});
}
diff --git a/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js b/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
index c179b38..f0a7528 100644
--- a/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
+++ b/asterix-app/src/main/resources/sdk/static/js/asterix-sdk-stable.js
@@ -30,12 +30,42 @@
this._callbacks = callbacks;
myThis = this;
- $.ajax({
- type : 'GET',
- url : endpoint,
- data : payload,
- dataType : "json",
- success : function(response) {
+ $.getJSON( endpoint, payload, function (response) {
+ //alert("DEBUG: Run Response: " + JSON.stringify(response));
+
+ if (response && response["error-code"]) {
+
+ alert("Error [Code" + response["error-code"][0] + "]: " + response["error-code"][1]);
+
+ } else if (response && response["results"]) {
+
+ var fn_callback = myThis._callbacks["sync"];
+ fn_callback(response, myThis._extras);
+
+ } else if (response["handle"]) {
+
+ var fn_callback = myThis._callbacks["async"];
+ fn_callback(response, myThis._extras);
+
+ } else if (response["status"]) {
+
+ var fn_callback = myThis._callbacks["sync"];
+ fn_callback(response, myThis._extras);
+ }
+ })
+ .error(function() {
+ alert("error");
+ });
+
+ /*$.ajax({
+ "type" : 'GET',
+ "url" : endpoint,
+ "data" : payload,
+ "dataType" : "json",
+ "success" : function(response) {
+
+ alert("DEBUG: Run Response: " + JSON.stringify(response));
+
if (response && response["error-code"]) {
alert("Error [Code" + response["error-code"][0] + "]: " + response["error-code"][1]);
@@ -55,16 +85,16 @@
var fn_callback = myThis._callbacks["sync"];
fn_callback(response, myThis._extras);
}
+ },
+ "error": function (xhr, ajaxOptions, thrownError) {
+ alert("AJAX ERROR " + thrownError);
}
- });
+ });*/
return this;
};
-
-
-
AExpression.prototype.val = function() {
var value = "";