@rmlio/rmlmapper-java-wrapper
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -8,2 +8,10 @@ # Changelog | ||
## [0.1.0] - 2019-07-16 | ||
## Added | ||
- Select serialization of the RDF. | ||
### Fixed | ||
- Add options of execute() as object instead of separate arguments. | ||
## [0.0.5] - 2019-05-20 | ||
@@ -30,5 +38,6 @@ | ||
[0.0.5]: https://github.com/RMLio/yarrrml-parser/compare/v0.0.4...v0.0.5 | ||
[0.0.4]: https://github.com/RMLio/yarrrml-parser/compare/v0.0.3...v0.0.4 | ||
[0.0.3]: https://github.com/RMLio/yarrrml-parser/compare/v0.0.2...v0.0.3 | ||
[0.0.2]: https://github.com/RMLio/yarrrml-parser/compare/v0.0.1...v0.0.2 | ||
[0.1.0]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v0.0.5...v0.1.0 | ||
[0.0.5]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v0.0.4...v0.0.5 | ||
[0.0.4]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v0.0.3...v0.0.4 | ||
[0.0.3]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v0.0.2...v0.0.3 | ||
[0.0.2]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v0.0.1...v0.0.2 |
@@ -27,3 +27,3 @@ /** | ||
// WHEN generating the quads without the metadata and expected the results to by an array of quads | ||
const result = await wrapper.execute(rml, sources, false, true); | ||
const result = await wrapper.execute(rml, {sources, generateMetadata: false, asQuads: true}); | ||
@@ -45,3 +45,3 @@ // THEN the mapping should succeed and the output should match one of the file | ||
try { | ||
await wrapper.execute(rml, sources, false, true); | ||
await wrapper.execute(rml, {sources, generateMetadata: false, asQuads: true}); | ||
} catch (err) { | ||
@@ -55,2 +55,22 @@ error = err; | ||
}); | ||
it('Serialization: JSON-LD', async () => { | ||
const wrapper = new RMLMapperWrapper(rmlmapperPath, tempFolderPath, true); | ||
const rml = fs.readFileSync('./test/tc03/mapping.ttl', 'utf-8'); | ||
const sources = { | ||
'student.csv': fs.readFileSync('./test/tc03/student.csv', 'utf-8') | ||
}; | ||
const result = await wrapper.execute(rml, {sources, serialization: 'jsonld'}); | ||
let error = null; | ||
try { | ||
JSON.parse(result.output); | ||
} catch (err) { | ||
error = err; | ||
} | ||
assert.ok(error === null); | ||
}); | ||
}); |
@@ -29,3 +29,15 @@ /** | ||
execute(rml, sources, generateMetadata, asQuads = false) { | ||
execute(rml, options = {}) { | ||
options = Object.assign({ | ||
generateMetadata: false, | ||
asQuads: false, | ||
serialization: 'nquads' | ||
}, options); | ||
if (!options.asQuads) { | ||
options.serialization = this._sanitizeSerialization(options.serialization); | ||
} else { | ||
options.serialization = 'nquads'; | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -55,8 +67,8 @@ // current time | ||
} else { | ||
const outputFile = path.resolve(processDir, "output.nq"); | ||
const metadataFile = path.resolve(processDir, "metadata.nq"); | ||
const outputFile = path.resolve(processDir, "output." + options.serialization); | ||
const metadataFile = path.resolve(processDir, "metadata." + options.serialization); | ||
let execCommand = `java -jar ${self.path} -m ${mappingFile} -o ${outputFile}`; | ||
let execCommand = `java -jar ${self.path} -m ${mappingFile} -o ${outputFile} -s ${options.serialization}`; | ||
if (generateMetadata) { | ||
if (options.generateMetadata) { | ||
execCommand += ` -l triple -e ${metadataFile}`; | ||
@@ -78,7 +90,7 @@ } | ||
} else { | ||
if (asQuads) { | ||
if (options.asQuads) { | ||
output = await strToQuads(output); | ||
} | ||
if (generateMetadata) { | ||
if (options.generateMetadata) { | ||
fs.readFile(metadataFile, 'utf8', async (metadataErr, metadata) => { | ||
@@ -120,4 +132,4 @@ if (metadataErr) { | ||
if (sources) { | ||
this._saveSources(sources, sourceDirPrefix) | ||
if (options.sources) { | ||
this._saveSources(options.sources, sourceDirPrefix) | ||
.then(callback) | ||
@@ -190,4 +202,9 @@ .catch(reject); | ||
} | ||
_sanitizeSerialization(serialization) { | ||
serialization = serialization.toLowerCase(serialization); | ||
return serialization.replace(/[-_]/g, ''); | ||
} | ||
} | ||
module.exports = RMLMapperWrapper; |
{ | ||
"name": "@rmlio/rmlmapper-java-wrapper", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "A JavaScript wrapper around the Java RMLMapper.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
16830
16
300