Made extend data from freebase command available on columns not officially reconciled, since some columns might contain reconciled data copied from other columns.
More error checking in the extend data utility. git-svn-id: http://google-refine.googlecode.com/svn/trunk@583 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
d303adc48e
commit
9641f28fe0
@ -61,6 +61,10 @@ public class PreviewExtendDataCommand extends Command {
|
||||
topicNames.add(cell.recon.match.topicName);
|
||||
topicGuids.add(cell.recon.match.topicGUID);
|
||||
guids.add(cell.recon.match.topicGUID);
|
||||
} else {
|
||||
topicNames.add(null);
|
||||
topicGuids.add(null);
|
||||
guids.add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,7 +105,7 @@ public class PreviewExtendDataCommand extends Command {
|
||||
String guid = topicGuids.get(r);
|
||||
String topicName = topicNames.get(r);
|
||||
|
||||
if (map.containsKey(guid)) {
|
||||
if (guid != null && map.containsKey(guid)) {
|
||||
DataExtension ext = map.get(guid);
|
||||
boolean first = true;
|
||||
|
||||
@ -134,7 +138,14 @@ public class PreviewExtendDataCommand extends Command {
|
||||
}
|
||||
|
||||
writer.array();
|
||||
writer.value(topicName);
|
||||
if (guid != null) {
|
||||
writer.object();
|
||||
writer.key("id"); writer.value("/guid/" + guid.substring(1));
|
||||
writer.key("name"); writer.value(topicName);
|
||||
writer.endObject();
|
||||
} else {
|
||||
writer.value("<not reconciled>");
|
||||
}
|
||||
writer.endArray();
|
||||
}
|
||||
writer.endArray();
|
||||
|
@ -70,16 +70,18 @@ public class FreebaseDataExtensionJob {
|
||||
JSONObject o = ParsingUtilities.evaluateJsonStringToObject(s);
|
||||
|
||||
Map<String, FreebaseDataExtensionJob.DataExtension> map = new HashMap<String, FreebaseDataExtensionJob.DataExtension>();
|
||||
JSONArray a = o.getJSONArray("result");
|
||||
int l = a.length();
|
||||
|
||||
for (int i = 0; i < l; i++) {
|
||||
JSONObject o2 = a.getJSONObject(i);
|
||||
String guid = o2.getString("guid");
|
||||
FreebaseDataExtensionJob.DataExtension ext = collectResult(o2, reconCandidateMap);
|
||||
if (o.has("result")) {
|
||||
JSONArray a = o.getJSONArray("result");
|
||||
int l = a.length();
|
||||
|
||||
if (ext != null) {
|
||||
map.put(guid, ext);
|
||||
for (int i = 0; i < l; i++) {
|
||||
JSONObject o2 = a.getJSONObject(i);
|
||||
String guid = o2.getString("guid");
|
||||
FreebaseDataExtensionJob.DataExtension ext = collectResult(o2, reconCandidateMap);
|
||||
|
||||
if (ext != null) {
|
||||
map.put(guid, ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +286,9 @@ public class FreebaseDataExtensionJob {
|
||||
jsonWriter.key("guid|=");
|
||||
jsonWriter.array();
|
||||
for (String guid : guids) {
|
||||
jsonWriter.value(guid);
|
||||
if (guid != null) {
|
||||
jsonWriter.value(guid);
|
||||
}
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
|
||||
|
@ -53,8 +53,9 @@ function ExtendDataPreviewDialog(column, columnIndex, rowIndices, onDone) {
|
||||
}).appendTo(footer);
|
||||
|
||||
var dismissBusy = DialogSystem.showBusy();
|
||||
var type = "reconConfig" in column && "type" in column.reconConfig ? column.reconConfig.type.id : "/common/topic";
|
||||
|
||||
ExtendDataPreviewDialog.getAllProperties(column.reconConfig.type.id, function(properties) {
|
||||
ExtendDataPreviewDialog.getAllProperties(type, function(properties) {
|
||||
dismissBusy();
|
||||
self._show(properties);
|
||||
});
|
||||
@ -131,12 +132,14 @@ ExtendDataPreviewDialog.prototype._show = function(properties) {
|
||||
}
|
||||
|
||||
var suggestConfig = {
|
||||
type: '/type/property',
|
||||
schema: this._column.reconConfig.type.id
|
||||
type: '/type/property'
|
||||
};
|
||||
if ("reconConfig" in this._column && "type" in this._column.reconConfig) {
|
||||
suggestConfig.schema = this._column.reconConfig.type.id
|
||||
}
|
||||
|
||||
this._elmts.addPropertyInput.suggestP(suggestConfig).bind("fb-select", function(evt, data) {
|
||||
var expected = data["/type/property/expected_type"];
|
||||
var expected = data["expected_type"];
|
||||
self._addProperty({
|
||||
id : data.id,
|
||||
name: data.name,
|
||||
|
@ -866,30 +866,26 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doAddColumnFromFreebase = function() {
|
||||
if ("reconConfig" in this._column && "type" in this._column.reconConfig) {
|
||||
var o = DataTableView.sampleVisibleRows(this._column);
|
||||
var self = this;
|
||||
new ExtendDataPreviewDialog(
|
||||
this._column,
|
||||
this._columnIndex,
|
||||
o.rowIndices,
|
||||
function(extension) {
|
||||
Gridworks.postProcess(
|
||||
"extend-data",
|
||||
{
|
||||
baseColumnName: self._column.name,
|
||||
columnInsertIndex: self._columnIndex + 1
|
||||
},
|
||||
{
|
||||
extension: JSON.stringify(extension)
|
||||
},
|
||||
{ rowsChanged: true, modelsChanged: true }
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
alert("This column has not been reconciled yet.");
|
||||
}
|
||||
var o = DataTableView.sampleVisibleRows(this._column);
|
||||
var self = this;
|
||||
new ExtendDataPreviewDialog(
|
||||
this._column,
|
||||
this._columnIndex,
|
||||
o.rowIndices,
|
||||
function(extension) {
|
||||
Gridworks.postProcess(
|
||||
"extend-data",
|
||||
{
|
||||
baseColumnName: self._column.name,
|
||||
columnInsertIndex: self._columnIndex + 1
|
||||
},
|
||||
{
|
||||
extension: JSON.stringify(extension)
|
||||
},
|
||||
{ rowsChanged: true, modelsChanged: true }
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doRemoveColumn = function() {
|
||||
|
Loading…
Reference in New Issue
Block a user