Jackson deserialization for ReconUseValuesAsIdsOperation

This commit is contained in:
Antonin Delpeuch 2018-10-22 10:41:41 +01:00
parent 0a5ea4e3dd
commit c58854d947
2 changed files with 12 additions and 12 deletions

View File

@ -1,11 +1,12 @@
package com.google.refine.operations.recon; package com.google.refine.operations.recon;
import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Properties;
import org.json.JSONObject; import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ -24,7 +25,7 @@ import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange; import com.google.refine.model.changes.ReconChange;
import com.google.refine.model.recon.StandardReconConfig; import com.google.refine.model.recon.StandardReconConfig;
import com.google.refine.operations.EngineDependentMassCellOperation; import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.operations.OperationRegistry; import com.google.refine.util.ParsingUtilities;
public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCellOperation { public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCellOperation {
@ -38,11 +39,17 @@ public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCel
@JsonIgnore @JsonIgnore
protected StandardReconConfig reconConfig; protected StandardReconConfig reconConfig;
@JsonCreator
public ReconUseValuesAsIdentifiersOperation( public ReconUseValuesAsIdentifiersOperation(
@JsonProperty("engineConfig")
EngineConfig engineConfig, EngineConfig engineConfig,
@JsonProperty("columnName")
String columnName, String columnName,
@JsonProperty("service")
String service, String service,
@JsonProperty("identifierSpace")
String identifierSpace, String identifierSpace,
@JsonProperty("schemaSpace")
String schemaSpace) { String schemaSpace) {
super(engineConfig, columnName, false); super(engineConfig, columnName, false);
this.service = service; this.service = service;
@ -51,15 +58,8 @@ public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCel
this.reconConfig = new StandardReconConfig(service, identifierSpace, schemaSpace, null, null, true, Collections.emptyList()); this.reconConfig = new StandardReconConfig(service, identifierSpace, schemaSpace, null, null, true, Collections.emptyList());
} }
static public ReconUseValuesAsIdentifiersOperation reconstruct(JSONObject obj) throws Exception { static public ReconUseValuesAsIdentifiersOperation reconstruct(JSONObject obj) throws IOException {
JSONObject engineConfig = obj.getJSONObject("engineConfig"); return ParsingUtilities.mapper.readValue(obj.toString(), ReconUseValuesAsIdentifiersOperation.class);
return new ReconUseValuesAsIdentifiersOperation(
EngineConfig.reconstruct(engineConfig),
obj.getString("columnName"),
obj.getString("service"),
obj.getString("identifierSpace"),
obj.getString("schemaSpace")
);
} }
@Override @Override

View File

@ -18,7 +18,7 @@ import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils; import com.google.refine.tests.util.TestUtils;
public class ReconUseValuesAsIdsOperation extends RefineTest { public class ReconUseValuesAsIdsOperationTests extends RefineTest {
String json = "{" String json = "{"
+ "\"op\":\"core/recon-use-values-as-identifiers\"," + "\"op\":\"core/recon-use-values-as-identifiers\","
+ "\"description\":\"Use values as reconciliation identifiers in column ids\"," + "\"description\":\"Use values as reconciliation identifiers in column ids\","