Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dad
FFDS-register-front
Commits
1d8fbc65
Commit
1d8fbc65
authored
Sep 28, 2020
by
Administrator
Browse files
list dataset description in search page
parent
2972aa33
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/app/search/search.component.html
View file @
1d8fbc65
...
...
@@ -7,11 +7,12 @@
<div
*ngIf=
"!isXmlItemsEmpty()"
class=
"w3-container"
>
<table
class=
"w3-table-all w3-card-4"
>
<thead>
<tr
style=
"text-align: center;"
>
Uri d
ataset
</tr>
<tr
style=
"text-align: center;"
>
D
ataset
description
</tr>
</thead>
<tbody>
<tr
*ngFor=
"let item of xmlItems"
>
<td>
{{item}}
</td>
<td>
{{item.title.value}}
</td>
<td>
{{item.description.value}}
</td>
</tr>
</tbody>
</table>
...
...
src/app/search/search.component.ts
View file @
1d8fbc65
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
HttpClient
,
HttpHeaders
}
from
'
@angular/common/http
'
;
import
xml2js
from
'
xml2js
'
;
import
{
ParseXmlService
}
from
'
../services/parse-xml.service
'
;
...
...
@@ -15,7 +14,7 @@ import { ParseXmlService } from '../services/parse-xml.service';
export
class
SearchComponent
implements
OnInit
{
public
xmlItems
:
string
[]
=
[];
public
xmlItems
:
string
[]
[]
=
[];
constructor
(
private
http
:
HttpClient
,
...
...
@@ -30,68 +29,33 @@ export class SearchComponent implements OnInit {
//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
;
let
parser
=
new
xml2js
.
Parser
();
query
=
'
query=SELECT * where {?s a <http://www.w3.org/ns/dcat#Dataset> }
'
const
httpOptions
=
{
headers
:
new
HttpHeaders
({
'
Accept
'
:
'
application/rdf+xml
'
,
'
Content-Type
'
:
'
application/x-www-form-urlencoded
'
,
'
responseType
'
:
'
text
'
})
};
/*
this.http.post("http://10.6.10.9:8888/blazegraph/sparql",
query,
{headers: new HttpHeaders()
.set('Content-Type', 'aapplication/rdf+xml')
.set('Content-Type', 'application/x-www-form-urlencoded')
.append('Access-Control-Allow-Methods', 'POST')
.append('Access-Control-Allow-Origin', 'http://localhost:4200')
.append('Access-Control-Allow-Headers', "Access-Control-Allow-Headers, Access-Control-Allow-Origin, Access-Control-Request-Method")
})
.subscribe((data) => {
this.parseXML(data)
.then((data) => {
this.xmlItems = data;
});
}); */
// 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\
}
'
this
.
parserService
.
getXmlResult
(
"
http://10.6.10.9:8888/blazegraph/sparql
"
,
query
).
subscribe
(
data
=>
{
if
(
data
){
console
.
log
(
"
Data :
"
,
data
.
results
.
bindings
[
0
].
s
.
value
);
data
.
results
.
bindings
.
forEach
(
element
=>
{
console
.
log
(
"
element :
"
,
element
.
s
.
value
)
this
.
xmlItems
.
push
(
element
.
s
.
value
);
this
.
xmlItems
.
push
(
element
);
});
}
})
return
null
;
}
parseXML
(
data
)
{
return
new
Promise
(
resolve
=>
{
let
k
:
string
|
number
,
arr
=
[],
parser
=
new
xml2js
.
Parser
(
{
trim
:
true
,
explicitArray
:
true
});
parser
.
parseString
(
data
,
(
err
,
result
)
=>
{
console
.
error
(
"
Object found :
"
,
result
);
var
obj
=
result
.
results
;
for
(
k
in
obj
.
result
.
bindings
.
s
)
{
var
item
=
obj
.
result
.
bindings
.
s
[
k
];
arr
.
push
({
uri
:
item
.
uri
[
0
]
});
}
resolve
(
arr
);
});
});
}
isXmlItemsEmpty
(){
return
this
.
xmlItems
.
length
===
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment