Skip to content

Commit 15f5d3c

Browse files
committed
Merge branch 'dev' into canary
2 parents 723847c + e5f9ce3 commit 15f5d3c

File tree

5 files changed

+60
-42
lines changed

5 files changed

+60
-42
lines changed

lib/query/woqlCore.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ WOQLQuery.prototype.cleanDataValue = function(o, t) {
338338
} else if (typeof o == 'boolean') {
339339
t = t || 'xsd:boolean'
340340
obj['data'] = this.jlt(o, t)
341+
} else if (Array.isArray(o)) {
342+
let res = []
343+
for( var i = 0; i < o.length; i++ ){
344+
res.push(this.cleanDataValue(o[i]))
345+
}
346+
obj['list'] = res
341347
} else if (typeof o == 'object' && o) {
342348
if (o['@value']) obj['data'] = o
343349
else return o
@@ -638,7 +644,7 @@ function getClauseAndRemainder(pat) {
638644
}
639645
return []
640646
}
641-
if (pat[0] == '+' || pat[0] == ',' || pat[0] == '|') {
647+
if (pat[0] == '+' || pat[0] == ',' || pat[0] == '|' || pat[0] == '*') {
642648
let ret = [pat[0]]
643649
if (pat.substring(1)) ret.push(pat.substring(1))
644650
return ret
@@ -649,7 +655,7 @@ function getClauseAndRemainder(pat) {
649655
return ret
650656
}
651657
for (var i = 1; i < pat.length; i++) {
652-
if (pat[i] == ',' || pat[i] == '|' || pat[i] == '+' || pat[i] == '{')
658+
if (pat[i] == ',' || pat[i] == '|' || pat[i] == '+' || pat[i] == '{' || pat[i] == '*')
653659
return [pat.substring(0, i), pat.substring(i)]
654660
}
655661
return [pat]
@@ -670,14 +676,17 @@ function compilePredicate(pp, q) {
670676
}
671677
} else if (pp.indexOf('<') != -1) {
672678
let pred = pp.slice(1, pp.length)
673-
let cleaned = pred == '*' ? 'owl:topObjectProperty' : q.cleanPathPredicate(pred)
679+
//let cleaned = pred == '*' ? 'owl:topObjectProperty' : q.cleanPathPredicate(pred)
680+
let cleaned = q.cleanPathPredicate(pred)
674681
return {'@type': 'InvertedPathPredicate', 'predicate': cleaned}
675682
} else if (pp.indexOf('>') != -1) {
676683
let pred = pp.slice(0, pp.length - 1)
677-
let cleaned = pred == '*' ? 'owl:topObjectProperty' : q.cleanPathPredicate(pred)
684+
//let cleaned = pred == '*' ? 'owl:topObjectProperty' : q.cleanPathPredicate(pred)
685+
let cleaned = q.cleanPathPredicate(pred)
678686
return {'@type': 'PathPredicate', 'predicate': cleaned}
679687
} else {
680-
let pred = pp == '*' ? 'owl:topObjectProperty' : q.cleanPathPredicate(pp)
688+
//let pred = pp == '*' ? 'owl:topObjectProperty' : q.cleanPathPredicate(pp)
689+
let pred = q.cleanPathPredicate(pp)
681690
return {'@type': 'PathPredicate', 'predicate': pred}
682691
}
683692
}
@@ -720,6 +729,12 @@ function tokensToJSON(seq, q) {
720729
'@type': 'PathPlus',
721730
'plus': tokensToJSON([seq[0]], q),
722731
}
732+
} else if (seq[1] == '*') {
733+
//binds tightest of all
734+
return {
735+
'@type': 'PathStar',
736+
'star': tokensToJSON([seq[0]], q),
737+
}
723738
} else if (seq[1].charAt(0) == '{') {
724739
//binds tightest of all
725740
let meat = seq[1].substring(1, seq[1].length - 1).split(',')

lib/query/woqlQuery.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ WOQLQuery.prototype.unique = function(prefix, vari, type) {
647647
if (this.cursor['@type']) this.wrapCursorWithAnd()
648648
this.cursor['@type'] = 'HashKey'
649649
this.cursor['base'] = this.cleanDataValue(prefix,'xsd:string')
650-
this.cursor['key_list'] = this.dataList(vari)
650+
this.cursor['key_list'] = this.cleanDataValue(vari)
651651
this.cursor['uri'] = this.cleanNodeValue(type)
652652
return this
653653
}
@@ -713,7 +713,7 @@ WOQLQuery.prototype.split = function(input, glue, output) {
713713
this.cursor['@type'] = 'Split'
714714
this.cursor['string'] = this.cleanDataValue(input)
715715
this.cursor['pattern'] = this.cleanDataValue(glue)
716-
this.cursor['list'] = this.dataList(output)
716+
this.cursor['list'] = this.cleanDataValue(output)
717717
return this
718718
}
719719

@@ -748,7 +748,7 @@ WOQLQuery.prototype.concat = function(list, v) {
748748
if (Array.isArray(list)) {
749749
if (this.cursor['@type']) this.wrapCursorWithAnd()
750750
this.cursor['@type'] = 'Concatenate'
751-
this.cursor['list'] = this.dataList(list, true)
751+
this.cursor['list'] = this.cleanDataValue(list, true)
752752
this.cursor['result'] = this.cleanDataValue(v)
753753
}
754754
return this
@@ -761,7 +761,7 @@ WOQLQuery.prototype.join = function(input, glue, output) {
761761
//return ['join_list', 'join_separator', 'join']
762762
if (this.cursor['@type']) this.wrapCursorWithAnd()
763763
this.cursor['@type'] = 'Join'
764-
this.cursor['list'] = this.dataList(input)
764+
this.cursor['list'] = this.cleanDataValue(input)
765765
this.cursor['separator'] = this.cleanDataValue(glue)
766766
this.cursor['result'] = this.cleanDataValue(output)
767767
return this
@@ -771,7 +771,7 @@ WOQLQuery.prototype.sum = function(input, output) {
771771
//if (input && input == 'args') return ['sum_list', 'sum']
772772
if (this.cursor['@type']) this.wrapCursorWithAnd()
773773
this.cursor['@type'] = 'Sum'
774-
this.cursor['list'] = this.dataList(input)
774+
this.cursor['list'] = this.cleanDataValue(input)
775775
this.cursor['result'] = this.cleanObject(output)
776776
return this
777777
}
@@ -799,7 +799,7 @@ WOQLQuery.prototype.re = function(p, s, m) {
799799
this.cursor['@type'] = 'Regexp'
800800
this.cursor['pattern'] = this.cleanDataValue(p)
801801
this.cursor['string'] = this.cleanDataValue(s)
802-
this.cursor['result'] = this.dataList(m)
802+
this.cursor['result'] = this.cleanDataValue(m)
803803
return this
804804
}
805805

@@ -810,7 +810,7 @@ WOQLQuery.prototype.length = function(va, vb) {
810810
//return ['length_list', 'length']
811811
if (this.cursor['@type']) this.wrapCursorWithAnd()
812812
this.cursor['@type'] = 'Length'
813-
this.cursor['list'] = this.cleanObject(va)
813+
this.cursor['list'] = this.cleanDataValue(va)
814814
if (typeof vb == 'number') {
815815
this.cursor['length'] = this.cleanObject(vb, 'xsd:nonNegativeInteger')
816816
} else if (typeof vb == 'string') {
@@ -932,7 +932,7 @@ WOQLQuery.prototype.path = function(Subject, Pattern, Object, Path) {
932932
this.cursor['@type'] = 'Path'
933933
this.cursor['subject'] = this.cleanSubject(Subject)
934934
if (typeof Pattern == 'string') Pattern = this.compilePathPattern(Pattern)
935-
this.cursor['path_pattern'] = Pattern
935+
this.cursor['pattern'] = Pattern
936936
this.cursor['object'] = this.cleanObject(Object)
937937
this.cursor['path'] = this.varj(Path)
938938
return this
@@ -968,4 +968,4 @@ WOQLQuery.prototype.type_of = function(a, b) {
968968
return this
969969
}
970970

971-
module.exports = WOQLQuery
971+
module.exports = WOQLQuery

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"axios": "^0.21.1",
2424
"sockjs": ">=0.3.20",
2525
"ssri": ">=6.0.2",
26-
"y18n": ">=4.0.1"
26+
"y18n": ">=4.0.1",
27+
"path-parse": ">=1.0.7"
2728
},
2829
"devDependencies": {
2930
"y18n": ">=4.0.1",

test/woqlJson/woqlConcatJson.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
module.exports={
22
"@type": "Concatenate",
3-
"list": [
4-
{
5-
"@type": "DataValue",
6-
"variable": "Duration"
7-
},
8-
{
9-
"@type": "DataValue",
10-
"data": {
11-
"@type": "xsd:string",
12-
"@value": " yo "
13-
}
14-
},
15-
{
16-
"@type": "DataValue",
17-
"variable": "Duration_Cast"
18-
}
19-
],
3+
"list": { "@type" : "DataValue",
4+
"list" : [
5+
{
6+
"@type": "DataValue",
7+
"variable": "Duration"
8+
},
9+
{
10+
"@type": "DataValue",
11+
"data": {
12+
"@type": "xsd:string",
13+
"@value": " yo "
14+
}
15+
},
16+
{
17+
"@type": "DataValue",
18+
"variable": "Duration_Cast"
19+
}
20+
]},
2021
"result": {
2122
"@type": "DataValue",
2223
"data": {

test/woqlJson/woqlJoinSplitJson.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
module.exports={joinJson:{
22
"@type": "Join",
3-
"list": [
4-
{
5-
"@type": "DataValue",
6-
"variable": "A_obj"
7-
},
8-
{
9-
"@type": "DataValue",
10-
"variable": "B_obj"
11-
}
12-
],
3+
"list": { "@type" : "DataValue",
4+
"list" : [
5+
{
6+
"@type": "DataValue",
7+
"variable": "A_obj"
8+
},
9+
{
10+
"@type": "DataValue",
11+
"variable": "B_obj"
12+
}
13+
]},
1314
"separator": {
1415
"@type": "DataValue",
1516
"data": {

0 commit comments

Comments
 (0)