import { Component, OnInit } from '@angular/core'; import { IsService } from '../is.service'; import { ResourceIdentification, TYPE_PROPERTY_KEY } from './resourceidentification'; import { Resource } from '../is-model/reference/entities/Resource'; @Component({ selector: 'app-resource-list', templateUrl: './resource-list.component.html', styleUrls: ['./resource-list.component.css'] }) export class ResourceListComponent implements OnInit { public resources: Map; constructor(private isService: IsService) { } ngOnInit() { this.isService.getResourceInstances('Service', res => { this.resources = this.analyseResources(res); }); } analyseResources(resources: Resource[]): Map { const map = new Map(); for (const resource of resources) { const facetType: string = resource.consistsOf[0].target[TYPE_PROPERTY_KEY]; let resourceIdentification: ResourceIdentification; if (map.has(facetType)) { resourceIdentification = map.get(facetType); } else { resourceIdentification = new ResourceIdentification(facetType); map.set(facetType, resourceIdentification); } resourceIdentification.addResource(resource); } return map; } }