-
Notifications
You must be signed in to change notification settings - Fork 1
/
mission.html
207 lines (166 loc) · 7.74 KB
/
mission.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="lib/fabric.min.js"></script>
<script src="mission.js" defer type="module"></script>
<link rel="stylesheet" href="./bordure.css">
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="https://unpkg.com/gridjs/dist/theme/mermaid.min.css">
<title>Projet Nodelink</title>
<script type="module">
import {recolt_Data, executeSPARQLRequest, table_creator, color_merger, nodelink_creator, buildNodes, buildLinks, buildLegend} from "./mission.js"
const endpointUrl = 'http://localhost:8080/sparql'
const query = recolt_Data()
let dataset = await fetch(endpointUrl + '?query=' + encodeURIComponent(query), {
headers: {
'Accept': 'application/sparql-results+json'
}
})
.then(response => response.json())
.catch(error => console.error(error))
console.log(dataset)
let dataset_bis = await fetch("http://localhost:8082/sparqljs?uri=" + encodeURIComponent(query))
.then(response => response.json())
.catch(error => console.error(error))
console.log(dataset_bis)
/*
fetch('post_corese.xml')
.then(response => response.text())
.then(data => {
const parser = new DOMParser()
const xml = parser.parseFromString(data, 'text/xml')
const results = xml.querySelectorAll('result')
console.log(results)
results.forEach(result => {
console.log(result)
let row = ''
let output
Array.from(result.children).forEach(element => {
row += `<td>${element.tagName}: ${element.textContent}</td>`
})
output += `<tr>${row}</tr>`
})
})
/*
document.addEventListener('DOMContentLoaded', function() {
let send_button = document.querySelector('#recolt_request')
send_button.addEventListener('click', async function(event) {
event.preventDefault()
const dataset = await executeSPARQLRequest("http://prod-dekalog.inria.fr/sparql", recolt_Data())
const result_data = dataset.results.bindings
const edge_test = [
{source : "s", target : "o", relation : "p", color : ["red", "blue"], color_link : "gold"},
{source : "o", target : "p", relation : "s", color : ["green", "purple"], color_link : "silver"}
]
const nodes = buildNodes(result_data, edge_test)
const links = buildLinks(result_data, edge_test)
let dataset_nodelink = {nodes : nodes, links : links}
table_creator(dataset_nodelink)
nodelink_creator(dataset_nodelink)
})
})
Allow to create the dataset with an input to the button. In comment for the tests for a faster execution.
const dataset = await executeSPARQLRequest("http://prod-dekalog.inria.fr/sparql", recolt_Data())
*/
const result_data = dataset.results.bindings
const edges = [
{source : "team", target : "proportionMenInCity", relation : "totalPeople", color_link : "silver"}
]
const nodes = buildNodes(result_data, edges)
const links = buildLinks(result_data, edges)
const legend = buildLegend(edges)
/*
const result_data = dataset.results.bindings
const edge_test = [
{source : "s", target : "o", relation : "p", color_link : "gold"},
{source : "p", target : "s", relation : "o", color_link : "silver"}
]
const nodes = buildNodes(result_data, edge_test)
const links = buildLinks(result_data, edge_test)
const legend = buildLegend(edge_test)
*/
const dataset_nodelink = {nodes : nodes, links : links, legend : legend}
table_creator(dataset_nodelink)
nodelink_creator(dataset_nodelink)
/* The next part is a 2nd test dataset, less usefull but kept for faster use if needed.
const dataset_bis = {
nodes: [
{id: 1, label: "https://id.nlm.nih.gov/mesh/sparql", color : "red"},
{id: 2, label: "https://ldf.fi/mufi/sparql", color : "red"},
{id: 3, label: "https://jsu.eagle-i.net/sparqler/sparql", color : "red"},
{id: 4, label: "https://ld.cultural.jp/sparql", color : "red"},
{id: 5, label: "https://lingualibre.org/bigdata/namespace/wdq/sparql", color : "red"},
{id: 6, label: "http://linkeddata.finki.ukim.mk/sparql", color : "red"},
{id: 7, label: "https://montana.eagle-i.net/sparqler/sparql", color : "red"},
{id: 8, label: "https://lingualibre.fr/bigdata/namespace/wdq/sparql", color : "red"},
{id: 9, label: "SPARQL10", color : "blue"},
{id: 10, label: "SPARQL11", color : "blue"}
],
links: [
{source: 1, target: 9, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
{source: 2, target: 9, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
{source: 3, target: 9, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
{source: 4, target: 10, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
{source: 5, target: 10, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
{source: 6, target: 10, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
{source: 7, target: 9, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
{source: 8, target: 9, label : "http://www.w3.org/1999/02/22-rdf-syntax-ns#value", color : "gold"},
]
}
//nodelink_creator(dataset_bis)
PREFIX ex_ont: <http://example.org/ontology#>
SELECT ?s ?city
WHERE {
?s ex_ont:city ?city
}
*/
</script>
</head>
<body>
<div style>
<label for="user_text">Please enter the SparQL request</label><br>
<textarea id="user_text" name="user_message" rows="10">
PREFIX ex: <http://example.org/>
PREFIX ex_ont: <http://example.org/ontology#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?team
(COALESCE(?nbMenInCity, 0) AS ?nbMenInCity)
(COALESCE(?totalPeople, 0) AS ?totalPeople)
(COALESCE((?nbMenInCity / ?totalPeople), 0) AS ?proportionMenInCity)
WHERE {
{
SELECT ?team (COUNT(?Person) AS ?totalPeople)
WHERE {
?Person ex_ont:team ?team .
}
GROUP BY ?team
}
OPTIONAL {
SELECT ?team (COUNT(?Person) AS ?nbMenInCity)
WHERE {
?Person foaf:gender foaf:Man ;
ex_ont:team ?team ;
ex_ont:city ex:Nice .
}
GROUP BY ?team
}
}
GROUP BY ?team ?nbMenInCity ?totalPeople
</textarea><br>
<button id="recolt_request">Send</button>
</div>
<div class = "table_svg_container" style = "display: flex;">
<div class = "table_container" style = "display: flex;">
<table id = "result_table" border="1" cellpadding="5" class = "table"></table>
</div>
<div class = "graph_container" style = "display: flex;" padding = "0 2rem">
<svg id = "nodelink_graph" style = "display: flex;" class = "svg_container"></svg>
</div>
</div>
<div id = "div_labels" height = 150px style = "display: flex;">
<p id = "labels" style = "display: flex;"></p>
</div>
</body>
</html>