Jackson deserialization for RowRemovalOperation
This commit is contained in:
parent
5f19628618
commit
242a3abb7d
@ -33,11 +33,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.refine.operations.row;
|
||||
|
||||
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;
|
||||
import com.google.refine.browsing.EngineConfig;
|
||||
import com.google.refine.browsing.FilteredRows;
|
||||
@ -48,17 +52,17 @@ import com.google.refine.model.Project;
|
||||
import com.google.refine.model.Row;
|
||||
import com.google.refine.model.changes.RowRemovalChange;
|
||||
import com.google.refine.operations.EngineDependentOperation;
|
||||
import com.google.refine.util.ParsingUtilities;
|
||||
|
||||
public class RowRemovalOperation extends EngineDependentOperation {
|
||||
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
|
||||
JSONObject engineConfig = obj.getJSONObject("engineConfig");
|
||||
|
||||
return new RowRemovalOperation(
|
||||
EngineConfig.reconstruct(engineConfig)
|
||||
);
|
||||
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
|
||||
return ParsingUtilities.mapper.readValue(obj.toString(), RowRemovalOperation.class);
|
||||
}
|
||||
|
||||
public RowRemovalOperation(EngineConfig engineConfig) {
|
||||
@JsonCreator
|
||||
public RowRemovalOperation(
|
||||
@JsonProperty("engineConfig")
|
||||
EngineConfig engineConfig) {
|
||||
super(engineConfig);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.google.refine.tests.operations.row;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
@ -20,7 +22,7 @@ public class RowRemovalOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeRowRemovalOperation() throws JSONException, Exception {
|
||||
public void serializeRowRemovalOperation() throws JSONException, IOException {
|
||||
Project project = mock(Project.class);
|
||||
String json = "{"
|
||||
+ "\"op\":\"core/row-removal\","
|
||||
|
Loading…
Reference in New Issue
Block a user