Exterminated bugs with the fire of a thousand angry suns.
diff --git a/asterix-app/src/main/resources/sdk/static/example/demo.html b/asterix-app/src/main/resources/sdk/static/example/demo.html
index 9d98546..3afaaa4 100644
--- a/asterix-app/src/main/resources/sdk/static/example/demo.html
+++ b/asterix-app/src/main/resources/sdk/static/example/demo.html
@@ -45,14 +45,10 @@
</pre></div>
<div class="how-to-run"><pre><code class="javascript">
- var expression0a = new FLWOGRExpression({
- "dataverse" : "TinySocial",
- "success" : function(res) {
- $('#result0a').html(res["results"]);
- }
- })
- .bind( new ForClause("user", null, new AsterixExpression().set(["dataset FacebookUsers"])) )
- .bind( new WhereClause(new BooleanExpression("$user.id = 8")));
+ var expression0a = new FLWOGRExpression()
+ .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers")))
+ .bind( new WhereClause(new AExpression().set("$user.id = 8")))
+ .ReturnClause("$user");
</code></pre></div>
<div class="result-output" id="result0a">
@@ -72,8 +68,15 @@
return $user;
</pre></div>
- <div class="how-to-run"><pre>
- </pre></div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression0b = new FLWOGRExpression()
+ .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers")))
+ .bind( new WhereClause().and(
+ new AExpression().set("$user.id >= 2"),
+ new AExpression().set("$user.id <= 4")
+ ))
+ .ReturnClause("$user");
+ </code></pre></div>
<div class="result-output" id="result0b">
</div>
@@ -93,8 +96,15 @@
return $user;
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression1 = new FLWOGRExpression()
+ .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers")))
+ .bind( new WhereClause().and(
+ new AExpression().set("$user.user-since >= datetime('2010-07-22T00:00:00')"),
+ new AExpression().set("$user.user-since <= datetime('2012-07-29T23:59:59')")
+ ))
+ .ReturnClause("$user");
+ </code></pre></div>
<div class="result-output" id="result1">
</div>
@@ -117,8 +127,16 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression2a = new FLWOGRExpression()
+ .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers")))
+ .bind( new ForClause ("message", new AQLClause().set("dataset FacebookMessages")))
+ .bind( new WhereClause (new AExpression().set("$message.author-id = $user.id")))
+ .ReturnClause({
+ "uname" : "$user.name",
+ "message" : "$message.message"
+ });
+ </code></pre></div>
<div class="result-output" id="result2a">
</div>
@@ -141,8 +159,18 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression2b = new FLWOGRExpression()
+ .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers")))
+ .bind( new ForClause ("message", new AQLClause().set("dataset FacebookMessages")))
+ .bind( new WhereClause (new AExpression().set("$message.author-id /*+ indexnl */ = $user.id")))
+ .ReturnClause(
+ {
+ "uname" : "$user.name",
+ "message" : "$message.message"
+ }
+ );
+ </code></pre></div>
<div class="result-output" id="result2b">
</div>
@@ -165,8 +193,19 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression3messages = new FLWOGRExpression()
+ .bind( new ForClause("message", new AExpression().set("dataset FacebookMessages")))
+ .bind( new WhereClause(new AExpression().set("$message.author-id = $user.id")))
+ .ReturnClause("$message.message");
+
+ var expression3 = new FLWOGRExpression()
+ .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers")))
+ .ReturnClause({
+ "uname": "$user.name",
+ "messages" : expression3messages
+ });
+ </code></pre></div>
<div class="result-output" id="result3">
</div>
@@ -189,8 +228,19 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression4messages = new FLWOGRExpression()
+ .bind( new ForClause( "t2", new AExpression().set("dataset TweetMessages")))
+ .bind( new WhereClause( new AExpression().set("spatial-distance($t.sender-location, $t2.sender-location) <= 1")))
+ .ReturnClause({ "msgtxt" : "$t2.message-text" });
+
+ var expression4 = new FLWOGRExpression()
+ .bind( new ForClause( "t", new AExpression().set("dataset TweetMessages") ))
+ .ReturnClause({
+ "message" : "$t.message-text",
+ "nearby-messages" : expression4messages
+ });
+ </code></pre></div>
<div class="result-output" id="result4">
</div>
@@ -221,8 +271,26 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var similarUsersExpression = new FLWOGRExpression()
+ .bind( new ForClause ("t", new AQLClause().set("dataset TweetMessages")))
+ .bind( new LetClause ("tu", new AExpression().set("$t.user")))
+ .bind( new WhereClause (new AExpression().set("$tu.name ~= $fbu.name")))
+ .ReturnClause({
+ "twitter-screenname": "$tu.screen-name",
+ "twitter-name": "$tu.name"
+ });
+
+ var expression5 = new FLWOGRExpression()
+ .bind( new ForClause ("fbu", new AQLClause().set("dataset FacebookUsers")))
+ .ReturnClause(
+ {
+ "id" : "$fbu.id",
+ "name" : "$fbu.name",
+ "similar-users" : similarUsersExpression
+ }
+ );
+ </code></pre></div>
<div class="result-output" id="result5">
</div>
@@ -241,8 +309,18 @@
return $fbu;
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression6 = new FLWOGRExpression()
+ .bind( new ForClause ("fbu", new AQLClause().set("dataset FacebookUsers")))
+ .bind( new WhereClause (
+ new QuantifiedExpression (
+ "some" ,
+ {"$e" : new AQLClause().set("$fbu.employment") },
+ new AQLClause().set("is-null($e.end-date)")
+ )
+ ))
+ .ReturnClause("$fbu");
+ </code></pre></div>
<div class="result-output" id="result6">
</div>
@@ -261,8 +339,21 @@
return $fbu;
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression7 = new FLWOGRExpression()
+ .bind( new ForClause (
+ "fbu",
+ new AQLClause().set("dataset FacebookUsers")
+ ))
+ .bind( new WhereClause (
+ new QuantifiedExpression (
+ "every" ,
+ {"$e" : new AQLClause().set("$fbu.employment") },
+ new AQLClause().set("not(is-null($e.end-date))")
+ )
+ ))
+ .ReturnClause("$fbu");
+ </code></pre></div>
<div class="result-output" id="result7">
</div>
@@ -282,18 +373,10 @@
<div class="how-to-run"><pre><code class="javascript">
var expression8 = new FunctionExpression(
"count",
- new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers"))
- .bind(new ReturnClause("$fbu"))
+ new FLWOGRExpression()
+ .bind( new ForClause("fbu", new AQLClause().set("dataset FacebookUsers")))
+ .ReturnClause("$fbu")
);
-
- OR
-
- var expression8 = new FunctionExpression()
- .fn("count")
- .expression(
- new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers"))
- .bind(new ReturnClause("$fbu"))
- );
</code></pre></div>
<div class="result-output" id="result8">
@@ -316,8 +399,17 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression9a = new FLWOGRExpression()
+ .bind( new ForClause("t", new AExpression().set("dataset TweetMessages")))
+ .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
+ .ReturnClause(
+ {
+ "user" : "$uid",
+ "count" : new FunctionExpression("count", new AExpression().set("$t"))
+ }
+ );
+ </code></pre></div>
<div class="result-output" id="result9a">
</div>
@@ -340,8 +432,18 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression9b = new FLWOGRExpression()
+ .bind( new ForClause("t", new AExpression().set("dataset TweetMessages")))
+ .bind( new AQLClause().set("/*+ hash*/"))
+ .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
+ .ReturnClause(
+ {
+ "user" : "$uid",
+ "count" : new FunctionExpression("count", new AExpression().set("$t"))
+ }
+ );
+ </code></pre></div>
<div class="result-output" id="result9b">
</div>
@@ -366,8 +468,23 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression10 = new FLWOGRExpression()
+ .bind( new ForClause("t", new AExpression().set("dataset TweetMessages")))
+ .bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
+ .bind( new LetClause(
+ "c",
+ new FunctionExpression("count", new AExpression().set("$t"))
+ ))
+ .bind( new OrderbyClause( new AExpression().set("$c"), "desc" ) )
+ .bind( new LimitClause(new AExpression().set("3")) )
+ .ReturnClause(
+ {
+ "user" : "$uid",
+ "count" : "$c"
+ }
+ );
+ </code></pre></div>
<div class="result-output" id="result10">
</div>
@@ -394,8 +511,20 @@
};
</pre></div>
- <div class="how-to-run">
- </div>
+ <div class="how-to-run"><pre><code class="javascript">
+ var expression11 = new FLWOGRExpression()
+ .bind( new ForClause( "t", new AExpression().set("dataset TweetMessages") ))
+ .ReturnClause({
+ "tweet" : new AExpression().set("$t"),
+ "similar-tweets": new FLWOGRExpression()
+ .bind( new ForClause( "t2", new AExpression().set("dataset TweetMessages") ))
+ .bind( new WhereClause().and(
+ new AExpression().set("$t2.referred-topics ~= $t.referred-topics"),
+ new AExpression().set("$t2.tweetid != $t.tweetid")
+ ))
+ .ReturnClause("$t2.referred-topics")
+ });
+ </code></pre></div>
<div class="result-output" id="result11">
</div>
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 f1970b2..3310b30 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
@@ -7,7 +7,7 @@
$('#result0a').html('');
var expression0a = new FLWOGRExpression()
- .bind( new ForClause("user", null, new AExpression().set("dataset FacebookUsers")))
+ .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers")))
.bind( new WhereClause(new AExpression().set("$user.id = 8")))
.ReturnClause("$user");
@@ -23,7 +23,7 @@
$('#result0b').html('');
var expression0b = new FLWOGRExpression()
- .bind( new ForClause("user", null, new AExpression().set("dataset FacebookUsers")))
+ .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers")))
.bind( new WhereClause().and(
new AExpression().set("$user.id >= 2"),
new AExpression().set("$user.id <= 4")
@@ -43,7 +43,7 @@
$('#result1').html('');
var expression1 = new FLWOGRExpression()
- .bind( new ForClause("user", null, new AExpression().set("dataset FacebookUsers")))
+ .bind( new ForClause("user", new AExpression().set("dataset FacebookUsers")))
.bind( new WhereClause().and(
new AExpression().set("$user.user-since >= datetime('2010-07-22T00:00:00')"),
new AExpression().set("$user.user-since <= datetime('2012-07-29T23:59:59')")
@@ -61,15 +61,13 @@
$('#result2a').html('');
var expression2a = new FLWOGRExpression()
- .bind( new ForClause ("user", null, new AQLClause().set("dataset FacebookUsers")))
- .bind( new ForClause ("message", null, new AQLClause().set("dataset FacebookMessages")))
+ .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers")))
+ .bind( new ForClause ("message", new AQLClause().set("dataset FacebookMessages")))
.bind( new WhereClause (new AExpression().set("$message.author-id = $user.id")))
- .ReturnClause(
- {
+ .ReturnClause({
"uname" : "$user.name",
"message" : "$message.message"
- }
- );
+ });
var success2a = function(res) {
$('#result2a').html(res["results"]);
@@ -82,8 +80,8 @@
$('#result2b').html('');
var expression2b = new FLWOGRExpression()
- .bind( new ForClause ("user", null, new AQLClause().set("dataset FacebookUsers")))
- .bind( new ForClause ("message", null, new AQLClause().set("dataset FacebookMessages")))
+ .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers")))
+ .bind( new ForClause ("message", new AQLClause().set("dataset FacebookMessages")))
.bind( new WhereClause (new AExpression().set("$message.author-id /*+ indexnl */ = $user.id")))
.ReturnClause(
{
@@ -103,12 +101,12 @@
$('#result3').html('');
var expression3messages = new FLWOGRExpression()
- .bind( new ForClause("message", null, new AExpression().set("dataset FacebookMessages")))
+ .bind( new ForClause("message", new AExpression().set("dataset FacebookMessages")))
.bind( new WhereClause(new AExpression().set("$message.author-id = $user.id")))
.ReturnClause("$message.message");
var expression3 = new FLWOGRExpression()
- .bind( new ForClause ("user", null, new AQLClause().set("dataset FacebookUsers")))
+ .bind( new ForClause ("user", new AQLClause().set("dataset FacebookUsers")))
.ReturnClause({
"uname": "$user.name",
"messages" : expression3messages
@@ -125,12 +123,12 @@
$('#result4').html('');
var expression4messages = new FLWOGRExpression()
- .bind( new ForClause( "t2", null, new AExpression().set("dataset TweetMessages")))
+ .bind( new ForClause( "t2", new AExpression().set("dataset TweetMessages")))
.bind( new WhereClause( new AExpression().set("spatial-distance($t.sender-location, $t2.sender-location) <= 1")))
.ReturnClause({ "msgtxt" : "$t2.message-text" });
var expression4 = new FLWOGRExpression()
- .bind( new ForClause( "t", null, new AExpression().set("dataset TweetMessages") ))
+ .bind( new ForClause( "t", new AExpression().set("dataset TweetMessages") ))
.ReturnClause({
"message" : "$t.message-text",
"nearby-messages" : expression4messages
@@ -147,18 +145,16 @@
$('#result5').html('');
var similarUsersExpression = new FLWOGRExpression()
- .bind( new ForClause ("t", null, new AQLClause().set("dataset TweetMessages")))
+ .bind( new ForClause ("t", new AQLClause().set("dataset TweetMessages")))
.bind( new LetClause ("tu", new AExpression().set("$t.user")))
.bind( new WhereClause (new AExpression().set("$tu.name ~= $fbu.name")))
.ReturnClause({
"twitter-screenname": "$tu.screen-name",
"twitter-name": "$tu.name"
});
- // TODO Move Sets!
+
var expression5 = new FLWOGRExpression()
- .bind( new SetStatement( "simfunction", "edit-distance" ))
- .bind( new SetStatement( "simthreshold", "3"))
- .bind( new ForClause ("fbu", null, new AQLClause().set("dataset FacebookUsers")))
+ .bind( new ForClause ("fbu", new AQLClause().set("dataset FacebookUsers")))
.ReturnClause(
{
"id" : "$fbu.id",
@@ -170,7 +166,14 @@
var success5 = function (res) {
$('#result5').html(res["results"]);
};
- A.run(expression5.val(), success5);
+
+ var simfunction = new SetStatement( "simfunction", "edit-distance" );
+ var simthreshold = new SetStatement( "simthreshold", "3");
+
+ A.run(
+ [ simfunction.val() , simthreshold.val() , expression5.val() ],
+ success5
+ );
});
// 6 - Existential Quantification
@@ -178,19 +181,15 @@
$('#result6').html('');
var expression6 = new FLWOGRExpression()
- .bind( new ForClause (
- "fbu",
- null,
- new AQLClause().set("dataset FacebookUsers")
- ))
- .bind( new WhereClause (
- new QuantifiedExpression (
- "some" ,
- {"$e" : new AQLClause().set("$fbu.employment") },
- new AQLClause().set("is-null($e.end-date)")
- )
- ))
- .ReturnClause("$fbu");
+ .bind( new ForClause ("fbu", new AQLClause().set("dataset FacebookUsers")))
+ .bind( new WhereClause (
+ new QuantifiedExpression (
+ "some" ,
+ {"$e" : new AQLClause().set("$fbu.employment") },
+ new AQLClause().set("is-null($e.end-date)")
+ )
+ ))
+ .ReturnClause("$fbu");
var success6 = function(res) {
$('#result6').html(res["results"]);
@@ -205,8 +204,7 @@
var expression7 = new FLWOGRExpression()
.bind( new ForClause (
- "fbu",
- null,
+ "fbu",
new AQLClause().set("dataset FacebookUsers")
))
.bind( new WhereClause (
@@ -232,7 +230,7 @@
var expression8 = new FunctionExpression(
"count",
new FLWOGRExpression()
- .bind( new ForClause("fbu", null, new AQLClause().set("dataset FacebookUsers")))
+ .bind( new ForClause("fbu", new AQLClause().set("dataset FacebookUsers")))
.ReturnClause("$fbu")
);
@@ -247,7 +245,7 @@
$('#result9a').html('');
var expression9a = new FLWOGRExpression()
- .bind( new ForClause("t", null, new AExpression().set("dataset TweetMessages")))
+ .bind( new ForClause("t", new AExpression().set("dataset TweetMessages")))
.bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
.ReturnClause(
{
@@ -267,7 +265,7 @@
$('#result9b').html('');
var expression9b = new FLWOGRExpression()
- .bind( new ForClause("t", null, new AExpression().set("dataset TweetMessages")))
+ .bind( new ForClause("t", new AExpression().set("dataset TweetMessages")))
.bind( new AQLClause().set("/*+ hash*/"))
.bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
.ReturnClause(
@@ -288,7 +286,7 @@
$('#result10').html('');
var expression10 = new FLWOGRExpression()
- .bind( new ForClause("t", null, new AExpression().set("dataset TweetMessages")))
+ .bind( new ForClause("t", new AExpression().set("dataset TweetMessages")))
.bind( new GroupClause("uid", new AExpression().set("$t.user.screen-name"), "with", "t") )
.bind( new LetClause(
"c",
@@ -313,14 +311,12 @@
$("#run11").click(function() {
$('#result11').html('');
- var expression11 = new FLWOGRExpression()
- .bind( new SetStatement( "simfunction", "jaccard" ))
- .bind( new SetStatement( "simthreshold", "0.3"))
- .bind( new ForClause( "t", null, new AExpression().set("dataset TweetMessages") ))
+ var expression11 = new FLWOGRExpression()
+ .bind( new ForClause( "t", new AExpression().set("dataset TweetMessages") ))
.ReturnClause({
"tweet" : new AExpression().set("$t"),
"similar-tweets": new FLWOGRExpression()
- .bind( new ForClause( "t2", null, new AExpression().set("dataset TweetMessages") ))
+ .bind( new ForClause( "t2", new AExpression().set("dataset TweetMessages") ))
.bind( new WhereClause().and(
new AExpression().set("$t2.referred-topics ~= $t.referred-topics"),
new AExpression().set("$t2.tweetid != $t.tweetid")
@@ -331,7 +327,14 @@
var success11 = function(res) {
$('#result11').html(res["results"]);
};
- A.run(expression11.val(), success11);
+
+ var simfunction = new SetStatement( "simfunction", "jaccard" );
+ var simthreshold = new SetStatement( "simthreshold", "0.3");
+ A.run(
+ [ simfunction.val(), simthreshold.val(), expression11.val()],
+ success11
+ );
+
});
$('#run0a').trigger('click');
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 8899953..1877846 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
@@ -43,7 +43,7 @@
success_fn(data);
},
error: function(r) {
- alert("AsterixSDK ERROR\n" + JSON.stringify(r));
+ //alert("AsterixSDK ERROR\n" + JSON.stringify(r));
}
});
@@ -172,17 +172,6 @@
};
-// FLWOGR ::= ( ForClause | LetClause ) ( Clause )* "return" Expression
-// Clause ::= ForClause | LetClause | WhereClause | OrderbyClause | GroupClause | LimitClause | DistinctClause
-//
-// WhereClause ::= "where" Expression
-// OrderbyClause ::= "order" "by" Expression ( ( "asc" ) | ( "desc" ) )? ( "," Expression ( ( "asc" ) | ( "desc" ) )? )*
-//
-// GroupClause ::= "group" "by" ( Variable ":=" )? Expression ( "," ( Variable ":=" )? Expression )* ( "decor" Variable ":=" Expression ( "," "decor" Variable ":=" Expression )* )? "with" VariableRef ( "," VariableRef )*
-// LimitClause ::= "limit" Expression ( "offset" Expression )?
-// DistinctClause ::= "distinct" "by" Expression ( "," Expression )*
-
-
// FLWOGRExpression
//
// FLWOGRExpression ::= ( ForClause | LetClause ) ( Clause )* "return" Expression
@@ -286,15 +275,15 @@
function ForClause(for_variable, at_variable, expression) {
AQLClause.call(this);
- // at_variable is optional, check if defined
- var at = typeof at_variable ? at_variable : null;
-
- // Prepare clause
- this._properties["clause"] = "for $" + for_variable;
- if (at != null) {
- this._properties["clause"] += " at $" + at_variable;
+ this._properties["clause"] = "for $" + arguments[0];
+
+ if (arguments.length == 3) {
+ this._properties["clause"] += " at $" + arguments[1];
+ this._properties["clause"] += " in " + arguments[2].val();
+ } else if (arguments.length == 2) {
+ this._properties["clause"] += " in " + arguments[1].val();
}
- this._properties["clause"] += " in " + expression.val();
+
return this;
}