@rmlio/yarrrml-parser
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -10,2 +10,7 @@ # Changelog | ||
## [0.3.6] - 2019-08-12 | ||
### Fixed | ||
- Condition and function on the same predicate object (see [issue 17](https://github.com/RMLio/yarrrml-parser/issues/17)) | ||
## [0.3.5] - 2019-08-05 | ||
@@ -89,2 +94,3 @@ | ||
[0.3.6]: https://github.com/RMLio/yarrrml-parser/compare/v0.3.5...v0.3.6 | ||
[0.3.5]: https://github.com/RMLio/yarrrml-parser/compare/v0.3.4...v0.3.5 | ||
@@ -91,0 +97,0 @@ [0.3.4]: https://github.com/RMLio/yarrrml-parser/compare/v0.3.3...v0.3.4 |
@@ -373,4 +373,5 @@ /** | ||
parameter: idlabfn + 'str', | ||
value: o.value, | ||
from: 'subject' | ||
value: o.function ? o : o.value, | ||
type: o.type, | ||
from: o.function ? 'function' : 'subject' | ||
} | ||
@@ -377,0 +378,0 @@ ], |
@@ -566,2 +566,157 @@ /** | ||
}); | ||
it('condition and function on same po', () => { | ||
const input = { | ||
mappings: { | ||
person: { | ||
po: [ | ||
{ | ||
predicates: 'foaf:firstName', | ||
objects: [ | ||
{ | ||
function: 'grel:toUpperCase', | ||
parameters: [ | ||
{ | ||
parameter: 'grel:valueParamter', | ||
value: '$(firstname)' | ||
} | ||
] | ||
} | ||
], | ||
condition: { | ||
function: 'idlab-fn:stringContainsOtherString', | ||
parameters: [ | ||
{ | ||
parameter: 'idlab-fn:str', | ||
value: '$(firstname)' | ||
}, | ||
{ | ||
parameter: 'idlab-fn:otherStr', | ||
value: 'J' | ||
}, | ||
{ | ||
parameter: 'idlab-fn:delimiter', | ||
value: '' | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}; | ||
const expectedOutput = { | ||
mappings: | ||
{ | ||
person: | ||
{ | ||
predicateobjects: | ||
[{ | ||
predicates: ['foaf:firstName'], | ||
objects: | ||
[{ | ||
function: 'http://example.com/idlab/function/trueCondition', | ||
parameters: | ||
[{ | ||
parameter: 'http://example.com/idlab/function/strBoolean', | ||
value: | ||
{ | ||
function: 'idlab-fn:stringContainsOtherString', | ||
parameters: | ||
[{parameter: 'idlab-fn:str', value: '$(firstname)'}, | ||
{parameter: 'idlab-fn:otherStr', value: 'J'}, | ||
{parameter: 'idlab-fn:delimiter', value: ''}] | ||
}, | ||
from: 'function' | ||
}, | ||
{ | ||
parameter: 'http://example.com/idlab/function/str', | ||
value: | ||
{ | ||
function: 'grel:toUpperCase', | ||
parameters: | ||
[{parameter: 'grel:valueParamter', value: '$(firstname)'}] | ||
}, | ||
type: undefined, | ||
from: 'function' | ||
}], | ||
type: undefined | ||
}] | ||
}] | ||
} | ||
} | ||
} | ||
; | ||
const output = expand(input); | ||
assert.deepStrictEqual(output, expectedOutput); | ||
}); | ||
it('condition on po', () => { | ||
const input = { | ||
mappings: { | ||
person: { | ||
po: [ | ||
{ | ||
predicates: 'foaf:firstName', | ||
objects: '$(firstname)', | ||
condition: { | ||
function: 'idlab-fn:equal', | ||
parameters: [ | ||
{ | ||
parameter: 'grel:valueParameter', | ||
value: '$(firstname)' | ||
}, | ||
{ | ||
parameter: 'grel:valueParameter2', | ||
value: 'test' | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}; | ||
const expectedOutput = { | ||
mappings: | ||
{ | ||
person: | ||
{ | ||
predicateobjects: | ||
[{ | ||
predicates: ['foaf:firstName'], | ||
objects: | ||
[{ | ||
function: 'http://example.com/idlab/function/trueCondition', | ||
parameters: | ||
[{ | ||
parameter: 'http://example.com/idlab/function/strBoolean', | ||
value: | ||
{ | ||
function: 'idlab-fn:equal', | ||
parameters: | ||
[{parameter: 'grel:valueParameter', value: '$(firstname)'}, | ||
{parameter: 'grel:valueParameter2', value: 'test'}] | ||
}, | ||
from: 'function' | ||
}, | ||
{ | ||
parameter: 'http://example.com/idlab/function/str', | ||
value: '$(firstname)', | ||
type: 'literal', | ||
from: 'subject' | ||
}], | ||
type: 'literal' | ||
}] | ||
}] | ||
} | ||
} | ||
}; | ||
const output = expand(input); | ||
assert.deepStrictEqual(output, expectedOutput); | ||
}); | ||
}); |
@@ -107,2 +107,6 @@ /** | ||
}); | ||
it('condition and function on same po', function (done) { | ||
work('condition-function-on-po/mapping.yarrrml', 'condition-function-on-po/mapping.rml.ttl', done); | ||
}); | ||
}); | ||
@@ -109,0 +113,0 @@ |
{ | ||
"name": "@rmlio/yarrrml-parser", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "Parse YARRRML descriptions into RML RDF statements", | ||
@@ -5,0 +5,0 @@ "main": "lib/yarrrml2rml.js", |
230594
82
3101