Skip to content

Commit

Permalink
Introduced the specificationType flag for the `oslo-webuniversum-ge…
Browse files Browse the repository at this point in the history
…nerator` and migrated the `SpecificationType` enum to the `oslo-core`
  • Loading branch information
KristofVDB1 committed Nov 6, 2024
1 parent d4877ff commit 00cb717
Show file tree
Hide file tree
Showing 23 changed files with 255 additions and 96 deletions.
4 changes: 2 additions & 2 deletions packages/oslo-converter-stakeholders/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/stakeholders-converter",
"version": "0.0.16-alpha.0",
"version": "0.0.17-alpha.0",
"description": "Converts an OSLO stakeholders csv file to a different format",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-converter-stakeholders-oslo#readme",
Expand Down Expand Up @@ -29,7 +29,7 @@
"url": "https://github.com/Informatievlaanderen/OSLO-UML-Transformer/issues"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"csv-parse": "^5.3.6",
"inversify": "^6.0.1",
"reflect-metadata": "^0.1.13",
Expand Down
4 changes: 2 additions & 2 deletions packages/oslo-converter-uml-ea/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/ea-converter",
"version": "0.0.33-alpha.0",
"version": "0.0.34-alpha.0",
"description": "Transform an Enterprise Architect UML diagram to RDF",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-converter-uml-ea#readme",
Expand Down Expand Up @@ -41,7 +41,7 @@
"jest-runner-groups": "^2.2.0"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"@oslo-flanders/ea-uml-extractor": "^0.0.27-alpha.0",
"@oslo-flanders/output-handlers": "^0.0.4-alpha.0",
"inversify": "^6.0.1",
Expand Down
1 change: 1 addition & 0 deletions packages/oslo-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './lib/store/QuadStore';
export * from './lib/ServiceIdentifier';
export * from './lib/enums/Scope';
export * from './lib/enums/PropertyTypes';
export * from './lib/enums/specificationType';
export * from './lib/logging/LogLevel';
export * from './lib/logging/Logger';
export * from './lib/logging/VoidLogger';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum SpecificationType {
ApplicationProfile,
Vocabulary
Vocabulary,
}
2 changes: 1 addition & 1 deletion packages/oslo-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/core",
"version": "0.0.17-alpha.0",
"version": "0.0.18-alpha.0",
"description": "Core interfaces and utilities",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-core#readme",
Expand Down
4 changes: 2 additions & 2 deletions packages/oslo-extractor-uml-ea/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/ea-uml-extractor",
"version": "0.0.28-alpha.0",
"version": "0.0.29-alpha.0",
"description": "Reads all the information from an Enterprise Architect UML diagram",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-extract-uml-ea#readme",
Expand Down Expand Up @@ -31,7 +31,7 @@
"url": "https://github.com/Informatievlaanderen/OSLO-UML-Transformer/issues"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"alasql": "4.5.2",
"inversify": "^6.0.1",
"mdb-reader": "github:Informatievlaanderen/mdb-reader",
Expand Down
4 changes: 2 additions & 2 deletions packages/oslo-generator-examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/examples-generator",
"version": "0.0.2-alpha.0",
"version": "0.0.3-alpha.0",
"description": "Generates examples based on an OSLO JSON-LD file",
"author": "Kristof Vandenbroucke <kristof.vandenbroucke@vlaanderen.be>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-examples#readme",
Expand Down Expand Up @@ -36,7 +36,7 @@
"url": "https://github.com/Informatievlaanderen/OSLO-UML-Transformer/issues"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"inversify": "^6.0.1",
"n3": "^1.17.2",
"rdf-data-factory": "^1.1.2",
Expand Down
1 change: 0 additions & 1 deletion packages/oslo-generator-html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export * from './lib/HtmlGenerationService';
export * from './lib/HtmlGenerationServiceRunner';
export * from './lib/config/DependencyInjectionConfig';
export * from './lib/config/HtmlGenerationServiceConfiguration';
export * from './lib/utils/specificationTypeEnum';
4 changes: 2 additions & 2 deletions packages/oslo-generator-html/lib/HtmlGenerationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ export class HtmlGenerationService implements IService {

let data: any = {};

const { baseURI, entities, classes, dataTypes, properties } = config;

const { baseURI, classes, dataTypes, properties } = config;

data = {
...data,
baseURI,
entities,
classes,
dataTypes,
properties,
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions packages/oslo-generator-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/html-generator",
"version": "0.0.26-alpha.0",
"version": "0.0.27-alpha.0",
"description": "Generates an HTML file using an OSLO webuniversum config",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-html#readme",
Expand Down Expand Up @@ -35,7 +35,7 @@
"url": "https://github.com/Informatievlaanderen/OSLO-UML-Transformer/issues"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"inversify": "^6.0.1",
"n3": "^1.16.4",
"nunjucks": "^3.2.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/oslo-generator-json-webuniversum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ The service is executed from the CLI and expects the following parameters:
| `--language` | The language in which the config must be generated | :heavy_check_mark: | |
| `--applyFiltering` | Wether or not to apply filters on the generated output. The filters limit the generated classes, datatypes, entities and properties that will be shown. If you just want all possible values, you can set the value to `false`. | No, default `true` | `true` or `false` |
| `--publicationEnvironment` | The base URI of environment where the document will be published | :heavy_check_mark: | |
| `--specificationType` | The type of specification | No, defaults to `Vocabulary` | `ApplicationProfile` or `Vocabulary`|

## Usage

```bash
oslo-webuniversum-json-generator --input report.jsonld --language nl --publicationEnvironment https://data.vlaanderen.be
oslo-webuniversum-json-generator --input report.jsonld --language nl --applyFiltering false --publicationEnvironment https://data.vlaanderen.be
oslo-webuniversum-json-generator --input report.jsonld --language nl --applyFiltering false --publicationEnvironment https://data.vlaanderen.be --specificationType ApplicationProfile
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ns,
getMinCount,
getMaxCount,
SpecificationType,
} from '@oslo-flanders/core';
import { inject, injectable } from 'inversify';
import { JsonWebuniversumGenerationServiceConfiguration } from './config/JsonWebuniversumGenerationServiceConfiguration';
Expand Down Expand Up @@ -101,10 +102,12 @@ export class JsonWebuniversumGenerationService implements IService {

template = {
...template,
// In package classes and in publication Environment classes
classes: sortWebuniversumObjects(
[...inPublicationEnvironmentClasses, ...inPackageClasses],
this.configuration.language
classes: this.getFilteredClasses(
classes,
inPublicationEnvironmentClasses,
inPackageClasses,
this.configuration.language,
this.configuration.specificationType
),
// scoped data types
dataTypes: sortWebuniversumObjects(
Expand Down Expand Up @@ -149,6 +152,25 @@ export class JsonWebuniversumGenerationService implements IService {
return inPackageUri;
}

// AP needs to show all classes (no scope filtering)
// In package classes and in publication Environment classes
// Introduce a new parameter similar to html-generation-service
private getFilteredClasses(
classes: WebuniversumObject[],
inPublicationEnvironmentClasses: WebuniversumObject[],
inPackageClasses: WebuniversumObject[],
language: string,
specificationType: SpecificationType
): WebuniversumObject[] {
if (specificationType === SpecificationType.ApplicationProfile) {
return sortWebuniversumObjects(classes, language);
}
return sortWebuniversumObjects(
[...inPublicationEnvironmentClasses, ...inPackageClasses],
language
);
}

private getBaseURI(): string {
const packageSubject: RDF.Term = <RDF.Term>(
this.store.findQuad(null, ns.rdf('type'), ns.oslo('Package'))?.subject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export class JsonWebuniversumGenerationServiceRunner extends AppRunner<
default: true,
boolean: true,
})
.option('specificationType', {
describe:
'The specification type to generate the webuniversum config for',
choices: ['ApplicationProfile', 'Vocabulary'],
default: 'Vocabulary',
})
.option('publicationEnvironment', {
describe:
'The base URI of environment where the document will be published',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { IConfiguration, YargsParams } from '@oslo-flanders/core';
import { SpecificationType } from '@oslo-flanders/core';
import { injectable } from 'inversify';

@injectable()
Expand Down Expand Up @@ -31,12 +32,21 @@ export class JsonWebuniversumGenerationServiceConfiguration
*/
private _publicationEnvironment: string | undefined;

/**
* The specification that must be generated: an application profile
* or vocabulary.
*/
private _specificationType: SpecificationType | undefined;

public async createFromCli(params: YargsParams): Promise<void> {
this._input = <string>params.input;
this._output = <string>params.output;
this._language = <string>params.language;
this._applyFiltering = <boolean>params.applyFiltering;
this._publicationEnvironment = <string>params.publicationEnvironment;
this._specificationType = this.getSpecificationType(
<string>params.specificationType
);
}

public get input(): string {
Expand Down Expand Up @@ -72,4 +82,28 @@ export class JsonWebuniversumGenerationServiceConfiguration
}
return this._publicationEnvironment;
}

public get specificationType(): SpecificationType {
if (this._specificationType === undefined) {
throw new Error(
`Trying to access property "specificationType" before it was set.`
);
}
return this._specificationType;
}

private getSpecificationType(value: string): SpecificationType {
switch (value) {
case 'Vocabulary':
return SpecificationType.Vocabulary;

case 'ApplicationProfile':
return SpecificationType.ApplicationProfile;

default:
throw new Error(
`Unable to translate ${value} to a specification type.`
);
}
}
}
4 changes: 2 additions & 2 deletions packages/oslo-generator-json-webuniversum/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/json-webuniversum-generator",
"version": "0.0.14-alpha.0",
"version": "0.0.15-alpha.0",
"description": "Generates a JSON file which is used to generate an HTML template using Webuniversum 3",
"author": "Dwight Van Lancker <dwight.vanlancker@vlaanderen.be>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-json-webuniversum#readme",
Expand Down Expand Up @@ -30,7 +30,7 @@
"url": "https://github.com/Informatievlaanderen/OSLO-UML-Transformer/issues"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"inversify": "^6.0.1",
"n3": "^1.17.2",
"rdf-data-factory": "^1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/oslo-generator-jsonld-context/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/jsonld-context-generator",
"version": "0.0.12-alpha.0",
"version": "0.0.13-alpha.0",
"description": "Generates a JSON-LD context file from an OSLO-compliant RDF file",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-jsonld-context#readme",
Expand Down Expand Up @@ -39,7 +39,7 @@
"@rdfjs/types": "^1.1.0"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"inversify": "^6.0.1",
"n3": "^1.16.2",
"rdf-data-factory": "^1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/oslo-generator-rdf-vocabulary/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/rdf-vocabulary-generator",
"version": "0.0.14-alpha.0",
"version": "0.0.15-alpha.0",
"description": "Transform an Enterprise Architect UML diagram to RDF",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-rdf-vocabulary#readme",
Expand Down Expand Up @@ -40,7 +40,7 @@
"@types/streamify-array": "^1.0.0"
},
"dependencies": {
"@oslo-flanders/core": "^0.0.17-alpha.0",
"@oslo-flanders/core": "^0.0.18-alpha.0",
"inversify": "^6.0.1",
"n3": "^1.16.2",
"rdf-data-factory": "^1.1.1",
Expand Down
1 change: 0 additions & 1 deletion packages/oslo-generator-respec-html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export * from './lib/config/DependencyInjectionConfig';
export * from './lib/config/HtmlRespecGenerationServiceConfiguration';
export * from './lib/utils/scopeFilter';
export * from './lib/utils/alphabeticalSort';
export * from './lib/utils/specificationTypeEnum';
Loading

0 comments on commit 00cb717

Please sign in to comment.