import { Component, OnInit } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { ParseXmlService } from '../services/parse-xml.service'; import { FormControl, FormGroup } from '@angular/forms'; @Component({ selector: 'app-search', templateUrl: './search.component.html', styleUrls: ['./search.component.scss'] }) export class SearchComponent implements OnInit { public xmlItems: string[][] = []; Form = new FormGroup({ keyword: new FormControl() }); constructor( private http: HttpClient, private parserService: ParseXmlService ) { } ngOnInit(): void { } simpleSearch(){ //effectuer une recherche plein text en SPARL sur la BDD Blazegraph //curl -X POST -H 'Accept: application/rdf+xml' -i 'http://10.6.10.9:8888/blazegraph/sparql' --data 'query=SELECT * where {?s a }' let query: string; // query ='query=SELECT * where {?s a }' query= 'query=PREFIX dcat: \n\ PREFIX dcterms: \n\ SELECT ?title ?description ?uri \n\ where {\n\ ?dataset a dcat:Dataset ;\n\ dcterms:title ?title ;\n\ dcterms:description ?description; \n\ dcat:keyword ?uri ; \n\ FILTER (contains( ?description, "'+ this.Form.value.keyword +'") || contains( ?title, "'+ this.Form.value.keyword +'"))\n\ .\n\ }' this.parserService.getXmlResult("http://10.6.10.9:8888/blazegraph/sparql",query).subscribe( data=>{ if (data){ data.results.bindings.forEach(element => { this.xmlItems.push(element); }); } }) return null; } isXmlItemsEmpty(){ return this.xmlItems.length === 0; } }