From 0c87687e9262ac2a73cc74f8f6225eed7d82854d Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 22 Oct 2018 11:27:31 +0100 Subject: [PATCH] Jackson deserialization for RowStarOperation --- .../operations/row/RowStarOperation.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/main/src/com/google/refine/operations/row/RowStarOperation.java b/main/src/com/google/refine/operations/row/RowStarOperation.java index d7be153b4..ed88f6d31 100644 --- a/main/src/com/google/refine/operations/row/RowStarOperation.java +++ b/main/src/com/google/refine/operations/row/RowStarOperation.java @@ -33,11 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.row; - import java.util.ArrayList; + import java.io.IOException; +import java.util.ArrayList; 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 +54,21 @@ import com.google.refine.model.Row; import com.google.refine.model.changes.MassChange; import com.google.refine.model.changes.RowStarChange; import com.google.refine.operations.EngineDependentOperation; +import com.google.refine.util.ParsingUtilities; public class RowStarOperation extends EngineDependentOperation { final protected boolean _starred; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - JSONObject engineConfig = obj.getJSONObject("engineConfig"); - boolean starred = obj.getBoolean("starred"); - - return new RowStarOperation( - EngineConfig.reconstruct(engineConfig), - starred - ); + static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { + return ParsingUtilities.mapper.readValue(obj.toString(), RowStarOperation.class); } - public RowStarOperation(EngineConfig engineConfig, boolean starred) { + @JsonCreator + public RowStarOperation( + @JsonProperty("engineConfig") + EngineConfig engineConfig, + @JsonProperty("starred") + boolean starred) { super(engineConfig); _starred = starred; }