Skip to content

Commit a4efa74

Browse files
committed
Automatically detect whether proxy is needed.
- Remove checkbox for proxy on start view. - Put proxy url into separate config files for development and production.
1 parent a8192f5 commit a4efa74

File tree

10 files changed

+78
-111
lines changed

10 files changed

+78
-111
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ coverage/
33
dist/
44
.idea/
55
.vscode/
6+
production.conf.json
7+
development.conf.json

app/components/start/start.ctrl.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@
55
* @param {$location} $location
66
* @param {Data} Data
77
* @param {View} View
8-
* @param {Requests} Requests
98
* @param {RequestConfig} RequestConfig
109
* @param {Endpoints} Endpoints
1110
*
1211
* @ngInject
1312
*/
14-
function startCtrl($log, $location, Data, View, Requests, RequestConfig, Endpoints) {
13+
function startCtrl($log, $location, Data, View, RequestConfig, Endpoints) {
1514

1615
const start = this;
1716

18-
start.proxyAvailable = __PROXY__; // eslint-disable-line no-undef
19-
2017
start.endpoints = [];
2118

2219
start.endpoint = RequestConfig.getEndpointURL() || '';
@@ -25,15 +22,6 @@ function startCtrl($log, $location, Data, View, Requests, RequestConfig, Endpoin
2522

2623
start.endpointAlert = true;
2724

28-
/**
29-
* This function is triggered every time the proxy flag is toggled.
30-
*/
31-
start.updateUseProxy = function () {
32-
Requests.clear();
33-
$log.warn('[Start] Cleared old requests.');
34-
start.loadProxyEndpoints();
35-
};
36-
3725
/**
3826
* Shows the graph for the current endpoint and clears all data if endpoint has changed.
3927
*/
@@ -51,7 +39,7 @@ function startCtrl($log, $location, Data, View, Requests, RequestConfig, Endpoin
5139
Data.initMaps();
5240
}
5341

54-
RequestConfig.setUseProxy(start.useProxy);
42+
RequestConfig.setUseProxy(false);
5543

5644
if (start.endpoint !== undefined && start.endpoint.length > 0) {
5745
$log.debug('[Start] Show Graph!');
@@ -104,14 +92,6 @@ function startCtrl($log, $location, Data, View, Requests, RequestConfig, Endpoin
10492
*/
10593
start.loadEndpoints = function () {
10694
Endpoints.getNonProxyEndpoints().then(handleEndpointListResponse, handleEndpointListError);
107-
108-
if (start.useProxy) {
109-
start.loadProxyEndpoints();
110-
}
111-
};
112-
113-
start.loadProxyEndpoints = function () {
114-
$log.debug('[Start] Also load endpoints only accessible via proxy.');
11595
Endpoints.getProxyEndpoints().then(handleEndpointListResponse, handleEndpointListError);
11696
};
11797

app/components/start/start.html

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ <h1>LD-VOWL</h1>
3838
</uib-alert>
3939
</div>
4040
</div>
41-
42-
<div class="form-group" ng-if="start.proxyAvailable">
43-
<div class="col-sm-offset-2 col-sm-10">
44-
<div class="checkbox">
45-
<label>
46-
<input type="checkbox" ng-model="start.useProxy" ng-change="start.updateUseProxy()">
47-
Use local proxy
48-
</label>
49-
</div>
50-
</div>
51-
</div><!-- end of .form-group -->
5241
</form><!-- end of .form-horizontal -->
5342
</div><!-- end of .well -->
5443
</div><!-- end of .container -->

app/nonproxy_endpoints.json

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,42 @@
66
{
77
"name": "BCN Datos",
88
"url": "http://datos.bcn.cl/sparql",
9-
"description": "",
10-
"proxyNeeded": false
9+
"description": ""
1110
},
1211
{
1312
"name": "Database Center for Life Science (DBCLS)",
1413
"url": "http://data.allie.dbcls.jp/sparql",
15-
"description": "",
16-
"proxyNeeded": false
14+
"description": ""
1715
},
1816
{
1917
"name": "dbpedia",
2018
"url": "http://dbpedia.org/sparql",
21-
"description": "",
22-
"proxyNeeded": false
19+
"description": ""
2320
},
2421
{
2522
"name": "Dutch Ships and Sailors (DSS)",
2623
"url": "http://dutchshipsandsailors.nl/data/sparql/",
27-
"description": "maritime historical data set",
28-
"proxyNeeded": false
24+
"description": "maritime historical data set"
2925
},
3026
{
3127
"name": "Dutch Ships and Sailors (DSS) Semantic Layer",
3228
"url": "http://semanticweb.cs.vu.nl/dss/sparql/",
33-
"description": "",
34-
"proxyNeeded": false
29+
"description": ""
3530
},
3631
{
3732
"name": "EBI BioModels Database",
3833
"url": "https://www.ebi.ac.uk/rdf/services/biomodels/sparql",
39-
"description": "",
40-
"proxyNeeded": false
34+
"description": ""
4135
},
4236
{
4337
"name": "EBI Biosamples Database",
4438
"url": "https://www.ebi.ac.uk/rdf/services/biosamples/sparql",
45-
"description": "",
46-
"proxyNeeded": false
39+
"description": ""
4740
},
4841
{
4942
"name": "EBI ChEMBL",
5043
"url": "https://www.ebi.ac.uk/rdf/services/chembl/sparql",
51-
"description": "",
52-
"proxyNeeded": false
44+
"description": ""
5345
},
5446
{
5547
"name": "Enipedia",
@@ -58,14 +50,12 @@
5850
{
5951
"name": "Environment Agency Bathing Water Quality",
6052
"url": "http://environment.data.gov.uk/sparql/bwq/query",
61-
"description": "",
62-
"proxyNeeded": false
53+
"description": ""
6354
},
6455
{
6556
"name": "EUscreen Linked Open Data Pilot",
6657
"url": "http://lod.euscreen.eu/sparql",
67-
"description": "about television",
68-
"proxyNeeded": false
58+
"description": "about television"
6959
},
7060
{
7161
"name": "FOODpedia",
@@ -107,8 +97,7 @@
10797
{
10898
"name": "MORElab",
10999
"url": "http://apps.morelab.deusto.es/labman/sparql",
110-
"description": "",
111-
"proxyNeeded": true
100+
"description": ""
112101
},
113102
{
114103
"name": "Nobelprize.org",
@@ -125,34 +114,29 @@
125114
{
126115
"name": "Springer LOD Conference Portal",
127116
"url": "http://lod.springer.com/sparql",
128-
"description": "about scientific publications at springer",
129-
"proxyNeeded": false
117+
"description": "about scientific publications at springer"
130118
},
131119
{
132120
"name": "Swiss Federal Statistics Office Linked Data",
133121
"url": "http://bfs.270a.info/sparql",
134-
"description": "swiss statistics",
135-
"proxyNeeded": false
122+
"description": "swiss statistics"
136123
},
137124
{
138125
"name": "Transparency International Linked Data",
139126
"url": "http://transparency.270a.info/sparql",
140-
"description": "data set about corruption",
141-
"proxyNeeded": false
127+
"description": "data set about corruption"
142128
},
143129
{
144130
"name": "WKD - Arbeitsrechtsthesaurus",
145131
"url": "http://vocabulary.wolterskluwer.de/PoolParty/sparql/arbeitsrecht"
146132
},
147133
{
148134
"name": "WKD - Gerichtsthesaurus",
149-
"url": "http://vocabulary.wolterskluwer.de/PoolParty/sparql/court",
150-
"proxyNeeded": false
135+
"url": "http://vocabulary.wolterskluwer.de/PoolParty/sparql/court"
151136
},
152137
{
153138
"name": "ww1lod",
154139
"url": "http://ldf.fi/ww1lod/sparql",
155-
"description": "about WW1",
156-
"proxyNeeded": false
140+
"description": "about WW1"
157141
}
158142
]

app/services/extractors/class-extractor.srv.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class ClassExtractor extends Extractor {
4444
this.setBlacklist(classInput.split(','));
4545
} else {
4646
// set up new blacklists
47-
for (var type in CLASS_BLACKLIST) {
47+
for (let type in CLASS_BLACKLIST) {
4848
if (CLASS_BLACKLIST.hasOwnProperty(type) && type !== 'SKOS') {
49-
for (var i = 0; i < CLASS_BLACKLIST[type].length; i++) {
49+
for (let i = 0; i < CLASS_BLACKLIST[type].length; i++) {
5050
this.blacklist.push(PREFIX[type] + CLASS_BLACKLIST[type][i]);
5151
}
5252
}
@@ -69,11 +69,10 @@ class ClassExtractor extends Extractor {
6969

7070
let limit = this.reqConfig.getLimit() || 10;
7171

72-
const requestURL = this.reqConfig.getRequestURL();
73-
7472
const self = this;
7573

7674
function doQuery(lastTry = false, offset = 0, limit = 10) {
75+
let requestURL = self.reqConfig.getRequestURL();
7776
let query = self.queryFactory.getClassQuery(limit, offset);
7877

7978
self.$log.debug(`[Classes] Send Request with offset ${offset}...`);
@@ -89,31 +88,30 @@ class ClassExtractor extends Extractor {
8988

9089
let fetchMore = 0;
9190

92-
for (let i = 0; i < bindings.length; i++) {
93-
94-
var currentClassURI = bindings[i].class.value;
91+
bindings.forEach((binding) => {
92+
let currentClassURI = binding.class.value;
9593

9694
if (currentClassURI.match(/^http.*/) && !self.inBlacklist(currentClassURI) &&
97-
bindings[i].instanceCount !== undefined) {
98-
var node = {};
95+
binding.instanceCount !== undefined) {
96+
let node = {};
9997

10098
node.uri = currentClassURI;
101-
node.name = (bindings[i].label !== undefined) ? bindings[i].label.value : '';
102-
node.value = parseInt(bindings[i].instanceCount.value);
99+
node.name = (binding.label !== undefined) ? binding.label.value : '';
100+
node.value = parseInt(binding.instanceCount.value);
103101
node.type = 'class';
104102
node.active = false;
105-
var newClassId = self.nodes.addNode(node);
103+
const newClassId = self.nodes.addNode(node);
106104

107105
classIds.push(newClassId);
108106

109-
if (bindings[i].class !== undefined && bindings[i].class.value !== undefined) {
107+
if (binding.class !== undefined && binding.class.value !== undefined) {
110108
self.requestClassLabel(newClassId, currentClassURI);
111109
}
112110
} else {
113111
self.$log.debug(`[Classes] Class '${currentClassURI}' is either blacklisted or has an invalid URI!`);
114112
fetchMore++;
115113
}
116-
}
114+
});
117115

118116
if (fetchMore === 0) {
119117
deferred.resolve(classIds);
@@ -142,19 +140,25 @@ class ClassExtractor extends Extractor {
142140
}, function handleErrorExtractingClasses(err) {
143141
if (err.config.timeout.$$state.value === 'canceled') {
144142
self.$log.warn('[Class Extractor] Class extraction was canceled!');
143+
deferred.reject(classIds);
145144
} else {
146145
self.$log.error(err);
147-
}
148146

149-
// TODO check whether this was because of CORS
150-
deferred.reject(classIds);
147+
if (!self.reqConfig.getUseProxy()) {
148+
self.$log.warn('Might need a proxy here, try again...');
149+
self.reqConfig.setUseProxy(true);
150+
doQuery(false, 0, limit);
151+
} else {
152+
deferred.reject(classIds);
153+
}
154+
}
151155
})
152156
.finally(function () {
153157
self.promises.removePromise(promiseId);
154158
});
155159
} // end of doQuery()
156160

157-
doQuery(false, 0,limit);
161+
doQuery(false, 0, limit);
158162

159163
return deferred.promise;
160164
}

0 commit comments

Comments
 (0)