@rmlio/rmlmapper-java-wrapper
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -10,2 +10,7 @@ # Changelog | ||
## [2.0.3] - 2022-02-22 | ||
### Fixed | ||
- Support data source files that in are not in the root folder | ||
## [2.0.2] - 2021-08-31 | ||
@@ -15,2 +20,3 @@ | ||
- Bug causing invalid paths in RML on windows | ||
- Better error handling when stderr is non-empty but also doesn't contain errors | ||
@@ -94,2 +100,3 @@ ## [2.0.1] - 2021-07-02 | ||
[2.0.3]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.2...v2.0.3 | ||
[2.0.2]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.1...v2.0.2 | ||
@@ -96,0 +103,0 @@ [2.0.1]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.0...v2.0.1 |
@@ -223,2 +223,18 @@ /** | ||
}); | ||
it('Data source in subdirectory', async () => { | ||
// GIVEN a wrapper and a simple CSV mapping generating one quad | ||
const wrapper = new RMLMapperWrapper(rmlmapperPath, tempFolderPath, true); | ||
const rml = fs.readFileSync('./test/tc08/mapping.ttl', 'utf-8'); | ||
const sources = { | ||
'./data/student.csv': fs.readFileSync('./test/tc08/data/student.csv', 'utf-8') | ||
}; | ||
// WHEN generating the quads without the metadata and expected the results to by an array of quads | ||
const result = await wrapper.execute(rml, {sources, generateMetadata: false, asQuads: true}); | ||
// THEN the mapping should succeed and the output should match one of the file | ||
const expected = await strToQuads(fs.readFileSync('./test/tc01/output.nq', 'utf-8')); | ||
assert.ok(isomorphic(result.output, expected)); | ||
}); | ||
}); |
@@ -14,2 +14,3 @@ /** | ||
const {strToQuads} = require('./utils'); | ||
const { v4: uuidv4 } = require('uuid'); | ||
@@ -80,2 +81,3 @@ const sourceFilePrefix = 'data-'; | ||
if (options.sources) { | ||
this._sanitizeSources(options.sources); | ||
await this._saveSources(options.sources, sourceDirPrefix); | ||
@@ -94,3 +96,4 @@ } | ||
fno: options.fno, | ||
targetDirPrefix | ||
targetDirPrefix, | ||
sources: options.sources | ||
}); | ||
@@ -105,3 +108,3 @@ resolve(result) | ||
async _executeCLI(options) { | ||
let {rml, sourceDirPrefix, processDir, logFile, serialization, asQuads, generateMetadata, fno, targetDirPrefix} = options; | ||
let {rml, sourceDirPrefix, sources, processDir, logFile, serialization, asQuads, generateMetadata, fno, targetDirPrefix} = options; | ||
const mappingFile = this._fixPath(path.join(processDir, 'mapping.rml.ttl')); | ||
@@ -113,3 +116,3 @@ let functionsFile; | ||
const targetFiles = result.targetFiles; | ||
const rmlStr = await this._setSourcesInRMLRules(rml, sourceDirPrefix); | ||
const rmlStr = await this._setSourcesInRMLRules(rml, sourceDirPrefix, sources); | ||
@@ -254,5 +257,5 @@ await fs.writeFile(mappingFile, rmlStr); | ||
if (sources[names[index]]) { | ||
if (typeof sources[names[index]] === 'string') { | ||
if (typeof sources[names[index]].data === 'string') { | ||
try { | ||
await fs.writeFile(prefix + names[index], sources[names[index]]); | ||
await fs.writeFile(prefix + sources[names[index]].path, sources[names[index]].data); | ||
done(); | ||
@@ -301,3 +304,3 @@ } catch (err) { | ||
*/ | ||
async _setSourcesInRMLRules(rmlQuads, prefix) { | ||
async _setSourcesInRMLRules(rmlQuads, prefix, sources) { | ||
return new Promise((resolve, reject) => { | ||
@@ -310,3 +313,3 @@ const adjustedRMLQuads = []; | ||
if (rmlQuad.predicate.value === 'http://semweb.mmlab.be/ns/rml#source' && rmlQuad.object.termType === 'Literal') { | ||
adjustedQuad = newQuad(rmlQuad.subject, rmlQuad.predicate, literal(prefix + rmlQuad.object.value)); | ||
adjustedQuad = newQuad(rmlQuad.subject, rmlQuad.predicate, literal(prefix + sources[rmlQuad.object.value].path)); | ||
} | ||
@@ -397,4 +400,14 @@ | ||
_sanitizeSources(sources) { | ||
const filePaths = Object.keys(sources); | ||
filePaths.forEach(filePath => { | ||
sources[filePath] = { | ||
data: sources[filePath], | ||
path: uuidv4() + '-' + path.basename(filePath) | ||
}; | ||
}); | ||
} | ||
} | ||
module.exports = RMLMapperWrapper; |
{ | ||
"name": "@rmlio/rmlmapper-java-wrapper", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "A JavaScript wrapper around the Java RMLMapper.", | ||
@@ -20,3 +20,4 @@ "main": "index.js", | ||
"n3": "^1.9.0", | ||
"rdf-isomorphic": "^1.1.0" | ||
"rdf-isomorphic": "^1.1.0", | ||
"uuid": "^8.3.2" | ||
}, | ||
@@ -23,0 +24,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
598768
44
601
5
+ Addeduuid@^8.3.2
+ Addeduuid@8.3.2(transitive)