SDK Review Feedback: Adds SDK Connection Bridge
diff --git a/asterix-app/src/main/resources/sdk/static/example/js/demo.js b/asterix-app/src/main/resources/sdk/static/example/js/demo.js
index 7ca6ab6..1ebfa0b 100644
--- a/asterix-app/src/main/resources/sdk/static/example/js/demo.js
+++ b/asterix-app/src/main/resources/sdk/static/example/js/demo.js
@@ -1,9 +1,6 @@
$(document).ready(function() {
- //A = AsterixSDK({
- // "dataverse" : "TinySocial
- //});
- //a.run(expression, fn);
+ var A = new AsterixDBConnection().dataverse("TinySocial");
// 0A - Exact-Match Lookup
$('#run0a').click(function () {
@@ -17,7 +14,9 @@
var success0a = function(res) {
$('#result0a').html(res["results"]);
};
- expression0a.run(success0a);
+
+ A.run(expression0a.val(), success0a);
+ //expression0a.run(success0a);
});
// 0B - Range Scan
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 207c393..8899953 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
@@ -1,4 +1,57 @@
-// Temporary AsterixExpression Placeholder
+function AsterixDBConnection(configuration) {
+ this._properties = {};
+ this._properties["dataverse"] = "";
+ this._properties["mode"] = "synchronous";
+
+ var configuration = arguments || {};
+
+ for (var key in configuration) {
+ this._properties[key] = configuration[key];
+ }
+
+ return this;
+}
+
+
+AsterixDBConnection.prototype.dataverse = function(dataverseName) {
+ this._properties["dataverse"] = dataverseName;
+
+ return this;
+};
+
+
+AsterixDBConnection.prototype.run = function(statements, successFn) {
+
+ var success_fn = successFn;
+
+ if ( typeof statements === 'string') {
+ statements = [ statements ];
+ }
+
+ var query = "use dataverse " + this._properties["dataverse"] + "\n;" + statements.join("\n");
+ var mode = this._properties["mode"];
+
+ $.ajax({
+ type : 'GET',
+ url : "http://localhost:19002/query",
+ data : {
+ "query" : query,
+ "mode" : mode
+ },
+ dataType : "json",
+ success : function(data) {
+ success_fn(data);
+ },
+ error: function(r) {
+ alert("AsterixSDK ERROR\n" + JSON.stringify(r));
+ }
+ });
+
+ return this;
+};
+
+
+// Asterix Expressions
function AExpression () {
this._properties = {};
this._success = function() {};