@@ -94,6 +94,15 @@ WOQLQuery.prototype.loadDefaultVocabulary = function(){
94
94
vocab . type = "rdf:type" ;
95
95
vocab . label = "rdfs:label" ;
96
96
vocab . Class = "owl:Class" ;
97
+ vocab . DatatypeProperty = "owl:DatatypeProperty" ;
98
+ vocab . ObjectProperty = "owl:ObjectProperty" ;
99
+ vocab . Entity = "tcs:Entity" ;
100
+ vocab . Document = "tcs:Document" ;
101
+ vocab . Relationship = "tcs:Relationship" ;
102
+ vocab . temporality = "tcs:temporality" ;
103
+ vocab . geotemporality = "tcs:geotemporality" ;
104
+ vocab . geography = "tcs:geography" ;
105
+ vocab . abstract = "tcs:abstract" ;
97
106
vocab . comment = "rdfs:comment" ;
98
107
vocab . range = "rdfs:range" ;
99
108
vocab . domain = "rdfs:domain" ;
@@ -275,15 +284,15 @@ WOQLQuery.prototype.prettyPrint = function(indent, show_context, q, embed){
275
284
str += "(\n" + this . nspaces ( indent ) + "WOQL." + clauses . join ( ",\n" + this . nspaces ( indent ) + "WOQL." ) + "\n" + this . nspaces ( indent - this . indent ) + ")" ;
276
285
277
286
}
278
- else if ( typeof val [ val . length - 1 ] == "object" ) {
287
+ else if ( typeof val [ val . length - 1 ] == "object" && typeof val [ val . length - 1 ] [ '@value' ] == "undefined" ) {
279
288
var nvals = [ ]
280
289
for ( var i = 0 ; i < val . length - 1 ; i ++ ) {
281
290
if ( key == "limit" || key == "start" ) {
282
291
nvals . push ( val [ i ] ) ;
283
292
}
284
293
else {
285
294
if ( typeof val [ i ] == "string" ) {
286
- nvals . push ( '"' + self . unclean ( val [ i ] ) + '"' ) ;
295
+ nvals . push ( self . unclean ( val [ i ] ) ) ;
287
296
}
288
297
else if ( typeof val [ i ] == "object" ) {
289
298
nvals . push ( JSON . stringify ( val [ i ] ) ) ;
@@ -295,8 +304,8 @@ WOQLQuery.prototype.prettyPrint = function(indent, show_context, q, embed){
295
304
}
296
305
if ( nvals . length ) {
297
306
str += unclean ( nvals ) ;
298
- if ( key == "from" ) str += ") \n ." ;
299
- else str += ") ." ;
307
+ if ( key == "from" ) str += "\n ." ;
308
+ else str += "." ;
300
309
}
301
310
if ( nvals . length ) {
302
311
str += `(${ nvals . join ( ',' ) } ` ;
@@ -345,20 +354,7 @@ WOQLQuery.prototype.setPage = function (pagenum) {
345
354
return this ;
346
355
} ;
347
356
348
- < << << << HEAD
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
- WOQLQuery . prototype . nextPage = function ( ) {
359
- = === ===
360
357
WOQLQuery . prototype . nextPage = function ( ) {
361
- > >>> >>> c85055e6384aa4c834e1a014093ad63850781f8f
362
358
return this . setPage ( this . getPage ( ) + 1 ) ;
363
359
} ;
364
360
@@ -372,13 +368,8 @@ WOQLQuery.prototype.previousPage = function () {
372
368
return this ;
373
369
} ;
374
370
375
- < << << << HEAD
376
- WOQLQuery . prototype . hasSelect = function ( ) {
377
- return this . getPagingProperty ( 'select' ) ;
378
- } ;
379
- = === ===
380
371
WOQLQuery . prototype . setPageSize = function ( size ) {
381
- this . setPagingProperty ( "limit" , size ) ;
372
+ this . setPagingProperty ( "limit" , size ) ;
382
373
if ( this . hasStart ( ) ) {
383
374
this . setStart ( 0 ) ;
384
375
}
@@ -389,9 +380,8 @@ WOQLQuery.prototype.setPageSize = function(size){
389
380
}
390
381
391
382
WOQLQuery . prototype . hasSelect = function ( ) {
392
- return this . getPagingProperty ( "select" ) ;
383
+ return this . getPagingProperty ( "select" ) ;
393
384
}
394
- >>> > >>> c85055e6384aa4c834e1a014093ad63850781f8f
395
385
396
386
WOQLQuery . prototype . getSelectVariables = function ( q ) {
397
387
q = ( q || this . query ) ;
@@ -409,21 +399,6 @@ WOQLQuery.prototype.getSelectVariables = function (q) {
409
399
}
410
400
} ;
411
401
412
- < << << << HEAD
413
- WOQLQuery . prototype . setStart = function ( start ) {
414
- return this . setPagingProperty ( "start" , start ) ;
415
- }
416
-
417
- WOQLQuery . prototype . setPageSize = function ( size ) {
418
- this . setPagingProperty ( 'limit' , size ) ;
419
- if ( this . hasStart ( ) ) {
420
- this . setStart ( 0 ) ;
421
- } else {
422
- this . addStart ( 0 ) ;
423
- }
424
- return this ;
425
- } ;
426
- = === ===
427
402
WOQLQuery . prototype . hasStart = function ( ) {
428
403
return ( typeof this . getPagingProperty ( "start" ) != "undefined" ) ;
429
404
}
@@ -433,9 +408,8 @@ WOQLQuery.prototype.getStart = function(){
433
408
}
434
409
435
410
WOQLQuery . prototype . setStart = function ( start ) {
436
- return this . setPagingProperty ( "start" , start ) ;
411
+ return this . setPagingProperty ( "start" , start ) ;
437
412
}
438
- >>> > >>> c85055e6384aa4c834e1a014093ad63850781f8f
439
413
440
414
/*
441
415
* Called to indicate an update that is the last chainable element in a query
@@ -508,8 +482,8 @@ WOQLQuery.prototype.when = function (Query, Update) {
508
482
509
483
WOQLQuery . prototype . opt = function ( query ) {
510
484
if ( query ) {
511
- q = ( query . json ? query . json ( ) : q ) ;
512
- this . cursor [ "opt" ] = [ query ] ;
485
+ var q = ( ( typeof query . json == "function" ) ? query . json ( ) : query ) ;
486
+ this . cursor [ "opt" ] = [ q ] ;
513
487
}
514
488
else {
515
489
this . cursor [ 'opt' ] = [ { } ] ;
@@ -690,8 +664,9 @@ WOQLQuery.prototype.addClass = function(c, graph){
690
664
}
691
665
692
666
WOQLQuery . prototype . addProperty = function ( p , t , g ) {
693
- if ( p && t ) {
694
- graph = ( g ? this . cleanGraph ( g ) : "db:schema" ) ;
667
+ t = ( t ? t : "xsd:string" ) ;
668
+ if ( p ) {
669
+ var graph = ( g ? this . cleanGraph ( g ) : "db:schema" ) ;
695
670
p = ( p . indexOf ( ":" ) == - 1 ) ? "scm:" + p : p ;
696
671
t = ( t . indexOf ( ":" ) == - 1 ) ? this . cleanType ( t ) : t ;
697
672
var tc = this . cursor ;
@@ -799,22 +774,13 @@ WOQLQuery.prototype.propertyMetadata = function(){
799
774
800
775
WOQLQuery . prototype . elementMetadata = function ( ) {
801
776
return this . and (
802
- < << << << HEAD
803
- WOQL . quad ( 'v:Element' , 'rdf:type' , 'v:Type' , 'db:schema' ) ,
804
- WOQL . opt ( ) . quad ( 'v:Element' , 'tcs:tag' , 'v:Abstract' , 'db:schema' ) ,
805
- WOQL . opt ( ) . quad ( 'v:Element' , 'rdfs:label' , 'v:Label' , 'db:schema' ) ,
806
- WOQL . opt ( ) . quad ( 'v:Element' , 'rdfs:comment' , 'v:Comment' , 'db:schema' ) ,
807
- WOQL . opt ( ) . quad ( 'v:Element' , 'rdfs:domain' , 'v:Domain' , 'db:schema' ) ,
808
- WOQL . opt ( ) . quad ( 'v:Element' , 'rdfs:range' , 'v:Range' , 'db:schema' )
809
- === = ===
810
777
WOQL . quad ( "v:Element" , "rdf:type" , "v:Type" , "db:schema" ) ,
811
778
WOQL . opt ( ) . quad ( "v:Element" , "tcs:tag" , "v:Abstract" , "db:schema" ) ,
812
779
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:label" , "v:Label" , "db:schema" ) ,
813
780
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:comment" , "v:Comment" , "db:schema" ) ,
814
781
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:subClassOf" , "v:Parent" , "db:schema" ) ,
815
782
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:domain" , "v:Domain" , "db:schema" ) ,
816
783
WOQL . opt ( ) . quad ( "v:Element" , "rdfs:range" , "v:Range" , "db:schema" )
817
- >>> > >>> c85055e6384aa4c834e1a014093ad63850781f8f
818
784
) ;
819
785
} ;
820
786
@@ -948,12 +914,15 @@ function TripleBuilder(type, cursor, s, query){
948
914
this . type = type ;
949
915
this . cursor = cursor ;
950
916
this . subject = query . cleanSubject ( s ) ;
951
- this . graph = false ;
917
+ this . g = false ;
952
918
this . query = query ; //the containing query
953
919
}
954
920
955
921
TripleBuilder . prototype . graph = function ( g ) {
956
- this . graph = g ;
922
+ this . g = this . query . cleanGraph ( g ) ;
923
+ if ( this . type == "triple" ) this . type = "quad" ;
924
+ if ( this . type == "add_triple" ) this . type = "add_quad" ;
925
+ if ( this . type == "delete_triple" ) this . type = "delete_quad" ;
957
926
return this ;
958
927
} ;
959
928
@@ -972,8 +941,8 @@ TripleBuilder.prototype.addPO = function(p, o, g){
972
941
else {
973
942
evstr += o ;
974
943
}
975
- if ( ttype . substring ( ttype . length - 4 ) == "quad" ) {
976
- var g = ( g ? g : ( this . graph ? this . graph : "db:schema" ) ) ;
944
+ if ( ttype . substring ( ttype . length - 4 ) == "quad" || this . g ) {
945
+ var g = ( g ? g : ( this . g ? this . g : "db:schema" ) ) ;
977
946
evstr += ", '" + g + "'" ;
978
947
}
979
948
evstr += ")" ;
@@ -1013,13 +982,19 @@ TripleBuilder.prototype.isa = function(s){
1013
982
return this . addEntry ( unit ) ;
1014
983
}
1015
984
985
+ TripleBuilder . prototype . domain = function ( d ) {
986
+ d = this . query . cleanClass ( d ) ;
987
+ var x = this . addPO ( 'rdfs:domain' , d ) ;
988
+ return x ;
989
+ }
990
+
991
+
1016
992
TripleBuilder . prototype . sub = function ( s ) {
1017
993
s = this . query . cleanClass ( s ) ;
1018
994
var unit = new WOQLQuery . sub ( this . subject , s ) ;
1019
995
return this . addEntry ( unit ) ;
1020
996
}
1021
997
1022
-
1023
998
TripleBuilder . prototype . label = function ( l , lang ) {
1024
999
lang = ( lang ? lang : "en" ) ;
1025
1000
var x = this . addPO ( 'rdfs:label' , { "@value" : l , "@language" : lang } ) ;
@@ -1031,9 +1006,14 @@ TripleBuilder.prototype.comment = function(c, lang){
1031
1006
return this . addPO ( 'rdfs:comment' , { "@value" : c , "@language" : lang } ) ;
1032
1007
}
1033
1008
1009
+ TripleBuilder . prototype . property = function ( p , val ) {
1010
+ p = this . query . cleanPredicate ( p ) ;
1011
+ return this . addPO ( p , val ) ;
1012
+ }
1013
+
1034
1014
TripleBuilder . prototype . parent = function ( ...p ) {
1035
1015
for ( var i = 0 ; i < p . length ; i ++ ) {
1036
- pn = this . query . cleanClass ( p [ i ] ) ;
1016
+ var pn = this . query . cleanClass ( p [ i ] ) ;
1037
1017
this . addPO ( 'rdfs:subClassOf' , pn ) ;
1038
1018
}
1039
1019
return this ;
0 commit comments