Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFDS-register-front
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dad
FFDS-register-front
Commits
1d8fbc65
Commit
1d8fbc65
authored
4 years ago
by
Administrator
Browse files
Options
Downloads
Patches
Plain Diff
list dataset description in search page
parent
2972aa33
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/search/search.component.html
+3
-2
3 additions, 2 deletions
src/app/search/search.component.html
src/app/search/search.component.ts
+18
-54
18 additions, 54 deletions
src/app/search/search.component.ts
with
21 additions
and
56 deletions
src/app/search/search.component.html
+
3
−
2
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>
...
...
This diff is collapsed.
Click to expand it.
src/app/search/search.component.ts
+
18
−
54
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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment