"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
This commit is contained in:
parent
40c5fb8ff1
commit
76c8cd77eb
@ -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
|
||||
);
|
||||
|
@ -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
|
||||
);
|
||||
|
@ -169,10 +169,22 @@ DataTableCellUI.prototype._render = function() {
|
||||
|
||||
$('<span>').text("(New topic)").appendTo(liNew);
|
||||
|
||||
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) {
|
||||
$('<a href="javascript:{}"></a>')
|
||||
.addClass("data-table-recon-search")
|
||||
.click(function(evt) {
|
||||
self._searchForMatch();
|
||||
.click(function(evt) {console.log(suggestOptions);
|
||||
self._searchForMatch(suggestOptions);
|
||||
return false;
|
||||
})
|
||||
.text("search for match")
|
||||
@ -180,6 +192,8 @@ DataTableCellUI.prototype._render = function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
divContent.appendTo(this._td);
|
||||
};
|
||||
@ -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,25 +274,15 @@ DataTableCellUI.prototype._searchForMatch = function() {
|
||||
var match = null;
|
||||
var commit = function() {
|
||||
if (match !== null) {
|
||||
var query = {
|
||||
"id" : match.id,
|
||||
"type" : []
|
||||
};
|
||||
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(",")
|
||||
id: match.id,
|
||||
name: match.name,
|
||||
types: $.map(match.type, function(elmt) {
|
||||
return typeof elmt == "string" ? elmt : elmt.id;
|
||||
}).join(",")
|
||||
};
|
||||
|
||||
if (elmts.checkSimilar[0].checked) {
|
||||
params.similarValue = self._cell.v;
|
||||
params.columnName = Gridworks.cellIndexToColumn(self._cellIndex).name;
|
||||
@ -292,9 +296,6 @@ DataTableCellUI.prototype._searchForMatch = function() {
|
||||
}
|
||||
|
||||
DialogSystem.dismissUntil(level - 1);
|
||||
},
|
||||
"jsonp"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user