diff --git a/src/export/exporter.js b/src/export/exporter.js index 4e3d821ad..8909388b1 100644 --- a/src/export/exporter.js +++ b/src/export/exporter.js @@ -55,7 +55,7 @@ export default class Exporter extends ProcessGraph { generateBuilder() {} - generateMetadata(/*key, value*/) {} + generateMetadataEntry(/*variable, key, value*/) {} generateMissingParameter() {} @@ -125,7 +125,11 @@ export default class Exporter extends ProcessGraph { } } - generateMetadata() { + getMetadataPosition() { + return "start"; + } + + generateMetadata(variable) { let hasComment = false; for(let key in this.process) { if (key === 'process_graph') { @@ -146,7 +150,7 @@ export default class Exporter extends ProcessGraph { this.comment(`Set the metadata for the process`); hasComment = true; } - this.generateMetadataEntry(key, val); + this.generateMetadataEntry(variable, key, val); } } @@ -281,8 +285,10 @@ export default class Exporter extends ProcessGraph { this.generateConnection(); this.generateAuthentication(); this.newLine(); - this.generateBuilder(); - this.generateMetadata(); + let builderVar = this.generateBuilder(); + if (this.getMetadataPosition() === "start") { + this.generateMetadata(builderVar); + } this.newLine(); } let params = this.getProcessParameters(); @@ -299,6 +305,9 @@ export default class Exporter extends ProcessGraph { this.comment(`The process can be executed synchronously (see below), as batch job or as web service now`); } this.generateResult(this.getResultNode(), callback); + if (!callback && this.getMetadataPosition() === "end") { + this.generateMetadata(); + } return this.code.join('').trim(); } diff --git a/src/export/javascript.js b/src/export/javascript.js index 0f25c317f..87df354d0 100644 --- a/src/export/javascript.js +++ b/src/export/javascript.js @@ -116,6 +116,7 @@ export default class JavaScript extends Exporter { generateBuilder() { this.addCode(`let builder = await connection.buildProcess();`); + return 'builder'; } generateMetadataEntry(key, value) { diff --git a/src/export/python.js b/src/export/python.js index 271ff4cb8..db7d5b64e 100644 --- a/src/export/python.js +++ b/src/export/python.js @@ -41,7 +41,11 @@ export default class Python extends Exporter { generateBuilder() {} - generateMetadataEntry(key, value) { + getMetadataPosition() { + return "end"; + } + + generateMetadataEntry(variable, key, value) { this.comment(`${key}: ${this.e(value)}`); } diff --git a/src/export/r.js b/src/export/r.js index dd34e6fdf..e2f53d2c6 100644 --- a/src/export/r.js +++ b/src/export/r.js @@ -1,3 +1,4 @@ +import { ProcessSchema } from "@openeo/js-commons"; import Utils from "../utils"; import Exporter from "./exporter"; @@ -51,9 +52,20 @@ export default class R extends Exporter { generateBuilder() { this.addCode(`p = processes()`); + return 'p'; } - generateMetadataEntry(key, value) { + getMetadataPosition() { + return "end"; + } + + generateMetadataEntry(variable, key, value) { + switch(key) { + case 'id': + case 'summary': + case 'description': + setDescription + } this.comment(`${key}: ${this.e(value)}`); }