Skip to content
Permalink
Browse files
fix(link-value): loop through all ontologies of a project to create l…
…ist of resource classes (#766)
  • Loading branch information
mdelez committed Jun 16, 2022
1 parent 9c83b7e commit 7c824bf84775c3dc7db98c55cecf61491aab7635
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
@@ -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];
}
}

@@ -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<string, ReadOntology>) => {
const resClasses = onto.get(this.currentOntoIri).getClassDefinitionsByType(ResourceClassDefinition);
(ontoMap: Map<string, ReadOntology>) => {

// 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
};

0 comments on commit 7c824bf

Please sign in to comment.