Jackson deserialization for TransposeRowsIntoColumnsOperation

This commit is contained in:
Antonin Delpeuch 2018-10-22 13:56:46 +01:00
parent 6358a4aeb5
commit 8f9004f7ee

View File

@ -38,6 +38,7 @@ import java.util.List;
import org.json.JSONObject; import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.history.HistoryEntry; import com.google.refine.history.HistoryEntry;
@ -47,20 +48,21 @@ import com.google.refine.model.Column;
import com.google.refine.model.Project; import com.google.refine.model.Project;
import com.google.refine.model.Row; import com.google.refine.model.Row;
import com.google.refine.model.changes.MassRowColumnChange; import com.google.refine.model.changes.MassRowColumnChange;
import com.google.refine.util.ParsingUtilities;
public class TransposeRowsIntoColumnsOperation extends AbstractOperation { public class TransposeRowsIntoColumnsOperation extends AbstractOperation {
final protected String _columnName; final protected String _columnName;
final protected int _rowCount; final protected int _rowCount;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception { static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return new TransposeRowsIntoColumnsOperation( return ParsingUtilities.mapper.readValue(obj.toString(), TransposeRowsIntoColumnsOperation.class);
obj.getString("columnName"),
obj.getInt("rowCount")
);
} }
@JsonCreator
public TransposeRowsIntoColumnsOperation( public TransposeRowsIntoColumnsOperation(
@JsonProperty("columnName")
String columnName, String columnName,
@JsonProperty("rowCount")
int rowCount int rowCount
) { ) {
_columnName = columnName; _columnName = columnName;