2019-09-30 14:32:24 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2019-10-16 11:02:59 +02:00
|
|
|
import { IsService } from '../is.service';
|
|
|
|
import { ResourceIdentification, TYPE_PROPERTY_KEY } from './resourceidentification';
|
2019-09-30 14:32:24 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-resource-list',
|
|
|
|
templateUrl: './resource-list.component.html',
|
|
|
|
styleUrls: ['./resource-list.component.css']
|
|
|
|
})
|
|
|
|
export class ResourceListComponent implements OnInit {
|
|
|
|
|
2019-10-16 11:02:59 +02:00
|
|
|
public resourceIdentificationList: Array<ResourceIdentification>;
|
|
|
|
|
|
|
|
constructor(private isService: IsService) { }
|
2019-09-30 14:32:24 +02:00
|
|
|
|
|
|
|
ngOnInit() {
|
2019-10-16 11:02:59 +02:00
|
|
|
// this.isService.getIdentifyingFacets('Service', facets => {this.identifyingFacets = facets;});
|
|
|
|
this.isService.getIdentifyingFacets('Service', facets => { this.resourceIdentificationList = this.analyseIdentifyingFacets(facets); });
|
|
|
|
}
|
|
|
|
|
|
|
|
analyseIdentifyingFacets(identifyingFacets: any[]): Array<ResourceIdentification> {
|
|
|
|
|
|
|
|
const map = new Map<string, ResourceIdentification>();
|
|
|
|
const facets = new Array<ResourceIdentification>();
|
|
|
|
|
|
|
|
for (const facet of identifyingFacets) {
|
|
|
|
|
|
|
|
const facetType: string = facet[TYPE_PROPERTY_KEY];
|
|
|
|
let facetList: ResourceIdentification;
|
|
|
|
|
|
|
|
if (map.has(facetType)) {
|
|
|
|
facetList = map.get(facetType);
|
|
|
|
} else {
|
|
|
|
facetList = new ResourceIdentification(facetType);
|
|
|
|
map.set(facetType, facetList);
|
|
|
|
facets.push(facetList);
|
|
|
|
}
|
|
|
|
facetList.add(facet);
|
|
|
|
}
|
|
|
|
|
|
|
|
return facets;
|
2019-09-30 14:32:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|