Save a change right after it gets applied rather than when it gets created. This is because when a change gets applied, it might grab onto the old data in order to able to revert later, and we need to save that old data together with the change.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@74 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
cd376c7532
commit
b7cf18b86a
@ -38,8 +38,6 @@ public class HistoryEntry implements Serializable, Jsonizable {
|
|||||||
this.time = new Date();
|
this.time = new Date();
|
||||||
|
|
||||||
_change = change;
|
_change = change;
|
||||||
|
|
||||||
saveChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(JSONWriter writer, Properties options)
|
public void write(JSONWriter writer, Properties options)
|
||||||
@ -59,6 +57,11 @@ public class HistoryEntry implements Serializable, Jsonizable {
|
|||||||
loadChange();
|
loadChange();
|
||||||
}
|
}
|
||||||
_change.apply(project);
|
_change.apply(project);
|
||||||
|
|
||||||
|
// When a change is applied, it can hang on to old data (in order to be able
|
||||||
|
// to revert later). Hence, we need to save the change out.
|
||||||
|
|
||||||
|
saveChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void revert(Project project) {
|
public void revert(Project project) {
|
||||||
|
@ -5,20 +5,87 @@ SchemaAlignment.autoAlign = function() {
|
|||||||
|
|
||||||
var columns = theProject.columnModel.columns;
|
var columns = theProject.columnModel.columns;
|
||||||
|
|
||||||
var typedColumns = [];
|
var typedCandidates = [];
|
||||||
var candidates = [];
|
var candidates = [];
|
||||||
|
|
||||||
for (var c = 0; c < columns.length; c++) {
|
for (var c = 0; c < columns.length; c++) {
|
||||||
var column = columns[c];
|
var column = columns[c];
|
||||||
if ("reconConfig" in column && column.reconConfig != null) {
|
var typed = "reconConfig" in column && column.reconConfig != null;
|
||||||
typedColumns.push(column);
|
var candidate = {
|
||||||
}
|
|
||||||
candidates.push({
|
|
||||||
status: "unbound",
|
status: "unbound",
|
||||||
|
typed: typed,
|
||||||
index: c,
|
index: c,
|
||||||
column: column
|
column: column
|
||||||
})
|
};
|
||||||
|
|
||||||
|
candidates.push(candidate);
|
||||||
|
if (typed) {
|
||||||
|
typedCandidates.push(candidate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typedCandidates.length > 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var queries = {};
|
||||||
|
for (var i = 0; i < candidates.length; i++) {
|
||||||
|
var candidate = candidates[i];
|
||||||
|
var name = SchemaAlignment._cleanName(candidate.column.headerLabel);
|
||||||
|
var key = "t" + i + ":search";
|
||||||
|
queries[key] = {
|
||||||
|
"query" : name,
|
||||||
|
"limit" : 10,
|
||||||
|
"type" : "/type/type,/type/property",
|
||||||
|
"type_strict" : "any"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
SchemaAlignment._batchSearch(queries, function(result) {
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignment._batchSearch = function(queries, onDone) {
|
||||||
|
var keys = [];
|
||||||
|
for (var n in queries) {
|
||||||
|
if (queries.hasOwnProperty(n)) {
|
||||||
|
keys.push(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
var result = {};
|
||||||
|
var args = [];
|
||||||
|
var makeBatch = function(keyBatch) {
|
||||||
|
var batch = {};
|
||||||
|
for (var k = 0; k < keyBatch.length; k++) {
|
||||||
|
var key = keyBatch[k];
|
||||||
|
batch[key] = queries[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push("http://api.freebase.com/api/service/search?" +
|
||||||
|
$.param({ "queries" : JSON.stringify(batch) }) + "&callback=?");
|
||||||
|
|
||||||
|
args.push(null); // no data
|
||||||
|
args.push(function(data) {
|
||||||
|
for (var k = 0; k < keyBatch.length; k++) {
|
||||||
|
var key = keyBatch[k];
|
||||||
|
result[key] = data[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var i = 0; i < keys.length; i += 10) {
|
||||||
|
makeBatch(keys.slice(i, i + 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push(function() {
|
||||||
|
onDone(result);
|
||||||
|
})
|
||||||
|
|
||||||
|
Ajax.chainGetJSON.apply(null, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignment._cleanName = function(s) {
|
||||||
|
return s.replace(/\W/g, " ").replace(/\s+/g, " ").toLowerCase();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user