@@ -44,6 +44,9 @@ WOQL.as = function(map, vari){ return new WOQLQuery().as(map, vari); }
44
44
WOQL . remote = function ( url ) { return new WOQLQuery ( ) . remote ( url ) ; }
45
45
WOQL . unique = function ( prefix , vari ) { return new WOQLQuery ( ) . unique ( prefix , vari ) ; }
46
46
WOQL . list = function ( ...vars ) { return new WOQLQuery ( ) . list ( ...vars ) ; }
47
+ WOQL . group_by = function ( ...vars ) { return new WOQLQuery ( ) . group_by ( ...vars ) ; }
48
+ WOQL . update = function ( Q ) { return new WOQLQuery ( ) . update ( Q ) ; }
49
+
47
50
48
51
//language extensions that can be chained after 'grounded' stuff (clauses with a specific subject) sub, isa, delete_triple, add_triple, delete_quad, add_quad, node
49
52
//WOQL.value = function(vars){ return new WOQLQuery().list(vars); }
@@ -92,15 +95,83 @@ function WOQLQuery(query){
92
95
}
93
96
94
97
WOQLQuery . prototype . get = function ( map , target ) {
95
- this . cursor [ 'get' ] = [ map , target ] ;
98
+ if ( target ) {
99
+ this . cursor [ 'get' ] = [ map , target ] ;
100
+ }
101
+ else {
102
+ this . cursor [ 'get' ] = [ map ] ;
103
+ this . cursor = this . cursor [ "get" ] [ 1 ] ;
104
+ }
96
105
return this ;
97
106
}
98
107
108
+ WOQLQuery . prototype . concat = function ( list , v ) {
109
+ this . cursor [ 'concat' ] = [ list , v ] ;
110
+ return this ;
111
+ }
112
+
113
+ WOQLQuery . prototype . lower = function ( u , l ) {
114
+ this . cursor [ 'lower' ] = [ u , l ] ;
115
+ return this ;
116
+ }
117
+
118
+ WOQLQuery . prototype . pad = function ( input , pad , len , output ) {
119
+ this . cursor [ 'pad' ] = [ input , pad , len , output ] ;
120
+ return this ;
121
+ }
122
+
123
+ WOQLQuery . prototype . join = function ( ...list ) {
124
+ this . cursor [ 'join' ] = list ;
125
+ return this ;
126
+ }
127
+
128
+
129
+ //concat() //"concat" : [{"list" : ["doc:", "v:Polity_Lower"]}, "v:Polity_ID"] },
130
+ /**
131
+ * [{"list" : [{"@value " : "[", "@type" : "xsd:string"},
132
+ "v:GYear",
133
+ {"@value " : ",","@type" : "xsd:string"},
134
+ "v:GYear",
135
+ {"@value " : "]","@type" : "xsd:string"}]
136
+ */
137
+ //lower(v1, v2) ["v:Polity", "v:Polity_Lower"]
138
+ //pad(var,pad,len,nvar]) ["v:Year",0,4,"v:GYear"]
139
+ //unique(prefix, vars, type)
140
+ //group_by
141
+ //file
142
+ //join(...x)
143
+ //{"join" : ["v:Records",
144
+ //{"@value" : ",", "@type" : "xsd:string" },
145
+ //"v:Coord_String"
146
+ //]},
147
+
99
148
WOQLQuery . prototype . remote = function ( json ) {
100
149
this . cursor [ 'remote' ] = [ json ] ;
101
150
return this ;
102
151
}
103
152
153
+ WOQLQuery . prototype . group_by = function ( ...grouped ) {
154
+ var ngs = [ ] ;
155
+ for ( var i = 0 ; i < grouped . length ; i ++ ) {
156
+ ngs . push ( grouped [ i ] . json ( ) ) ;
157
+ }
158
+ this . cursor [ 'group_by' ] = ngs ;
159
+ this . cursor = this . cursor [ "group_by" ] [ ngs . length ] ;
160
+ return this ;
161
+ }
162
+
163
+
164
+ WOQLQuery . prototype . unique = function ( prefix , vari , type ) {
165
+ this . cursor [ 'unique' ] = [ prefix , vari , type ] ;
166
+ return this ;
167
+ }
168
+
169
+ WOQLQuery . prototype . list = function ( ...vars ) {
170
+ this . cursor [ 'list' ] = vars ;
171
+ return this ;
172
+ }
173
+
174
+
104
175
/*
105
176
* json version of query for passing to api
106
177
*/
@@ -117,9 +188,14 @@ WOQLQuery.prototype.json = function(json){
117
188
* into the corrent place in the encompassing json
118
189
*/
119
190
WOQLQuery . prototype . when = function ( Query , Update ) {
191
+ if ( typeof Query == "boolean" ) {
192
+ var jq = { } ;
193
+ jq [ Query ] = [ ] ;
194
+ Query = jq ;
195
+ }
120
196
this . advanceCursor ( "when" , Query ) ;
121
197
if ( Update ) {
122
- this . cursor = Update . json ( ) ;
198
+ this . cursor = ( Update . json ? Update . json ( ) : Update ) ;
123
199
}
124
200
return this ;
125
201
}
@@ -381,7 +457,6 @@ WOQLQuery.prototype.as = function(a, b){
381
457
return this . lastUpdate ( ) ;
382
458
}
383
459
384
-
385
460
/**
386
461
* WOQL API
387
462
*/
0 commit comments