search.component.ts 1.47 KB
Newer Older
Administrator's avatar
Administrator committed
1
import { Component, OnInit } from '@angular/core';
Administrator's avatar
Administrator committed
2
import { HttpClient, HttpHeaders } from '@angular/common/http';
3
import { ParseXmlService } from '../services/parse-xml.service';
Administrator's avatar
Administrator committed
4
5
6
7
8
9
10
11
12
13
14
15


@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.scss']
})



export class SearchComponent implements OnInit {

Administrator's avatar
Administrator committed
16

17
  public xmlItems: string[][] = []; 
Administrator's avatar
Administrator committed
18
19

  constructor(
20
21
    private http: HttpClient,
    private parserService: ParseXmlService
Administrator's avatar
Administrator committed
22
  ) { }
Administrator's avatar
Administrator committed
23
24
25
26

  ngOnInit(): void {
  }

Administrator's avatar
Administrator committed
27
28
29
30
  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 <http://www.w3.org/ns/dcat#Dataset> }'

Administrator's avatar
Administrator committed
31
     let query: string;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//     query ='query=SELECT * where {?s a <http://www.w3.org/ns/dcat#Dataset> }'
     


query= 
'query=PREFIX dcat: <http://www.w3.org/ns/dcat#>\n\
PREFIX dcterms: <http://purl.org/dc/terms/>\n\
SELECT  ?title ?description\n\
where {\n\
?dataset a dcat:Dataset ;\n\
dcterms:title ?title ;\n\
dcterms:description ?description.\n\
}'


47
48
49
50
      this.parserService.getXmlResult("http://10.6.10.9:8888/blazegraph/sparql",query).subscribe(
        data=>{
          if (data){
            data.results.bindings.forEach(element => {
51
              this.xmlItems.push(element);
52
53
54
            });
          }
        })
Administrator's avatar
Administrator committed
55
      return null;
Administrator's avatar
Administrator committed
56
57
  }

58

Paulo's avatar
Paulo committed
59
60
61
  isXmlItemsEmpty(){
    return this.xmlItems.length === 0;
  } 
Administrator's avatar
Administrator committed
62
63

}