Commit 494011874cfde96bb838e0b594afa77c76aa9c38
1 parent
68664dca
Exists in
master
and in
111 other branches
epntap: Do not use metadata but query services directly on module startup
Showing
4 changed files
with
95 additions
and
97 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
... | ... | @@ -41,7 +41,7 @@ Ext.define('amdaDesktop.EpnTapModule', { |
41 | 41 | this.addStoreListeners(); |
42 | 42 | |
43 | 43 | this.servicesStore.load(); |
44 | - this.metadataStore.load(); | |
44 | + // this.metadataStore.load(); | |
45 | 45 | this.productTypesStore.load(); |
46 | 46 | }, |
47 | 47 | |
... | ... | @@ -63,25 +63,25 @@ Ext.define('amdaDesktop.EpnTapModule', { |
63 | 63 | // stores elements |
64 | 64 | this.servicesStore = Ext.data.StoreManager.lookup('servicesStore'); |
65 | 65 | this.granulesStore = Ext.data.StoreManager.lookup('granulesStore'); |
66 | - this.metadataStore = Ext.data.StoreManager.lookup('metadataStore') | |
66 | + // this.metadataStore = Ext.data.StoreManager.lookup('metadataStore') | |
67 | 67 | this.productTypesStore = Ext.data.StoreManager.lookup('productTypesStore'); |
68 | 68 | this.targetNamesStore = Ext.data.StoreManager.lookup('targetNamesStore'); |
69 | 69 | }, |
70 | 70 | |
71 | 71 | addStoreListeners: function() { |
72 | - this.servicesStore.on({ | |
73 | - beforeload: function(store) { | |
74 | - loadMask.show(); | |
75 | - AmdaAction.epnTapGetServices( function(services) { | |
76 | - store.add(services); | |
77 | - }); | |
78 | - }, | |
79 | - add: function(store) { | |
80 | - this.updateNbResults(); | |
81 | - loadMask.hide(); | |
82 | - }, | |
83 | - scope: this | |
84 | - }); | |
72 | + // this.servicesStore.on({ | |
73 | + // beforeload: function(store) { | |
74 | + // loadMask.show(); | |
75 | + // AmdaAction.epnTapGetServices( function(services) { | |
76 | + // store.add(services); | |
77 | + // }); | |
78 | + // }, | |
79 | + // add: function(store) { | |
80 | + // this.updateNbResults(); | |
81 | + // loadMask.hide(); | |
82 | + // }, | |
83 | + // scope: this | |
84 | + // }); | |
85 | 85 | |
86 | 86 | this.productTypesStore.on({ |
87 | 87 | load: function(store) { |
... | ... | @@ -174,8 +174,8 @@ Ext.define('amdaDesktop.EpnTapModule', { |
174 | 174 | this.aquireElements(); |
175 | 175 | this.addUIListeners(); |
176 | 176 | |
177 | - this.servicesStore.clearFilter(); | |
178 | - this.metadataStore.clearFilter(); | |
177 | + // this.servicesStore.clearFilter(); | |
178 | + // this.metadataStore.clearFilter(); | |
179 | 179 | this.granulesStore.removeAll(); |
180 | 180 | |
181 | 181 | this.productTypeCB.getStore().add({'id': 'all', 'name': 'All dataproduct types'}); |
... | ... | @@ -189,9 +189,9 @@ Ext.define('amdaDesktop.EpnTapModule', { |
189 | 189 | this.targetNameCB.select('all'); |
190 | 190 | this.productTypeCB.select('all'); |
191 | 191 | |
192 | - this.servicesStore.each(function(record, idx) { | |
193 | - record.set('nb_results', this.metadataStore.sum('nb_results')); | |
194 | - }, this); | |
192 | + // this.servicesStore.each(function(record, idx) { | |
193 | + // record.set('nb_results', this.metadataStore.sum('nb_results')); | |
194 | + // }, this); | |
195 | 195 | } |
196 | 196 | }, |
197 | 197 | |
... | ... | @@ -360,15 +360,15 @@ Ext.define('amdaDesktop.EpnTapModule', { |
360 | 360 | ]; |
361 | 361 | } |
362 | 362 | |
363 | - this.servicesStore.each(function(record, idx) { | |
364 | - this.metadataStore.filter(filter.concat({property: 'service_id', value: record.get('id')})); | |
365 | - record.set('nb_results', this.metadataStore.sum('nb_results')); | |
366 | - this.metadataStore.clearFilter(); | |
367 | - }, this); | |
368 | - this.servicesStore.sort('nb_results', 'DESC'); | |
369 | - | |
370 | - var timeMin = this.metadataStore.min('time_min'); | |
371 | - var timeMax = this.metadataStore.max('time_max'); | |
363 | + // this.servicesStore.each(function(record, idx) { | |
364 | + // this.metadataStore.filter(filter.concat({property: 'service_id', value: record.get('id')})); | |
365 | + // record.set('nb_results', this.metadataStore.sum('nb_results')); | |
366 | + // this.metadataStore.clearFilter(); | |
367 | + // }, this); | |
368 | + // this.servicesStore.sort('nb_results', 'DESC'); | |
369 | + // | |
370 | + // var timeMin = this.metadataStore.min('time_min'); | |
371 | + // var timeMax = this.metadataStore.max('time_max'); | |
372 | 372 | this.timeSelector.setLimits(timeMin, timeMax); |
373 | 373 | this.timeSelector.setInterval(timeMin, timeMax); |
374 | 374 | }, | ... | ... |
js/app/views/EpnTapUI.js
... | ... | @@ -100,27 +100,11 @@ Ext.create('Ext.data.Store', { |
100 | 100 | {name: 'created', type: 'date', dateFormat: 'c'}, |
101 | 101 | {name: 'updated', type: 'date', dateFormat: 'c'}, |
102 | 102 | {name: 'nb_results', type: 'integer'} |
103 | - ] | |
104 | -}); | |
105 | - | |
106 | -/** | |
107 | -`metadataStore`: [...] | |
108 | -*/ | |
109 | -Ext.create('Ext.data.ArrayStore', { | |
110 | - storeId: 'metadataStore', | |
111 | - fields: [ | |
112 | - {name: 'dataproduct_type', type: 'string', mapping: 0}, | |
113 | - {name: 'target_class', type: 'string', mapping: 1}, | |
114 | - {name: 'target_name', type: 'string', mapping: 2}, | |
115 | - {name: 'service_id', type: 'string', mapping: 3}, | |
116 | - {name: 'nb_results', type: 'integer', mapping: 4}, | |
117 | - {name: 'time_min', type: 'date', dateFormat: 'd/m/Y', mapping: 5}, | |
118 | - {name: 'time_max', type: 'date', dateFormat: 'd/m/Y', mapping: 6} | |
119 | 103 | ], |
120 | 104 | proxy: { |
121 | 105 | type: 'ajax', |
122 | - // url : '../../../generic_data/EpnTapData/metadata.json' | |
123 | - url : 'generic_data/EpnTapData/metadata.json' | |
106 | + url: 'php/epntap.php', | |
107 | + extraParams : { action: 'get_services' } | |
124 | 108 | } |
125 | 109 | }); |
126 | 110 | |
... | ... | @@ -448,15 +432,13 @@ Ext.define('amdaUI.EpnTapUI', { |
448 | 432 | store: Ext.data.StoreManager.lookup('servicesStore'), |
449 | 433 | flex: 1, |
450 | 434 | columns: [ |
451 | - {text: 'Name', dataIndex: 'short_name', flex: 1}, | |
452 | - {text: '~Nb results', dataIndex: 'nb_results', flex: 1} | |
435 | + {text: 'Name', dataIndex: 'short_name', flex: 3}, | |
436 | + {text: 'nb results', dataIndex: 'nb_results', flex: 2} | |
453 | 437 | ], |
454 | - renderer: function(value, metadata, record) { | |
455 | - return getExpandableImage(value, metadata,record); | |
456 | - }, | |
457 | 438 | viewConfig: { |
458 | 439 | getRowClass: function(record, index) { |
459 | - if (record.get('nb_results') === 0) { | |
440 | + var nb_res = record.get('nb_results'); | |
441 | + if (nb_res <= 0 || isNaN(nb_res)) { | |
460 | 442 | return 'disabled_row'; |
461 | 443 | } |
462 | 444 | } |
... | ... | @@ -469,16 +451,17 @@ Ext.define('amdaUI.EpnTapUI', { |
469 | 451 | trackMouse: true, |
470 | 452 | listeners: { |
471 | 453 | beforeshow: function updateTipBody(tooltip) { |
472 | - var column_titles = {'res_title': 'Title', | |
473 | - 'ivoid': 'ivoid', | |
474 | - 'access_url': 'Access URL', | |
475 | - 'table_name': 'Table name', | |
476 | - 'content_type': 'content type', | |
477 | - 'creator_seq': 'Creator', | |
478 | - 'content_level': 'Content level', | |
479 | - 'reference_url': 'reference URL', | |
480 | - 'created': 'Created on', | |
481 | - 'updated': 'Updated on'}; | |
454 | + var column_titles = { | |
455 | + 'res_title': 'Title', | |
456 | + 'ivoid': 'ivoid', | |
457 | + 'access_url': 'Access URL', | |
458 | + 'table_name': 'Table name', | |
459 | + 'content_type': 'content type', | |
460 | + 'creator_seq': 'Creator', | |
461 | + 'content_level': 'Content level', | |
462 | + 'reference_url': 'reference URL', | |
463 | + 'created': 'Created on', | |
464 | + 'updated': 'Updated on'}; | |
482 | 465 | var service = epnTapServicesGrid.getView().getRecord(tooltip.triggerElement); |
483 | 466 | var ttContent = '<h3>' + service.get('short_name') + '</h3><ul>'; |
484 | 467 | for (var column in column_titles) { | ... | ... |
php/classes/EpnTapMgr.php
... | ... | @@ -76,34 +76,6 @@ class EpnTapMgr { |
76 | 76 | return $result; |
77 | 77 | } |
78 | 78 | |
79 | - /* Return the list of available services by querying some usual registries. */ | |
80 | - public function getServices() { | |
81 | - $registriesURL = ["http://registry.euro-vo.org/regtap/tap", "http://dc.zah.uni-heidelberg.de/tap", "http://gavo.aip.de/tap", "http://reg.g-vo.org/tap"]; | |
82 | - $columns = ['short_name', 'res_title', 'ivoid', 'access_url', 'table_name', 'content_type', 'creator_seq', 'content_level', 'reference_url', 'created', 'updated']; | |
83 | - $getServicesQuery = "SELECT DISTINCT " . implode(', ', $columns) . " FROM rr.resource | |
84 | - NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability | |
85 | - WHERE standard_id='ivo://ivoa.net/std/tap' AND intf_type='vs:paramhttp' AND detail_xpath='/capability/dataModel/@ivo-id' | |
86 | - AND 1=ivo_nocasematch(detail_value, 'ivo://vopdc.obspm/std/EpnCore%') AND table_name LIKE '%.epn_core' ORDER BY short_name, table_name"; | |
87 | - | |
88 | - for($i=0; $i<count($registriesURL); $i++) { | |
89 | - $services = $this->request($registriesURL[$i], $getServicesQuery); | |
90 | - if(! array_key_exists("error", $services)) { | |
91 | - for($j=0; $j<count($services); $j++) { | |
92 | - $services[$j]['id'] = $this->generateServiceId($services[$j]); | |
93 | - } | |
94 | - return $services; | |
95 | - } else if($i === count($registriesURL)-1) { | |
96 | - error_log("Can not access any of these services : " . implode(', ', $registriesURL) . "."); | |
97 | - return; | |
98 | - } | |
99 | - } | |
100 | - } | |
101 | - | |
102 | - /* Generate a unique service identifier from the service ivoid and the table name. */ | |
103 | - public function generateServiceId($service) { | |
104 | - return str_replace(['ivo://', '.epn_core'], '', $service['ivoid'] . '/' . $service['table_name']); | |
105 | - } | |
106 | - | |
107 | 79 | /* filter order: product type, target name, time min, time max */ |
108 | 80 | public function getNbRows($table_name, $access_url, $filter) { |
109 | 81 | $query = "SELECT COUNT(*) AS nb_rows FROM {$table_name} " . $this->createFilter($filter[0], $filter[1], $filter[2], $filter[3]); | ... | ... |
php/epntap.php
1 | 1 | <?php |
2 | 2 | |
3 | -$action = preg_replace("/[^a-z]+/", "", filter_var($_GET['action'], FILTER_SANITIZE_STRING)); | |
3 | +include(realpath(dirname(__FILE__) . "/config.php")); | |
4 | +// include(CLASSPATH . "EpnTapMgr.php"); | |
5 | +include(CLASSPATH . "VOTableMgr.php"); | |
6 | + | |
7 | +$action = preg_replace("/[^a-z_]+/", "", filter_var($_GET['action'], FILTER_SANITIZE_STRING)); | |
4 | 8 | |
5 | 9 | switch ($action) { |
6 | 10 | case 'resolver': |
7 | - echo resolver(filter_var($_GET['input'], FILTER_SANITIZE_URL)); | |
11 | + echo json_encode(resolver(filter_var($_GET['input'], FILTER_SANITIZE_URL))); | |
8 | 12 | break; |
9 | 13 | case 'get_services': |
10 | - echo get_services(); | |
14 | + echo json_encode(getServices()); | |
11 | 15 | break; |
12 | 16 | |
13 | 17 | default: |
... | ... | @@ -18,13 +22,52 @@ function resolver($input) { |
18 | 22 | $resolver_url = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete?q=%22$input%22"; |
19 | 23 | $result = json_decode(file_get_contents($resolver_url), true); |
20 | 24 | |
21 | - $response = array(); | |
25 | + $targets = array(); | |
22 | 26 | foreach($result['hits'] as $e) { |
23 | 27 | $aliases = '<li>' . join('</li><li>', $e['aliases']) . '</li>'; |
24 | 28 | $target = array('name' => $e['name'], 'type' => $e['type'], 'parent' => $e['parent'], 'aliases' => $aliases); |
25 | - array_push($response, $target); | |
29 | + array_push($targets, $target); | |
30 | + } | |
31 | + return $targets; | |
32 | +} | |
33 | + | |
34 | +/* Return the list of available services by querying some usual registries. */ | |
35 | +function getServices() { | |
36 | + $registriesURL = ["http://registry.euro-vo.org/regtap/tap", "http://dc.zah.uni-heidelberg.de/tap", "http://gavo.aip.de/tap", "http://reg.g-vo.org/tap"]; | |
37 | + $columns = ['short_name', 'res_title', 'ivoid', 'access_url', 'table_name', 'content_type', 'creator_seq', 'content_level', 'reference_url', 'created', 'updated']; | |
38 | + $getServicesQuery = "SELECT DISTINCT " . implode(', ', $columns) . " FROM rr.resource | |
39 | + NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability | |
40 | + WHERE standard_id='ivo://ivoa.net/std/tap' AND intf_type='vs:paramhttp' AND detail_xpath='/capability/dataModel/@ivo-id' | |
41 | + AND 1=ivo_nocasematch(detail_value, 'ivo://vopdc.obspm/std/EpnCore%') AND table_name LIKE '%.epn_core' ORDER BY short_name, table_name"; | |
42 | + | |
43 | + for($i=0; $i<count($registriesURL); $i++) { | |
44 | + $services = request($registriesURL[$i], $getServicesQuery); | |
45 | + if(! array_key_exists("error", $services)) { | |
46 | + for($j=0; $j<count($services); $j++) { | |
47 | + $services[$j]['id'] = generateServiceId($services[$j]); | |
48 | + $services[$j]['nb_results'] = -1; | |
49 | + } | |
50 | + return $services; | |
51 | + } else if($i === count($registriesURL)-1) { | |
52 | + error_log("Can not access any of these services : " . implode(', ', $registriesURL) . "."); | |
53 | + return; | |
54 | + } | |
26 | 55 | } |
27 | - return json_encode($response); | |
28 | 56 | } |
29 | 57 | |
58 | +/* Generate a unique service identifier from the service ivoid and the table name. */ | |
59 | +function generateServiceId($service) { | |
60 | + return str_replace(['ivo://', '.epn_core'], '', $service['ivoid'] . '/' . $service['table_name']); | |
61 | +} | |
62 | + | |
63 | +function request($access_url, $query) { | |
64 | + $votMgr = new VOTableMgr; | |
65 | + $params = 'FORMAT=votable&LANG=ADQL&REQUEST=doQuery'; | |
66 | + $url = $access_url . '/sync?' . $params . '&QUERY=' . urlencode(preg_replace('/\s+/', ' ', $query)); | |
67 | + | |
68 | + $votMgr->load($url); | |
69 | + | |
70 | + $result = $votMgr->parseStream(); | |
71 | + return $votMgr->getVotableError() ? array('error' => $votMgr->getVotableError()) : $result; | |
72 | +} | |
30 | 73 | ?> | ... | ... |