Migrate "Match all filtered cells" to use standard reconciliation services

Closes #1376.
This commit is contained in:
Antonin Delpeuch 2018-04-23 17:33:04 +02:00
parent 3c4002ee2c
commit 3fcde510f9
3 changed files with 31 additions and 29 deletions

View File

@ -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",

View File

@ -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",

View File

@ -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 = $('<input />').appendTo($('<p></p>').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=?";
$.getJSON(
url,
null,
function(o) {
var types = "result" in o ? o.result.type : [];
input.suggest(suggestOptions).bind("fb-select", function(e, data) {
var types = [];
Refine.postCoreProcess(
"recon-match-specific-topic-to-cells",
{
columnName: column.name,
topicID: data.id,
topicGUID: data.guid,
topicName: data.name,
types: types.join(",")
types: types.join(","),
identifierSpace: service.identifierSpace,
schemaSpace: service.schemaSpace
},
null,
{ cellsChanged: true, columnStatsChanged: true }
);
DialogSystem.dismissUntil(level - 1);
}
);
});
$('<button class="button"></button>').text($.i18n._('core-buttons')["cancel"]).click(function() {