Skip to content

Commit 9503751

Browse files
committed
Add button to stop a running extraction in order to repeat it for issue #3.
- Fix jQuery sliders to be initialized correctly. - Add endpoint requirements to start page. - Add missing order to sparql query for referring types. - Use ES6 template strings in query factory.
1 parent 8640036 commit 9503751

File tree

8 files changed

+108
-93
lines changed

8 files changed

+108
-93
lines changed

app/components/graph/graph.ctrl.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
* @param StopWatch
1818
* @param Data
1919
* @param View
20+
* @param Promises
2021
*/
2122
function graphCtrl($scope, $q, $location, $log, Filters, ClassExtractor, RelationExtractor, TypeExtractor,
22-
DetailExtractor, Requests, RequestConfig, Prefixes, StopWatch, Data, View) {
23+
DetailExtractor, Requests, RequestConfig, Prefixes, StopWatch, Data, View, Promises) {
2324
'ngInject';
2425

2526
/* jshint validthis: true */
@@ -133,6 +134,14 @@ function graphCtrl($scope, $q, $location, $log, Filters, ClassExtractor, Relatio
133134
}
134135
};
135136

137+
/**
138+
* Stop the extraction by rejecting all promises.
139+
*/
140+
vm.stopLoading = function () {
141+
Promises.rejectAll();
142+
StopWatch.stop();
143+
};
144+
136145
/**
137146
* First clear all loaded data, then restart Loading
138147
*/
@@ -159,7 +168,7 @@ function graphCtrl($scope, $q, $location, $log, Filters, ClassExtractor, Relatio
159168
// do not try to query an empty url
160169
return;
161170
} else {
162-
if (vm.endpointURL != RequestConfig.getEndpointURL()) {
171+
if (vm.endpointURL !== RequestConfig.getEndpointURL()) {
163172
Data.clearAll();
164173
RequestConfig.setEndpointURL(vm.endpointURL);
165174
Data.initMaps();

app/components/sidebar/groups/endpoint-group/endpoint-group.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@
3636
<span ng-show="failedRequests === 0">None</span>
3737
</p>
3838

39-
<div class="text-center" ng-if="pendingRequests === 0 && vm.endpointURL.length > 0">
40-
<button type="button" class="btn btn-warning" ng-click="vm.restartLoading()">
39+
<div class="text-center" ng-if="vm.endpointURL.length > 0">
40+
<button type="button" class="btn btn-warning" ng-click="vm.restartLoading()" ng-show="pendingRequests === 0">
4141
<span class="glyphicon glyphicon-repeat" aria-hidden="true"></span>
4242
Reload
4343
</button>
44+
45+
<button type="button" class="btn btn-danger" ng-click="vm.stopLoading()" ng-hide="pendingRequests === 0">
46+
<span class="glyphicon glyphicon-stop" aria-hidden="true"></span>
47+
Stop
48+
</button>
4449
</div>
4550

4651
</div>

app/components/sidebar/slider.drv.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ function slider($rootScope) {
2424
scope.value = parseInt(ui.value);
2525
$rootScope.$broadcast(attrs.model + '-changed', ui.value);
2626
});
27+
},
28+
29+
// this function is needed to set the initial value, otherwise slider will always be at zero in the beginning
30+
create: function() {
31+
$(this).slider('value', scope.value);
2732
}
2833
});
2934
} // end pf link()

app/components/start/start.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ <h1>LD-VOWL</h1>
88
</a>
99
(with minor modifications).
1010
</p>
11+
12+
<p><strong>Endpoint requirements:</strong></p>
13+
<ul>
14+
<li>speaks SPARQL</li>
15+
<li>returns JSON</li>
16+
<li>allows CORS</li>
17+
</ul>
1118
</div>
1219

1320
<div class="well">

app/services/model/properties.srv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ function properties($interval, $log, $rootScope, RequestConfig) {
303303
};
304304

305305
self.clearAll = function () {
306-
self.properties = [];
306+
self.properties.length = 0;
307307
self.needsUpdate = true;
308308
self.startStorageUpdate();
309309
};

