From 8ca0cbeb69f2b63b43a52d86dfaea5de3875acb7 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 25 May 2020 18:14:45 +0200 Subject: [PATCH] ref 17249: Save produced charts as report https://support.d4science.org/issues/17249 Added PDF support for BoxPlot --- .classpath | 6 +- .settings/org.eclipse.wst.common.component | 2 +- .../PerformFishAnnualAnalyticsController.java | 12 +- .../PerformFishAnalyticsController.java | 12 +- .../BoxPlotAnnualPanelResult.java | 125 ++++++++++++++--- .../ScatterAnnualPanelResult.java | 21 +-- .../SpeedometerAnnualPanelResult.java | 19 +-- .../SynopticTableAnnualPanelResult.java | 20 +-- .../client/viewbinder/BoxPlotPanelResult.java | 132 ++++++++++++++---- .../client/viewbinder/ScatterPanelResult.java | 18 +-- .../viewbinder/SpeedometerPanelResult.java | 19 +-- .../viewbinder/SynopticTablePanelResult.java | 21 +-- 12 files changed, 300 insertions(+), 107 deletions(-) diff --git a/.classpath b/.classpath index b4bde20..0aec32c 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index d64210d..076f017 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/annualcontrollers/PerformFishAnnualAnalyticsController.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/annualcontrollers/PerformFishAnnualAnalyticsController.java index 9de6174..92e4c8a 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/annualcontrollers/PerformFishAnnualAnalyticsController.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/annualcontrollers/PerformFishAnnualAnalyticsController.java @@ -325,9 +325,10 @@ public class PerformFishAnnualAnalyticsController { * Call algorithm synoptic table farm. */ protected void callAlgorithmSynopticTableFarm() { - + + requestId++; @SuppressWarnings("unused") - SynopticTableAnnualPanelResult synopticTablePanelResult = new SynopticTableAnnualPanelResult(requestId++, + SynopticTableAnnualPanelResult synopticTablePanelResult = new SynopticTableAnnualPanelResult(requestId, viewAnnualController, thePerformFishResponse); } @@ -640,21 +641,22 @@ public class PerformFishAnnualAnalyticsController { private void callAlgorithm(DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI) { + requestId++; switch (algorithm) { case BOXPLOT: @SuppressWarnings("unused") - BoxPlotAnnualPanelResult boxPlotPanelResult = new BoxPlotAnnualPanelResult(requestId++, + BoxPlotAnnualPanelResult boxPlotAnnualPanelResult = new BoxPlotAnnualPanelResult(requestId, viewAnnualController, thePerformFishResponse, algorithm, focusID, inputKPI, outputKPI); break; case SPEEDOMETER: @SuppressWarnings("unused") - SpeedometerAnnualPanelResult speedometerPanelResult = new SpeedometerAnnualPanelResult(requestId++, + SpeedometerAnnualPanelResult speedometerAnnualPanelResult = new SpeedometerAnnualPanelResult(requestId, viewAnnualController, thePerformFishResponse, algorithm, focusID, inputKPI, outputKPI); break; case SCATTER: @SuppressWarnings("unused") - ScatterAnnualPanelResult scatterPanelResult = new ScatterAnnualPanelResult(requestId++, + ScatterAnnualPanelResult scatterAnnualPanelResult = new ScatterAnnualPanelResult(requestId, viewAnnualController, thePerformFishResponse, algorithm, focusID, inputKPI, outputKPI); break; default: diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java index 84930e8..a7f5c12 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java @@ -366,8 +366,9 @@ public class PerformFishAnalyticsController { final Map> performFishRequestParameters) { GWT.log("Read perform fish response: " + performFishResponse); + requestId++; @SuppressWarnings("unused") - SynopticTablePanelResult synopticTablePanelResult = new SynopticTablePanelResult(requestId++, viewController, + SynopticTablePanelResult synopticTablePanelResult = new SynopticTablePanelResult(requestId, viewController, performFishResponse, performFishRequestParameters); } @@ -563,22 +564,23 @@ public class PerformFishAnalyticsController { if (selectedBatchID == null || selectedBatchID.isEmpty()) Window.alert("Something seems wrong, no selected BatchID, try again"); - + + requestId++; switch (algorithm) { case BOXPLOT: @SuppressWarnings("unused") - BoxPlotPanelResult boxPlotPanelResult = new BoxPlotPanelResult(requestId++, viewController, algorithm, + BoxPlotPanelResult boxPlotPanelResult = new BoxPlotPanelResult(requestId, viewController, algorithm, focusID, inputKPI, outputKPI); break; case SPEEDOMETER: @SuppressWarnings("unused") - SpeedometerPanelResult speedometerPanelResult = new SpeedometerPanelResult(requestId++, viewController, + SpeedometerPanelResult speedometerPanelResult = new SpeedometerPanelResult(requestId, viewController, algorithm, focusID, inputKPI, outputKPI); break; case SCATTER: @SuppressWarnings("unused") - ScatterPanelResult scatterPanelResult = new ScatterPanelResult(requestId++, viewController, algorithm, + ScatterPanelResult scatterPanelResult = new ScatterPanelResult(requestId, viewController, algorithm, focusID, inputKPI, outputKPI); break; default: diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/BoxPlotAnnualPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/BoxPlotAnnualPanelResult.java index d8235e8..532af69 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/BoxPlotAnnualPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/BoxPlotAnnualPanelResult.java @@ -15,6 +15,7 @@ import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFish import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.ShowResult; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.SubmitRequestPanel; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -46,13 +47,16 @@ public class BoxPlotAnnualPanelResult { private PerformFishAnnualAnalyticsViewController viewAnnualController; private int outputIteration = 0; - private int outputNumber = 0; - private int requestId; + private int outputNumber = 2; + private int requestId=0; + + public BoxPlotAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController, PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI) { - this.requestId = reqId; + GWT.log("RequestID: "+reqId); + requestId=reqId; this.viewAnnualController = viewAnnualController; TextResource algDescr = PerformFishResources.INSTANCE.farm_BOXPLOT(); @@ -89,6 +93,7 @@ public class BoxPlotAnnualPanelResult { oIteration++; String title = "KPI: " + kpi.getName(); HTML toBigTitle = new HTML(title); + toBigTitle.getElement().setId("KPI_BoxPlotAnnual_"+requestId+"_"+oIteration); toBigTitle.getElement().addClassName("to-big-title"); submitRequestPanel.addWidget(toBigTitle); HorizontalPanel hp = new HorizontalPanel(); @@ -101,7 +106,7 @@ public class BoxPlotAnnualPanelResult { submitRequestPanel.addWidget(hp); } outputIteration = oIteration; - + GWT.log("outputInteration: "+outputIteration); } /** @@ -243,11 +248,29 @@ public class BoxPlotAnnualPanelResult { return dataInputsFormatter; } + + + private String getOutputId(int oIteration, String title){ + if (title.startsWith("My")) { + return null; + } else if (title.startsWith("All")) { + String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 1; + return outputId; + } else { + String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 2; + return outputId; + } + + + + } + - + + private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, - final Panel container, boolean displayError, int oIteration) { + final Panel container, boolean displayError, final int oIteration) { String title = displayError ? "No results " : ""; @@ -262,16 +285,11 @@ public class BoxPlotAnnualPanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); - - int oNumber = 0; - - for (final OutputFile outputFile : dmResponse.getListOutput()) { - oNumber++; - final String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + oNumber; - + for (OutputFile outputFile : dmResponse.getListOutput()) { + final FileContentType fileContentType= outputFile.getDataType(); switch (outputFile.getDataType()) { case IMAGE: + PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, new AsyncCallback() { @@ -291,8 +309,9 @@ public class BoxPlotAnnualPanelResult { title = chartType.getTitle() + " - on all farm data
"; title += "Blue dots indicate the selected farm: " + focusID; - - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + + String outputId=getOutputId(oIteration,title); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); displayingOrderedBoxPlot(dmResponse, title, container, showResult); @@ -300,6 +319,7 @@ public class BoxPlotAnnualPanelResult { }); break; case CSV: + PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback() { @@ -327,8 +347,10 @@ public class BoxPlotAnnualPanelResult { } title += "
"; title += "Data aggregation is performed by considering farms as base units"; - - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + + + String outputId=getOutputId(oIteration,title); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); displayingOrderedBoxPlot(dmResponse, title, container, showResult); @@ -341,7 +363,7 @@ public class BoxPlotAnnualPanelResult { } } - + } private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, @@ -436,6 +458,21 @@ public class BoxPlotAnnualPanelResult { for (var i = 1; i <= outputIteration; i++) { + var kpiId = 'KPI_BoxPlotAnnual_' + requestId + '_' + i; + console.log('kpiId: ' + kpiId); + + var kpiName = $doc.getElementById(kpiId); + + yPos += 2; + pdoc.setFontSize(16); + pdoc.setFontType("bold"); + pdoc.text(kpiName.textContent, xPos, yPos, 'left'); + yPos += 6; + + pdoc.setFontSize(10); + pdoc.setFontType("normal"); + + for (var j = 1; j <= outputNumber; j++) { var outputId = 'OutputId_' + requestId + '_' + i + '_' + j; @@ -456,6 +493,19 @@ public class BoxPlotAnnualPanelResult { // foo could get resolved and it's defined var childrenTable = resultOutputNumber.children; + var titleCurrentTable = childrenTable[0].rows[0].cells[0]; + console.log('Title current table: ' + + titleCurrentTable.textContent); + yPos += 2; + pdoc.setFontSize(12); + pdoc.setFontType("bold"); + pdoc.text(titleCurrentTable.textContent, xPos, yPos, + 'left'); + yPos += 6; + + pdoc.setFontSize(10); + pdoc.setFontType("normal"); + var secondDiv = childrenTable[0].rows[1].cells[0]; var secondTable = secondDiv.children[0].children[0]; @@ -476,6 +526,21 @@ public class BoxPlotAnnualPanelResult { if (resultType == 'image') { console.log('Result Type image: ' + i); var childrenTable = resultOutputNumber.children; + + var titleCurrentImage = childrenTable[0].rows[0].cells[0]; + console.log('Title current image: ' + + titleCurrentImage.textContent); + yPos += 2; + pdoc.setFontSize(12); + pdoc.setFontType("bold"); + pdoc.text(titleCurrentImage.textContent, xPos, + yPos, 'left'); + yPos += 6; + + pdoc.setFontSize(10); + pdoc.setFontType("normal"); + + var secondDiv = childrenTable[0].rows[1].cells[0]; var imageElement = secondDiv.getElementsByTagName( 'img').item(0); @@ -494,6 +559,27 @@ public class BoxPlotAnnualPanelResult { } } + + if (i < outputIteration) { + //var numberOfPages=pdoc.internal.getNumberOfPages(); + //console.log('NumberOfPages: '+numberOfPages); + var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber; + console.log('CurrentPage: ' + currentPage); + var footner = 'Page ' + currentPage; + pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center'); + pdoc.addPage(); + + yPos = tMargin; // Restart position + } else { + if (i = outputIteration) { + var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber; + console.log('CurrentPage: ' + currentPage); + var footner = 'Page ' + currentPage; + pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center'); + } + + } + } console.log('Done'); @@ -502,4 +588,5 @@ public class BoxPlotAnnualPanelResult { }-*/; + } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/ScatterAnnualPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/ScatterAnnualPanelResult.java index a620f45..12fa200 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/ScatterAnnualPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/ScatterAnnualPanelResult.java @@ -15,6 +15,7 @@ import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFish import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.ShowResult; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.SubmitRequestPanel; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -48,7 +49,8 @@ public class ScatterAnnualPanelResult { public ScatterAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController, PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI) { - this.requestId = reqId; + GWT.log("RequestID: "+reqId); + requestId=reqId; this.viewAnnualController = viewAnnualController; TextResource algDescr = PerformFishResources.INSTANCE.farm_SCATTER(); @@ -258,14 +260,14 @@ public class ScatterAnnualPanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); - + int oNumber = 0; - for (final OutputFile outputFile : dmResponse.getListOutput()) { + for (OutputFile outputFile : dmResponse.getListOutput()) { oNumber++; - final String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + oNumber; - + final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; + final FileContentType fileContentType= outputFile.getDataType(); + switch (outputFile.getDataType()) { case IMAGE: PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, @@ -284,7 +286,7 @@ public class ScatterAnnualPanelResult { public void onSuccess(String base64Content) { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); container.add(showResult); @@ -311,7 +313,7 @@ public class ScatterAnnualPanelResult { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); container.add(showResult); } @@ -323,7 +325,8 @@ public class ScatterAnnualPanelResult { } } - + + outputNumber=oNumber; } /** diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SpeedometerAnnualPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SpeedometerAnnualPanelResult.java index 1394ed4..5d9c525 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SpeedometerAnnualPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SpeedometerAnnualPanelResult.java @@ -15,6 +15,7 @@ import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFish import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.ShowResult; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.SubmitRequestPanel; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -52,7 +53,8 @@ public class SpeedometerAnnualPanelResult { public SpeedometerAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController, PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI) { - this.requestId = reqId; + GWT.log("RequestID: "+reqId); + requestId=reqId; this.viewAnnualController = viewAnnualController; TextResource algDescr = PerformFishResources.INSTANCE.farm_SPEEDOMETER(); @@ -262,14 +264,13 @@ public class SpeedometerAnnualPanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); - int oNumber = 0; - for (final OutputFile outputFile : dmResponse.getListOutput()) { + for (OutputFile outputFile : dmResponse.getListOutput()) { oNumber++; - final String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + oNumber; - + final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; + final FileContentType fileContentType= outputFile.getDataType(); + switch (outputFile.getDataType()) { case IMAGE: PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, @@ -293,7 +294,7 @@ public class SpeedometerAnnualPanelResult { title += "Selected Farm: " + focusID + "
"; title += "Normalized with respect to all farm data in the VRE"; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); container.add(showResult); @@ -320,7 +321,7 @@ public class SpeedometerAnnualPanelResult { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); container.add(showResult); @@ -333,6 +334,8 @@ public class SpeedometerAnnualPanelResult { } } + + outputNumber=oNumber; } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SynopticTableAnnualPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SynopticTableAnnualPanelResult.java index 0c6631c..ffed24f 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SynopticTableAnnualPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/SynopticTableAnnualPanelResult.java @@ -14,6 +14,7 @@ import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFish import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.ShowResult; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.SubmitRequestPanel; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -48,7 +49,8 @@ public class SynopticTableAnnualPanelResult { public SynopticTableAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController, PerformFishResponse performFishResponse) { - this.requestId = reqId; + GWT.log("RequestID: "+reqId); + requestId=reqId; this.viewAnnualController = viewAnnualController; final DataMinerAlgorithms algorithm = DataMinerAlgorithms.PERFORMFISH_SYNOPTIC_TABLE_FARM; @@ -199,14 +201,15 @@ public class SynopticTableAnnualPanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); + int oNumber = 0; - for (final OutputFile outputFile : dmResponse.getListOutput()) { + for (OutputFile outputFile : dmResponse.getListOutput()) { oNumber++; - final String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + oNumber; - + final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; + final FileContentType fileContentType= outputFile.getDataType(); + switch (outputFile.getDataType()) { case IMAGE: PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, @@ -226,7 +229,7 @@ public class SynopticTableAnnualPanelResult { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); container.add(showResult); @@ -260,7 +263,7 @@ public class SynopticTableAnnualPanelResult { cssTableStyle = "simpletable-synoptic"; } ShowResult showResultSin = new ShowResult(outputId, title, - outputFile.getDataType()); + fileContentType); showResultSin.showCSVFile(result, cssTableStyle); displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, showResultSin); @@ -275,7 +278,7 @@ public class SynopticTableAnnualPanelResult { break; } - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); container.add(showResult); @@ -288,6 +291,7 @@ public class SynopticTableAnnualPanelResult { } } + outputNumber=oNumber; } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BoxPlotPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BoxPlotPanelResult.java index 46b8c9d..ff2aef7 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BoxPlotPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BoxPlotPanelResult.java @@ -12,6 +12,7 @@ import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsS import org.gcube.portlets.user.performfishanalytics.client.controllers.PerformFishAnalyticsViewController; import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFishResources; import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -38,18 +39,18 @@ import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Panel; public class BoxPlotPanelResult { - + private Map boxPlotOrderBy = new HashMap(); private PerformFishAnalyticsViewController viewController; private int outputIteration = 0; - private int outputNumber = 0; - private int requestId; - + private int outputNumber = 3; + private int requestId = 0; - public BoxPlotPanelResult(int reqId,PerformFishAnalyticsViewController viewController, final DataMinerAlgorithms algorithm, - String focusID, List inputKPI, final List outputKPI) { - this.requestId=reqId; + public BoxPlotPanelResult(int reqId, PerformFishAnalyticsViewController viewController, + final DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI) { + GWT.log("RequestID: " + reqId); + requestId = reqId; this.viewController = viewController; TextResource algDescr = PerformFishResources.INSTANCE.batch_BOXPLOT(); @@ -86,6 +87,7 @@ public class BoxPlotPanelResult { oIteration++; String title = "KPI: " + kpi.getName(); HTML toBigTitle = new HTML(title); + toBigTitle.getElement().setId("KPI_BoxPlot_"+requestId+"_"+oIteration); toBigTitle.getElement().addClassName("to-big-title"); submitRequestPanel.addWidget(toBigTitle); HorizontalPanel hp = new HorizontalPanel(); @@ -194,11 +196,29 @@ public class BoxPlotPanelResult { } }); + } + + + private String getOutputId(int oIteration, String title){ + if (title.startsWith("My")) { + String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 1; + return outputId; + } else if (title.startsWith("All")) { + String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 2; + return outputId; + } else { + String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 3; + return outputId; + } + + } + + private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, - final Panel container, boolean displayError, int oIteration) { + final Panel container, boolean displayError, final int oIteration) { String title = displayError ? "No results " : ""; @@ -213,13 +233,9 @@ public class BoxPlotPanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); - - int oNumber = 0; - - for (final OutputFile outputFile : dmResponse.getListOutput()) { - oNumber++; - final String outputId = "OutputId_" +requestId+"_"+ oIteration + "_" + oNumber; + for (OutputFile outputFile : dmResponse.getListOutput()) { + + final FileContentType fileContentType = outputFile.getDataType(); switch (outputFile.getDataType()) { case IMAGE: @@ -242,8 +258,9 @@ public class BoxPlotPanelResult { title = chartType.getName() + " - on all batches
"; title += "Blue dots indicate the selected batch(es): " + focusID; - - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + + String outputId=getOutputId(oIteration,title); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); displayingOrderedBoxPlot(dmResponse, title, container, showResult); } @@ -276,8 +293,9 @@ public class BoxPlotPanelResult { } title += "
"; title += "Data aggregation is performed by considering batches as base units"; - - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + + String outputId=getOutputId(oIteration,title); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); displayingOrderedBoxPlot(dmResponse, title, container, showResult); @@ -291,8 +309,10 @@ public class BoxPlotPanelResult { } + + } - + private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, ShowResult showResult) { int hashcode = dmResponse.hashCode(); @@ -314,7 +334,7 @@ public class BoxPlotPanelResult { flex.setWidget(0, 2, showResult); } } - + /** * Remove the spinner if all DM responses are returned. * @@ -337,7 +357,7 @@ public class BoxPlotPanelResult { int requestId, int outputIteration, int outputNumber)/*-{ var that = this; console.log('saveFilePDF()'); - console.log('requestId: '+requestId); + console.log('requestId: ' + requestId); console.log('OutputIteration: ' + outputIteration); console.log('OutputNumber:' + outputNumber); @@ -385,9 +405,24 @@ public class BoxPlotPanelResult { for (var i = 1; i <= outputIteration; i++) { + var kpiId = 'KPI_BoxPlot_' + requestId + '_' + i; + console.log('kpiId: ' + kpiId); + + var kpiName = $doc.getElementById(kpiId); + + yPos += 2; + pdoc.setFontSize(16); + pdoc.setFontType("bold"); + pdoc.text(kpiName.textContent, xPos, yPos, 'left'); + yPos += 6; + + pdoc.setFontSize(10); + pdoc.setFontType("normal"); + + for (var j = 1; j <= outputNumber; j++) { - var outputId = 'OutputId_'+requestId+'_'+ i + '_' + j; + var outputId = 'OutputId_' + requestId + '_' + i + '_' + j; console.log('OutputId: ' + outputId); var resultOutputNumber = $doc.getElementById(outputId); @@ -405,6 +440,19 @@ public class BoxPlotPanelResult { // foo could get resolved and it's defined var childrenTable = resultOutputNumber.children; + var titleCurrentTable = childrenTable[0].rows[0].cells[0]; + console.log('Title current table: ' + + titleCurrentTable.textContent); + yPos += 2; + pdoc.setFontSize(12); + pdoc.setFontType("bold"); + pdoc.text(titleCurrentTable.textContent, xPos, yPos, + 'left'); + yPos += 6; + + pdoc.setFontSize(10); + pdoc.setFontType("normal"); + var secondDiv = childrenTable[0].rows[1].cells[0]; var secondTable = secondDiv.children[0].children[0]; @@ -425,6 +473,21 @@ public class BoxPlotPanelResult { if (resultType == 'image') { console.log('Result Type image: ' + i); var childrenTable = resultOutputNumber.children; + + var titleCurrentImage = childrenTable[0].rows[0].cells[0]; + console.log('Title current image: ' + + titleCurrentImage.textContent); + yPos += 2; + pdoc.setFontSize(12); + pdoc.setFontType("bold"); + pdoc.text(titleCurrentImage.textContent, xPos, + yPos, 'left'); + yPos += 6; + + pdoc.setFontSize(10); + pdoc.setFontType("normal"); + + var secondDiv = childrenTable[0].rows[1].cells[0]; var imageElement = secondDiv.getElementsByTagName( 'img').item(0); @@ -443,6 +506,27 @@ public class BoxPlotPanelResult { } } + + if (i < outputIteration) { + //var numberOfPages=pdoc.internal.getNumberOfPages(); + //console.log('NumberOfPages: '+numberOfPages); + var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber; + console.log('CurrentPage: ' + currentPage); + var footner = 'Page ' + currentPage; + pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center'); + pdoc.addPage(); + + yPos = tMargin; // Restart position + } else { + if (i = outputIteration) { + var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber; + console.log('CurrentPage: ' + currentPage); + var footner = 'Page ' + currentPage; + pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center'); + } + + } + } console.log('Done'); @@ -450,5 +534,5 @@ public class BoxPlotPanelResult { pdoc.save(filename); }-*/; - + } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ScatterPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ScatterPanelResult.java index 577642e..702126f 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ScatterPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ScatterPanelResult.java @@ -12,6 +12,7 @@ import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsS import org.gcube.portlets.user.performfishanalytics.client.controllers.PerformFishAnalyticsViewController; import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFishResources; import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -38,13 +39,14 @@ import com.google.gwt.user.client.ui.Panel; public class ScatterPanelResult { private PerformFishAnalyticsViewController viewController; - private int requestId; + private int requestId=0; private int outputIteration = 0; private int outputNumber = 0; public ScatterPanelResult(int reqId,PerformFishAnalyticsViewController viewController, final DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI) { - this.requestId=reqId; + GWT.log("RequestID: "+reqId); + requestId=reqId; this.viewController = viewController; TextResource algDescr = PerformFishResources.INSTANCE.batch_SCATTER(); @@ -208,14 +210,12 @@ public class ScatterPanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); - int oNumber = 0; - for (final OutputFile outputFile : dmResponse.getListOutput()) { + for (OutputFile outputFile : dmResponse.getListOutput()) { oNumber++; final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; - + final FileContentType fileContentType= outputFile.getDataType(); switch (outputFile.getDataType()) { case IMAGE: PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, @@ -234,7 +234,7 @@ public class ScatterPanelResult { public void onSuccess(String base64Content) { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); container.add(showResult); @@ -262,7 +262,7 @@ public class ScatterPanelResult { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); container.add(showResult); } @@ -274,6 +274,8 @@ public class ScatterPanelResult { } } + + outputNumber=oNumber; } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SpeedometerPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SpeedometerPanelResult.java index 6f13715..5f09767 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SpeedometerPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SpeedometerPanelResult.java @@ -12,6 +12,7 @@ import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsS import org.gcube.portlets.user.performfishanalytics.client.controllers.PerformFishAnalyticsViewController; import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFishResources; import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -45,7 +46,8 @@ public class SpeedometerPanelResult { public SpeedometerPanelResult(int reqId,PerformFishAnalyticsViewController viewController, final DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI) { - this.requestId=reqId; + GWT.log("RequestID: "+reqId); + requestId=reqId; this.viewController = viewController; TextResource algDescr = PerformFishResources.INSTANCE.batch_SPEEDOMETER(); @@ -208,14 +210,13 @@ public class SpeedometerPanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); - int oNumber = 0; - for (final OutputFile outputFile : dmResponse.getListOutput()) { + for (OutputFile outputFile : dmResponse.getListOutput()) { oNumber++; - final String outputId = "OutputId_" +requestId+"_"+ oIteration + "_" + oNumber; - + final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; + final FileContentType fileContentType= outputFile.getDataType(); + switch (outputFile.getDataType()) { case IMAGE: PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, @@ -238,7 +239,7 @@ public class SpeedometerPanelResult { title += "Selected Batch ID: " + focusID + "
"; title += "Normalized with respect to all batches in the VRE"; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); container.add(showResult); @@ -265,7 +266,7 @@ public class SpeedometerPanelResult { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); container.add(showResult); } @@ -277,6 +278,8 @@ public class SpeedometerPanelResult { } } + + outputNumber=oNumber; } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SynopticTablePanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SynopticTablePanelResult.java index 535cdc0..8aa4866 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SynopticTablePanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/SynopticTablePanelResult.java @@ -11,6 +11,7 @@ import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsS import org.gcube.portlets.user.performfishanalytics.client.controllers.PerformFishAnalyticsViewController; import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFishResources; import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; +import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; @@ -45,7 +46,8 @@ public class SynopticTablePanelResult { public SynopticTablePanelResult(int reqId, PerformFishAnalyticsViewController viewController, PerformFishResponse performFishResponse, final Map> performFishRequestParameters) { - this.requestId = reqId; + GWT.log("RequestID: "+reqId); + requestId=reqId; this.viewController = viewController; String batchTableURL = performFishResponse.getMapParameters().get(PerformFishAnalyticsConstant.BATCHES_TABLE); @@ -194,14 +196,13 @@ public class SynopticTablePanelResult { final String toTitle = title; - outputNumber = dmResponse.getListOutput().size(); - int oNumber = 0; - for (final OutputFile outputFile : dmResponse.getListOutput()) { + for (OutputFile outputFile : dmResponse.getListOutput()) { oNumber++; - final String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + oNumber; - + final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; + final FileContentType fileContentType= outputFile.getDataType(); + switch (outputFile.getDataType()) { case IMAGE: PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, @@ -221,7 +222,7 @@ public class SynopticTablePanelResult { String title = toTitle; - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showImage(base64Content); container.add(showResult); @@ -259,7 +260,7 @@ public class SynopticTablePanelResult { } ShowResult showResultSin = new ShowResult(outputId, title, - outputFile.getDataType()); + fileContentType); showResultSin.showCSVFile(result, cssTableStyle); displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, showResultSin); @@ -271,7 +272,7 @@ public class SynopticTablePanelResult { break; } // ALL OTHER CASES - ShowResult showResult = new ShowResult(outputId, title, outputFile.getDataType()); + ShowResult showResult = new ShowResult(outputId, title, fileContentType); showResult.showCSVFile(result, cssTableStyle); container.add(showResult); } @@ -283,6 +284,8 @@ public class SynopticTablePanelResult { } } + + outputNumber = oNumber; }