From 7c824bf84775c3dc7db98c55cecf61491aab7635 Mon Sep 17 00:00:00 2001 From: mdelez <60604010+mdelez@users.noreply.github.com> Date: Thu, 16 Jun 2022 08:56:30 +0200 Subject: [PATCH] fix(link-value): loop through all ontologies of a project to create list of resource classes (#766) --- .../create-link-resource.component.ts | 6 ++++++ .../values/link-value/link-value.component.ts | 20 +++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/app/workspace/resource/operations/create-link-resource/create-link-resource.component.ts b/src/app/workspace/resource/operations/create-link-resource/create-link-resource.component.ts index 2d60e522c6..afbb864e5e 100644 --- a/src/app/workspace/resource/operations/create-link-resource/create-link-resource.component.ts +++ b/src/app/workspace/resource/operations/create-link-resource/create-link-resource.component.ts @@ -127,8 +127,14 @@ export class CreateLinkResourceComponent implements OnInit { case 'audio': this.propertiesObj[Constants.HasAudioFileValue] = [this.fileValue]; break; + case 'movingImage': + this.propertiesObj[Constants.HasMovingImageFileValue] = [this.fileValue]; + break; case 'archive': this.propertiesObj[Constants.HasArchiveFileValue] = [this.fileValue]; + break; + case 'text': + this.propertiesObj[Constants.HasTextFileValue] = [this.fileValue]; } } diff --git a/src/app/workspace/resource/values/link-value/link-value.component.ts b/src/app/workspace/resource/values/link-value/link-value.component.ts index bb1edd47ad..ecf83c758c 100644 --- a/src/app/workspace/resource/values/link-value/link-value.component.ts +++ b/src/app/workspace/resource/values/link-value/link-value.component.ts @@ -14,6 +14,7 @@ import { AbstractControl, FormBuilder, FormControl, FormGroup } from '@angular/f import { MatAutocompleteTrigger } from '@angular/material/autocomplete'; import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; import { + Constants, CreateLinkValue, KnoraApiConnection, ReadLinkValue, @@ -142,8 +143,19 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On ); this._dspApiConnection.v2.ontologyCache.getOntology(this.currentOntoIri).subscribe( - (onto: Map) => { - const resClasses = onto.get(this.currentOntoIri).getClassDefinitionsByType(ResourceClassDefinition); + (ontoMap: Map) => { + + // filter out knorabase ontology + const filteredOntoMap = new Map( + Array.from(ontoMap).filter(([key, _]) => key !== Constants.KnoraApiV2) + ); + + let resClasses = []; + + // loop through each ontology in the project and create an array of ResourceClassDefinitions + filteredOntoMap.forEach( onto => { + resClasses = resClasses.concat(filteredOntoMap.get(onto.id).getClassDefinitionsByType(ResourceClassDefinition)); + }); // add the superclass to the list of resource classes this.resourceClasses = resClasses.filter( @@ -154,7 +166,7 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On // and add them to the list of resource classes this.resourceClasses = this.resourceClasses.concat(this._getSubclasses(resClasses, this.restrictToResourceClass)); - this.properties = onto.get(this.currentOntoIri).getPropertyDefinitionsByType(ResourcePropertyDefinition); + this.properties = filteredOntoMap.get(this.currentOntoIri).getPropertyDefinitionsByType(ResourcePropertyDefinition); }, error => { console.error(error); @@ -263,7 +275,7 @@ export class LinkValueComponent extends BaseValueDirective implements OnInit, On position: { top: '112px' }, - data: { mode: mode, title: resClass.label, id: iri, parentResource: this.parentResource, resourceClassDefinition: resClass.id, ontoIri: this.currentOntoIri }, + data: { mode: mode, title: resClass.label, id: iri, parentResource: this.parentResource, resourceClassDefinition: resClass.id }, disableClose: true };