@Test public void testGetCacheKey() throws JSONException { long pluginId = 1L; String indicatorId = "232"; long layerId = 1850L; String selectionStr = "{\"year\":\"2015\",\"sex\":\"female\"}"; JSONObject selectionJSON = new JSONObject(selectionStr); String actual = StatisticsHelper.getIndicatorDataCacheKey(pluginId, indicatorId, layerId, selectionJSON); String expected = "oskari:stats:1:data:232:1850:sex=female:year=2015"; Assert.assertEquals(expected, actual); }
public static String getIndicatorDataCacheKey(long datasourceId, String indicatorId, long layerId, JSONObject selectorJSON) { StringBuilder cacheKey = new StringBuilder("oskari:stats:"); cacheKey.append(datasourceId); cacheKey.append(":data:"); cacheKey.append(indicatorId); cacheKey.append(':'); cacheKey.append(layerId); Iterator<String> it = selectorJSON.sortedKeys(); while (it.hasNext()) { String key = it.next(); cacheKey.append(':'); cacheKey.append(key); cacheKey.append('='); try { cacheKey.append(selectorJSON.get(key)); } catch (JSONException e) { } } return cacheKey.toString(); }
StatisticsHelper { public static String getIndicatorDataCacheKey(long datasourceId, String indicatorId, long layerId, JSONObject selectorJSON) { StringBuilder cacheKey = new StringBuilder("oskari:stats:"); cacheKey.append(datasourceId); cacheKey.append(":data:"); cacheKey.append(indicatorId); cacheKey.append(':'); cacheKey.append(layerId); Iterator<String> it = selectorJSON.sortedKeys(); while (it.hasNext()) { String key = it.next(); cacheKey.append(':'); cacheKey.append(key); cacheKey.append('='); try { cacheKey.append(selectorJSON.get(key)); } catch (JSONException e) { } } return cacheKey.toString(); } }
StatisticsHelper { public static String getIndicatorDataCacheKey(long datasourceId, String indicatorId, long layerId, JSONObject selectorJSON) { StringBuilder cacheKey = new StringBuilder("oskari:stats:"); cacheKey.append(datasourceId); cacheKey.append(":data:"); cacheKey.append(indicatorId); cacheKey.append(':'); cacheKey.append(layerId); Iterator<String> it = selectorJSON.sortedKeys(); while (it.hasNext()) { String key = it.next(); cacheKey.append(':'); cacheKey.append(key); cacheKey.append('='); try { cacheKey.append(selectorJSON.get(key)); } catch (JSONException e) { } } return cacheKey.toString(); }  }
StatisticsHelper { public static String getIndicatorDataCacheKey(long datasourceId, String indicatorId, long layerId, JSONObject selectorJSON) { StringBuilder cacheKey = new StringBuilder("oskari:stats:"); cacheKey.append(datasourceId); cacheKey.append(":data:"); cacheKey.append(indicatorId); cacheKey.append(':'); cacheKey.append(layerId); Iterator<String> it = selectorJSON.sortedKeys(); while (it.hasNext()) { String key = it.next(); cacheKey.append(':'); cacheKey.append(key); cacheKey.append('='); try { cacheKey.append(selectorJSON.get(key)); } catch (JSONException e) { } } return cacheKey.toString(); }  static String getIndicatorMetadataCacheKey(long datasourceId, String indicatorId); static String getIndicatorDataCacheKey(long datasourceId, String indicatorId,
                                                  long layerId, JSONObject selectorJSON); static void flushDataFromCache(long pluginId, String indicatorId, long layerId, JSONObject selectorJSON); static StatisticalIndicatorDataModel getIndicatorDataModel(JSONObject selectorJSON); static JSONObject toJSON(StatisticalIndicator indicator); static JSONArray toJSON(StatisticalIndicatorDataModel selectors); static JSONArray toJSON(List<StatisticalIndicatorLayer> layers); }
StatisticsHelper { public static String getIndicatorDataCacheKey(long datasourceId, String indicatorId, long layerId, JSONObject selectorJSON) { StringBuilder cacheKey = new StringBuilder("oskari:stats:"); cacheKey.append(datasourceId); cacheKey.append(":data:"); cacheKey.append(indicatorId); cacheKey.append(':'); cacheKey.append(layerId); Iterator<String> it = selectorJSON.sortedKeys(); while (it.hasNext()) { String key = it.next(); cacheKey.append(':'); cacheKey.append(key); cacheKey.append('='); try { cacheKey.append(selectorJSON.get(key)); } catch (JSONException e) { } } return cacheKey.toString(); }  static String getIndicatorMetadataCacheKey(long datasourceId, String indicatorId); static String getIndicatorDataCacheKey(long datasourceId, String indicatorId,
                                                  long layerId, JSONObject selectorJSON); static void flushDataFromCache(long pluginId, String indicatorId, long layerId, JSONObject selectorJSON); static StatisticalIndicatorDataModel getIndicatorDataModel(JSONObject selectorJSON); static JSONObject toJSON(StatisticalIndicator indicator); static JSONArray toJSON(StatisticalIndicatorDataModel selectors); static JSONArray toJSON(List<StatisticalIndicatorLayer> layers); static final String PARAM_DATASOURCE_ID; static final String PARAM_INDICATOR_ID; static final String PARAM_SELECTORS; static final String PARAM_REGIONSET; }