-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.php
446 lines (423 loc) · 17 KB
/
dev.php
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<?php
/*
Author - Klaas Andries de Graaf
Use of sparqllib.php under LGPL license
*/
/*
Note Author (Klaas Andries de Graaf):
Querys and data is often hardcoded (not dynamic from e.g. CASE tool database) with examples
to allow for easy understanding of code.
Making this fully dynamic + linking it to database/code repository is easy, but introduces more complex code to read for reviewers.
*/
require_once('sparqllib.php');
//$db = sparql_connect('http://dbpedia.org/sparql');
$db = sparql_connect('http://www.archimind.nl/archimindLOD/index.php/sparql');
//$query = "SELECT ?film
//WHERE { ?film <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:French_films> }";
//echo $_POST['query'];
//echo strlen(trim($_POST['query']));
//echo $_POST['query'];
//if ($_POST['query'] !== ""){$query = $_POST['query'];}
if (strlen(trim($_POST['query']))){$query = $_POST['query'];}
else{
$query = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE { ?uri rdf:type AKO:Pattern .
?uri AKO:description ?description .
?uri AKO:knowledge_is_located_in ?wikipage .
?uri rdf:seeAlso ?DBpedia}";
}
$result = sparql_query($query);
$fields = sparql_field_array($result);
//echo $_GET['query'];
?>
<!DOCTYPE html>
<html>
<head>
<title>AK-Finder - Development interface</title>
<link href="layout.css" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
<script src="jquery-3.1.1.min.js"></script>
<script type="text/javascript">
function predefined(question) {
//=============================Question 1===================
var Q1 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT ?components ?datastores ?p ?impl_units \n" +
"WHERE { \n" +
"{?impl_unit_class rdfs:subClassOf AKO:Architecture . \n" +
"?impl_units rdf:type ?impl_unit_class . \n" +
"?components rdf:type AKO:Component . \n" +
"?impl_units ?p ?components} UNION \n" +
"{?impl_unit_class rdfs:subClassOf AKO:Architecture . \n" +
"?impl_units rdf:type ?impl_unit_class . \n" +
"?datastores rdf:type AKO:Data_store . \n" +
"?impl_units ?p ?datastores } \n" +
"} \n" +
"LIMIT 2000";
if (question == 1){$('#query').val(Q1);}
//=============================Question 2===================
var Q2 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT * \n" +
"WHERE { \n" +
"{AKO:"+$('#Q2parameter').val()+" AKO:results_in ?impl_units} UNION \n" +
"{AKO:"+$('#Q2parameter').val()+" AKO:realized_by ?impl_units} UNION \n" +
"{AKO:"+$('#Q2parameter').val()+" AKO:depends_on ?decisions} UNION \n" +
"{AKO:"+$('#Q2parameter').val()+" AKO:addressed_by ?decisions}} \n" +
"LIMIT 2000";
if (question == 2){$('#query').val(Q2);}
//=============================Question 3===================
var Q3 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT DISTINCT ?uri \n" +
"WHERE { ?uri rdf:type AKO:Pattern} \n" +
"LIMIT 2000";
if (question == 3){$('#query').val(Q3);}
//=============================Question 4===================
var Q4 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT ?FuncReq \n" +
"WHERE {{?FuncReq rdf:type AKO:Functional_requirement . \n" +
"?FuncReq ?p AKO:"+$('#Q4parameter').val()+"} UNION \n" +
"{?FuncReq rdf:type AKO:Functional_requirement . \n" +
"AKO:"+$('#Q4parameter').val()+" ?p ?FuncReq }} \n" +
"LIMIT 2000";
if (question == 4){$('#query').val(Q4);}
//=============================Question 5===================
var Q5 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT DISTINCT ?wikipage \n" +
"WHERE { \n" +
"?concern rdf:type AKO:Concern . \n" +
"?concern AKO:knowledge_is_located_in ?wikipage \n" +
"} \n" +
"LIMIT 2000";
if (question == 5){$('#query').val(Q5);}
//=============================requirements realized by architecture===================
var D1 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT ?Req ?AKelement \n" +
"WHERE {{?Req rdf:type AKO:Functional_Requirement} \n" +
"UNION {?Req rdf:type AKO:Non_functional_requirement } \n" +
"OPTIONAL {?Req AKO:realized_by ?AKelement} . \n" +
"FILTER(!bound(?AKelement))} \n" ;
if (question == 6){$('#query').val(D1);}
//=============================decisions not realized===================
var D2 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT ?Req ?decision \n" +
"WHERE {{?Req rdf:type AKO:Functional_Requirement} \n" +
"UNION {?Req rdf:type AKO:Non_functional_requirement } \n" +
"OPTIONAL{?Req AKO:addressed_by ?decision}. \n" +
"FILTER(!bound(?decision))} \n" ;
if (question == 7){$('#query').val(D2);}
//=============================Question 3 - patterns with context - LOD===================
var D3 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT * \n" +
"WHERE { ?uri rdf:type AKO:Pattern . \n" +
"?uri AKO:description ?description . \n" +
"?uri AKO:knowledge_is_located_in ?wikipage . \n" +
"?uri rdf:seeAlso ?DBpedia} \n" ;
if (question == 8){$('#query').val(D3);}
//=============================Other queries================
var X1 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT * \n" +
"LIMIT 2000";
if (question == 60){$('#query').val(X1);}
//=============================CASE 1================
var CASE1 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT DISTINCT ?requirement ?req_name \n" +
"WHERE \n" +
"{AKO:Business_rules_engine AKO:satisfies ?requirement . \n" +
"?requirement rdfs:label ?req_name} ";
if (question == 10){$('#case').val('reqs1'); $('#query').val(CASE1);}
//=============================CASE 2================
var CASE2 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT DISTINCT ?decision ?dec_name \n" +
"WHERE \n" +
"{?decision AKO:decision_is_about AKO:Business_rules_engine . \n" +
"?decision rdfs:label ?dec_name} ";
if (question == 11){$('#case').val('decs1'); $('#query').val(CASE1);}
//=============================CASE 3================
var CASE3 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT DISTINCT ?requirement ?req_name \n" +
"WHERE \n" +
"{AKO:Transformer AKO:satisfies ?requirement . \n" +
"?requirement rdfs:label ?req_name} ";
if (question == 12){$('#case').val('reqs2'); $('#query').val(CASE3);}
//=============================CASE 4================
var CASE4 = "PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:> \n" +
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
"SELECT DISTINCT ?decision ?dec_name \n" +
"WHERE \n" +
"{?decision AKO:decision_is_about AKO:Transformer . \n" +
"?decision rdfs:label ?dec_name} ";
if (question == 13){$('#case').val('decs2'); $('#query').val(CASE4);}
//=============================execute================
//alert('To execute: press "Submit Query"-button in top-right of screen');
$('#submit').click();
/*
$("#wijzigen_form").hide("slow");
$.ajax({
method: "post",url: "wijzig.php",data:
"gebruikers_id="+gebruikers_id+"&voornaam="+voornaam+"&naam="+naam+"&adres="+adres+"&geslacht="+geslacht+"&wijknr="+wijknr+"&activiteit="+activiteit+"&beroep="+beroep+"&telefoonnummer="+telefoonnummer+"&toelichting="+toelichting,
beforeSend: function(){},
complete: function(){},
success: function(html){
$("#wijzigen_form").html(html);
$("#wijzigen_form").show("slow");
}
}); //close $.ajax(
}
*/
}
</script>
</head>
<body>
<center><h2>AK-Finder - Architectural Knowledge Finder</h2></center>
<div id='menu' style="background-color: lightgreen; font-size: 150%;">
<center>
<table style="width:100%; text-align: center;">
<th>
<td> <a href="index.php">Index</a> </td>
<td> <a href="review.php">Review interface</a> </td>
<td> <a href="design.php">Design interface</a> </td>
<td> <b>Development interface</b> </td>
</th>
</table>
<center>
</div>
<div id='casediv' style="background-color: lightblue;">
<h2>Development interface</h2>
<b>Tasks</b> <br />
<ul>
<li>Implement component <b>Business rules engine</b> (<a href='http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl%3ABusiness_rules_engine' target='_blank'>See knowledge in ArchiMind</a>)
<?php
if ($_POST['case'] == 'reqs1'){
echo " <br \>- [Related requirements in ArchiMind: ";
if (sparql_num_rows( $result ) > 0)
{
while($row = sparql_fetch_array($result))
{
foreach($fields as $field)
{
if(strpos($row[$field], "ttp:") !== false)
{echo "<a href='".$row[$field] . "' target='_blank'>";}
else
{echo $row[$field] . "</a>, ";}
//print"$row[$field] <br\>";
}
}
}
else
{
echo '<b>ARCHITECTURAL RULE VIOLATION - NO RELATED REQUIREMENTS <a href="http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl%3ABusiness_rules_engine" target="_blank">Change</a></b>';
}
echo '] <br \>- <a href="#" onclick="predefined(11);">[find related decisions in ArchiMind]</a>';
}
else if ($_POST['case'] == 'decs1'){
echo ' <br \>- <a href="#" onclick="predefined(10);">[find related requirements in ArchiMind]</a> <br \>- [Related decisions in ArchiMind: ';
if (sparql_num_rows( $result ) > 0)
{
while($row = sparql_fetch_array($result))
{
foreach($fields as $field)
{
if(strpos($row[$field], "ttp:") !== false)
{echo "<a href='".$row[$field] . "' target='_blank'>";}
else
{echo $row[$field] . "</a>, ";}
//print"$row[$field] <br\>";
}
}
}
else
{
echo '<b>ARCHITECTURAL RULE VIOLATION - NO RELATED DECISIONS <a href="http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl%3ABusiness_rules_engine" target="_blank">Change</a></b>';
}
echo '] ';
}
else{
echo ' <br \>- <a href="#" onclick="predefined(10);">[find related requirements in ArchiMind]</a> <br \>- <a href="#" onclick="predefined(11);">[find related decisions in ArchiMind]</a>';
}
?>
<br \>[Link to code repository] [Link to JIRA project planning]
<br \>[Notes:]
<textarea rows="3" cols="40" name="notes" id="notes">Get rules from business stakeholders. Check with finance.</textarea>
[comments:]
<textarea rows="3" cols="40" name="notes" id="notes">Goes in release 3.01.x.</textarea>
[Reply]<br \>
<br \>
</li>
<li>Implement component <b>Transformer (business)</b> (<a href='http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl%3ATransformer' target='_blank'>See knowledge in ArchiMind</a>)
<?php
if ($_POST['case'] == 'reqs2'){
echo " <br \>- [Related requirements in ArchiMind: ";
if (sparql_num_rows( $result ) > 0)
{
while($row = sparql_fetch_array($result))
{
foreach($fields as $field)
{
if(strpos($row[$field], "ttp:") !== false)
{echo "<a href='".$row[$field] . "' target='_blank'>";}
else
{echo $row[$field] . "</a>, ";}
//print"$row[$field] <br\>";
}
}
}
else
{
echo '<b>ARCHITECTURAL RULE VIOLATION - NO RELATED REQUIREMENTS <a href="http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl%3ATransformer" target="_blank">Change</a>]</b>';
}
echo '] <br \> - <a href="#" onclick="predefined(13);">[find related decisions in ArchiMind]</a>';
}
else if ($_POST['case'] == 'decs2'){
echo ' <br \>- <a href="#" onclick="predefined(12);">[find related requirements in ArchiMind]</a> <br \>- [Related decisions in ArchiMind: ';
if (sparql_num_rows( $result ) > 0)
{
while($row = sparql_fetch_array($result))
{
foreach($fields as $field)
{
if(strpos($row[$field], "ttp:") !== false)
{echo "<a href='".$row[$field] . "' target='_blank'>";}
else
{echo $row[$field] . "</a>, ";}
//print"$row[$field] <br\>";
}
}
}
else
{
echo '<b>ARCHITECTURAL RULE VIOLATION - NO RELATED DECISIONS <a href="http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl%3ATransformer" target="_blank">Change</a></b>';
}
echo ']';
}
else{
echo ' <br \>- <a href="#" onclick="predefined(12);">[find related requirements in ArchiMind]</a> <br \>- <a href="#" onclick="predefined(13);">[find related decisions in ArchiMind]</a>';
}
?>
<br \>[Link to code repository] [Link to JIRA project planning]
<br \>[Notes]
<textarea rows="5" cols="40" name="notes" id="notes">Transformation in DL.</textarea>
[comments:]
<textarea rows="5" cols="40" name="notes" id="notes">Goes in release 2.02.x.</textarea>
[Reply]
</li>
</ul>
<div id="editor">
<br />
<b>SPARQL Query Editor</b>
<form action="dev.php" method="POST">
<textarea rows="15" cols="100" name="query" id="query"><?php echo $_POST['query'];
if ($_POST['query'] == '')
{?>PREFIX AKO: <http://www.archimind.nl/archimindLOD/index.php/view/r/sadocontology1.owl:>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE { ?uri rdf:type AKO:Pattern .
?uri AKO:description ?description .
?uri AKO:knowledge_is_located_in ?wikipage .
?uri rdf:seeAlso ?DBpedia}
<?php
}
?></textarea>
<br/>
<input type="hidden" type="text" id="case" name="case">
<input class="button-groot" type="submit" id="submit" name="submit" value="submit">
</form>
</center>
<?php
if($_POST['case'] == 'decs1' || $_POST['case'] == 'reqs1' || $_POST['case'] == 'decs2' || $_POST['case'] == 'reqs2')
{
$result = sparql_query($query);
$fields = sparql_field_array($result);
}
print "<p>Number of results: ".sparql_num_rows( $result )." results.</p>";
print "<table class='CSSTableGenerator' border='1'>";
print "<tr>";
foreach( $fields as $field )
{
print "<th>$field</th>";
}
print "</tr>";
while( $row = sparql_fetch_array( $result ) )
{
print "<tr>";
foreach( $fields as $field )
{
if(strpos($row[$field], "ttp:") !== false)
{print "<td><a href='".$row[$field] . "' target='_blank'>" . $row[$field] . "</a></td>";}
else
{print "<td>$row[$field]</td>";}
}
print "</tr>";
}
print "</table>";
/*
while($row = sparql_fetch_array($result))
{
foreach($fields as $field)
{
if(strpos($row[$field], "ttp:") !== false)
{echo "<a href='".$row[$field] . "' target='_blank'>" . $row[$field] . "</a><br/>";}
else
{echo $row[$field] . "<br/>";}
//print"$row[$field] <br\>";
}
}
*/
?>
<b><a id='refresh' href='http://softcode.nl/querytool/index.php'>refresh</a></b>
</div>
</div>
<?php
//echo $_POST['case'];
//echo $_POST['query'];
if($_POST['case'] != '')
{
// echo "test";
?>
<script type="text/javascript">
$(function() {
//alert('test');
$("#casediv").focus();
});
</script>
<?php
} else if($_POST['query'] != '')
{
?>
<script type="text/javascript">
$(function() {
//alert('test1');
$("#refresh").focus();
});
</script>
<?php
}
?>
</body>
</html>