Various serialization fixes
This commit is contained in:
parent
1790799bfe
commit
fec28b99bc
@ -41,6 +41,7 @@ import java.util.stream.Collectors;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
@ -69,8 +70,9 @@ public class Engine {
|
|||||||
public final static String MODE_RECORD_BASED = "record-based";
|
public final static String MODE_RECORD_BASED = "record-based";
|
||||||
|
|
||||||
protected Project _project;
|
protected Project _project;
|
||||||
|
@JsonProperty("facets")
|
||||||
protected List<Facet> _facets = new LinkedList<Facet>();
|
protected List<Facet> _facets = new LinkedList<Facet>();
|
||||||
@JsonValue
|
@JsonIgnore
|
||||||
protected EngineConfig _config = new EngineConfig(Collections.emptyList(), Mode.RowBased);
|
protected EngineConfig _config = new EngineConfig(Collections.emptyList(), Mode.RowBased);
|
||||||
|
|
||||||
static public String modeToString(Mode mode) {
|
static public String modeToString(Mode mode) {
|
||||||
@ -84,6 +86,7 @@ public class Engine {
|
|||||||
_project = project;
|
_project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonProperty("engine-mode")
|
||||||
public Mode getMode() {
|
public Mode getMode() {
|
||||||
return _config.getMode();
|
return _config.getMode();
|
||||||
}
|
}
|
||||||
|
@ -231,16 +231,18 @@ public class ListFacet implements Facet {
|
|||||||
@JsonProperty("choiceCount")
|
@JsonProperty("choiceCount")
|
||||||
@JsonInclude(Include.NON_NULL)
|
@JsonInclude(Include.NON_NULL)
|
||||||
public Integer getChoiceCount() {
|
public Integer getChoiceCount() {
|
||||||
if (_errorMessage == null && _choices.size() > getLimit())
|
if (_errorMessage == null && _choices.size() > getLimit()) {
|
||||||
return _choices.size();
|
return _choices.size();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("choices")
|
@JsonProperty("choices")
|
||||||
@JsonInclude(Include.NON_NULL)
|
@JsonInclude(Include.NON_NULL)
|
||||||
public List<NominalFacetChoice> getChoices() {
|
public List<NominalFacetChoice> getChoices() {
|
||||||
if (getError() == null)
|
if (getError() == null) {
|
||||||
return _choices;
|
return _choices;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,14 +43,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
import com.google.refine.ProjectManager;
|
import com.google.refine.ProjectManager;
|
||||||
import com.google.refine.preference.PreferenceStore;
|
import com.google.refine.preference.PreferenceStore;
|
||||||
|
import com.google.refine.preference.TopList;
|
||||||
|
|
||||||
public class GetPreferenceCommand extends Command {
|
public class GetPreferenceCommand extends Command {
|
||||||
protected static class PreferenceValue {
|
protected static class PreferenceValue {
|
||||||
@JsonProperty("value")
|
@JsonProperty("value")
|
||||||
protected Object pref;
|
protected Object value;
|
||||||
|
|
||||||
protected PreferenceValue(Object o) {
|
protected PreferenceValue(Object pref) {
|
||||||
pref = o;
|
if (pref == null || pref instanceof String || pref instanceof Number || pref instanceof Boolean || pref instanceof TopList) {
|
||||||
|
value = pref;
|
||||||
|
} else {
|
||||||
|
value = pref.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import com.google.refine.RefineServlet;
|
import com.google.refine.RefineServlet;
|
||||||
|
|
||||||
abstract public class HttpHeadersSupport {
|
abstract public class HttpHeadersSupport {
|
||||||
@ -44,8 +47,11 @@ abstract public class HttpHeadersSupport {
|
|||||||
static final protected Map<String, HttpHeaderInfo> s_headers = new HashMap<String, HttpHeaderInfo>();
|
static final protected Map<String, HttpHeaderInfo> s_headers = new HashMap<String, HttpHeaderInfo>();
|
||||||
|
|
||||||
static public class HttpHeaderInfo {
|
static public class HttpHeaderInfo {
|
||||||
|
@JsonIgnore
|
||||||
final public String name;
|
final public String name;
|
||||||
|
@JsonProperty("header")
|
||||||
final public String header;
|
final public String header;
|
||||||
|
@JsonProperty("defaultValue")
|
||||||
final public String defaultValue;
|
final public String defaultValue;
|
||||||
|
|
||||||
HttpHeaderInfo(String header, String defaultValue) {
|
HttpHeaderInfo(String header, String defaultValue) {
|
||||||
|
@ -39,6 +39,9 @@ import java.util.Map;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import com.google.refine.grel.Parser;
|
import com.google.refine.grel.Parser;
|
||||||
|
|
||||||
import clojure.lang.IFn;
|
import clojure.lang.IFn;
|
||||||
@ -47,8 +50,11 @@ import clojure.lang.RT;
|
|||||||
abstract public class MetaParser {
|
abstract public class MetaParser {
|
||||||
|
|
||||||
static public class LanguageInfo {
|
static public class LanguageInfo {
|
||||||
|
@JsonProperty("name")
|
||||||
final public String name;
|
final public String name;
|
||||||
|
@JsonIgnore
|
||||||
final public LanguageSpecificParser parser;
|
final public LanguageSpecificParser parser;
|
||||||
|
@JsonProperty("defaultExpression")
|
||||||
final public String defaultExpression;
|
final public String defaultExpression;
|
||||||
|
|
||||||
LanguageInfo(String name, LanguageSpecificParser parser, String defaultExpression) {
|
LanguageInfo(String name, LanguageSpecificParser parser, String defaultExpression) {
|
||||||
|
@ -42,6 +42,9 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonRawValue;
|
||||||
|
|
||||||
import com.google.refine.ProjectManager;
|
import com.google.refine.ProjectManager;
|
||||||
import com.google.refine.model.Project;
|
import com.google.refine.model.Project;
|
||||||
import com.google.refine.model.metadata.ProjectMetadata;
|
import com.google.refine.model.metadata.ProjectMetadata;
|
||||||
@ -77,6 +80,11 @@ public class ImportingJob {
|
|||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonProperty("config")
|
||||||
|
@JsonRawValue
|
||||||
|
public String getJsonConfig() {
|
||||||
|
return config.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public JSONObject getOrCreateDefaultConfig() {
|
public JSONObject getOrCreateDefaultConfig() {
|
||||||
return config;
|
return config;
|
||||||
|
@ -149,9 +149,9 @@ public class ReconOperation extends EngineDependentOperation {
|
|||||||
"{\n" +
|
"{\n" +
|
||||||
" \"action\" : \"createFacet\",\n" +
|
" \"action\" : \"createFacet\",\n" +
|
||||||
" \"facetConfig\" : {\n" +
|
" \"facetConfig\" : {\n" +
|
||||||
" \"columnName\" : \"researcher\",\n" +
|
" \"columnName\" : \"" + _columnName + "\",\n" +
|
||||||
" \"expression\" : \"forNonBlank(cell.recon.judgment, v, v, if(isNonBlank(value), \\\"(unreconciled)\\\", \\\"(blank)\\\"))\",\n" +
|
" \"expression\" : \"forNonBlank(cell.recon.judgment, v, v, if(isNonBlank(value), \\\"(unreconciled)\\\", \\\"(blank)\\\"))\",\n" +
|
||||||
" \"name\" : \"researcher: judgment\"\n" +
|
" \"name\" : \"" + _columnName + ": judgment\"\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"facetOptions\" : {\n" +
|
" \"facetOptions\" : {\n" +
|
||||||
" \"scroll\" : false\n" +
|
" \"scroll\" : false\n" +
|
||||||
@ -162,10 +162,10 @@ public class ReconOperation extends EngineDependentOperation {
|
|||||||
"{\n" +
|
"{\n" +
|
||||||
" \"action\" : \"createFacet\",\n" +
|
" \"action\" : \"createFacet\",\n" +
|
||||||
" \"facetConfig\" : {\n" +
|
" \"facetConfig\" : {\n" +
|
||||||
" \"columnName\" : \"researcher\",\n" +
|
" \"columnName\" : \"" + _columnName + "\",\n" +
|
||||||
" \"expression\" : \"cell.recon.best.score\",\n" +
|
" \"expression\" : \"cell.recon.best.score\",\n" +
|
||||||
" \"mode\" : \"range\",\n" +
|
" \"mode\" : \"range\",\n" +
|
||||||
" \"name\" : \"researcher: best candidate's score\"\n" +
|
" \"name\" : \"" + _columnName + ": best candidate's score\"\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"facetType\" : \"range\"\n" +
|
" \"facetType\" : \"range\"\n" +
|
||||||
"}";
|
"}";
|
||||||
|
@ -79,7 +79,7 @@ public class PreferenceStore {
|
|||||||
|
|
||||||
private Object wrapJSONArray(Object value) {
|
private Object wrapJSONArray(Object value) {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
if(value != null && value instanceof JSONArray) {
|
if(value != null && (value instanceof JSONArray || value instanceof JSONObject)) {
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(value.toString(), JsonNode.class);
|
return mapper.readValue(value.toString(), JsonNode.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -107,6 +107,7 @@ public class Pool {
|
|||||||
|
|
||||||
for (Recon recon : recons2) {
|
for (Recon recon : recons2) {
|
||||||
ParsingUtilities.saveWriter.writeValue(writer, recon);
|
ParsingUtilities.saveWriter.writeValue(writer, recon);
|
||||||
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class ListFacetTests extends RefineTest {
|
|||||||
+ "\"expression\":\"value+\\\"bar\\\"\","
|
+ "\"expression\":\"value+\\\"bar\\\"\","
|
||||||
+ "\"columnName\":\"Column A\","
|
+ "\"columnName\":\"Column A\","
|
||||||
+ "\"invert\":false,"
|
+ "\"invert\":false,"
|
||||||
+ "\"error\":\"No column named Column A\"}\" are not equal as JSON strings.\n" +
|
+ "\"error\":\"No column named Column A\"" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
private static String jsonFacet = "{"
|
private static String jsonFacet = "{"
|
||||||
|
Loading…
Reference in New Issue
Block a user