Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdtt 343 add an extra flag the ea converter that allows to export all tags from the uml diagram instead of a controlled selection #88

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/oslo-converter-uml-ea/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ 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` |
| `--allTags` | Add all tags from EA to the generated output | No, default `false` | `true` or `false` |
| `--debug` | A flag to enable debug mode which is more resilient to errors | | `false` |

## Usage

```bash
oslo-converter-ea --umlFile path/to/uml/diagram.eap --diagramName "diagramName" --versionId "test/1" --outputFile path/to/output.jsonld --outputFormat application/ld+json --publicationEnvironment https://data.vlaanderen.be
oslo-converter-ea --umlFile https://github.com/path/to/uml/diagram.eap --diagramName "My UML diagram" --versionId "test/1" --outputFormat application/ld+json --publicationEnvironment https://data.vlaanderen.be
oslo-converter-ea --umlFile https://github.com/path/to/uml/diagram.eap --diagramName "My UML diagram" --versionId "test/1" --outputFormat application/ld+json --publicationEnvironment https://data.vlaanderen.be --allTags true
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export class EaUmlConversionServiceRunner extends AppRunner<
default: 'info',
choices: LOG_LEVELS,
})
.option('allTags', {
describe: 'Add all tags from EA to the generated output',
default: false,
boolean: true,
})
.option('debug', {
describe:
'A flag to enable debug mode which is more resilient to errors',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ export class EaUmlConverterConfiguration implements IConfiguration {
*/
private _debug: boolean | undefined;

/**
* A boolean that decided whether or not all tags will be added to the generated output
*/
private _allTags: boolean | undefined;

public async createFromCli(params: YargsParams): Promise<void> {
this._umlFile = <string>params.umlFile;
this._diagramName = <string>params.diagramName;
this._outputFile = <string>(params.outputFile || 'report.jsonld');
this._versionId = <string>params.versionId;
this._outputFormat = <string>params.outputFormat;
this._publicationEnvironment = <string>params.publicationEnvironment;
this._allTags = <boolean>params.allTags;
this._debug = <boolean>params.debug;
}

Expand All @@ -57,7 +63,7 @@ export class EaUmlConverterConfiguration implements IConfiguration {
public get diagramName(): string {
if (!this._diagramName) {
throw new Error(
`Trying to access property "diagramName" before it was set.`
`Trying to access property "diagramName" before it was set.`,
);
}
return this._diagramName;
Expand All @@ -66,7 +72,7 @@ export class EaUmlConverterConfiguration implements IConfiguration {
public get outputFile(): string {
if (!this._outputFile) {
throw new Error(
`Trying to access property "outputFile" before it was set.`
`Trying to access property "outputFile" before it was set.`,
);
}
return this._outputFile;
Expand All @@ -75,7 +81,7 @@ export class EaUmlConverterConfiguration implements IConfiguration {
public get versionId(): string {
if (!this._versionId) {
throw new Error(
`Trying to access property "versionId" before it was set.`
`Trying to access property "versionId" before it was set.`,
);
}
return this._versionId;
Expand All @@ -84,7 +90,7 @@ export class EaUmlConverterConfiguration implements IConfiguration {
public get outputFormat(): string {
if (!this._outputFormat) {
throw new Error(
`Trying to access property "outputFormat" before it was set.`
`Trying to access property "outputFormat" before it was set.`,
);
}
return this._outputFormat;
Expand All @@ -93,12 +99,16 @@ export class EaUmlConverterConfiguration implements IConfiguration {
public get publicationEnvironment(): string {
if (!this._publicationEnvironment) {
throw new Error(
`Trying to access property "publicationEnvironment" before it was set.`
`Trying to access property "publicationEnvironment" before it was set.`,
);
}
return this._publicationEnvironment;
}

public get allTags(): boolean {
return !!this._allTags;
}

public get debug(): boolean {
return !!this._debug;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TagNames } from '../enums/TagNames';
import { ConverterHandler } from '../interfaces/ConverterHandler';
import type { UriRegistry } from '../UriRegistry';
import { getTagValue, ignore, toPascalCase } from '../utils/utils';
import { Language } from '@oslo-flanders/core/lib/enums/Language';

@injectable()
export class ElementConverterHandler extends ConverterHandler<EaElement> {
Expand Down Expand Up @@ -179,6 +180,10 @@ export class ElementConverterHandler extends ConverterHandler<EaElement> {
this.addLabels(object, objectInternalId, this.df.defaultGraph(), quads);
this.addUsageNotes(object, objectInternalId, this.df.defaultGraph(), quads);
this.addStatus(object, objectInternalId, this.df.defaultGraph(), quads);
// Add the remaining tags that are not in TagNames enum if the config requires so.
if (this.config.allTags) {
this.addOtherTags(object, objectInternalId, this.df.defaultGraph(), quads);
}

// To be able to determine the scope of the element,
// we need to compare it to the base URI of the package
Expand Down
Loading
Loading