app/services/model/view.srv.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function viewService() {
88
let scale;
99
let translate;
1010

11+
/* jshint validthis: true */
1112
let that = this;
1213

1314
that.getScale = function() {

app/services/requests/query-factory.srv.js

Lines changed: 75 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,33 @@ function queryFactory() {
3636
// CLASS QUERIES
3737

3838
getClassQuery: function (limit, offset) {
39-
4039
// check parameters
4140
limit = (typeof limit === 'number' && limit > 0) ? limit : defaultLimit;
4241
offset = (typeof offset === 'number' && offset >= 0) ? offset : defaultOffset;
4342

4443
// build query and return it
45-
var query = prefixes() +
46-
'SELECT DISTINCT ?class (count(?sub) AS ?instanceCount) ' +
47-
'WHERE { ' +
48-
'?sub a ?class. ' +
49-
'} ' +
50-
'GROUP BY ?class ' +
51-
'ORDER BY DESC(?instanceCount) ' +
52-
'LIMIT ' + limit + ' ' +
53-
'OFFSET ' + offset;
54-
return query;
44+
return prefixes() +
45+
`SELECT DISTINCT ?class (count(?sub) AS ?instanceCount) ` +
46+
`WHERE { ` +
47+
`?sub a ?class. ` +
48+
`} ` +
49+
`GROUP BY ?class ` +
50+
`ORDER BY DESC(?instanceCount) ` +
51+
`LIMIT ${limit} ` +
52+
`OFFSET ${offset}`;
5553
},
5654

5755
// PROPERTY QUERIES
5856

5957
getLabelQuery: function (uri, labelLang) {
6058
labelLang = labelLang || defaultLang;
6159

62-
var query = prefixes() +
63-
'SELECT (SAMPLE (?lbl) AS ?label) ' +
64-
'WHERE { ' +
65-
'<' + uri + '> rdfs:label ?lbl. ' +
66-
"FILTER (langMatches(lang(?lbl), '" + labelLang + "'))" +
67-
'}';
68-
return query;
60+
return prefixes() +
61+
`SELECT (SAMPLE (?lbl) AS ?label) ` +
62+
`WHERE { ` +
63+
`<${uri}> rdfs:label ?lbl. ` +
64+
`FILTER (langMatches(lang(?lbl), '${labelLang} ')) ` +
65+
`}`;
6966
},
7067

7168
// alternative without SAMPLE
@@ -83,112 +80,103 @@ function queryFactory() {
8380
getPreferredLabelQuery: function (uri, labelLang) {
8481
labelLang = labelLang || defaultLang;
8582

86-
var query = prefixes() +
87-
'SELECT ?label ' +
88-
'WHERE { ' +
89-
'<' + uri + '> skos:prefLabel ?label . ' +
90-
"FILTER (langMatches(lang(?label), '" + labelLang + "')) " +
91-
'}';
92-
return query;
83+
return prefixes() +
84+
`SELECT ?label ` +
85+
`WHERE { ` +
86+
`<${uri}> skos:prefLabel ?label . ` +
87+
`FILTER (langMatches(lang(?label), '${labelLang}')) ` +
88+
`}`;
9389
},
9490

9591
getInstanceReferringTypesQuery: function (classURI, limit) {
9692
limit = (typeof limit === 'number' && limit > 0) ? limit : defaultLimit;
9793

98-
var typeQuery = prefixes() +
99-
'SELECT (COUNT(?val) AS ?valCount) ?valType ' +
100-
'WHERE { ' +
101-
'?instance a <' + classURI + '> . ' +
102-
'?instance ?prop ?val . ' +
103-
'BIND (datatype(?val) AS ?valType) . ' +
104-
'} ' +
105-
'GROUP BY ?valType ' +
106-
'LIMIT ' + limit;
107-
return typeQuery;
94+
return prefixes() +
95+
`SELECT (COUNT(?val) AS ?valCount) ?valType ` +
96+
`WHERE { ` +
97+
`?instance a <${classURI}> . ` +
98+
`?instance ?prop ?val . ` +
99+
`BIND (datatype(?val) AS ?valType) . ` +
100+
`} ` +
101+
`GROUP BY ?valType ` +
102+
`ORDER BY DESC(?valCount) ` +
103+
`LIMIT ${limit}`;
108104
},
109105

110106
// RELATION queries
111107

112108
getOrderedClassClassRelationQuery: function (originClass, targetClass, limit, offset) {
113-
var query = prefixes() +
114-
'SELECT (count(?originInstance) as ?count) ?prop ' +
115-
'WHERE { ' +
116-
'?originInstance a <' + originClass + '> . ' +
117-
'?targetInstance a <' + targetClass + '> . ' +
118-
'?originInstance ?prop ?targetInstance . ' +
119-
'} ' +
120-
'GROUP BY ?prop ' +
121-
'ORDER BY DESC(?count) ' +
122-
'LIMIT ' + limit + ' ' +
123-
'OFFSET ' + offset;
124-
return query;
109+
return prefixes() +
110+
`SELECT (count(?originInstance) as ?count) ?prop ` +
111+
`WHERE { ` +
112+
`?originInstance a <${originClass}> . ` +
113+
`?targetInstance a <${targetClass}> . ` +
114+
`?originInstance ?prop ?targetInstance . ` +
115+
`} ` +
116+
`GROUP BY ?prop ` +
117+
`ORDER BY DESC(?count) ` +
118+
`LIMIT ${limit} ` +
119+
`OFFSET ${offset}`;
125120
},
126121

127122
getUnorderedClassClassRelationQuery: function (originClass, targetClass, limit, offset) {
128-
var query = prefixes() +
129-
'SELECT DISTINCT ?prop ' +
130-
'WHERE { ' +
131-
'?originInstance a <' + originClass + '> . ' +
132-
'?targetInstance a <' + targetClass + '> . ' +
133-
'?originInstance ?prop ?targetInstance . ' +
134-
'} ' +
135-
'LIMIT ' + limit + ' ' +
136-
'OFFSET ' + offset;
137-
return query;
123+
return prefixes() +
124+
`SELECT DISTINCT ?prop ` +
125+
`WHERE { ` +
126+
`?originInstance a <${originClass}> . ` +
127+
`?targetInstance a <${targetClass}> . ` +
128+
`?originInstance ?prop ?targetInstance . ` +
129+
`} ` +
130+
`LIMIT ${limit} ` +
131+
`OFFSET ${offset} `;
138132
},
139133

140134
getOrderedClassTypeRelationQuery: function (classURI, typeURI, limit = 5, offset = 0) {
141-
const query = prefixes() +
142-
'SELECT (count(?instance) AS ?count) ?prop ' +
143-
'WHERE { ' +
135+
return prefixes() +
136+
`SELECT (count(?instance) AS ?count) ?prop ` +
137+
`WHERE { ` +
144138
`?instance a <${classURI}> . ` +
145-
'?instance ?prop ?val . ' +
139+
`?instance ?prop ?val . ` +
146140
`FILTER (datatype(?val) = <${typeURI}>) ` +
147-
'} ' +
148-
'GROUP BY ?prop ' +
149-
'ORDER BY DESC(?count) ' +
141+
`} ` +
142+
`GROUP BY ?prop ` +
143+
`ORDER BY DESC(?count) ` +
150144
`LIMIT ${limit} ` +
151145
`OFFSET ${offset}`;
152-
153-
return query;
154146
},
155147

156148
getUnorderedClassTypeRelationQuery: function (classURI, typeURI, limit = 5, offset = 0) {
157-
const query = prefixes() +
158-
'SELECT DISTINCT ?prop ' +
159-
'WHERE { ' +
149+
return prefixes() +
150+
`SELECT DISTINCT ?prop ` +
151+
`WHERE { ` +
160152
`?instance a <${classURI}> . ` +
161-
'?instance ?prop ?val . ' +
153+
`?instance ?prop ?val . ` +
162154
`FILTER (datatype(?val) = <${typeURI}>) ` +
163-
'} ' +
155+
`} ` +
164156
`LIMIT ${limit} ` +
165157
`OFFSET ${offset}`;
166-
167-
return query;
168158
},
169159

170160
// INSTANCE QUERIES
171161

172162
getNumberOfCommonInstancesQuery: function (classURI1, classURI2) {
173-
var query = prefixes() +
174-
'SELECT (count(?commonInstance) AS ?commonInstanceCount) ' +
175-
'WHERE { ' +
176-
'?commonInstance a <' + classURI1 + '>. ' +
177-
'?commonInstance a <' + classURI2 + '>. ' +
178-
'}';
179-
return query;
163+
return prefixes() +
164+
`SELECT (count(?commonInstance) AS ?commonInstanceCount) ` +
165+
`WHERE { ` +
166+
`?commonInstance a <${classURI1}>. ` +
167+
`?commonInstance a <${classURI2}>. ` +
168+
`}`;
180169
},
181170

182171
// DETAILS QUERIES
183172

184173
getCommentQuery: function (uri) {
185-
var commentQuery = prefixes() +
186-
'SELECT ?comment ' +
187-
'WHERE { ' +
188-
'<' + uri + '> rdfs:comment ?comment . ' +
189-
'} ' +
190-
'LIMIT 1';
191-
return commentQuery;
174+
return prefixes() +
175+
`SELECT ?comment ` +
176+
`WHERE { ` +
177+
`<${uri}> rdfs:comment ?comment . ` +
178+
`} ` +
179+
`LIMIT 1`;
192180
}
193181

194182
}; // end of public API to return

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ld-vowl",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Extract ontology information out of arbitrary SPARQL endpoints and visualize it using a slightly adjusted form of VOWL.",
55
"keywords": ["Linked Data", "SPARQL", "Visualization", "VOWL"],
66
"homepage": "http://ldvowl.visualdataweb.org/",

0 commit comments

Comments
 (0)