From 868269116ae4b37980be8d4fe2d13c68dcd99537 Mon Sep 17 00:00:00 2001 From: Kristof Vandenbroucke Date: Thu, 14 Nov 2024 17:51:44 +0100 Subject: [PATCH 01/10] Sdtt 344 create a debugging friendly option for the ea converter (#84) * Introduced a new `debug` flag for quick handling of errors * Updated `README` --- packages/oslo-converter-uml-ea/README.md | 1 + .../lib/EaUmlConversionServiceRunner.ts | 65 +++++++++++-------- .../lib/config/EaUmlConverterConfiguration.ts | 29 +++++++-- .../AttributeConverterHandler.ts | 24 +++++-- packages/oslo-converter-uml-ea/package.json | 2 +- 5 files changed, 85 insertions(+), 36 deletions(-) diff --git a/packages/oslo-converter-uml-ea/README.md b/packages/oslo-converter-uml-ea/README.md index 5a1363a..b834886 100644 --- a/packages/oslo-converter-uml-ea/README.md +++ b/packages/oslo-converter-uml-ea/README.md @@ -27,6 +27,7 @@ The service is executed from the CLI and expects the following parameters: | `--versionId` | Version identifier for the document | :heavy_check_mark: || | `--outputFile` | The name of the RDF output file | No, but if omitted, output is written to process.stdout || | `--outputFormat` | RDF content-type specifiying the output format | :heavy_check_mark: | `application/ld+json` | +| `--debug` | A flag to enable debug mode which is more resilient to errors | | `false` | ## Usage diff --git a/packages/oslo-converter-uml-ea/lib/EaUmlConversionServiceRunner.ts b/packages/oslo-converter-uml-ea/lib/EaUmlConversionServiceRunner.ts index 7fe7421..9aec998 100644 --- a/packages/oslo-converter-uml-ea/lib/EaUmlConversionServiceRunner.ts +++ b/packages/oslo-converter-uml-ea/lib/EaUmlConversionServiceRunner.ts @@ -6,44 +6,57 @@ import { container } from './config/DependencyInjectionConfig'; import type { EaUmlConverterConfiguration } from './config/EaUmlConverterConfiguration'; import type { EaUmlConversionService } from './EaUmlConversionService'; -export class EaUmlConversionServiceRunner extends AppRunner { +export class EaUmlConversionServiceRunner extends AppRunner< + EaUmlConversionService, + EaUmlConverterConfiguration +> { public async runCli(argv: CliArgv): Promise { const yargv = yargs(argv.slice(2)) .usage('node ./bin/runner.js [args]') .option('umlFile', { describe: 'URL or local path to an EAP file.' }) - .option('diagramName', { describe: 'Name of the diagram within the EAP file.' }) - .option('outputFile', - { - describe: 'Name of the output file (default: console).', - }) - .option('versionId', { describe: 'Relative URI used to identify this document.' }) - .option('outputFormat', - { - describe: 'RDF content-type in which the output must be written or to the console.', - choices: ['application/ld+json', 'application/trig'], - default: 'application/ld+json', - }) - .option('publicationEnvironment', - { - describe: 'The base URI of environment where the document will be published', - }) - .option('silent', - { - describe: 'All logs are suppressed', - default: false, - boolean: true, - }) + .option('diagramName', { + describe: 'Name of the diagram within the EAP file.', + }) + .option('outputFile', { + describe: 'Name of the output file (default: console).', + }) + .option('versionId', { + describe: 'Relative URI used to identify this document.', + }) + .option('outputFormat', { + describe: + 'RDF content-type in which the output must be written or to the console.', + choices: ['application/ld+json', 'application/trig'], + default: 'application/ld+json', + }) + .option('publicationEnvironment', { + describe: + 'The base URI of environment where the document will be published', + }) + .option('silent', { + describe: 'All logs are suppressed', + default: false, + boolean: true, + }) .option('logLevel', { describe: 'Log only if level is less than or equal to this level', default: 'info', choices: LOG_LEVELS, }) - .demandOption(['umlFile', 'diagramName', 'versionId', 'publicationEnvironment'], - 'Please provide the necessary arguments to work with this tool.') + .option('debug', { + describe: + 'A flag to enable debug mode which is more resilient to errors', + default: false, + boolean: true, + }) + .demandOption( + ['umlFile', 'diagramName', 'versionId', 'publicationEnvironment'], + 'Please provide the necessary arguments to work with this tool.', + ) .help('h') .alias('h', 'help'); const params = await yargv.parse(); - this.startApp(params, container).catch(error => console.error(error)); + this.startApp(params, container).catch((error) => console.error(error)); } } diff --git a/packages/oslo-converter-uml-ea/lib/config/EaUmlConverterConfiguration.ts b/packages/oslo-converter-uml-ea/lib/config/EaUmlConverterConfiguration.ts index 931e27d..d33d419 100644 --- a/packages/oslo-converter-uml-ea/lib/config/EaUmlConverterConfiguration.ts +++ b/packages/oslo-converter-uml-ea/lib/config/EaUmlConverterConfiguration.ts @@ -32,6 +32,10 @@ export class EaUmlConverterConfiguration implements IConfiguration { * The base URI of the environment where the document will be published */ private _publicationEnvironment: string | undefined; + /** + * A boolean to enable debug mode which is more resilient to errors + */ + private _debug: boolean | undefined; public async createFromCli(params: YargsParams): Promise { this._umlFile = params.umlFile; @@ -40,6 +44,7 @@ export class EaUmlConverterConfiguration implements IConfiguration { this._versionId = params.versionId; this._outputFormat = params.outputFormat; this._publicationEnvironment = params.publicationEnvironment; + this._debug = params.debug; } public get umlFile(): string { @@ -51,36 +56,50 @@ export class EaUmlConverterConfiguration implements IConfiguration { public get diagramName(): string { if (!this._diagramName) { - throw new Error(`Trying to access property "diagramName" before it was set.`); + throw new Error( + `Trying to access property "diagramName" before it was set.` + ); } return this._diagramName; } public get outputFile(): string { if (!this._outputFile) { - throw new Error(`Trying to access property "outputFile" before it was set.`); + throw new Error( + `Trying to access property "outputFile" before it was set.` + ); } return this._outputFile; } public get versionId(): string { if (!this._versionId) { - throw new Error(`Trying to access property "versionId" before it was set.`); + throw new Error( + `Trying to access property "versionId" before it was set.` + ); } return this._versionId; } public get outputFormat(): string { if (!this._outputFormat) { - throw new Error(`Trying to access property "outputFormat" before it was set.`); + throw new Error( + `Trying to access property "outputFormat" before it was set.` + ); } return this._outputFormat; } public get publicationEnvironment(): string { if (!this._publicationEnvironment) { - throw new Error(`Trying to access property "publicationEnvironment" before it was set.`); + throw new Error( + `Trying to access property "publicationEnvironment" before it was set.` + ); } return this._publicationEnvironment; } + + public get debug(): boolean { + return !!this._debug; + } } diff --git a/packages/oslo-converter-uml-ea/lib/converter-handlers/AttributeConverterHandler.ts b/packages/oslo-converter-uml-ea/lib/converter-handlers/AttributeConverterHandler.ts index 54dc742..71f95bb 100644 --- a/packages/oslo-converter-uml-ea/lib/converter-handlers/AttributeConverterHandler.ts +++ b/packages/oslo-converter-uml-ea/lib/converter-handlers/AttributeConverterHandler.ts @@ -298,10 +298,10 @@ export class AttributeConverterHandler extends ConverterHandler { } } - if (!rangeURI) { - throw new Error( - `[AttributeConverterHandler]: Unable to get the URI for the range of attribute (${object.path}).` - ); + // https://vlaamseoverheid.atlassian.net/browse/SDTT-344 + // Needed a way to log errors without throwing them so that the conversion process can continue + if (this.handleRangeError(object, rangeURI)) { + return []; } quads.push( @@ -362,6 +362,22 @@ export class AttributeConverterHandler extends ConverterHandler { return quads; } + private handleRangeError( + object: EaAttribute, + rangeURI: string | null + ): boolean { + if (!rangeURI) { + const error: string = `[AttributeConverterHandler]: Unable to determine the range for attribute (${object.path}).`; + if (this.config.debug) { + this.logger.error(error); + return true; + } else { + throw new Error(error); + } + } + return false; + } + private getDatatypeQuads( rangeInternalId: RDF.NamedNode, rangeAssignedURI: RDF.NamedNode, diff --git a/packages/oslo-converter-uml-ea/package.json b/packages/oslo-converter-uml-ea/package.json index d0ee84f..200c8a1 100644 --- a/packages/oslo-converter-uml-ea/package.json +++ b/packages/oslo-converter-uml-ea/package.json @@ -1,6 +1,6 @@ { "name": "@oslo-flanders/ea-converter", - "version": "0.0.34-alpha.0", + "version": "0.0.35-alpha.0", "description": "Transform an Enterprise Architect UML diagram to RDF", "author": "Digitaal Vlaanderen ", "homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-converter-uml-ea#readme", From d095ce5933b41741517f3cb7c0e81bb4d647eccb Mon Sep 17 00:00:00 2001 From: Kristof Vandenbroucke Date: Mon, 18 Nov 2024 15:08:45 +0100 Subject: [PATCH 02/10] Added a `line-break` class to the `ap` due to external terminology overflowing --- packages/oslo-generator-html/lib/templates/ap2.j2 | 5 ++++- packages/oslo-generator-html/package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/oslo-generator-html/lib/templates/ap2.j2 b/packages/oslo-generator-html/lib/templates/ap2.j2 index d842ff2..6f8962b 100644 --- a/packages/oslo-generator-html/lib/templates/ap2.j2 +++ b/packages/oslo-generator-html/lib/templates/ap2.j2 @@ -568,7 +568,7 @@

Merk op, dat de nood om een mapping wijziging door te voeren ook dikwijls ook semantische aanpassingen met zich mee brengt. Daarom is het aangewezen om wijzingen in het normale veranderingsbeheer van de standaard op te nemen.

- +
@@ -680,6 +680,9 @@
term