import {Injectable} from '@angular/core';

import ontology from '../../data/rural_attractiveness.owl.json';
import {DatasetDescriptor} from './metadata-dialog.component';

@Injectable({providedIn: 'root'})
export class MetadataDialogService {
  constructor() {}
  
  loadDatasetMetadata(datasetName: string): DatasetDescriptor {
    console.log(ontology);
    const ontoInfo = ontology.find((subject) => subject['http://www.w3.org/2000/01/rdf-schema#label']?.find((label) => label['@value']?.includes(datasetName)))
    console.log(ontoInfo);
    //TODO: the returned values must reflect possibility of multi-values (e.g. coverage CZ + EU)
    return {
      title: datasetName,
      coverage: ontoInfo['http://www.semanticweb.org/attractiveness/hasCoverage'][0]['@id'] ?? null,
      link: ontoInfo['http://www.semanticweb.org/attractiveness/link'][0]['@value'] ?? null,
      lod: ontoInfo['http://www.semanticweb.org/attractiveness/hasLoD'][0]['@id'] ?? null,
      source: ontoInfo['http://www.semanticweb.org/attractiveness/hasSource'][0]['@id'] ?? null,
      update: ontoInfo['http://www.semanticweb.org/attractiveness/update'][0]['@value'] ?? null
    };
  }
}
