From 76c8cd77eb13e0d36c67be55e2ae52e51375e812 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Sun, 27 Jun 2010 03:31:56 +0000 Subject: [PATCH] "search for match" links in data table cells now use recon service's entity suggest options. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1041 7d457c2a-affb-35e4-300a-418c747d4874 --- .../recon/ReconJudgeOneCellCommand.java | 8 +- .../recon/ReconJudgeSimilarCellsCommand.java | 8 +- .../views/data-table/data-table-cell-ui.js | 83 ++++++++++--------- 3 files changed, 51 insertions(+), 48 deletions(-) diff --git a/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java b/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java index 5e4ddfadd..070816fd5 100644 --- a/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java +++ b/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeOneCellCommand.java @@ -38,13 +38,13 @@ public class ReconJudgeOneCellCommand extends Command { Judgment judgment = Recon.stringToJudgment(request.getParameter("judgment")); ReconCandidate match = null; - String topicID = request.getParameter("topicID"); - if (topicID != null) { + String id = request.getParameter("id"); + if (id != null) { String scoreString = request.getParameter("score"); match = new ReconCandidate( - topicID, - request.getParameter("topicName"), + id, + request.getParameter("name"), request.getParameter("types").split(","), scoreString != null ? Double.parseDouble(scoreString) : 100 ); diff --git a/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java b/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java index 0bbf38c82..18b9353c0 100644 --- a/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java +++ b/main/src/com/metaweb/gridworks/commands/recon/ReconJudgeSimilarCellsCommand.java @@ -23,13 +23,13 @@ public class ReconJudgeSimilarCellsCommand extends EngineDependentCommand { Judgment judgment = Recon.stringToJudgment(request.getParameter("judgment")); ReconCandidate match = null; - String topicID = request.getParameter("topicID"); - if (topicID != null) { + String id = request.getParameter("id"); + if (id != null) { String scoreString = request.getParameter("score"); match = new ReconCandidate( - topicID, - request.getParameter("topicName"), + id, + request.getParameter("name"), request.getParameter("types").split(","), scoreString != null ? Double.parseDouble(scoreString) : 100 ); diff --git a/main/webapp/modules/core/scripts/views/data-table/data-table-cell-ui.js b/main/webapp/modules/core/scripts/views/data-table/data-table-cell-ui.js index d03d68a0a..9a94a16cf 100644 --- a/main/webapp/modules/core/scripts/views/data-table/data-table-cell-ui.js +++ b/main/webapp/modules/core/scripts/views/data-table/data-table-cell-ui.js @@ -169,14 +169,28 @@ DataTableCellUI.prototype._render = function() { $('').text("(New topic)").appendTo(liNew); - $('') - .addClass("data-table-recon-search") - .click(function(evt) { - self._searchForMatch(); - return false; - }) - .text("search for match") - .appendTo($('
').appendTo(divContent)); + if (service) { + var suggestOptions; + var addSuggest = false; + + if ((service.suggest) && (service.suggest.entity)) { + suggestOptions = service.suggest.entity; + addSuggest = true; + } else if (ReconciliationManager.isFreebaseId(service.identifierSpace)) { + addSuggest = true; + } + + if (addSuggest) { + $('') + .addClass("data-table-recon-search") + .click(function(evt) {console.log(suggestOptions); + self._searchForMatch(suggestOptions); + return false; + }) + .text("search for match") + .appendTo($('
').appendTo(divContent)); + } + } } } } @@ -236,7 +250,7 @@ DataTableCellUI.prototype._doJudgmentForSimilarCells = function(judgment, params this._postProcessSeveralCells("recon-judge-similar-cells", params, true); }; -DataTableCellUI.prototype._searchForMatch = function() { +DataTableCellUI.prototype._searchForMatch = function(suggestOptions) { var self = this; var frame = DialogSystem.createDialog(); frame.width("400px"); @@ -260,41 +274,28 @@ DataTableCellUI.prototype._searchForMatch = function() { var match = null; var commit = function() { if (match !== null) { - var query = { - "id" : match.id, - "type" : [] + var params = { + judgment: "matched", + id: match.id, + name: match.name, + types: $.map(match.type, function(elmt) { + return typeof elmt == "string" ? elmt : elmt.id; + }).join(",") }; - var baseUrl = "http://api.freebase.com/api/service/mqlread"; - var url = baseUrl + "?" + $.param({ query: JSON.stringify({ query: query }) }) + "&callback=?"; - $.getJSON( - url, - null, - function(o) { - var types = "result" in o ? o.result.type : []; - var params = { - judgment: "matched", - topicID: match.id, - topicGUID: match.guid, - topicName: match.name, - types: $.map(types, function(elmt) { return elmt.id; }).join(",") - }; - if (elmts.checkSimilar[0].checked) { - params.similarValue = self._cell.v; - params.columnName = Gridworks.cellIndexToColumn(self._cellIndex).name; + if (elmts.checkSimilar[0].checked) { + params.similarValue = self._cell.v; + params.columnName = Gridworks.cellIndexToColumn(self._cellIndex).name; - self._postProcessSeveralCells("recon-judge-similar-cells", params, true); - } else { - params.row = self._rowIndex; - params.cell = self._cellIndex; + self._postProcessSeveralCells("recon-judge-similar-cells", params, true); + } else { + params.row = self._rowIndex; + params.cell = self._cellIndex; - self._postProcessOneCell("recon-judge-one-cell", params, true); - } + self._postProcessOneCell("recon-judge-one-cell", params, true); + } - DialogSystem.dismissUntil(level - 1); - }, - "jsonp" - ); + DialogSystem.dismissUntil(level - 1); } }; @@ -307,7 +308,9 @@ DataTableCellUI.prototype._searchForMatch = function() { elmts.input .attr("value", this._cell.v) - .suggest({}) + .suggest(suggestOptions || { + all_types: true + }) .bind("fb-select", function(e, data) { match = data; commit();