Skip to content

Commit

Permalink
Update to the respec-generator to also include DataTypes into the o…
Browse files Browse the repository at this point in the history
…verview
  • Loading branch information
KristofVDB1 committed Dec 10, 2024
1 parent 87d1238 commit eec6a67
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class HtmlRespecGenerationService implements IService {
@inject(ServiceIdentifier.Logger) logger: Logger,
@inject(ServiceIdentifier.Configuration)
config: HtmlRespecGenerationServiceConfiguration,
@inject(ServiceIdentifier.QuadStore) store: QuadStore
@inject(ServiceIdentifier.QuadStore) store: QuadStore,
) {
this.logger = logger;
this.configuration = config;
Expand Down Expand Up @@ -99,7 +99,7 @@ export class HtmlRespecGenerationService implements IService {

if (!classObject) {
this.logger.error(
`Unable to find a related class object for domain ${property.domain} of property ${property.assignedUri}.`
`Unable to find a related class object for domain ${property.domain} of property ${property.id}.`,
);
return;
}
Expand All @@ -113,9 +113,21 @@ export class HtmlRespecGenerationService implements IService {
}

private async extractClassInformation(): Promise<any[]> {
const classJobs = this.store.getClassIds();

const datatypeJobs = this.store.findSubjects(
ns.rdf('type'),
ns.rdfs('Datatype'),
);

const classes: RDF.Term[] = await Promise.all(classJobs);
const dataTypes: RDF.Term[] = await Promise.all(datatypeJobs);
const entities = [...classes, ...dataTypes];
const uniqueEntities = Array.from(
new Map(entities.map((entity) => [entity.value, entity])).values(),
);
return (
this.store
.findSubjects(ns.rdf('type'), ns.owl('Class'))
uniqueEntities
// .filter(x => isInScope(<RDF.NamedNode>x, this.store))
.map((subjectId) => {
const assignedUri = this.store.getAssignedUri(subjectId);
Expand All @@ -127,12 +139,12 @@ export class HtmlRespecGenerationService implements IService {
? getApplicationProfileLabel(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
)
: getVocabularyLabel(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
);

const definition =
Expand All @@ -141,12 +153,12 @@ export class HtmlRespecGenerationService implements IService {
? getApplicationProfileDefinition(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
)
: getVocabularyDefinition(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
);

const usageNote =
Expand All @@ -155,12 +167,12 @@ export class HtmlRespecGenerationService implements IService {
? getApplicationProfileUsageNote(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
)
: getVocabularyUsageNote(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
);

const parentAssignedUris: string[] = [];
Expand All @@ -169,7 +181,7 @@ export class HtmlRespecGenerationService implements IService {

if (!parentAssignedUri) {
this.logger.error(
`Unable to find the assigned URI of parent (${parent.value}) of class ${subjectId.value}.`
`Unable to find the assigned URI of parent (${parent.value}) of class ${subjectId.value}.`,
);
} else {
parentAssignedUris.push(parentAssignedUri.value);
Expand Down Expand Up @@ -205,12 +217,12 @@ export class HtmlRespecGenerationService implements IService {
? getApplicationProfileLabel(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
)
: getVocabularyLabel(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
);

const definition =
Expand All @@ -219,12 +231,12 @@ export class HtmlRespecGenerationService implements IService {
? getApplicationProfileDefinition(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
)
: getVocabularyDefinition(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
);

const usageNote =
Expand All @@ -233,34 +245,34 @@ export class HtmlRespecGenerationService implements IService {
? getApplicationProfileUsageNote(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
)
: getVocabularyUsageNote(
subjectId,
this.store,
this.configuration.language
this.configuration.language,
);

const domain = this.store.getDomain(subjectId);
if (!domain) {
throw new Error(
`Unable to find the domain of subject ${subjectId.value}.`
`Unable to find the domain of subject ${subjectId.value}.`,
);
}
const domainAssignedUri = this.store.getAssignedUri(domain);

const range = this.store.getRange(subjectId);
if (!range) {
throw new Error(
`Unable to find the range for subject ${subjectId.value}.`
`Unable to find the range for subject ${subjectId.value}.`,
);
}

let rangeAssignedUri = this.store.getAssignedUri(range);

if (!rangeAssignedUri) {
this.logger.error(
`Unable to find the assigned URI of range (${range.value}) of attribute ${subjectId.value}.`
`Unable to find the assigned URI of range (${range.value}) of attribute ${subjectId.value}.`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/oslo-generator-respec-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/html-respec-generator",
"version": "0.0.15-alpha.0",
"version": "0.0.16-alpha.0",
"description": "Generates an HTML respec file using 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-respec-html#readme",
Expand Down

0 comments on commit eec6a67

Please sign in to comment.