@@ -23,14 +23,14 @@ WOQL.and = function(...queries){ return new WOQLQuery().and(...queries); }
23
23
WOQL . not = function ( query ) { return new WOQLQuery ( ) . not ( query ) ; }
24
24
WOQL . triple = function ( a , b , c ) { return new WOQLQuery ( ) . triple ( a , b , c ) ; }
25
25
WOQL . quad = function ( a , b , c , d ) { return new WOQLQuery ( ) . quad ( a , b , c , d ) ; }
26
- WOQL . eq = function ( a , b ) { return new WOQLQuery ( ) . eq ( a , b ) ; }
27
26
WOQL . sub = function ( a , b ) { return new WOQLQuery ( ) . sub ( a , b ) ; }
28
27
WOQL . isa = function ( a , b ) { return new WOQLQuery ( ) . isa ( a , b ) ; }
28
+ WOQL . eq = function ( a , b ) { return new WOQLQuery ( ) . eq ( a , b ) ; }
29
29
WOQL . trim = function ( a , b ) { return new WOQLQuery ( ) . trim ( a , b ) ; }
30
30
WOQL . delete = function ( JSON_or_IRI ) { return new WOQLQuery ( ) . delete ( JSON_or_IRI ) ; }
31
31
WOQL . delete_triple = function ( S , P , O ) { return new WOQLQuery ( ) . delete_triple ( S , P , O ) ; }
32
- WOQL . add_triple = function ( S , P , O ) { return new WOQLQuery ( ) . add_triple ( S , P , O ) ; }
33
32
WOQL . delete_quad = function ( S , P , O , G ) { return new WOQLQuery ( ) . delete_quad ( S , P , O , G ) ; }
33
+ WOQL . add_triple = function ( S , P , O ) { return new WOQLQuery ( ) . add_triple ( S , P , O ) ; }
34
34
WOQL . add_quad = function ( S , P , O , G ) { return new WOQLQuery ( ) . add_quad ( S , P , O , G ) ; }
35
35
WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
36
36
WOQL . plus = function ( ...args ) { return new WOQLQuery ( ) . plus ( ...args ) ; }
@@ -49,11 +49,12 @@ WOQL.list = function(vars){ return new WOQLQuery().list(vars); }
49
49
//WOQL.value = function(vars){ return new WOQLQuery().list(vars); }
50
50
//These ones are special ones for dealing with the schema only...
51
51
WOQL . addClass = function ( classid , graph ) { return new WOQLQuery ( ) . addClass ( classid , graph ) ; }
52
- WOQL . addProperty = function ( propid , graph ) { return new WOQLQuery ( ) . addProperty ( propid , graph ) ; }
52
+ WOQL . addProperty = function ( propid , type , graph ) { return new WOQLQuery ( ) . addProperty ( propid , type , graph ) ; }
53
+ WOQL . deleteClass = function ( classid , graph ) { return new WOQLQuery ( ) . deleteClass ( classid , graph ) ; }
54
+ WOQL . deleteProperty = function ( propid , type , graph ) { return new WOQLQuery ( ) . deleteProperty ( propid , type , graph ) ; }
53
55
WOQL . node = function ( nodeid , type ) { return new WOQLQuery ( ) . node ( nodeid , type ) ; }
54
56
55
57
56
-
57
58
/*
58
59
* Beneath here are pseudo predicates - they belong to the javascript object
59
60
* but not to the WOQL language
@@ -62,8 +63,6 @@ WOQL.node = function(nodeid, type){ return new WOQLQuery().node(nodeid, type); }
62
63
WOQL . query = function ( ) { return new WOQLQuery ( ) ; }
63
64
//loads query from json
64
65
WOQL . json = function ( json ) { return new WOQLQuery ( ) . json ( json ) ; }
65
- //returns a special schema object for terse schema updates
66
- WOQL . schema = function ( ) { return new WOQLSchema ( ) ; }
67
66
68
67
WOQL . rule = function ( ) { return new Pattern . FrameRule ( ) ; }
69
68
//Simple utility function for typechecking
@@ -238,7 +237,6 @@ WOQLQuery.prototype.nspaces = function(n){
238
237
return spaces ;
239
238
}
240
239
241
-
242
240
WOQLQuery . prototype . prettyPrint = function ( indent , show_context , q , embed ) {
243
241
if ( ! embed ) this . indent = indent ;
244
242
q = ( q ? q : this . query ) ;
@@ -346,15 +344,6 @@ WOQLQuery.prototype.setPage = function(pagenum){
346
344
return this ;
347
345
}
348
346
349
-
350
- WOQLQuery . prototype . hasStart = function ( ) {
351
- return ( typeof this . getPagingProperty ( "start" ) != "undefined" ) ;
352
- }
353
-
354
- WOQLQuery . prototype . getStart = function ( ) {
355
- return this . getPagingProperty ( "start" ) ;
356
- }
357
-
358
347
WOQLQuery . prototype . nextPage = function ( ) {
359
348
return this . setPage ( this . getPage ( ) + 1 ) ;
360
349
}
@@ -369,6 +358,17 @@ WOQLQuery.prototype.previousPage = function(){
369
358
return this ;
370
359
}
371
360
361
+ WOQLQuery . prototype . setPageSize = function ( size ) {
362
+ this . setPagingProperty ( "limit" , size ) ;
363
+ if ( this . hasStart ( ) ) {
364
+ this . setStart ( 0 ) ;
365
+ }
366
+ else {
367
+ this . addStart ( 0 ) ;
368
+ }
369
+ return this ;
370
+ }
371
+
372
372
WOQLQuery . prototype . hasSelect = function ( ) {
373
373
return this . getPagingProperty ( "select" ) ;
374
374
}
@@ -389,19 +389,16 @@ WOQLQuery.prototype.getSelectVariables = function(q){
389
389
}
390
390
}
391
391
392
- WOQLQuery . prototype . setStart = function ( start ) {
393
- return this . setPagingProperty ( "start" , start ) ;
392
+ WOQLQuery . prototype . hasStart = function ( ) {
393
+ return ( typeof this . getPagingProperty ( "start" ) != "undefined" ) ;
394
394
}
395
395
396
- WOQLQuery . prototype . setPageSize = function ( size ) {
397
- this . setPagingProperty ( "limit" , size ) ;
398
- if ( this . hasStart ( ) ) {
399
- this . setStart ( 0 ) ;
400
- }
401
- else {
402
- this . addStart ( 0 ) ;
403
- }
404
- return this ;
396
+ WOQLQuery . prototype . getStart = function ( ) {
397
+ return this . getPagingProperty ( "start" ) ;
398
+ }
399
+
400
+ WOQLQuery . prototype . setStart = function ( start ) {
401
+ return this . setPagingProperty ( "start" , start ) ;
405
402
}
406
403
407
404
/*
@@ -477,6 +474,7 @@ WOQLQuery.prototype.when = function(Query, Update){
477
474
478
475
WOQLQuery . prototype . opt = function ( query ) {
479
476
if ( query ) {
477
+ q = ( query . json ? query . json ( ) : q ) ;
480
478
this . cursor [ "opt" ] = [ query ] ;
481
479
}
482
480
else {
@@ -774,6 +772,7 @@ WOQLQuery.prototype.elementMetadata = function(){
774
772
WOQL . opt ( ) . quad ( "v:Element" , "tcs:tag" , "v:Abstract" , "db:schema" ) ,
775
773
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:label" , "v:Label" , "db:schema" ) ,
776
774
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:comment" , "v:Comment" , "db:schema" ) ,
775
+ WOQL . opt ( ) . quad ( "v:Element" , "rdfs:subClassOf" , "v:Parent" , "db:schema" ) ,
777
776
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:domain" , "v:Domain" , "db:schema" ) ,
778
777
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:range" , "v:Range" , "db:schema" )
779
778
) ;
@@ -868,36 +867,36 @@ WOQLQuery.prototype.cleanSubject = function(s){
868
867
if ( typeof s != "string" ) return s ;
869
868
if ( s . indexOf ( ":" ) != - 1 ) return s ;
870
869
if ( this . vocab && this . vocab [ s ] ) return this . vocab [ s ] ;
871
- return "v :" + s ;
870
+ return "doc :" + s ;
872
871
}
873
872
874
873
WOQLQuery . prototype . cleanPredicate = function ( p ) {
875
874
if ( p . indexOf ( ":" ) != - 1 ) return p ;
876
875
if ( this . vocab && this . vocab [ p ] ) return this . vocab [ p ] ;
877
- return "v :" + p ;
876
+ return "scm :" + p ;
878
877
}
879
878
WOQLQuery . prototype . cleanType = function ( t ) {
880
879
if ( t . indexOf ( ":" ) != - 1 ) return t ;
881
880
if ( this . vocab && this . vocab [ t ] ) return this . vocab [ t ] ;
882
- return "v :" + t ;
881
+ return "scm :" + t ;
883
882
}
884
883
885
884
WOQLQuery . prototype . cleanObject = function ( o ) {
886
885
if ( typeof o != "string" || o . indexOf ( ":" ) != - 1 ) return o ;
887
886
if ( this . vocab && this . vocab [ o ] ) return this . vocab [ o ] ;
888
- return "v:" + o ;
887
+ return { "@value" : o , "@language" : "en" } ;
889
888
}
890
889
891
890
WOQLQuery . prototype . cleanGraph = function ( g ) {
892
891
if ( g . indexOf ( ":" ) != - 1 ) return g ;
893
892
if ( this . vocab && this . vocab [ g ] ) return this . vocab [ g ] ;
894
- return "v :" + g ;
893
+ return "db :" + g ;
895
894
}
896
895
897
896
WOQLQuery . prototype . cleanClass = function ( c ) {
898
897
if ( c . indexOf ( ":" ) != - 1 ) return c ;
899
898
if ( this . vocab && this . vocab [ c ] ) return this . vocab [ c ] ;
900
- return "v :" + c ;
899
+ return "scm :" + c ;
901
900
}
902
901
903
902
/**
@@ -1036,11 +1035,16 @@ TripleBuilder.prototype.max = function(m){
1036
1035
return this . card ( m , "max" ) ;
1037
1036
}
1038
1037
1038
+ TripleBuilder . prototype . cardinality = function ( m ) {
1039
+ return this . card ( m , "cardinality" ) ;
1040
+ }
1041
+
1042
+
1039
1043
TripleBuilder . prototype . min = function ( m ) {
1040
1044
return this . card ( m , "min" ) ;
1041
1045
}
1042
1046
1043
- TripleBuilder . prototype . s = function ( s ) {
1047
+ TripleBuilder . prototype . node = function ( s ) {
1044
1048
this . subject = this . query . cleanSubject ( s ) ;
1045
1049
return this ;
1046
1050
}
0 commit comments