Commit 1daa3df5 authored by Paulo's avatar Paulo
Browse files

refactor(code): Form code change 2

parent 5b0c91b8
...@@ -16,57 +16,59 @@ export class SearchComponent implements OnInit { ...@@ -16,57 +16,59 @@ export class SearchComponent implements OnInit {
results: string[][] = []; results: string[][] = [];
//seachForm: FormGroup;
submitted = false;
searchForm = new FormGroup({ searchForm = new FormGroup({
searchTerm: new FormControl() searchTerm: new FormControl()
}); });
constructor(
private parserService: ParseXmlService
) { }
constructor(private parserService: ParseXmlService, private formBuild: FormBuilder) { } ngOnInit(): void {
}
ngOnDestroy(): 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 <http://www.w3.org/ns/dcat#Dataset> }'
let query: string;
// query ='query=SELECT * where {?s a <http://www.w3.org/ns/dcat#Dataset> }'
ngOnInit(): void {}
simpleSearch() { query=
this.submitted = true; 'query=PREFIX dcat: <http://www.w3.org/ns/dcat#>\n\
this.results = []; PREFIX dcterms: <http://purl.org/dc/terms/>\n\
//effectuer une recherche plein text en SPARL sur la BDD Blazegraph SELECT ?title ?description ?uri \n\
//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> }' where {\n\
?dataset a dcat:Dataset ;\n\
dcterms:title ?title ;\n\
dcterms:description ?description; \n\
dcat:keyword ?uri ; \n\
FILTER (contains( ?description, "'+ this.searchForm.value.searchTerm +'") || contains( ?title, "'+ this.searchForm.value.searchTerm +'"))\n\
.\n\
}'
//if (searchData) {
let query: string;
let searchTerm = this.searchForm.get("searchTerm").value
console.log("Log arrived : ", searchTerm)
//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 ?uri \n\
where {\n\
?dataset a dcat:Dataset ;\n\
dcterms:title ?title ;\n\
dcterms:description ?description; \n\
dcat:keyword ?uri ; \n\
FILTER ( contains( ?description, "' + searchTerm + '") || contains( ?title, "' + searchTerm + '"))\n\.\n\
}'
this.parserService.getXmlResult(query).subscribe( this.parserService.getXmlResult(query).subscribe(
data => { data=>{
if (data){ if (data){
console.error("Data", data) this.results = [];
data.results.bindings.forEach(element => { data.results.bindings.forEach(element => {
this.results.push(element); this.results.push(element);
}); });
} }
//console.warn('Data submited ', searchTerm, "Results : ", this.results); })
});
this.searchForm.reset(); this.searchForm.reset();
}
//}
}
isXmlItemsEmpty(){
return this.results.length === 0;
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment