Fixed bug in saving recon changes.
Fixed bug in discard recon judgment operation. git-svn-id: http://google-refine.googlecode.com/svn/trunk@218 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
78b1eb7e73
commit
db824bffeb
@ -75,7 +75,7 @@ public class Cell implements Serializable, HasFields, Jsonizable {
|
||||
}
|
||||
|
||||
static public Cell load(String s) throws Exception {
|
||||
return load(ParsingUtilities.evaluateJsonStringToObject(s));
|
||||
return s.length() == 0 ? null : load(ParsingUtilities.evaluateJsonStringToObject(s));
|
||||
}
|
||||
|
||||
static public Cell load(JSONObject obj) throws Exception {
|
||||
|
@ -118,7 +118,7 @@ public class Column implements Serializable, Jsonizable {
|
||||
column._reconConfig = ReconConfig.reconstruct(obj.getJSONObject("reconConfig"));
|
||||
}
|
||||
if (obj.has("reconStats")) {
|
||||
column._reconStats = ReconStats.reconstruct(obj.getJSONObject("reconStats"));
|
||||
column._reconStats = ReconStats.load(obj.getJSONObject("reconStats"));
|
||||
}
|
||||
|
||||
return column;
|
||||
|
@ -82,8 +82,10 @@ public class Recon implements Serializable, HasFields, Jsonizable {
|
||||
if (candidates != null) {
|
||||
r.candidates = new ArrayList<ReconCandidate>(candidates);
|
||||
}
|
||||
|
||||
r.judgment = judgment;
|
||||
r.match = match;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import com.metaweb.gridworks.model.Recon.Judgment;
|
||||
public class ReconStats implements Serializable, Jsonizable {
|
||||
private static final long serialVersionUID = -4831409797104437854L;
|
||||
|
||||
static public ReconStats reconstruct(JSONObject obj) throws Exception {
|
||||
static public ReconStats load(JSONObject obj) throws Exception {
|
||||
return new ReconStats(
|
||||
obj.getInt("nonBlanks"),
|
||||
obj.getInt("newTopics"),
|
||||
|
@ -162,8 +162,10 @@ public class Row implements Serializable, HasFields, Jsonizable {
|
||||
}
|
||||
|
||||
static public Row load(String s) throws Exception {
|
||||
JSONObject obj = ParsingUtilities.evaluateJsonStringToObject(s);
|
||||
return s.length() == 0 ? null : load(ParsingUtilities.evaluateJsonStringToObject(s));
|
||||
}
|
||||
|
||||
static public Row load(JSONObject obj) throws Exception {
|
||||
JSONArray a = obj.getJSONArray("cells");
|
||||
int count = a.length();
|
||||
|
||||
|
@ -66,11 +66,15 @@ public class CellChange implements Change {
|
||||
} else if ("cell".equals(field)) {
|
||||
cellIndex = Integer.parseInt(value);
|
||||
} else if ("new".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
newCell = Cell.load(value);
|
||||
}
|
||||
} else if ("old".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
oldCell = Cell.load(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new CellChange(row, cellIndex, oldCell, newCell);
|
||||
}
|
||||
|
@ -87,10 +87,30 @@ public class ReconChange extends MassCellChange {
|
||||
}
|
||||
|
||||
public void save(Writer writer, Properties options) throws IOException {
|
||||
writer.write("newReconConfig="); _newReconConfig.save(writer); writer.write('\n');
|
||||
writer.write("newReconStats="); _newReconStats.save(writer); writer.write('\n');
|
||||
writer.write("oldReconConfig="); _oldReconConfig.save(writer); writer.write('\n');
|
||||
writer.write("oldReconStats="); _oldReconStats.save(writer); writer.write('\n');
|
||||
writer.write("newReconConfig=");
|
||||
if (_newReconConfig != null) {
|
||||
_newReconConfig.save(writer);
|
||||
}
|
||||
writer.write('\n');
|
||||
|
||||
writer.write("newReconStats=");
|
||||
if (_newReconStats != null) {
|
||||
_newReconStats.save(writer);
|
||||
}
|
||||
writer.write('\n');
|
||||
|
||||
writer.write("oldReconConfig=");
|
||||
if (_oldReconConfig != null) {
|
||||
_oldReconConfig.save(writer);
|
||||
}
|
||||
writer.write('\n');
|
||||
|
||||
writer.write("oldReconStats=");
|
||||
if (_oldReconStats != null) {
|
||||
_oldReconStats.save(writer);
|
||||
}
|
||||
writer.write('\n');
|
||||
|
||||
super.save(writer, options);
|
||||
}
|
||||
|
||||
@ -111,13 +131,21 @@ public class ReconChange extends MassCellChange {
|
||||
String value = line.substring(equal + 1);
|
||||
|
||||
if ("newReconConfig".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
newReconConfig = ReconConfig.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
}
|
||||
} else if ("newReconStats".equals(field)) {
|
||||
newReconStats = ReconStats.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
if (value.length() > 0) {
|
||||
newReconStats = ReconStats.load(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
}
|
||||
} else if ("oldReconConfig".equals(field)) {
|
||||
if (value.length() > 0) {
|
||||
oldReconConfig = ReconConfig.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
}
|
||||
} else if ("oldReconStats".equals(field)) {
|
||||
oldReconStats = ReconStats.reconstruct(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
if (value.length() > 0) {
|
||||
oldReconStats = ReconStats.load(ParsingUtilities.evaluateJsonStringToObject(value));
|
||||
}
|
||||
} else if ("commonColumnName".equals(field)) {
|
||||
commonColumnName = value;
|
||||
} else if ("cellChangeCount".equals(field)) {
|
||||
|
@ -72,18 +72,17 @@ public class ReconDiscardJudgmentsOperation extends EngineDependentMassCellOpera
|
||||
}
|
||||
|
||||
public boolean visit(Project project, int rowIndex, Row row, boolean contextual) {
|
||||
if (cellIndex < row.cells.size()) {
|
||||
Cell cell = row.cells.get(cellIndex);
|
||||
if (cell.recon != null) {
|
||||
Cell cell = row.getCell(cellIndex);
|
||||
if (cell != null && cell.recon != null) {
|
||||
Recon recon = cell.recon.dup();
|
||||
recon.judgment = Judgment.None;
|
||||
recon.match = null;
|
||||
|
||||
Cell newCell = new Cell(cell.value, recon);
|
||||
|
||||
CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell);
|
||||
cellChanges.add(cellChange);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}.init(column.getCellIndex(), cellChanges);
|
||||
|
Loading…
Reference in New Issue
Block a user