|
34 | 34 | public class DashboardExporter { |
35 | 35 |
|
36 | 36 | private final JSONObjectUtils jsonObjectUtils; |
37 | | - private final String userUniqueIdentifier; |
| 37 | + protected final String userUniqueIdentifier; |
38 | 38 | private String imageB64; |
39 | 39 | protected Map<String, String> i18nMessages; |
40 | 40 | protected Locale locale; |
@@ -196,13 +196,18 @@ protected Map<String, Map<String, JSONArray>> getSelections(JSONObject body) { |
196 | 196 | } |
197 | 197 | return selectionsToReturn; |
198 | 198 | } catch (JSONException e) { |
199 | | - return Collections.emptyMap(); |
| 199 | + throw new SpagoBIRuntimeException("Cannot get selections from body", e); |
200 | 200 | } |
201 | 201 | } |
202 | 202 |
|
203 | 203 | private void loopOverSelectionValues(JSONObject selection, Map<String, Map<String, JSONArray>> selectionsToReturn) throws JSONException { |
204 | 204 | for (int j = 0; j < selection.getJSONArray("value").length(); j++) { |
205 | | - String valueToInsert = "('" + selection.getJSONArray("value").getString(j) + "')"; |
| 205 | + String valueToInsert; |
| 206 | + try { |
| 207 | + valueToInsert = "('" + selection.getJSONArray("value").getString(j) + "')"; |
| 208 | + } catch (JSONException e) { |
| 209 | + valueToInsert = "('" + selection.getJSONArray("value").getInt(j) + "')"; |
| 210 | + } |
206 | 211 | selectionsToReturn.get(selection.getString("datasetLabel")).get(selection.getString("columnName")).put(valueToInsert); |
207 | 212 | } |
208 | 213 | } |
@@ -286,7 +291,20 @@ public JSONObject transformParametersForDatastore(JSONObject body, JSONArray par |
286 | 291 | for (int i = 0; i < parameters.length(); i++) { |
287 | 292 | JSONObject parameter = parameters.getJSONObject(i); |
288 | 293 | if (parameter.getInt("dataset") == body.getInt("dataset")) { |
289 | | - parametersToSend.put(parameter.getString("name"), parameter.get("value")); |
| 294 | + if (parameter.get("value") != null && !parameter.getString("value").equals("null")) { |
| 295 | + parametersToSend.put(parameter.getString("name"), parameter.get("value")); |
| 296 | + } else { |
| 297 | + JSONArray drivers = body.optJSONArray("drivers") != null ? body.getJSONArray("drivers") : null; |
| 298 | + if (drivers != null) { |
| 299 | + for (int j = 0; j < drivers.length(); j++) { |
| 300 | + JSONObject driver = drivers.getJSONObject(j); |
| 301 | + if (driver.getString("urlName").equals(parameter.getString("name"))) { |
| 302 | + parametersToSend.put(parameter.getString("name"), driver.get("value")); |
| 303 | + break; |
| 304 | + } |
| 305 | + } |
| 306 | + } |
| 307 | + } |
290 | 308 | } |
291 | 309 | } |
292 | 310 | } |
@@ -815,10 +833,6 @@ public JSONObject getDataStoreForDashboardWidget(JSONObject widget, int offset, |
815 | 833 | buildLikeSelections(dashboardSelections, widget); |
816 | 834 | } |
817 | 835 |
|
818 | | - if (widget.getString("type").equalsIgnoreCase("static-pivot-table")) { |
819 | | - LOGGER.error(dashboardSelections.toString()); |
820 | | - } |
821 | | - |
822 | 836 | datastore = getDatastore(datasetLabel, map, dashboardSelections.toString(), offset, fetchSize); |
823 | 837 | datastore.put("widgetData", widget); |
824 | 838 |
|
|
0 commit comments