Skip to content

Commit 5430903

Browse files
Updating tests for change to WOQL syntax
1 parent 46ed4a7 commit 5430903

26 files changed

+1439
-2390
lines changed

lib/query/woqlBuilder.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ WOQLQuery.prototype.literal = function(s, t) {
5757

5858
WOQLQuery.prototype.iri = function(s) {
5959
return {
60-
'@type': 'woql:Node',
61-
'woql:node': s,
60+
'@type': 'NodeValue',
61+
'node': s,
6262
}
6363
}
6464

@@ -130,7 +130,7 @@ WOQLQuery.prototype.property = function(proId, type_or_value) {
130130
let part = this.findLastSubject(this.cursor)
131131
let g = false
132132
let gpart
133-
if (part) gpart = part['woql:graph_filter'] || part['woql:graph']
133+
if (part) gpart = part['graph_filter'] || part['graph']
134134
if (gpart) g = gpart['@value']
135135
let nprop = new WOQLQuery()
136136
.add_property(proId, type_or_value, g)
@@ -144,13 +144,13 @@ WOQLQuery.prototype.property = function(proId, type_or_value) {
144144

145145
WOQLQuery.prototype.node = function(node, type) {
146146
type = type || false
147-
if (type == 'add_quad') type = 'AddQuad'
148-
else if (type == 'delete_quad') type = 'DeleteQuad'
147+
if (type == 'add_quad') type = 'AddTriple'
148+
else if (type == 'delete_quad') type = 'DeleteTriple'
149149
else if (type == 'add_triple') type = 'AddTriple'
150150
else if (type == 'delete_triple') type = 'DeleteTriple'
151-
else if (type == 'quad') type = 'Quad'
151+
else if (type == 'quad') type = 'Triple'
152152
else if (type == 'triple') type = 'Triple'
153-
if (type && type.indexOf(':') == -1) type = 'woql:' + type
153+
if (type && type.indexOf(':') == -1) type = type
154154
let ctxt = {subject: node}
155155
if (type) ctxt.action = type
156156
this._set_context(ctxt)
@@ -161,9 +161,9 @@ WOQLQuery.prototype.insert = function(id, type, refGraph) {
161161
type = this.cleanType(type, true)
162162
refGraph = refGraph || (this.triple_builder_context ? this.triple_builder_context.graph : false)
163163
if (refGraph) {
164-
return this.add_quad(id, 'type', type, refGraph)
164+
return this.add_quad(id, 'rdf:type', '@schema:'+type, refGraph)
165165
}
166-
return this.add_triple(id, 'type', type)
166+
return this.add_triple(id, 'rdf:type', '@schema:'+type)
167167
}
168168

169169
WOQLQuery.prototype.insert_data = function(data, refGraph) {
@@ -290,24 +290,24 @@ WOQLQuery.prototype._add_partial = function(s, p, o, g) {
290290
//if the last subject is a cardinality restriction quad
291291
//I'm looking for the last property
292292
if (
293-
lastsubj['woql:predicate'] &&
294-
lastsubj['woql:predicate']['woql:node'] &&
295-
lastsubj['woql:predicate']['woql:node'].indexOf('Cardinality') > -1
293+
lastsubj['predicate'] &&
294+
lastsubj['predicate']['node'] &&
295+
lastsubj['predicate']['node'].indexOf('Cardinality') > -1
296296
) {
297297
lastsubj = this.findLastProperty(this.cursor)
298298
}
299-
if (lastsubj && !s) s = lastsubj['woql:subject']
299+
if (lastsubj && !s) s = lastsubj['subject']
300300
let t = ctxt.action || lastsubj['@type']
301301
if (!g) {
302-
const gobj = lastsubj['woql:graph_filter'] || lastsubj['woql:graph']
303-
g = gobj ? gobj['@value'] : 'schema/main'
302+
const gobj = lastsubj['graph_filter'] || lastsubj['graph']
303+
g = gobj ? gobj['@value'] : 'schema'
304304
}
305-
if (t == 'woql:AddTriple') this.and(new WOQLQuery().add_triple(s, p, o))
306-
else if (t == 'woql:DeleteTriple') this.and(new WOQLQuery().delete_triple(s, p, o))
307-
else if (t == 'woql:AddQuad') this.and(new WOQLQuery().add_quad(s, p, o, g))
308-
else if (t == 'woql:DeleteQuad') this.and(new WOQLQuery().delete_quad(s, p, o, g))
309-
else if (t == 'woql:Quad') this.and(new WOQLQuery().quad(s, p, o, g))
310-
else this.and(new WOQLQuery().triple(s, p, o))
305+
if (t == 'AddTriple') this.and(new WOQLQuery().add_quad(s, p, o,g))
306+
else if (t == 'DeleteTriple') this.and(new WOQLQuery().delete_quad(s, p, o,g))
307+
else if (t == 'AddTriple') this.and(new WOQLQuery().add_quad(s, p, o, g))
308+
else if (t == 'DeleteTriple') this.and(new WOQLQuery().delete_quad(s, p, o, g))
309+
else if (t == 'Triple') this.and(new WOQLQuery().quad(s, p, o, g))
310+
else this.and(new WOQLQuery().quad(s, p, o, g))
311311
return this
312312
}
313313

@@ -318,7 +318,7 @@ WOQLQuery.prototype._add_partial = function(s, p, o, g) {
318318
WOQLQuery.prototype._adding_class = function(string_only) {
319319
if (this.triple_builder_context) {
320320
let x = this.triple_builder_context['adding_class']
321-
if (x && string_only && typeof x == 'object') return x['woql:node']
321+
if (x && string_only && typeof x == 'object') return x['node']
322322
return x
323323
}
324324
return false
@@ -346,14 +346,14 @@ WOQLQuery.prototype._set_context = function(ctxt) {
346346
* used to find the class that a property cardinality restriction is applied to
347347
*/
348348
WOQLQuery.prototype._get_object = function(s, p) {
349-
if (this.cursor['@type'] == 'woql:And') {
350-
for (var i = 0; i < this.cursor['woql:query_list'].length; i++) {
351-
let subq = this.cursor['woql:query_list'][i]['woql:query']
349+
if (this.cursor['@type'] == 'And') {
350+
for (var i = 0; i < this.cursor['query_list'].length; i++) {
351+
let subq = this.cursor['query_list'][i]['query']
352352
if (
353-
this._same_entry(subq['woql:subject'], s) &&
354-
this._same_entry(subq['woql:predicate'], p)
353+
this._same_entry(subq['subject'], s) &&
354+
this._same_entry(subq['predicate'], p)
355355
)
356-
return subq['woql:object']
356+
return subq['object']
357357
}
358358
}
359359
return false
@@ -385,9 +385,9 @@ WOQLQuery.prototype._same_entry = function(a, b) {
385385
* @returns {string|boolean}
386386
*/
387387
WOQLQuery.prototype._string_matches_object = function(str, node) {
388-
if (node['woql:node']) return str == node['woql:node']
388+
if (node['node']) return str == node['node']
389389
if (node['@value']) return str == node['@value']
390-
if (node['woql:variable_name']) return str == 'v:' + node['woql:variable_name']['@value']
390+
if (node['variable_name']) return str == 'v:' + node['variable_name']['@value']
391391
return false
392392
}
393393

@@ -405,14 +405,14 @@ WOQLQuery.prototype._card = function(cardValue, which) {
405405
let subject = ctxt.subject
406406
let graph = ctxt.graph
407407
let lastsubj = this.findLastProperty(this.cursor)
408-
if (lastsubj && !subject) subject = lastsubj['woql:subject']
408+
if (lastsubj && !subject) subject = lastsubj['subject']
409409
if (typeof subject === 'object') {
410-
if (subject['woql:node']) subject = subject['woql:node']
410+
if (subject['node']) subject = subject['node']
411411
else return this
412412
}
413413

414414
if (lastsubj && !graph) {
415-
const gobj = lastsubj['woql:graph_filter'] || lastsubj['woql:graph']
415+
const gobj = lastsubj['graph_filter'] || lastsubj['graph']
416416
graph = gobj ? gobj['@value'] : false
417417
}
418418
let cardId = subject + '_' + which + '_' + cardValue

0 commit comments

Comments
 (0)