From 5f196286181cd07daea5f7637cd7b8dc07da01d6 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 22 Oct 2018 10:51:12 +0100 Subject: [PATCH] Jackson deserialization for RowFlagOperation --- .../refine/operations/row/RowFlagOperation.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/main/src/com/google/refine/operations/row/RowFlagOperation.java b/main/src/com/google/refine/operations/row/RowFlagOperation.java index b251d5ba8..5a998edda 100644 --- a/main/src/com/google/refine/operations/row/RowFlagOperation.java +++ b/main/src/com/google/refine/operations/row/RowFlagOperation.java @@ -38,6 +38,7 @@ import java.util.List; import org.json.JSONObject; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.Engine; @@ -52,21 +53,21 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.MassChange; import com.google.refine.model.changes.RowFlagChange; import com.google.refine.operations.EngineDependentOperation; +import com.google.refine.util.ParsingUtilities; public class RowFlagOperation extends EngineDependentOperation { final protected boolean _flagged; static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - JSONObject engineConfig = obj.getJSONObject("engineConfig"); - boolean flagged = obj.getBoolean("flagged"); - - return new RowFlagOperation( - EngineConfig.reconstruct(engineConfig), - flagged - ); + return ParsingUtilities.mapper.readValue(obj.toString(), RowFlagOperation.class); } - public RowFlagOperation(EngineConfig engineConfig, boolean flagged) { + @JsonCreator + public RowFlagOperation( + @JsonProperty("engineConfig") + EngineConfig engineConfig, + @JsonProperty("flagged") + boolean flagged) { super(engineConfig); _flagged = flagged; }