Remove uses of org.json after merge

This commit is contained in:
Antonin Delpeuch 2018-12-01 05:11:21 +09:00
parent 49a89c301b
commit 2e81c9ff2e
8 changed files with 35 additions and 101 deletions

View File

@ -235,70 +235,6 @@ public class ListFacet implements Facet {
}
return null;
}
<<<<<<< HEAD
@Override
public void write(JSONWriter writer, Properties options)
throws JSONException {
writer.object();
writer.key("name"); writer.value(_config.name);
writer.key("expression"); writer.value(_config.expression);
writer.key("columnName"); writer.value(_config.columnName);
writer.key("invert"); writer.value(_config.invert);
if (_errorMessage != null) {
writer.key("error"); writer.value(_errorMessage);
} else if (_choices.size() > getLimit()) {
writer.key("error"); writer.value(ERR_TOO_MANY_CHOICES);
writer.key("choiceCount"); writer.value(_choices.size());
} else {
writer.key("choices"); writer.array();
for (NominalFacetChoice choice : _choices) {
choice.write(writer, options);
}
writer.endArray();
if (_config.selectNumber || _numberCount > 0) {
writer.key("numberChoice");
writer.object();
writer.key("s"); writer.value(_config.selectNumber);
writer.key("c"); writer.value(_numberCount);
writer.endObject();
}
if (_config.selectDateTime || _datetimeCount > 0) {
writer.key("datetimeChoice");
writer.object();
writer.key("s"); writer.value(_config.selectDateTime);
writer.key("c"); writer.value(_datetimeCount);
writer.endObject();
}
if (_config.selectBoolean || _booleanCount > 0) {
writer.key("booleanChoice");
writer.object();
writer.key("s"); writer.value(_config.selectBoolean);
writer.key("c"); writer.value(_booleanCount);
writer.endObject();
}
if (!_config.omitBlank && (_config.selectBlank || _blankCount > 0)) {
writer.key("blankChoice");
writer.object();
writer.key("s"); writer.value(_config.selectBlank);
writer.key("c"); writer.value(_blankCount);
writer.endObject();
}
if (!_config.omitError && (_config.selectError || _errorCount > 0)) {
writer.key("errorChoice");
writer.object();
writer.key("s"); writer.value(_config.selectError);
writer.key("c"); writer.value(_errorCount);
writer.endObject();
}
}
writer.endObject();
}
=======
>>>>>>> Remove Jsonizable interface and write methods
protected int getLimit() {
Object v = ProjectManager.singleton.getPreferenceStore().get("ui.browsing.listFacet.limit");

View File

@ -106,7 +106,7 @@ public class CreateProjectCommand extends Command {
}
ObjectNode optionObj = null;
String optionsString = parameters.getParameter("options");
String optionsString = parameters.getProperty("options");
if (optionsString != null && !optionsString.isEmpty()) {
optionObj = ParsingUtilities.evaluateJsonStringToObjectNode(optionsString);
} else {

View File

@ -35,8 +35,6 @@ package com.google.refine.expr.functions.xml;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONWriter;
import org.jsoup.nodes.Element;
import com.google.refine.expr.EvalError;
@ -71,14 +69,18 @@ public class InnerXml implements Function {
@Override
public void write(JSONWriter writer, Properties options)
throws JSONException {
public String getDescription() {
return "The innerXml/innerHtml of an XML/HTML element";
}
writer.object();
writer.key("description"); writer.value("The innerXml/innerHtml of an XML/HTML element");
writer.key("params"); writer.value("Element e");
writer.key("returns"); writer.value("String innerXml/innerHtml");
writer.endObject();
@Override
public String getParams() {
return "Element e";
}
@Override
public String getReturns() {
return "String innerXml/innerHtml";
}
}

View File

@ -35,8 +35,6 @@ package com.google.refine.expr.functions.xml;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONWriter;
import org.jsoup.Jsoup;
import org.jsoup.parser.Parser;
@ -69,14 +67,18 @@ public class ParseXml implements Function {
@Override
public void write(JSONWriter writer, Properties options)
throws JSONException {
public String getDescription() {
return "Parses a string as XML";
}
writer.object();
writer.key("description"); writer.value("Parses a string as XML");
writer.key("params"); writer.value("string s");
writer.key("returns"); writer.value("XML object");
writer.endObject();
@Override
public String getParams() {
return "string s";
}
@Override
public String getReturns() {
return "XML object";
}
}

View File

@ -40,8 +40,6 @@ import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
@ -54,6 +52,7 @@ import com.google.refine.browsing.RowFilter;
import com.google.refine.browsing.facets.Facet;
import com.google.refine.browsing.facets.ListFacet.ListFacetConfig;
import com.google.refine.tests.RefineTest;
import com.google.refine.util.ParsingUtilities;
public class TextListFacetTests extends RefineTest {
@ -79,7 +78,7 @@ public class TextListFacetTests extends RefineTest {
}
@BeforeMethod
public void setUp() throws JSONException, IOException, ModelException {
public void setUp() throws IOException, ModelException {
project = createProjectWithColumns(projectName, columnName);
for (int i = 0; i < numberOfRows; i++) {
Row row = new Row(1);
@ -141,8 +140,7 @@ public class TextListFacetTests extends RefineTest {
+ "}";
//Add the facet to the project and create a row filter
ListFacetConfig facetConfig = new ListFacetConfig();
facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project);
@ -204,8 +202,7 @@ public class TextListFacetTests extends RefineTest {
+ "}";
//Add the facet to the project and create a row filter
ListFacetConfig facetConfig = new ListFacetConfig();
facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project);
@ -267,8 +264,7 @@ public class TextListFacetTests extends RefineTest {
+ "}";
//Add the facet to the project and create a row filter
ListFacetConfig facetConfig = new ListFacetConfig();
facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project);
@ -330,8 +326,7 @@ public class TextListFacetTests extends RefineTest {
+ "}";
//Add the facet to the project and create a row filter
ListFacetConfig facetConfig = new ListFacetConfig();
facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project);
@ -393,8 +388,7 @@ public class TextListFacetTests extends RefineTest {
+ "}";
//Add the facet to the project and create a row filter
ListFacetConfig facetConfig = new ListFacetConfig();
facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project);

View File

@ -364,7 +364,7 @@ public class SqlExporterTests extends RefineTest {
int noOfRows = 1;
createGridWithSingleQuote(noOfRows, noOfCols);
String tableName = "sql_table_test";
JSONObject optionsJson = createOptionsFromProject(tableName, null, null, null, false);
ObjectNode optionsJson = createOptionsFromProject(tableName, null, null, null, false);
optionsJson.put("includeStructure", true);
optionsJson.put("includeDropStatement", true);
optionsJson.put("convertNulltoEmptyString", true);

View File

@ -8,7 +8,7 @@ import com.google.refine.tests.util.TestUtils;
public class SelectXmlTests {
@Test
public void serializeSelectXml() {
String json = "{\"description\":\"Selects an element from an XML or HTML element using selector syntax.\",\"params\":\"Element e, String s\",\"returns\":\"XML/HTML Elements\"}";
String json = "{\"description\":\"Selects an element from an XML or HTML elementn using selector syntax.\",\"returns\":\"HTML Elements\",\"params\":\"Element e, String s\"}";
TestUtils.isSerializedTo(new SelectXml(), json);
}
}

View File

@ -8,7 +8,7 @@ import com.google.refine.tests.util.TestUtils;
public class xmlAttrTests {
@Test
public void serializeXmlAttr() {
String json = "{\"description\":\"Selects a value from an attribute on an xml or html Element.\",\"params\":\"Element e, String s\",\"returns\":\"String attribute Value\"}";
String json = "{\"description\":\"Selects a value from an attribute on an XML or HTML Element\",\"returns\":\"String attribute Value\",\"params\":\"Element e, String s\"}";
TestUtils.isSerializedTo(new XmlAttr(), json);
}
}