Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rmlio/rmlmapper-java-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rmlio/rmlmapper-java-wrapper - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

6

CHANGELOG.md

@@ -10,2 +10,7 @@ # Changelog

## [2.0.2] - 2021-08-31
### Fixed
- Bug causing invalid paths in RML on windows
## [2.0.1] - 2021-07-02

@@ -88,2 +93,3 @@

[2.0.2]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v2.0.0...v2.0.1

@@ -90,0 +96,0 @@ [2.0.0]: https://github.com/RMLio/rmlmapper-java-wrapper-js/compare/v1.2.0...v2.0.0

85

lib/wrapper.js

@@ -8,3 +8,3 @@ /**

const fs = require('fs-extra');
const exec = require('child_process').exec;
const spawn = require('child_process').spawn;
const N3 = require('n3');

@@ -76,4 +76,4 @@ const {DataFactory, Parser, Writer} = N3;

const logFile = path.join(processDir, 'rmlmapper.log');
const sourceDirPrefix = path.join(processDir, sourceFilePrefix);
const targetDirPrefix = path.join(processDir, targetFilePrefix);
const sourceDirPrefix = this._fixPath(path.join(processDir, sourceFilePrefix));
const targetDirPrefix = this._fixPath(path.join(processDir, targetFilePrefix));

@@ -85,3 +85,7 @@ if (options.sources) {

try {
const result = await this._executeCLI({rml, sourceDirPrefix, processDir, logFile,
const result = await this._executeCLI({
rml,
sourceDirPrefix,
processDir,
logFile,
serialization: options.serialization,

@@ -95,3 +99,3 @@ asQuads: options.asQuads,

} catch (e) {
reject (e);
reject(e);
}

@@ -103,3 +107,3 @@ });

let {rml, sourceDirPrefix, processDir, logFile, serialization, asQuads, generateMetadata, fno, targetDirPrefix} = options;
const mappingFile = path.join(processDir, 'mapping.rml.ttl');
const mappingFile = this._fixPath(path.join(processDir, 'mapping.rml.ttl'));
let functionsFile;

@@ -114,3 +118,3 @@

const outputFile = path.join(processDir, "output." + serialization);
const metadataFile = path.join(processDir, "metadata." + serialization);
const metadataFile = this._fixPath(path.join(processDir, "metadata." + serialization));

@@ -124,27 +128,54 @@ if (fno) {

let execCommand = `java `;
let execCommand = `java`;
let execParams = [];
Object.keys(this.javaVMOptions).forEach(key => {
const value = this.javaVMOptions[key];
execCommand += `-${key}=${value} `
execParams.push(`-${key}=${value}`);
});
execCommand += `-jar ${this.path} -m ${mappingFile} -o ${outputFile} -s ${serialization}`;
execParams.push('-jar')
execParams.push(this.path)
execParams.push(`-m`)
execParams.push(mappingFile)
execParams.push(`-o`)
execParams.push(outputFile)
execParams.push(`-s`)
execParams.push(serialization)
if (generateMetadata) {
execCommand += ` -l triple -e ${metadataFile}`;
execParams.push(`-l`)
execParams.push(`triple`)
execParams.push(`-e`)
execParams.push(metadataFile)
}
if (fno) {
execCommand += ` -f ${functionsFile}`;
execParams.push(`-f`)
execParams.push(functionsFile)
}
return new Promise((resolve, reject) => {
exec(execCommand, async (error, stdout, stderr) => {
const mapping = spawn(execCommand, execParams, {
// setting CWD when you have a mapping file that accesses (large) files directly
// so you don't need to needlessly copy that file
cwd: path.resolve(processDir, '../../')
});
let stdout = '';
let stderr = '';
mapping.stdout.on('data', data => {
stdout += data;
})
mapping.stderr.on('data', data => {
stderr += data;
})
mapping.on('close', async (code) => {
if (code !== 0 || stderr && stderr.indexOf('ERROR') >= 0) {
const err = new Error(`Error while executing the rules.`);
if (stderr) {
await fs.writeFile(logFile, stderr);
const err = new Error(`Error while executing the rules.`);
err.log = stderr;
}
reject(err);
} else {
}
try {

@@ -204,4 +235,3 @@ let output = await fs.readFile(outputFile, 'utf8');

}
}
});
})
});

@@ -305,2 +335,9 @@ }

/**
* Paths in the RML files can't have \\ so all \ must be replaced by /, for Windows, the RMLMapper takes care of reverting this again.
*/
_fixPath(filePath) {
return path.sep === '\\' ? filePath.replace(/\\/g, '/') : filePath;
}
_updateTargetsWithLocalFiles(options = {}) {

@@ -338,15 +375,18 @@ let {rmlQuads, dirPrefix} = options;

const p = dirPrefix + filename;
let p = dirPrefix + filename;
targetFiles.push(p);
p = this._fixPath(p);
store.addQuad(targetNode, namedNode('http://rdfs.org/ns/void#dataDump'), namedNode('file://' + p));
store.removeQuad(targetNode, namedNode('http://rdfs.org/ns/void#dataDump'), voidDataDumps[0]);
targetFiles.push(p);
} else if (dcatDataDumps.length > 0) {
const filename = path.basename(dcatDataDumps[0].value);
const p = dirPrefix + filename;
let p = dirPrefix + filename;
targetFiles.push(p);
p = this._fixPath(p);
store.addQuad(targetNode, namedNode('http://www.w3.org/ns/dcat#dataDump'), namedNode('file://' + p));
store.removeQuad(targetNode, namedNode('http://www.w3.org/ns/dcat#dataDump'), dcatDataDumps[0]);
targetFiles.push(p);
}

@@ -358,4 +398,5 @@ }

}
}
module.exports = RMLMapperWrapper;
{
"name": "@rmlio/rmlmapper-java-wrapper",
"version": "2.0.1",
"version": "2.0.2",
"description": "A JavaScript wrapper around the Java RMLMapper.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc