From 50ee6ecc6122c7767b8f9a58fd09f3a4a1e29dcc Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 22 Oct 2018 13:13:38 +0100 Subject: [PATCH] Jackson deserialization for KeyValueColumnizeOperation --- .../cell/KeyValueColumnizeOperation.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java b/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java index c4d29535d..cfb9398f5 100644 --- a/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java +++ b/main/src/com/google/refine/operations/cell/KeyValueColumnizeOperation.java @@ -33,6 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.operations.cell; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -40,6 +41,7 @@ import java.util.Map; import org.json.JSONObject; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.expr.ExpressionUtils; @@ -50,24 +52,24 @@ import com.google.refine.model.Column; import com.google.refine.model.Project; import com.google.refine.model.Row; import com.google.refine.model.changes.MassRowColumnChange; -import com.google.refine.util.JSONUtilities; +import com.google.refine.util.ParsingUtilities; public class KeyValueColumnizeOperation extends AbstractOperation { final protected String _keyColumnName; final protected String _valueColumnName; final protected String _noteColumnName; - static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { - return new KeyValueColumnizeOperation( - obj.getString("keyColumnName"), - obj.getString("valueColumnName"), - JSONUtilities.getString(obj, "noteColumnName", null) - ); + static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException { + return ParsingUtilities.mapper.readValue(obj.toString(), KeyValueColumnizeOperation.class); } + @JsonCreator public KeyValueColumnizeOperation( + @JsonProperty("keyColumnName") String keyColumnName, + @JsonProperty("valueColumnName") String valueColumnName, + @JsonProperty("noteColumnName") String noteColumnName ) { _keyColumnName = keyColumnName;