@@ -1405,72 +1405,6 @@ public void fillDashboardSelectionsSheetWithData(Map<String, Map<String, JSONArr
14051405 }
14061406 }
14071407
1408- public void transformDatasetDriversForExcelSheet (JSONObject body , JSONArray driversFromBody , JSONArray parameters ) {
1409- try {
1410- if (body .has ("datasetDrivers" ) && body .getJSONArray ("datasetDrivers" ) != null && body .getJSONArray ("datasetDrivers" ).length () > 0 ) {
1411- for (int i = 0 ; i < body .getJSONArray ("datasetDrivers" ).length (); i ++) {
1412- JSONObject datasetDriver = body .getJSONArray ("datasetDrivers" ).getJSONObject (i );
1413- getParameterValuesFromDatasetDriver (driversFromBody , datasetDriver );
1414- }
1415-
1416- } else if (body .has ("configuration" ) && body .getJSONObject ("configuration" ) != null && body .getJSONObject ("configuration" ).has ("datasets" ) && body .getJSONObject ("configuration" ).getJSONArray ("datasets" ) != null && body .getJSONObject ("configuration" ).getJSONArray ("datasets" ).length () > 0 ) {
1417- for (int i = 0 ; i < body .getJSONObject ("configuration" ).getJSONArray ("datasets" ).length (); i ++) {
1418- JSONObject dataset = body .getJSONObject ("configuration" ).getJSONArray ("datasets" ).getJSONObject (i );
1419- if (dataset .has ("drivers" ) && dataset .getJSONArray ("drivers" ) != null && dataset .getJSONArray ("drivers" ).length () > 0 ) {
1420- for (int j = 0 ; j < dataset .getJSONArray ("drivers" ).length (); j ++) {
1421- JSONObject datasetDriver = dataset .getJSONArray ("drivers" ).getJSONObject (j );
1422- getParameterValuesFromDatasetDriver (driversFromBody , datasetDriver );
1423- }
1424- }
1425- }
1426- }
1427-
1428- transformParametersForExcelSheet (parameters , driversFromBody );
1429- } catch (JSONException jsonException ) {
1430- LOGGER .error ("Unable to transform driver" , jsonException );
1431- throw new SpagoBIRuntimeException ("Unable to transform driver" , jsonException );
1432- }
1433- }
1434-
1435- public void transformParametersForExcelSheet (JSONArray parameters , JSONArray driversFromBody ) {
1436- if (parameters != null && parameters .length () > 0 ) {
1437- for (int i = 0 ; i < parameters .length (); i ++) {
1438- try {
1439- JSONObject parameter = parameters .getJSONObject (i );
1440- try {
1441- parameter .put ("value" , parameter .getString ("value" ));
1442- } catch (JSONException e ) {
1443- parameter .put ("value" , parameter .getJSONArray ("value" ).toString ());
1444- }
1445- parameter .put ("description" , "NOT APPLICABLE" );
1446- parameter .put ("driverLabel" , "NOT APPLICABLE" );
1447- parameter .put ("type" , "NOT APPLICABLE" );
1448- parameter .put ("urlName" , "NOT APPLICABLE" );
1449- driversFromBody .put (parameter );
1450-
1451- } catch (JSONException e ) {
1452- LOGGER .error ("Unable to transform parameter" , e );
1453- }
1454- }
1455- }
1456- }
1457-
1458- private void getParameterValuesFromDatasetDriver (JSONArray driversFromBody , JSONObject datasetDriver ) throws JSONException {
1459- JSONArray parameterValues = datasetDriver .getJSONArray ("parameterValue" );
1460- if (parameterValues != null && parameterValues .length () > 0 ) {
1461- for (int k = 0 ; k < parameterValues .length (); k ++) {
1462- JSONObject parameterValue = parameterValues .getJSONObject (k );
1463- if (!datasetDriver .has ("value" )) {
1464- datasetDriver .put ("value" , parameterValue .getString ("value" ));
1465- } else {
1466- datasetDriver .put ("value" ,"," + parameterValue .getString ("value" ));
1467- }
1468- }
1469- }
1470- datasetDriver .put ("name" , datasetDriver .getString ("driverLabel" ));
1471- driversFromBody .put (datasetDriver );
1472- }
1473-
14741408 public void fillDashboardDriversSheetWithData (JSONArray drivers , Sheet sheet ) {
14751409
14761410 try {
@@ -1500,59 +1434,28 @@ public void fillDashboardDriversSheetWithData(JSONArray drivers, Sheet sheet) {
15001434 DOCUMENT_NAME ,
15011435 sheet .getSheetName ());
15021436
1503- newheader = sheet .createRow ((short ) headerIndex + 1 ); // first row
1437+ newheader = sheet .createRow ((short ) headerIndex + 1 );
15041438
15051439 Cell cell = newheader .createCell (0 );
15061440 cell .setCellValue ("Name" );
15071441 CellStyle headerCellStyle = buildCellStyle (sheet , true , HorizontalAlignment .LEFT , VerticalAlignment .CENTER , (short ) 11 );
15081442 cell .setCellStyle (headerCellStyle );
15091443
15101444 Cell cell2 = newheader .createCell (1 );
1511- cell2 .setCellValue ("Type " );
1445+ cell2 .setCellValue ("Value " );
15121446 cell2 .setCellStyle (headerCellStyle );
15131447
1514- Cell cell3 = newheader .createCell (2 );
1515- cell3 .setCellValue ("Multivalue" );
1516- cell3 .setCellStyle (headerCellStyle );
1517-
1518- Cell cell4 = newheader .createCell (3 );
1519- cell4 .setCellValue ("Value" );
1520- cell4 .setCellStyle (headerCellStyle );
1521-
1522- Cell cell5 = newheader .createCell (4 );
1523- cell5 .setCellValue ("Url Name" );
1524- cell5 .setCellStyle (headerCellStyle );
1525-
1526- Cell cell6 = newheader .createCell (5 );
1527- cell6 .setCellValue ("Driver label" );
1528- cell6 .setCellStyle (headerCellStyle );
1529-
1530- Cell cell7 = newheader .createCell (6 );
1531- cell7 .setCellValue ("Driver type" );
1532- cell7 .setCellStyle (headerCellStyle );
1533-
15341448 int j = headerIndex + 2 ;
15351449
15361450 for (int i = 0 ; i < drivers .length (); i ++) {
15371451 JSONObject driver = drivers .getJSONObject (i );
1538- Row newRow = sheet .createRow (j );
1539- newRow .createCell (0 ).setCellValue (driver .getString ("name" ));
1540- newRow .createCell (1 ).setCellValue (driver .getString ("type" ));
1541- try {
1542- newRow .createCell (2 ).setCellValue (driver .getBoolean ("multivalue" ));
1543- } catch (JSONException e ) {
1544- try {
1545- newRow .createCell (2 ).setCellValue (driver .getString ("multivalue" ));
1546- } catch (JSONException ex ) {
1547- newRow .createCell (2 ).setCellValue (false );
1548- }
1452+ String value = driver .getString ("value" );
1453+ if (value != null && !value .isEmpty ()) {
1454+ Row newRow = sheet .createRow (j );
1455+ newRow .createCell (0 ).setCellValue (driver .getString ("name" ));
1456+ newRow .createCell (1 ).setCellValue (driver .getString ("value" ));
1457+ j ++;
15491458 }
1550- newRow .createCell (3 ).setCellValue (driver .getString ("value" ));
1551- newRow .createCell (4 ).setCellValue (driver .getString ("urlName" ));
1552- newRow .createCell (5 ).setCellValue (driver .getString ("driverLabel" ));
1553- newRow .createCell (6 ).setCellValue (setDriverType (driver ));
1554-
1555- j ++;
15561459 }
15571460
15581461 } catch (Exception e ) {
@@ -1562,22 +1465,6 @@ public void fillDashboardDriversSheetWithData(JSONArray drivers, Sheet sheet) {
15621465
15631466 }
15641467
1565- private String setDriverType (JSONObject driver ) {
1566- if (driver .has ("parameterValue" )) {
1567- return "DATASET DRIVER" ;
1568- } else {
1569- try {
1570- if (driver .getString ("description" ).equals ("NOT APPLICABLE" )) {
1571- return "DATASET PARAMETER" ;
1572- } else {
1573- return "DOCUMENT DRIVER" ;
1574- }
1575- } catch (JSONException e ) {
1576- throw new RuntimeException (e );
1577- }
1578- }
1579- }
1580-
15811468
15821469
15831470}
0 commit comments