Jackson deserialization for ColumnAdditionOperation
This commit is contained in:
parent
a07f825aad
commit
99852a193c
@ -33,6 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
package com.google.refine.operations.column;
|
package com.google.refine.operations.column;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -40,6 +41,7 @@ import java.util.Properties;
|
|||||||
|
|
||||||
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.browsing.Engine;
|
import com.google.refine.browsing.Engine;
|
||||||
@ -61,7 +63,7 @@ import com.google.refine.model.changes.CellAtRow;
|
|||||||
import com.google.refine.model.changes.ColumnAdditionChange;
|
import com.google.refine.model.changes.ColumnAdditionChange;
|
||||||
import com.google.refine.operations.EngineDependentOperation;
|
import com.google.refine.operations.EngineDependentOperation;
|
||||||
import com.google.refine.operations.OnError;
|
import com.google.refine.operations.OnError;
|
||||||
import com.google.refine.operations.cell.TextTransformOperation;
|
import com.google.refine.util.ParsingUtilities;
|
||||||
|
|
||||||
public class ColumnAdditionOperation extends EngineDependentOperation {
|
public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||||
final protected String _baseColumnName;
|
final protected String _baseColumnName;
|
||||||
@ -71,25 +73,23 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
|||||||
final protected String _newColumnName;
|
final protected String _newColumnName;
|
||||||
final protected int _columnInsertIndex;
|
final protected int _columnInsertIndex;
|
||||||
|
|
||||||
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
|
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
|
||||||
JSONObject engineConfig = obj.getJSONObject("engineConfig");
|
return ParsingUtilities.mapper.readValue(obj.toString(), ColumnAdditionOperation.class);
|
||||||
|
|
||||||
return new ColumnAdditionOperation(
|
|
||||||
EngineConfig.reconstruct(engineConfig),
|
|
||||||
obj.getString("baseColumnName"),
|
|
||||||
obj.getString("expression"),
|
|
||||||
TextTransformOperation.stringToOnError(obj.getString("onError")),
|
|
||||||
obj.getString("newColumnName"),
|
|
||||||
obj.getInt("columnInsertIndex")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
public ColumnAdditionOperation(
|
public ColumnAdditionOperation(
|
||||||
|
@JsonProperty("engineConfig")
|
||||||
EngineConfig engineConfig,
|
EngineConfig engineConfig,
|
||||||
|
@JsonProperty("baseColumnName")
|
||||||
String baseColumnName,
|
String baseColumnName,
|
||||||
|
@JsonProperty("expression")
|
||||||
String expression,
|
String expression,
|
||||||
|
@JsonProperty("onError")
|
||||||
OnError onError,
|
OnError onError,
|
||||||
String newColumnName,
|
@JsonProperty("newColumnName")
|
||||||
|
String newColumnName,
|
||||||
|
@JsonProperty("columnInsertIndex")
|
||||||
int columnInsertIndex
|
int columnInsertIndex
|
||||||
) {
|
) {
|
||||||
super(engineConfig);
|
super(engineConfig);
|
||||||
|
Loading…
Reference in New Issue
Block a user