Search in sources :

Example 1 with TextSearchFacet

use of com.google.refine.browsing.facets.TextSearchFacet in project OpenRefine by OpenRefine.

the class TextSearchFacetTests method serializeTextSearchFacet.

@Test
public void serializeTextSearchFacet() throws JsonParseException, JsonMappingException, IOException {
    TextSearchFacetConfig config = ParsingUtilities.mapper.readValue(sensitiveConfigJson, TextSearchFacetConfig.class);
    TextSearchFacet facet = config.apply(project);
    TestUtils.isSerializedTo(facet, sensitiveFacetJson);
}
Also used : TextSearchFacetConfig(com.google.refine.browsing.facets.TextSearchFacet.TextSearchFacetConfig) TextSearchFacet(com.google.refine.browsing.facets.TextSearchFacet) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with TextSearchFacet

use of com.google.refine.browsing.facets.TextSearchFacet in project OpenRefine by OpenRefine.

the class Engine method initializeFromJSON.

public void initializeFromJSON(JSONObject o) throws JSONException {
    if (o == null) {
        return;
    }
    if (o.has("facets") && !o.isNull("facets")) {
        JSONArray a = o.getJSONArray("facets");
        int length = a.length();
        for (int i = 0; i < length; i++) {
            JSONObject fo = a.getJSONObject(i);
            String type = fo.has("type") ? fo.getString("type") : "list";
            Facet facet = null;
            if ("list".equals(type)) {
                facet = new ListFacet();
            } else if ("range".equals(type)) {
                facet = new RangeFacet();
            } else if ("timerange".equals(type)) {
                facet = new TimeRangeFacet();
            } else if ("scatterplot".equals(type)) {
                facet = new ScatterplotFacet();
            } else if ("text".equals(type)) {
                facet = new TextSearchFacet();
            }
            if (facet != null) {
                facet.initializeFromJSON(_project, fo);
                _facets.add(facet);
            }
        }
    }
    // for backward compatibility
    if (o.has(INCLUDE_DEPENDENT) && !o.isNull(INCLUDE_DEPENDENT)) {
        _mode = o.getBoolean(INCLUDE_DEPENDENT) ? Mode.RecordBased : Mode.RowBased;
    }
    if (o.has(MODE) && !o.isNull(MODE)) {
        _mode = MODE_ROW_BASED.equals(o.getString(MODE)) ? Mode.RowBased : Mode.RecordBased;
    }
}
Also used : ScatterplotFacet(com.google.refine.browsing.facets.ScatterplotFacet) TimeRangeFacet(com.google.refine.browsing.facets.TimeRangeFacet) RangeFacet(com.google.refine.browsing.facets.RangeFacet) JSONObject(org.json.JSONObject) TextSearchFacet(com.google.refine.browsing.facets.TextSearchFacet) JSONArray(org.json.JSONArray) ListFacet(com.google.refine.browsing.facets.ListFacet) TimeRangeFacet(com.google.refine.browsing.facets.TimeRangeFacet) Facet(com.google.refine.browsing.facets.Facet) ScatterplotFacet(com.google.refine.browsing.facets.ScatterplotFacet) ListFacet(com.google.refine.browsing.facets.ListFacet) TimeRangeFacet(com.google.refine.browsing.facets.TimeRangeFacet) TextSearchFacet(com.google.refine.browsing.facets.TextSearchFacet) RangeFacet(com.google.refine.browsing.facets.RangeFacet)

Aggregations

TextSearchFacet (com.google.refine.browsing.facets.TextSearchFacet)2 RefineTest (com.google.refine.RefineTest)1 Facet (com.google.refine.browsing.facets.Facet)1 ListFacet (com.google.refine.browsing.facets.ListFacet)1 RangeFacet (com.google.refine.browsing.facets.RangeFacet)1 ScatterplotFacet (com.google.refine.browsing.facets.ScatterplotFacet)1 TextSearchFacetConfig (com.google.refine.browsing.facets.TextSearchFacet.TextSearchFacetConfig)1 TimeRangeFacet (com.google.refine.browsing.facets.TimeRangeFacet)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 BeforeTest (org.testng.annotations.BeforeTest)1 Test (org.testng.annotations.Test)1