Jackson deserialization for ReconOperation

This commit is contained in:
Antonin Delpeuch 2018-10-22 10:38:55 +01:00
parent 08c2b8fb2b
commit 0a5ea4e3dd

View File

@ -44,6 +44,7 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -75,19 +76,17 @@ public class ReconOperation extends EngineDependentOperation {
final protected String _columnName; final protected String _columnName;
final protected ReconConfig _reconConfig; final protected ReconConfig _reconConfig;
static public ReconOperation reconstruct(Project project, JSONObject obj) throws Exception { static public ReconOperation reconstruct(Project project, JSONObject obj) throws IOException {
JSONObject engineConfig = obj.getJSONObject("engineConfig"); return ParsingUtilities.mapper.readValue(obj.toString(), ReconOperation.class);
return new ReconOperation(
EngineConfig.reconstruct(engineConfig),
obj.getString("columnName"),
ReconConfig.reconstruct(obj.getJSONObject("config").toString())
);
} }
@JsonCreator
public ReconOperation( public ReconOperation(
@JsonProperty("engineConfig")
EngineConfig engineConfig, EngineConfig engineConfig,
@JsonProperty("columnName")
String columnName, String columnName,
@JsonProperty("config")
ReconConfig reconConfig ReconConfig reconConfig
) { ) {
super(engineConfig); super(engineConfig);