Fix deserialization of MassEditOperation

This commit is contained in:
Antonin Delpeuch 2018-11-02 15:06:54 +00:00
parent 2873035ee2
commit 5cf58d874b
2 changed files with 13 additions and 4 deletions

View File

@ -77,7 +77,7 @@ public class MassEditOperation extends EngineDependentMassCellOperation {
boolean fromError,
Serializable to) {
this.from = from;
this.fromBlank = fromBlank;
this.fromBlank = fromBlank || (from.size() == 1 && from.get(0).length() == 0);
this.fromError = fromError;
this.to = to;
}
@ -103,7 +103,16 @@ public class MassEditOperation extends EngineDependentMassCellOperation {
}
}
public MassEditOperation(EngineConfig engineConfig, String columnName, String expression, List<Edit> edits) {
@JsonCreator
public MassEditOperation(
@JsonProperty("engineConfig")
EngineConfig engineConfig,
@JsonProperty("columnName")
String columnName,
@JsonProperty("expression")
String expression,
@JsonProperty("edits")
List<Edit> edits) {
super(engineConfig, columnName, true);
_expression = expression;
_edits = edits;

View File

@ -93,7 +93,7 @@ public class MassOperationTests extends RefineTest {
public void testReconstructEditDate() throws Exception {
editsString = "[{\"from\":[\"2018-10-04T00:00:00Z\"],\"to\":\"newString\",\"type\":\"text\"}]";
editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference<List<Edit>>() {});
editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference<List<Edit>>() {});
Assert.assertEquals(editList.get(0).from.get(0), "2018-10-04T00:00:00Z");
Assert.assertEquals(editList.get(0).to,"newString" );
@ -105,7 +105,7 @@ public class MassOperationTests extends RefineTest {
public void testReconstructEditEmpty() throws Exception {
editsString = "[{\"from\":[\"\"],\"to\":\"newString\",\"type\":\"text\"}]";
editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference<List<Edit>>() {});
editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference<List<Edit>>() {});
Assert.assertEquals(editList.get(0).from.size(), 1);
Assert.assertEquals(editList.get(0).from.get(0), "");