@@ -48,14 +48,19 @@ WOQL.lower = function(u, l){ return new WOQLQuery().lower(u, l); }
48
48
WOQL . pad = function ( input , pad , len , output ) { return new WOQLQuery ( ) . pad ( input , pad , len , output ) ; }
49
49
WOQL . join = function ( ...list ) { return new WOQLQuery ( ) . join ( ...list ) ; }
50
50
WOQL . unique = function ( prefix , vari , type ) { return new WOQLQuery ( ) . unique ( prefix , vari , type ) ; }
51
+ WOQL . idgen = function ( prefix , vari , type , output ) { return new WOQLQuery ( ) . idgen ( prefix , vari , type , output ) ; }
52
+ WOQL . typecast = function ( vara , type , varb ) { return new WOQLQuery ( ) . typecast ( vara , type , varb ) ; }
53
+
51
54
52
55
/* Mathematical Processing */
53
- WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
56
+ WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
54
57
WOQL . plus = function ( ...args ) { return new WOQLQuery ( ) . plus ( ...args ) ; }
55
58
WOQL . minus = function ( ...args ) { return new WOQLQuery ( ) . minus ( ...args ) ; }
56
59
WOQL . times = function ( ...args ) { return new WOQLQuery ( ) . times ( ...args ) ; }
57
60
WOQL . divide = function ( ...args ) { return new WOQLQuery ( ) . divide ( ...args ) ; }
58
61
WOQL . exp = function ( a , b ) { return new WOQLQuery ( ) . exp ( a , b ) ; }
62
+ WOQL . div = function ( ...args ) { return new WOQLQuery ( ) . div ( ...args ) ; }
63
+ WOQL . comment = function ( arg ) { return new WOQLQuery ( ) . comment ( arg ) ; }
59
64
60
65
61
66
//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
@@ -147,6 +152,10 @@ WOQLQuery.prototype.buildAsClauses = function(vars, cols){
147
152
return clauses ;
148
153
}
149
154
155
+ WOQLQuery . prototype . typecast = function ( va , type , vb ) {
156
+ this . cursor [ 'typecast' ] = [ va , type , vb ] ;
157
+ return this ;
158
+ }
150
159
151
160
152
161
WOQLQuery . prototype . remote = function ( json ) {
@@ -189,6 +198,24 @@ WOQLQuery.prototype.group_by = function(gvarlist, groupedvar, groupquery, output
189
198
return this ;
190
199
}
191
200
201
+ WOQLQuery . prototype . idgen = function ( prefix , vari , type , mode ) {
202
+ this . cursor [ 'idgen' ] = [ prefix ] ;
203
+ if ( vari . json ) {
204
+ this . cursor [ 'idgen' ] . push ( vari . json ( ) ) ;
205
+ }
206
+ else if ( vari . list ) {
207
+ this . cursor [ 'idgen' ] . push ( vari ) ;
208
+ }
209
+ else {
210
+ this . cursor [ 'idgen' ] . push ( { "list" : vari } )
211
+ }
212
+ if ( mode ) {
213
+ this . cursor [ 'idgen' ] . push ( mode ) ;
214
+ }
215
+ this . cursor [ 'idgen' ] . push ( type ) ;
216
+ return this ;
217
+ }
218
+
192
219
193
220
WOQLQuery . prototype . unique = function ( prefix , vari , type ) {
194
221
this . cursor [ 'unique' ] = [ prefix ] ;
@@ -209,6 +236,13 @@ WOQLQuery.prototype.unique = function(prefix, vari, type){
209
236
WOQLQuery . prototype . concat = function ( list , v ) {
210
237
if ( typeof list == "string" ) {
211
238
var nlist = list . split ( / ( v : [ \w _ ] + ) \b / ) ;
239
+ var nxlist = [ ] ;
240
+ for ( var i = 1 ; i < nlist . length ; i ++ ) {
241
+ if ( nlist [ i - 1 ] . substring ( nlist [ i - 1 ] . length - 1 ) == "v" && nlist [ i ] . substring ( 0 , 1 ) == ":" ) {
242
+ nlist [ i - 1 ] = nlist [ i - 1 ] . substring ( 0 , nlist [ i - 1 ] . length - 1 ) ;
243
+ nlist [ i ] = nlist [ i ] . substring ( 1 ) ;
244
+ }
245
+ }
212
246
}
213
247
else if ( list . list ) {
214
248
var nlist = list . list ;
@@ -405,6 +439,19 @@ WOQLQuery.prototype.sub = function(a, b){
405
439
return this . last ( "sub" , a ) ;
406
440
}
407
441
442
+ WOQLQuery . prototype . comment = function ( val ) {
443
+ if ( val ) {
444
+ val = ( val . json ? val . json ( ) : val )
445
+ this . cursor [ 'comment' ] = val ;
446
+ }
447
+ else {
448
+ this . cursor [ 'comment' ] = null ;
449
+ this . cursor = this . cursor [ 'comment' ] ;
450
+ }
451
+ return this ;
452
+ }
453
+
454
+
408
455
WOQLQuery . prototype . abstract = function ( varname ) {
409
456
if ( varname ) {
410
457
return this . quad ( varname , "tcs:tag" , "tcs:abstract" , "db:schema" ) ;
@@ -432,31 +479,54 @@ WOQLQuery.prototype.trim = function(a, b){
432
479
}
433
480
434
481
WOQLQuery . prototype . eval = function ( arith , v ) {
482
+ arith = arith . json ? arith . json ( ) : arith ;
435
483
this . cursor [ 'eval' ] = [ arith , v ] ;
436
484
return this . last ( 'eval' , v ) ;
437
485
}
438
486
439
487
WOQLQuery . prototype . plus = function ( ...args ) {
440
- this . cursor . plus = args ;
488
+ this . cursor . plus = [ ] ;
489
+ for ( var i = 0 ; i < args . length ; i ++ ) {
490
+ this . cursor . plus . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
491
+ }
441
492
return this . last ( ) ;
442
493
} ;
443
494
444
495
WOQLQuery . prototype . minus = function ( ...args ) {
445
- this . cursor . minus = args ;
496
+ this . cursor . minus = [ ] ;
497
+ for ( var i = 0 ; i < args . length ; i ++ ) {
498
+ this . cursor . minus . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
499
+ }
446
500
return this . last ( ) ;
447
501
} ;
448
502
449
503
WOQLQuery . prototype . times = function ( ...args ) {
450
- this . cursor . times = args ;
504
+ this . cursor . times = [ ] ;
505
+ for ( var i = 0 ; i < args . length ; i ++ ) {
506
+ this . cursor . times . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
507
+ }
451
508
return this . last ( ) ;
452
509
} ;
453
510
454
511
WOQLQuery . prototype . divide = function ( ...args ) {
455
- this . cursor . divide = args ;
512
+ this . cursor . divide = [ ] ;
513
+ for ( var i = 0 ; i < args . length ; i ++ ) {
514
+ this . cursor . divide . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
515
+ }
516
+ return this . last ( ) ;
517
+ } ;
518
+
519
+ WOQLQuery . prototype . div = function ( ...args ) {
520
+ this . cursor . div = [ ] ;
521
+ for ( var i = 0 ; i < args . length ; i ++ ) {
522
+ this . cursor . div . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
523
+ }
456
524
return this . last ( ) ;
457
525
} ;
458
526
459
527
WOQLQuery . prototype . exp = function ( a , b ) {
528
+ a = ( a . json ? a . json ( ) : a ) ;
529
+ b = ( b . json ? b . json ( ) : b ) ;
460
530
this . cursor . exp = [ a , b ] ;
461
531
return this . last ( ) ;
462
532
} ;
@@ -613,7 +683,7 @@ WOQLQuery.prototype.label = function(l, lang){
613
683
return this ;
614
684
}
615
685
616
- WOQLQuery . prototype . comment = function ( c , lang ) {
686
+ WOQLQuery . prototype . description = function ( c , lang ) {
617
687
if ( this . tripleBuilder ) this . tripleBuilder . comment ( c , lang ) ;
618
688
return this ;
619
689
}
@@ -1211,7 +1281,7 @@ WOQLQuery.prototype.uncleanArguments = function(operator, args, indent, show_con
1211
1281
*/
1212
1282
WOQLQuery . prototype . uncleanArgument = function ( operator , val , index , allArgs ) {
1213
1283
//numeric values go out untouched...
1214
- const numeric_operators = [ "limit" , "start" , "eval" , "plus" , "minus" , "times" , "divide" , "exp" ] ;
1284
+ const numeric_operators = [ "limit" , "start" , "eval" , "plus" , "minus" , "times" , "divide" , "exp" , "div" ] ;
1215
1285
if ( operator == "isa" ) {
1216
1286
val = ( index == 0 ? this . unclean ( val , 'subject' ) : this . unclean ( val , 'class' ) ) ;
1217
1287
}
@@ -1245,10 +1315,13 @@ WOQLQuery.prototype.uncleanArgument = function(operator, val, index, allArgs){
1245
1315
}
1246
1316
return oval ;
1247
1317
}
1248
- else if ( numeric_operators . indexOf ( operator ) !== - 1 ) {
1249
- return val ;
1318
+ //else if(numeric_operators.indexOf(operator) !== -1){
1319
+ // return val;
1320
+ //}
1321
+ if ( typeof val == "string" ) {
1322
+ return '"' + val + '"' ;
1250
1323
}
1251
- return '"' + val + '"' ;
1324
+ return val ;
1252
1325
}
1253
1326
1254
1327
0 commit comments