diff --git a/main/src/com/google/refine/browsing/Engine.java b/main/src/com/google/refine/browsing/Engine.java index 827555d6d..db6c5b77d 100644 --- a/main/src/com/google/refine/browsing/Engine.java +++ b/main/src/com/google/refine/browsing/Engine.java @@ -38,9 +38,6 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; -import org.json.JSONException; -import org.json.JSONObject; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.browsing.facets.Facet; @@ -177,12 +174,6 @@ public class Engine { } throw new InternalError("This method should not be called when the engine is not in record mode."); } - - @Deprecated - public void initializeFromJSON(JSONObject o) throws JSONException { - EngineConfig config = EngineConfig.reconstruct(o); - initializeFromConfig(config); - } public void initializeFromConfig(EngineConfig config) { _config = config; @@ -191,7 +182,7 @@ public class Engine { .collect(Collectors.toList()); } - public void computeFacets() throws JSONException { + public void computeFacets() { if (_config.getMode().equals(Mode.RowBased)) { for (Facet facet : _facets) { FilteredRows filteredRows = getFilteredRows(facet); diff --git a/main/src/com/google/refine/browsing/EngineConfig.java b/main/src/com/google/refine/browsing/EngineConfig.java index 0898fbd89..b706d1c31 100644 --- a/main/src/com/google/refine/browsing/EngineConfig.java +++ b/main/src/com/google/refine/browsing/EngineConfig.java @@ -4,8 +4,6 @@ import java.io.IOException; import java.util.Collections; 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.Mode; @@ -38,12 +36,12 @@ public class EngineConfig { return _facets; } - public static EngineConfig reconstruct(JSONObject o) { - if(o == null) { + public static EngineConfig reconstruct(String json) { + if(json == null) { return new EngineConfig(Collections.emptyList(), Mode.RowBased); } try { - return ParsingUtilities.mapper.readValue(o.toString(), EngineConfig.class); + return ParsingUtilities.mapper.readValue(json, EngineConfig.class); } catch (IOException e) { e.printStackTrace(); return null; diff --git a/main/src/com/google/refine/commands/Command.java b/main/src/com/google/refine/commands/Command.java index 1edecbc5a..8108d207a 100644 --- a/main/src/com/google/refine/commands/Command.java +++ b/main/src/com/google/refine/commands/Command.java @@ -125,7 +125,7 @@ public abstract class Command { String json = request.getParameter("engine"); try{ return (json == null) ? null : - EngineConfig.reconstruct(ParsingUtilities.evaluateJsonStringToObject(json)); + EngineConfig.reconstruct(json); } catch (JSONException e){ logger.debug( json + " could not be parsed to JSON"); return null; diff --git a/main/tests/server/src/com/google/refine/tests/browsing/facets/EngineConfigTests.java b/main/tests/server/src/com/google/refine/tests/browsing/facets/EngineConfigTests.java index 51847b3ef..378203370 100644 --- a/main/tests/server/src/com/google/refine/tests/browsing/facets/EngineConfigTests.java +++ b/main/tests/server/src/com/google/refine/tests/browsing/facets/EngineConfigTests.java @@ -1,6 +1,5 @@ package com.google.refine.tests.browsing.facets; -import org.json.JSONObject; import org.testng.Assert; import org.testng.annotations.Test; @@ -36,13 +35,13 @@ public class EngineConfigTests { @Test public void serializeEngineConfig() { - EngineConfig ec = EngineConfig.reconstruct(new JSONObject(engineConfigJson)); + EngineConfig ec = EngineConfig.reconstruct(engineConfigJson); TestUtils.isSerializedTo(ec, engineConfigJson); } @Test public void serializeEngineConfigRecordMode() { - EngineConfig ec = EngineConfig.reconstruct(new JSONObject(engineConfigRecordModeJson)); + EngineConfig ec = EngineConfig.reconstruct(engineConfigRecordModeJson); TestUtils.isSerializedTo(ec, engineConfigRecordModeJson); } @@ -55,7 +54,7 @@ public class EngineConfigTests { @Test public void reconstructNoFacetsProvided() { - EngineConfig ec = EngineConfig.reconstruct(new JSONObject(noFacetProvided)); + EngineConfig ec = EngineConfig.reconstruct(noFacetProvided); Assert.assertEquals(ec.getMode(), Mode.RowBased); Assert.assertTrue(ec.getFacetConfigs().isEmpty()); } diff --git a/main/tests/server/src/com/google/refine/tests/model/CacheTests.java b/main/tests/server/src/com/google/refine/tests/model/CacheTests.java index cccacf68f..8662db575 100644 --- a/main/tests/server/src/com/google/refine/tests/model/CacheTests.java +++ b/main/tests/server/src/com/google/refine/tests/model/CacheTests.java @@ -81,7 +81,7 @@ public class CacheTests extends RefineTest { project = createProjectWithColumns("CacheTests", "Column A"); engine = new Engine(project); - engine_config = EngineConfig.reconstruct(new JSONObject(ENGINE_JSON_DUPLICATES)); + engine_config = EngineConfig.reconstruct(ENGINE_JSON_DUPLICATES); engine.initializeFromConfig(engine_config); engine.setMode(Engine.Mode.RowBased); diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java index 06e3d58a7..6a1b87076 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/BlankDownTests.java @@ -63,7 +63,7 @@ public class BlankDownTests extends RefineTest { @Test public void testBlankDownRecords() throws Exception { AbstractOperation op = new BlankDownOperation( - EngineConfig.reconstruct(new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}")), + EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"), "second"); Process process = op.createProcess(project, new Properties()); process.performImmediate(); @@ -77,7 +77,7 @@ public class BlankDownTests extends RefineTest { @Test public void testBlankDownRows() throws Exception { AbstractOperation op = new BlankDownOperation( - EngineConfig.reconstruct(new JSONObject("{\"mode\":\"row-based\",\"facets\":[]}")), + EngineConfig.reconstruct("{\"mode\":\"row-based\",\"facets\":[]}"), "second"); Process process = op.createProcess(project, new Properties()); process.performImmediate(); diff --git a/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java b/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java index 73d82f2e7..1612e363a 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/cell/FillDownTests.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Properties; import org.json.JSONException; -import org.json.JSONObject; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -61,7 +60,7 @@ public class FillDownTests extends RefineTest { @Test public void testFillDownRecordKey() throws Exception { AbstractOperation op = new FillDownOperation( - EngineConfig.reconstruct(new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}")), + EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"), "key"); Process process = op.createProcess(project, new Properties()); process.performImmediate(); @@ -77,7 +76,7 @@ public class FillDownTests extends RefineTest { @Test public void testFillDownRecords() throws Exception { AbstractOperation op = new FillDownOperation( - EngineConfig.reconstruct(new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}")), + EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"), "second"); Process process = op.createProcess(project, new Properties()); process.performImmediate(); @@ -93,7 +92,7 @@ public class FillDownTests extends RefineTest { @Test public void testFillDownRows() throws Exception { AbstractOperation op = new FillDownOperation( - EngineConfig.reconstruct(new JSONObject("{\"mode\":\"row-based\",\"facets\":[]}")), + EngineConfig.reconstruct("{\"mode\":\"row-based\",\"facets\":[]}"), "second"); Process process = op.createProcess(project, new Properties()); process.performImmediate(); diff --git a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java index 41101a5ff..22108ea4d 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/column/ColumnAdditionByFetchingURLsOperationTests.java @@ -105,7 +105,7 @@ public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest { // dependencies private Project project; private Properties options; - private EngineConfig engine_config = EngineConfig.reconstruct(new JSONObject(ENGINE_JSON_URLS)); + private EngineConfig engine_config = EngineConfig.reconstruct(ENGINE_JSON_URLS); @BeforeMethod public void SetUp() throws JSONException, IOException, ModelException { diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java index 8038c94d2..90587302e 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ExtendDataOperationTests.java @@ -146,7 +146,7 @@ public class ExtendDataOperationTests extends RefineTest { options = mock(Properties.class); engine = new Engine(project); - engine_config = EngineConfig.reconstruct(new JSONObject(ENGINE_JSON_URLS)); + engine_config = EngineConfig.reconstruct(ENGINE_JSON_URLS); engine.initializeFromConfig(engine_config); engine.setMode(Engine.Mode.RowBased); diff --git a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java index 4f5c8d263..ec6be5f1c 100644 --- a/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java +++ b/main/tests/server/src/com/google/refine/tests/operations/recon/ReconJudgeSimilarCellsTests.java @@ -7,7 +7,6 @@ import java.io.IOException; import java.util.Collections; import java.util.Properties; -import org.json.JSONObject; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -29,7 +28,7 @@ import com.google.refine.util.ParsingUtilities; public class ReconJudgeSimilarCellsTests extends RefineTest { - static final EngineConfig ENGINE_CONFIG = EngineConfig.reconstruct(new JSONObject("{\"mode\":\"row-based\"}}")); + static final EngineConfig ENGINE_CONFIG = EngineConfig.reconstruct("{\"mode\":\"row-based\"}}"); @Override @BeforeTest