From 3fcde510f9f33f1e9a007e20d46c1df2cf9ef7f8 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 23 Apr 2018 17:33:04 +0200 Subject: [PATCH] Migrate "Match all filtered cells" to use standard reconciliation services Closes #1376. --- .../modules/core/langs/translation-en.json | 2 +- .../modules/core/langs/translation-fr.json | 2 +- .../views/data-table/menu-reconcile.js | 56 ++++++++++--------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/main/webapp/modules/core/langs/translation-en.json b/main/webapp/modules/core/langs/translation-en.json index 55099f9cb..206cff2b0 100644 --- a/main/webapp/modules/core/langs/translation-en.json +++ b/main/webapp/modules/core/langs/translation-en.json @@ -463,7 +463,7 @@ "valid-values": "Valid values", "blanks": "Blanks", "errors": "Errors", - "search-fb-topic": "Search Freebase for a topic to match all filtered cells:", + "search-fb-topic": "Search for an item to match all filtered cells:", "copy-recon-judg": "Copy recon judgments from column", "copy-to-col": "Copy to Columns", "copy-opt": "Copying Options", diff --git a/main/webapp/modules/core/langs/translation-fr.json b/main/webapp/modules/core/langs/translation-fr.json index dcbb855f9..2e73f09e9 100644 --- a/main/webapp/modules/core/langs/translation-fr.json +++ b/main/webapp/modules/core/langs/translation-fr.json @@ -506,7 +506,7 @@ "re-trans": "Retransformer", "custom-text-facet": "Personnaliser la facette textuelle", "match-other": "Apparier les autres cellules avec le même contenu", - "search-fb-topic": "Chercher dans Freebase un sujet qui correspond à toutes les cellules filtrées :", + "search-fb-topic": "Chercher un item qui correspond à toutes les cellules filtrées :", "from-col": "De la colonne", "custom-numeric-label": "Facette numérique personnalisée sur la colonne", "start-recon": "Démarrer la réconciliation", diff --git a/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js b/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js index d67654747..be97cc00a 100644 --- a/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js +++ b/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js @@ -73,6 +73,20 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { }; var doSearchToMatch = function() { + var serviceUrl = null; + var service = null; + var suggestOptions = {}; + if (column.reconConfig) { + serviceUrl = column.reconConfig.service; + } + if (serviceUrl) { + service = ReconciliationManager.getServiceFromUrl(serviceUrl); + } + if (service && service.suggest && service.suggest.entity) { + suggestOptions = $.extend({}, service.suggest.entity); + suggestOptions.query_param_name = "prefix"; + } + var frame = DialogSystem.createDialog(); frame.width("400px"); @@ -84,36 +98,24 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { var input = $('').appendTo($('

').appendTo(body)); - input.suggest({}).bind("fb-select", function(e, data) { - var query = { - "id" : data.id, - "type" : [] - }; - var baseUrl = "https://www.googleapis.com/freebase/v1/mqlread?key=" + Freebase.API_KEY + "&"; - var url = baseUrl + $.param({ query: JSON.stringify(query) }) + "&callback=?"; + input.suggest(suggestOptions).bind("fb-select", function(e, data) { + var types = []; - $.getJSON( - url, + Refine.postCoreProcess( + "recon-match-specific-topic-to-cells", + { + columnName: column.name, + topicID: data.id, + topicName: data.name, + types: types.join(","), + identifierSpace: service.identifierSpace, + schemaSpace: service.schemaSpace + }, null, - function(o) { - var types = "result" in o ? o.result.type : []; + { cellsChanged: true, columnStatsChanged: true } + ); - Refine.postCoreProcess( - "recon-match-specific-topic-to-cells", - { - columnName: column.name, - topicID: data.id, - topicGUID: data.guid, - topicName: data.name, - types: types.join(",") - }, - null, - { cellsChanged: true, columnStatsChanged: true } - ); - - DialogSystem.dismissUntil(level - 1); - } - ); + DialogSystem.dismissUntil(level - 1); }); $('').text($.i18n._('core-buttons')["cancel"]).click(function() {