From 69836bacbad0f993b19d0ee9ff89ffd9451d21bc Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 7 Nov 2019 16:39:24 +0000 Subject: [PATCH] ref 17252: Enable DEA Analysis https://support.d4science.org/issues/17252 Added DEA Analysis git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/performfish-analytics-portlet@182231 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 6 +- .settings/com.google.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 2 +- distro/changelog.xml | 5 + pom.xml | 24 +- .../client/PerformFishAnalyticsConstant.java | 83 +- .../PerformFishAnnualAnalyticsController.java | 1278 ++++++++++------- .../PerformFishAnalyticsController.java | 1069 ++++++++------ .../client/resources/Batch_DEAANALYSIS | 5 + .../client/resources/Farm_DEAANALYSIS | 5 + .../resources/PerformFishResources.java | 7 + .../AnalyticsAnnualPanelResult.java | 860 +++-------- .../AnalyticsAnnualPanelResult.ui.xml | 59 +- .../DeaAnnualPanelResult.java | 971 +++++++++++++ .../DeaAnnualPanelResult.ui.xml | 119 ++ .../viewbinder/AnalyticsPanelResult.java | 452 +----- .../viewbinder/AnalyticsPanelResult.ui.xml | 62 +- .../client/viewbinder/DeaPanelResult.java | 876 +++++++++++ .../client/viewbinder/DeaPanelResult.ui.xml | 119 ++ .../client/viewbinder/RecapSubmitPage.java | 26 +- .../client/viewbinder/RecapSubmitPage.ui.xml | 3 + .../client/viewbinder/ShowResult.java | 7 +- .../PerformFishAnalyticsServiceImpl.java | 7 +- .../server/util/ContextUtil.java | 114 +- src/main/webapp/PerformFishAnalytics.css | 14 + 25 files changed, 3859 insertions(+), 2316 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Batch_DEAANALYSIS create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Farm_DEAANALYSIS create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.java create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.ui.xml create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.java create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.ui.xml diff --git a/.classpath b/.classpath index 99f76aa..1c1d5a5 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index c1b9544..964a7d2 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/home/francesco-mangiacrapa/wseclipseluna/performfish-analytics-portlet/target +lastWarOutDir=/home/giancarlo/workspacePerformFish/performfish-analytics-portlet/target/war warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 5216cf9..2b7c0bb 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + diff --git a/distro/changelog.xml b/distro/changelog.xml index a3adb5b..a187c5a 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,9 @@ + + [Task #17252] Enabled DEA Analysis + diff --git a/pom.xml b/pom.xml index 07ca1ba..b83c09f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.gcube.portlets.user performfish-analytics-portlet war - 0.3.0-SNAPSHOT + 0.4.0-SNAPSHOT Maven Archetype for GWT @@ -159,7 +159,7 @@ commons-io compile - + org.gcube.core common-encryption @@ -203,12 +203,12 @@ org.slf4j slf4j-log4j12 - compile + provided org.slf4j slf4j-api - compile + provided @@ -235,7 +235,21 @@ ${webappDirectory}/WEB-INF/classes - + + + org.projectlombok + lombok-maven-plugin + 1.18.10.0 + + + generate-sources + + delombok + + + + + org.codehaus.mojo diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/PerformFishAnalyticsConstant.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/PerformFishAnalyticsConstant.java index 13aa633..399b717 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/PerformFishAnalyticsConstant.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/PerformFishAnalyticsConstant.java @@ -4,7 +4,6 @@ package org.gcube.portlets.user.performfishanalytics.client; - /** * The Class PerformFishAnalyticsConstant. * @@ -27,11 +26,13 @@ public class PerformFishAnalyticsConstant { public static final String DM_YEARS_PARAM = "years"; public static final String DM_FARMFILE_PARAM = "farmFile"; public static final String DM_FOCUS_PARAM = "focus"; + public static final String DM_APDISEASES = "apdiseases"; + public static final String DM_ABDISEASES = "abdiseases"; public static final String DM_INPUT_KPI_PARAM = "inputKPI"; public static final String DM_OUTPUT_KPI_PARAM = "outputKPI"; public static final int CSV_BATCHES_TABLE_MINIMUM_SIZE = 4; - - //SYNOPTIC TABLE + + // SYNOPTIC TABLE public static final String DM_INPUT_TABLE = "inputTable"; public static final String DM_ZONE_LABELS = "zonesLabels"; public static final String DM_STOCKING_PERIOD = "stockingPeriod"; @@ -39,7 +40,6 @@ public class PerformFishAnalyticsConstant { public static final String DM_ALLYEARS_PARAM = "allyears"; public static final String DM_VALUE_ALL = "ALL"; - public static final String PERFORM_FISH_AREA_PARAM = "area"; public static final String PERFORM_FISH_QUARTER_PARAM = "quarter"; public static final String PERFORM_FISH_PERIOD_PARAM = "period"; @@ -48,83 +48,72 @@ public class PerformFishAnalyticsConstant { public static final String PERFORM_FISH_BATCH_TYPE_PARAM = "batch_type"; public static final String PERFORM_FISH_SPECIES_ID_PARAM = "speciesid"; - - public static final String DM_FOCUS_ID_ALL_ITEM_VALUE = "ALL"; public static final String DM_FOCUS_ID_ALL_ITEM_TEXT = "ALL the above"; - - /** * The Enum POPULATION_LEVEL. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR + * (francesco.mangiacrapa@isti.cnr.it) * - * May 8, 2019 + * May 8, 2019 */ - public static enum POPULATION_LEVEL{BATCH, FARM}; - - + public static enum POPULATION_LEVEL { + BATCH, FARM + }; + /** * The Enum BATCH_LEVEL. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Feb 27, 2019 + * @author Francesco Mangiacrapa at ISTI-CNR + * (francesco.mangiacrapa@isti.cnr.it) Feb 27, 2019 */ - public static enum BATCH_LEVEL{ - PRE_ONGROWING, - PRE_ONGROWING_CLOSED_BATCHES, - HATCHERY_INDIVIDUAL, - HATCHERY_INDIVIDUAL_CLOSED_BATCHES, - GROW_OUT_INDIVIDUAL, - GROW_OUT_INDIVIDUAL_CLOSED_BATCHES, - GROW_OUT_AGGREGATED, - GROW_OUT_AGGREGATED_CLOSED_BATCHES + public static enum BATCH_LEVEL { + PRE_ONGROWING, PRE_ONGROWING_CLOSED_BATCHES, HATCHERY_INDIVIDUAL, HATCHERY_INDIVIDUAL_CLOSED_BATCHES, GROW_OUT_INDIVIDUAL, GROW_OUT_INDIVIDUAL_CLOSED_BATCHES, GROW_OUT_AGGREGATED, GROW_OUT_AGGREGATED_CLOSED_BATCHES } - - + /** * The Enum PFServiceToDMMappingTable. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR + * (francesco.mangiacrapa@isti.cnr.it) * - * May 8, 2019 + * May 8, 2019 */ - public static enum PFSERVICE_TO_DM_MAPPING_TABLE{ + public static enum PFSERVICE_TO_DM_MAPPING_TABLE { - LethalIncidentsTable("LethalIncidentsTable", "lethalIncidentsFile"), - AntibioticsTable_internal("AntibioticsTable_internal", null), - AntibioticsTable("AntibioticsTable", "antibioticFile"), - AnnualTable_internal("AnnualTable_internal", null), - AnnualTable("AnnualTable", "annualFile"), - AntiparasiticTable("AntiparasiticTable", "antiparasiticFile"), - AntiparasiticTable_internal("AntiparasiticTable_internal", null); - + LethalIncidentsTable("LethalIncidentsTable", "lethalIncidentsFile"), AntibioticsTable_internal( + "AntibioticsTable_internal", + null), AntibioticsTable("AntibioticsTable", "antibioticFile"), AnnualTable_internal( + "AnnualTable_internal", + null), AnnualTable("AnnualTable", "annualFile"), AntiparasiticTable("AntiparasiticTable", + "antiparasiticFile"), AntiparasiticTable_internal("AntiparasiticTable_internal", null); /** * Instantiates a new PF service to DM mapping table. * - * @param performFishTable the perform fish table - * @param dataMinerTable the data miner table + * @param performFishTable + * the perform fish table + * @param dataMinerTable + * the data miner table */ - PFSERVICE_TO_DM_MAPPING_TABLE(String performFishTable, String dataMinerTable){ + PFSERVICE_TO_DM_MAPPING_TABLE(String performFishTable, String dataMinerTable) { this.performFishTable = performFishTable; - this.dataMinerTable=dataMinerTable; + this.dataMinerTable = dataMinerTable; } - + String performFishTable; String dataMinerTable; - - + public String getPerformFishTable() { return performFishTable; } - + public String getDataMinerTable() { return dataMinerTable; } - + } - } 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 985d662..6d5fdc2 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 @@ -3,6 +3,7 @@ */ package org.gcube.portlets.user.performfishanalytics.client.annualcontrollers; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -31,6 +32,7 @@ import org.gcube.portlets.user.performfishanalytics.client.event.SubmitRequestEv import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFishResources; import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.viewannualbinder.AnalyticsAnnualPanelResult; +import org.gcube.portlets.user.performfishanalytics.client.viewannualbinder.DeaAnnualPanelResult; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.AnalyticsPanelResult; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.ShowResult; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.SubmitRequestPanel; @@ -59,38 +61,34 @@ import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Panel; - // TODO: Auto-generated Javadoc /** * The Class PerformFishAnalyticsController. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Jan 16, 2019 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 16, 2019 */ public class PerformFishAnnualAnalyticsController { /** The Constant eventBus. */ public final static HandlerManager eventBus = new HandlerManager(null); - + /** The view controller. */ private PerformFishAnnualAnalyticsViewController viewAnnualController; /** The decrypt parameters. */ private PerformFishInitParameter decryptParameters; - - - private PerformFishResponse thePerformFishResponse; - - /** The focus. */ - //This value is read from the first value of column "FARM" contained in - //the table AnnualTable_internal.csv returned by PerformFish Service - private String theFocusValue = null; - - private Map boxPlotOrderBy = new HashMap(); - - private Map synopticOrderBy = new HashMap(); + private PerformFishResponse thePerformFishResponse; + + /** The focus. */ + // This value is read from the first value of column "FARM" contained in + // the table AnnualTable_internal.csv returned by PerformFish Service + private String theFocusValue = null; + + private Map boxPlotOrderBy = new HashMap(); + + private Map synopticOrderBy = new HashMap(); /** * Instantiates a new perform fish analytics controller. @@ -99,18 +97,18 @@ public class PerformFishAnnualAnalyticsController { registerHandlers(); } - + /** * Sets the inits the parmaters. * - * @param result the new inits the parmaters + * @param result + * the new inits the parmaters */ public void setInitParmaters(PerformFishInitParameter result) { this.decryptParameters = result; viewAnnualController = new PerformFishAnnualAnalyticsViewController(); } - /** * Register handlers. */ @@ -119,11 +117,11 @@ public class PerformFishAnnualAnalyticsController { eventBus.addHandler(LoadPopulationTypeEvent.TYPE, new LoadPopulationTypeEventHandler() { @Override - public void onLoadPopulationType( - LoadPopulationTypeEvent loadPopulationEvent) { - - viewAnnualController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), decryptParameters); - + public void onLoadPopulationType(LoadPopulationTypeEvent loadPopulationEvent) { + + viewAnnualController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), + decryptParameters); + } }); @@ -132,17 +130,18 @@ public class PerformFishAnnualAnalyticsController { @Override public void onCall(CallAlgorithmEvent callAlgorithmEvent) { - callAlgorithm(callAlgorithmEvent.getAlgorithm(), callAlgorithmEvent.getFocusID(), callAlgorithmEvent.getInputKPI(), callAlgorithmEvent.getOutputKPI()); + callAlgorithm(callAlgorithmEvent.getAlgorithm(), callAlgorithmEvent.getFocusID(), + callAlgorithmEvent.getInputKPI(), callAlgorithmEvent.getOutputKPI()); } }); eventBus.addHandler(SelectedPopulationTypeEvent.TYPE, new SelectedPopulationTypeEventHandler() { @Override - public void onSelectedPopulationType( - SelectedPopulationTypeEvent selectedPopulationTypeEvent) { + public void onSelectedPopulationType(SelectedPopulationTypeEvent selectedPopulationTypeEvent) { - viewAnnualController.setRootPopulationTypeForKPIs(selectedPopulationTypeEvent.getSelectedPopulationType()); + viewAnnualController + .setRootPopulationTypeForKPIs(selectedPopulationTypeEvent.getSelectedPopulationType()); } }); @@ -150,153 +149,176 @@ public class PerformFishAnnualAnalyticsController { @Override public void onSelectedKPI(SelectedKPIEvent selectedKPI) { - GWT.log("Selected KPI: "+selectedKPI); - viewAnnualController.manageKPI(selectedKPI.getKpi(), selectedKPI.isChecked(), selectedKPI.getSelectedPopulationType()); + GWT.log("Selected KPI: " + selectedKPI); + viewAnnualController.manageKPI(selectedKPI.getKpi(), selectedKPI.isChecked(), + selectedKPI.getSelectedPopulationType()); eventBus.fireEvent(new PerformFishFieldFormChangedEvent(null)); - - //viewController.manageAlgorithmsSubmit(selectedKPIsSize); -// List batchIds = viewController.getSelectedBatchID(); -// if(batchIds==null || batchIds.size()==0) { -// viewController.enableAllAlgorithmsForSubmit(false); -// }else - - //viewController.manageAlgorithmsSubmit(selectedKPIsSize); + + // viewController.manageAlgorithmsSubmit(selectedKPIsSize); + // List batchIds = viewController.getSelectedBatchID(); + // if(batchIds==null || batchIds.size()==0) { + // viewController.enableAllAlgorithmsForSubmit(false); + // }else + + // viewController.manageAlgorithmsSubmit(selectedKPIsSize); } }); - + eventBus.addHandler(PerformFishFieldFormChangedEvent.TYPE, new PerformFishFieldFormChangedEventHandler() { @Override - public void onFieldFormChanged( - PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) { + public void onFieldFormChanged(PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) { - //viewAnnualController.setReloadPerformFishServiceData(true); + // viewAnnualController.setReloadPerformFishServiceData(true); boolean isValidForm = viewAnnualController.validatePerformFishInputFields(); - - if(isValidForm) { - //boolean isKPIsSelected = viewAnnualController.validateKPIFields(); + + if (isValidForm) { + // boolean isKPIsSelected = + // viewAnnualController.validateKPIFields(); int selectedKPIsSize = viewAnnualController.getSelectedKPIs().size(); viewAnnualController.manageAlgorithmsSubmit(selectedKPIsSize); viewAnnualController.enableSynopticTable(true); - }else { - //viewController.enableLoadBatches(false); + } else { + // viewController.enableLoadBatches(false); viewAnnualController.enableAllAlgorithmsForSubmit(false); viewAnnualController.enableSynopticTable(false); } } }); - + eventBus.addHandler(LoadFocusEvent.TYPE, new LoadFocusEventHandler() { - + @Override public void onLoadFocusEvent(LoadFocusEvent loadFocusEvent) { final Map> mapParameters = new HashMap>(); - String farmId = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM); - String batchType = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM); + String farmId = decryptParameters.getParameters() + .get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM); + String batchType = decryptParameters.getParameters() + .get(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM); - //String batchType = viewAnnualController.getForm().getBatchType(); - - //List listYear = viewAnnualController.getForm().getYear(); + // String batchType = + // viewAnnualController.getForm().getBatchType(); + + // List listYear = + // viewAnnualController.getForm().getYear(); mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM, Arrays.asList(farmId)); mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM, Arrays.asList(batchType)); - PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters, new AsyncCallback() { + PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - //modal.hide(); - Window.alert(caught.getMessage()); - } + @Override + public void onFailure(Throwable caught) { + // modal.hide(); + Window.alert(caught.getMessage()); + } - @Override - public void onSuccess(PerformFishResponse performFishResponse) { - thePerformFishResponse = performFishResponse; - GWT.log("PerformFish Response: "+performFishResponse); - - final String pfTableName = PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable_internal.getPerformFishTable(); + @Override + public void onSuccess(PerformFishResponse performFishResponse) { + thePerformFishResponse = performFishResponse; + GWT.log("PerformFish Response: " + performFishResponse); - String fileURL = performFishResponse.getMapParameters().get(pfTableName); + final String pfTableName = PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable_internal + .getPerformFishTable(); - GWT.log(pfTableName+" is: "+fileURL); + String fileURL = performFishResponse.getMapParameters().get(pfTableName); - //Managing the Perform Fish Service Response - if(fileURL==null){ - viewAnnualController.showAlert("No table found by searching for name: "+PerformFishAnalyticsConstant.BATCHES_TABLE_INTERNAL, AlertType.ERROR); - }else{ + GWT.log(pfTableName + " is: " + fileURL); + // Managing the Perform Fish Service Response + if (fileURL == null) { + viewAnnualController.showAlert( + "No table found by searching for name: " + + PerformFishAnalyticsConstant.BATCHES_TABLE_INTERNAL, + AlertType.ERROR); + } else { - PerformFishAnalyticsServiceAsync.Util.getInstance().readCSVFile(fileURL, new AsyncCallback() { + PerformFishAnalyticsServiceAsync.Util.getInstance().readCSVFile(fileURL, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - Window.alert(caught.getMessage()); + @Override + public void onFailure(Throwable caught) { + Window.alert(caught.getMessage()); + + } + + @Override + public void onSuccess(CSVFile result) { + + if (result == null) { + viewAnnualController.showAlert( + "The focus was not found in the table " + pfTableName, + AlertType.ERROR); + return; + } + + int indexOfFARM = result.getHeaderRow().getListValues().indexOf( + PerformFishAnalyticsConstant.POPULATION_LEVEL.FARM.name()); + + GWT.log("The index of column " + + PerformFishAnalyticsConstant.POPULATION_LEVEL.FARM.name() + + " is " + indexOfFARM); + + if (indexOfFARM > -1) { + List rows = result.getValueRows(); + + if (rows == null || rows.isEmpty()) { + viewAnnualController + .showAlert("No valid focus was found in the table " + + pfTableName, AlertType.ERROR); + return; + } + + String focusValue = null; + // IN THE COLUMN WITH + // HEADER 'FARM' THE + // FOCUS VALUE IS THE + // SAME FOR ALL ROWS + for (CSVRow row : rows) { + focusValue = row.getListValues().get(indexOfFARM); + if (focusValue != null && !focusValue.isEmpty()) + break; + } + + if (focusValue == null) { + viewAnnualController + .showAlert("No valid focus was found in the table " + + pfTableName, AlertType.ERROR); + return; + } + + theFocusValue = focusValue; + GWT.log("Loaded the focus value: " + theFocusValue); + } + } + }); } + } + }); - @Override - public void onSuccess(CSVFile result) { - - if(result==null){ - viewAnnualController.showAlert("The focus was not found in the table "+pfTableName, AlertType.ERROR); - return; - } - - int indexOfFARM = result.getHeaderRow().getListValues().indexOf(PerformFishAnalyticsConstant.POPULATION_LEVEL.FARM.name()); - - GWT.log("The index of column "+PerformFishAnalyticsConstant.POPULATION_LEVEL.FARM.name()+" is "+indexOfFARM); - - if(indexOfFARM>-1){ - List rows = result.getValueRows(); - - if(rows==null || rows.isEmpty()){ - viewAnnualController.showAlert("No valid focus was found in the table "+pfTableName, AlertType.ERROR); - return; - } - - String focusValue = null; - //IN THE COLUMN WITH HEADER 'FARM' THE FOCUS VALUE IS THE SAME FOR ALL ROWS - for (CSVRow row : rows) { - focusValue = row.getListValues().get(indexOfFARM); - if(focusValue!=null && !focusValue.isEmpty()) - break; - } - - if(focusValue==null) { - viewAnnualController.showAlert("No valid focus was found in the table "+pfTableName, AlertType.ERROR); - return; - } - - theFocusValue = focusValue; - GWT.log("Loaded the focus value: "+theFocusValue); - } - } - }); - - } - } - }); - } }); -// + // eventBus.addHandler(SubmitRequestEvent.TYPE, new SubmitRequestEventHandler() { @Override public void onSubmitRequest(SubmitRequestEvent submitRequestEvent) { - //boolean isValidBatchId = viewAnnualController.validateBatchIdSelection(); + // boolean isValidBatchId = + // viewAnnualController.validateBatchIdSelection(); boolean isValidKPI = viewAnnualController.validateKPIFields(); List selectedKPI = viewAnnualController.getSelectedKPIs(); viewAnnualController.manageAlgorithmsSubmit(selectedKPI.size()); - - if(theFocusValue!=null) { - - if(isValidKPI){ + + if (theFocusValue != null) { + + if (isValidKPI) { submitRequestToDM(submitRequestEvent.getChartType()); } } @@ -304,9 +326,9 @@ public class PerformFishAnnualAnalyticsController { return; } }); - + eventBus.addHandler(LoadSynopticTableEvent.TYPE, new LoadSynopticTableEventHandler() { - + @Override public void onLoadSynopticTable(LoadSynopticTableEvent loadSynopticTableEvent) { @@ -315,45 +337,51 @@ public class PerformFishAnnualAnalyticsController { }); } - + /** * Call algorithm synoptic table farm. */ protected void callAlgorithmSynopticTableFarm() { - + final DataMinerAlgorithms algorithm = DataMinerAlgorithms.PERFORMFISH_SYNOPTIC_TABLE_FARM; final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); String tabTitle = "Synoptic Table"; - - final Tab tab = viewAnnualController.createTab(tabTitle+" #"+(viewAnnualController.currentNumberOfTab()+1),PerformFishResources.INSTANCE.synopticTable().getText(),submitRequestPanel); + + final Tab tab = viewAnnualController.createTab( + tabTitle + " #" + (viewAnnualController.currentNumberOfTab() + 1), + PerformFishResources.INSTANCE.synopticTable().getText(), submitRequestPanel); StringBuilder dataInputsFormatter = new StringBuilder(); Map performFishResponseMap = thePerformFishResponse.getMapParameters(); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable); - - + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable); + String yearsValue = ""; for (String year : viewAnnualController.getSelectedYears()) { - yearsValue+=year+"#"; + yearsValue += year + "#"; } - yearsValue = yearsValue.substring(0, yearsValue.length()-1); - - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"="+ yearsValue +";"); - - //dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"="+ PerformFishAnalyticsConstant.DM_VALUE_ALL +";"); - //dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"=2016;"); - + yearsValue = yearsValue.substring(0, yearsValue.length() - 1); + + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM + "=" + yearsValue + ";"); + + // dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"="+ + // PerformFishAnalyticsConstant.DM_VALUE_ALL +";"); + // dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"=2016;"); + String dataInParameters = dataInputsFormatter.toString(); - GWT.log("Calling DM service with client input parameters: "+dataInParameters); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); Map> mapParameters = new HashMap>(); mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); final HTMLPanel panelContainer = submitRequestPanel.getContainerPanel(); - final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to "+algorithm.getTitle()+"..."); + final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to " + algorithm.getTitle() + "..."); loaderIcon.setVisible(true); panelContainer.setVisible(true); panelContainer.add(loaderIcon); @@ -361,237 +389,389 @@ public class PerformFishAnnualAnalyticsController { @Override public void execute() { loaderIcon.setFocus(true); - }}); - - PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticAnnualTable(thePerformFishResponse, mapParameters, new AsyncCallback() { - - @Override - public void onSuccess(DataMinerResponse dmResponse) { - loaderIcon.setVisible(false); - checkTabSpinner(submitRequestPanel, tab); - //field_unary_algorithm.setVisible(true); - GWT.log("I'm displaying: "+dmResponse); - displayOutputFilesAsStaticEntities(dmResponse, algorithm, null, null, null, panelContainer, false); - } - - @Override - public void onFailure(Throwable caught) { - loaderIcon.setVisible(false); - checkTabSpinner(submitRequestPanel, tab); - displayOutputFilesAsStaticEntities(null, algorithm, null, null, null, panelContainer, true); - } }); + PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticAnnualTable( + thePerformFishResponse, mapParameters, new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + loaderIcon.setVisible(false); + checkTabSpinner(submitRequestPanel, tab); + // field_unary_algorithm.setVisible(true); + GWT.log("I'm displaying: " + dmResponse); + displayOutputFilesAsStaticEntities(dmResponse, algorithm, null, null, null, panelContainer, + false); + } + + @Override + public void onFailure(Throwable caught) { + loaderIcon.setVisible(false); + checkTabSpinner(submitRequestPanel, tab); + displayOutputFilesAsStaticEntities(null, algorithm, null, null, null, panelContainer, true); + + } + }); + } /** * Submit request to DM. * - * @param dmAlgorithm the dm algorithm + * @param dmAlgorithm + * the dm algorithm */ private void submitRequestToDM(DataMinerAlgorithms dmAlgorithm) { - + switch (dmAlgorithm) { - + case BOXPLOT: - //UNARY + // UNARY callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null); break; case SCATTER: - if(viewAnnualController.getSelectedKPIs().size()==2) + if (viewAnnualController.getSelectedKPIs().size() == 2) callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null); else - Window.alert("Something seems wrong... You must select exactly two KPIs to execute the "+dmAlgorithm); + Window.alert("Something seems wrong... You must select exactly two KPIs to execute the " + dmAlgorithm); break; - case CORRELATION: - //callDataMinerServiceForChartTypeCorrelation(thePerformFishResponse, viewController.getRequestMapParameters()); - callDataMinerServiceForChartTypeCorrelation(theFocusValue, viewAnnualController.getSelectedKPIs(), viewAnnualController.getSelectedKPIs()); - //callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null); + // callDataMinerServiceForChartTypeCorrelation(thePerformFishResponse, + // viewController.getRequestMapParameters()); + callDataMinerServiceForChartTypeCorrelation(theFocusValue, viewAnnualController.getSelectedKPIs(), + viewAnnualController.getSelectedKPIs()); + // callAlgorithm(dmAlgorithm, theFocusValue, + // viewAnnualController.getSelectedKPIs(), null); break; - case SPEEDOMETER: - //UNARY + // UNARY callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null); break; - + case DEA_ANALYSIS: + createTabToSelectIOParametersForDeaAnnualAnalysis(theFocusValue, viewAnnualController.getSelectedKPIs()); + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + break; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + break; default: break; + } - + } /** * Call data miner service for chart type correlation. * - * @param focusID the focus ID - * @param inputKPI the input KPI - * @param outputKPI the output KPI + * @param focusID + * the focus ID + * @param inputKPI + * the input KPI + * @param outputKPI + * the output KPI */ - private void callDataMinerServiceForChartTypeCorrelation(String focusID, final List inputKPI, final List outputKPI) { + private void createTabToSelectIOParametersForDeaAnnualAnalysis(String focusID, final List listKPI) { - DataMinerInputParameters dmInputParameters = new DataMinerInputParameters(thePerformFishResponse, viewAnnualController.getSelectedYears(), inputKPI, outputKPI, DataMinerAlgorithms.CORRELATION, focusID); - - GWT.log("Building DM request with input parameters: "+dmInputParameters); + DataMinerInputParameters dmInputParameters = new DataMinerInputParameters(thePerformFishResponse, + viewAnnualController.getSelectedYears(), listKPI, listKPI, DataMinerAlgorithms.DEA_ANALYSIS, focusID); + + GWT.log("Building DM request with input parameters: " + dmInputParameters); StringBuilder dataInputsFormatter = new StringBuilder(); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+ dmInputParameters.getChartType() +";"); - + //dataInputsFormatter.append( + // PerformFishAnalyticsConstant.DM_SCALEP_PARAM + "=" + viewAnnualController.getForm().getLevel() + ";"); + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + dmInputParameters.getChartType() + ";"); + String yearsValue = ""; for (String year : dmInputParameters.getSelectedYears()) { - yearsValue+=year+"|"; + yearsValue += year + "|"; } - yearsValue = yearsValue.substring(0, yearsValue.length()-1); - - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM+"="+ yearsValue +";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+dmInputParameters.getFocusID()+";"); - //dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;"); + yearsValue = yearsValue.substring(0, yearsValue.length() - 1); - if(dmInputParameters.getInputKPI()!=null && dmInputParameters.getInputKPI().size()>0){ + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM + "=" + yearsValue + ";"); + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=" + dmInputParameters.getFocusID() + ";"); + + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_APDISEASES + "=null;"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ABDISEASES + "=null;"); + + if (dmInputParameters.getInputKPI() != null && dmInputParameters.getInputKPI().size() > 0) { String kpiCodes = ""; for (KPI kpi : dmInputParameters.getInputKPI()) { - kpiCodes+=kpi.getCode()+"|"; + kpiCodes += kpi.getCode() + "|"; } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); - GWT.log("Input KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM+"="+kpiCodes+";"); + GWT.log("Input KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM + "=" + kpiCodes + ";"); } - if(dmInputParameters.getOutputKPI()!=null && dmInputParameters.getOutputKPI().size()>0){ + if (dmInputParameters.getOutputKPI() != null && dmInputParameters.getOutputKPI().size() > 0) { String kpiCodes = ""; for (KPI kpi : dmInputParameters.getOutputKPI()) { - kpiCodes+=kpi.getCode()+"|"; + kpiCodes += kpi.getCode() + "|"; } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); - GWT.log("Output KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM+"="+kpiCodes+";"); + GWT.log("Output KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM + "=" + kpiCodes + ";"); } - + Map performFishResponseMap = dmInputParameters.getPerformFishResponse().getMapParameters(); - - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable); - + + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable); + String dataInParameters = dataInputsFormatter.toString(); - GWT.log("Calling DM service with client input parameters: "+dataInParameters); + GWT.log("Calling DM service for annual with client input parameters: " + dataInParameters); final Map> mapParameters = new HashMap>(); mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); - submitRequestPanel.showLoader(true, "Submitting "+DataMinerAlgorithms.CORRELATION.getName()+" request to DM Service..."); - String tabTitle = DataMinerAlgorithms.CORRELATION.getName().substring(0,1).toUpperCase()+DataMinerAlgorithms.CORRELATION.getName().toLowerCase().substring(1, DataMinerAlgorithms.CORRELATION.getName().length()); //CAMEL CASE - - - final Tab tab = viewAnnualController.createTab(tabTitle+" #"+(viewAnnualController.currentNumberOfTab()+1),PerformFishResources.INSTANCE.farm_CORRELATION().getText(),submitRequestPanel); + submitRequestPanel.showLoader(false, null); + final Tab tab = viewAnnualController.createTab("Dea #" + (viewAnnualController.currentNumberOfTab() + 1), + PerformFishResources.INSTANCE.farm_DEAANALYSIS().getText(), submitRequestPanel); + viewAnnualController.noSpinner(tab); - PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualCorrelationAnalysis(dmInputParameters.getPerformFishResponse(), mapParameters, new AsyncCallback() { + final List selectedKPI = new ArrayList(viewAnnualController.getSelectedKPIs()); + final List focusIds = new ArrayList(); + focusIds.add(focusID); - @Override - public void onSuccess(DataMinerResponse dmResponse) { - submitRequestPanel.showLoader(false, null); - checkTabSpinner(submitRequestPanel, tab); - AnalyticsAnnualPanelResult analyticsPanelResult = new AnalyticsAnnualPanelResult(eventBus); - //analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); - analyticsPanelResult.addSelectedKPIs(inputKPI); - - //TODO COMMENTED NOW - analyticsPanelResult.addListBatchIds(Arrays.asList(theFocusValue)); - - analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, viewAnnualController.getForm().getBatchType()); - analyticsPanelResult.addResults(dmResponse); - submitRequestPanel.addWidget(analyticsPanelResult); - //viewController.geTabPanelView().addResult(resultPanel, "Analysis #"+(viewController.geTabPanelView().countTab()+1)); - //modal.hide(); - } + DeaAnnualPanelResult deaAnnualPanelResult = new DeaAnnualPanelResult(); - @Override - public void onFailure(Throwable caught) { - GWT.log(caught.toString()); - submitRequestPanel.showLoader(false, null); - checkTabSpinner(submitRequestPanel, tab); - try { - AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult(); - //analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); - analyticsPanelResult.addSelectedKPIs(viewAnnualController.getSelectedKPIs()); - - //TODO COMMENTED NOW - analyticsPanelResult.addListFocusIds(Arrays.asList(theFocusValue)); - - - analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, viewAnnualController.getForm().getBatchType()); - submitRequestPanel.addWidget(analyticsPanelResult); - }catch (Exception e) { - // TODO: handle exception - } - - Alert error = new Alert(caught.getMessage()); - error.setClose(false); - error.setType(AlertType.ERROR); - submitRequestPanel.addWidget(error); - } - }); + deaAnnualPanelResult.addSelectedKPIs(selectedKPI); + deaAnnualPanelResult.addListFocusIds(focusIds); + deaAnnualPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, + viewAnnualController.getForm().getBatchType()); + submitRequestPanel.addWidget(deaAnnualPanelResult); } + /** + * Call data miner service for chart type correlation. + * + * @param focusID + * the focus ID + * @param inputKPI + * the input KPI + * @param outputKPI + * the output KPI + */ + private void callDataMinerServiceForChartTypeCorrelation(String focusID, final List inputKPI, + final List outputKPI) { + + DataMinerInputParameters dmInputParameters = new DataMinerInputParameters(thePerformFishResponse, + viewAnnualController.getSelectedYears(), inputKPI, outputKPI, DataMinerAlgorithms.CORRELATION, focusID); + + GWT.log("Building DM request with input parameters: " + dmInputParameters); + + StringBuilder dataInputsFormatter = new StringBuilder(); + + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + dmInputParameters.getChartType() + ";"); + + String yearsValue = ""; + for (String year : dmInputParameters.getSelectedYears()) { + yearsValue += year + "|"; + } + yearsValue = yearsValue.substring(0, yearsValue.length() - 1); + + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM + "=" + yearsValue + ";"); + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=" + dmInputParameters.getFocusID() + ";"); + // dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;"); + + if (dmInputParameters.getInputKPI() != null && dmInputParameters.getInputKPI().size() > 0) { + String kpiCodes = ""; + for (KPI kpi : dmInputParameters.getInputKPI()) { + kpiCodes += kpi.getCode() + "|"; + } + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + + GWT.log("Input KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM + "=" + kpiCodes + ";"); + + } + + if (dmInputParameters.getOutputKPI() != null && dmInputParameters.getOutputKPI().size() > 0) { + String kpiCodes = ""; + for (KPI kpi : dmInputParameters.getOutputKPI()) { + kpiCodes += kpi.getCode() + "|"; + } + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + + GWT.log("Output KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM + "=" + kpiCodes + ";"); + } + + Map performFishResponseMap = dmInputParameters.getPerformFishResponse().getMapParameters(); + + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable); + + String dataInParameters = dataInputsFormatter.toString(); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); + + final Map> mapParameters = new HashMap>(); + mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); + + final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); + submitRequestPanel.showLoader(true, + "Submitting " + DataMinerAlgorithms.CORRELATION.getName() + " request to DM Service..."); + String tabTitle = DataMinerAlgorithms.CORRELATION.getName().substring(0, 1).toUpperCase() + + DataMinerAlgorithms.CORRELATION.getName().toLowerCase().substring(1, + DataMinerAlgorithms.CORRELATION.getName().length()); // CAMEL + // CASE + + final Tab tab = viewAnnualController.createTab( + tabTitle + " #" + (viewAnnualController.currentNumberOfTab() + 1), + PerformFishResources.INSTANCE.farm_CORRELATION().getText(), submitRequestPanel); + + PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualCorrelationAnalysis( + dmInputParameters.getPerformFishResponse(), mapParameters, new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + submitRequestPanel.showLoader(false, null); + checkTabSpinner(submitRequestPanel, tab); + AnalyticsAnnualPanelResult analyticsPanelResult = new AnalyticsAnnualPanelResult(eventBus); + // analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); + analyticsPanelResult.addSelectedKPIs(inputKPI); + + // TODO COMMENTED NOW + analyticsPanelResult.addListBatchIds(Arrays.asList(theFocusValue)); + + analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, + viewAnnualController.getForm().getBatchType()); + analyticsPanelResult.addResults(dmResponse); + submitRequestPanel.addWidget(analyticsPanelResult); + // viewController.geTabPanelView().addResult(resultPanel, + // "Analysis + // #"+(viewController.geTabPanelView().countTab()+1)); + // modal.hide(); + } + + @Override + public void onFailure(Throwable caught) { + GWT.log(caught.toString()); + submitRequestPanel.showLoader(false, null); + checkTabSpinner(submitRequestPanel, tab); + try { + AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult(); + // analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); + analyticsPanelResult.addSelectedKPIs(viewAnnualController.getSelectedKPIs()); + + // TODO COMMENTED NOW + analyticsPanelResult.addListFocusIds(Arrays.asList(theFocusValue)); + + analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, + viewAnnualController.getForm().getBatchType()); + submitRequestPanel.addWidget(analyticsPanelResult); + } catch (Exception e) { + // TODO: handle exception + } + + Alert error = new Alert(caught.getMessage()); + error.setClose(false); + error.setType(AlertType.ERROR); + submitRequestPanel.addWidget(error); + } + }); + } /** * Creating new TAB and calling DM algorithm. * - * @param algorithm the algorithm - * @param focusID the focus id - * @param inputKPI the input kpi - * @param outputKPI the output kpi + * @param algorithm + * the algorithm + * @param focusID + * the focus id + * @param inputKPI + * the input kpi + * @param outputKPI + * the output kpi */ - private void callAlgorithm(DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI){ + private void callAlgorithm(DataMinerAlgorithms algorithm, String focusID, List inputKPI, + final List outputKPI) { -// List listBatchID = viewController.getSelectedBatchID(); -// -// if(listBatchID==null || listBatchID.size()==0) -// Window.alert("Something seems wrong, no selected BatchID, try again"); + // List listBatchID = viewController.getSelectedBatchID(); + // + // if(listBatchID==null || listBatchID.size()==0) + // Window.alert("Something seems wrong, no selected BatchID, try + // again"); SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); - //submitRequestPanel.getElement().addClassName("ext-horizontal-panel"); - String tabTitle = algorithm.getTitle().substring(0,1).toUpperCase()+algorithm.getTitle().toLowerCase().substring(1, algorithm.getTitle().length()); //CAMEL CASE - - //TO MANAGE ALGORITHMS DESCRIPTION + // submitRequestPanel.getElement().addClassName("ext-horizontal-panel"); + String tabTitle = algorithm.getTitle().substring(0, 1).toUpperCase() + + algorithm.getTitle().toLowerCase().substring(1, algorithm.getTitle().length()); // CAMEL + // CASE + + // TO MANAGE ALGORITHMS DESCRIPTION TextResource algDescr = null; - switch(algorithm) { - case BOXPLOT: - algDescr = PerformFishResources.INSTANCE.farm_BOXPLOT(); - break; - case CORRELATION: - algDescr = PerformFishResources.INSTANCE.farm_CORRELATION(); - break; - case DEA_ANALYSIS: - break; - case DEA_CHART: - break; - case PERFORMFISH_SYNOPTIC_TABLE_FARM: - break; - case PERFORMFISH_SYNOPTICTABLE_BATCH: - break; - case SCATTER: - algDescr = PerformFishResources.INSTANCE.farm_SCATTER(); - break; - case SPEEDOMETER: - algDescr = PerformFishResources.INSTANCE.farm_SPEEDOMETER(); - break; + switch (algorithm) { + case BOXPLOT: + algDescr = PerformFishResources.INSTANCE.farm_BOXPLOT(); + break; + case CORRELATION: + algDescr = PerformFishResources.INSTANCE.farm_CORRELATION(); + break; + case DEA_ANALYSIS: + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + break; + case SCATTER: + algDescr = PerformFishResources.INSTANCE.farm_SCATTER(); + break; + case SPEEDOMETER: + algDescr = PerformFishResources.INSTANCE.farm_SPEEDOMETER(); + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + break; + default: + break; } - - String algDesrTxt = algDescr!=null?algDescr.getText():null; - - Tab tab = viewAnnualController.createTab(tabTitle+" #"+(viewAnnualController.currentNumberOfTab()+1),algDesrTxt,submitRequestPanel); + + String algDesrTxt = algDescr != null ? algDescr.getText() : null; + + Tab tab = viewAnnualController.createTab(tabTitle + " #" + (viewAnnualController.currentNumberOfTab() + 1), + algDesrTxt, submitRequestPanel); switch (algorithm) { case BOXPLOT: @@ -599,106 +779,124 @@ public class PerformFishAnnualAnalyticsController { submitRequestPanel.setTotalRequests(inputKPI.size()); for (KPI kpi : inputKPI) { - String title = "KPI: "+kpi.getName(); + String title = "KPI: " + kpi.getName(); HTML toBigTitle = new HTML(title); toBigTitle.getElement().addClassName("to-big-title"); submitRequestPanel.addWidget(toBigTitle); HorizontalPanel hp = new HorizontalPanel(); hp.getElement().addClassName("ext-horizontal-panel"); - - DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse, viewAnnualController.getSelectedYears(), Arrays.asList(kpi), null, algorithm, focusID); + + DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse, + viewAnnualController.getSelectedYears(), Arrays.asList(kpi), null, algorithm, focusID); callDataMinerServiceForChart(dmInputParams, submitRequestPanel, hp, tab); - //resultPanel.add(hp); + // resultPanel.add(hp); submitRequestPanel.addWidget(hp); } break; case SCATTER: - if(inputKPI.get(0)==null || inputKPI.get(1)==null){ - submitRequestPanel.setTheTitle("Sorry, something seems wrong, the selected KPIs are not valid. Please try again"); + if (inputKPI.get(0) == null || inputKPI.get(1) == null) { + submitRequestPanel + .setTheTitle("Sorry, something seems wrong, the selected KPIs are not valid. Please try again"); checkTabSpinner(submitRequestPanel, tab); return; -// Window.alert("Something seems wrong, no selected BatchID, try again"); + // Window.alert("Something seems wrong, no selected BatchID, try + // again"); } - String titleScatter = "KPI: "+inputKPI.get(0).getName() +" vs "+inputKPI.get(1).getName(); + String titleScatter = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName(); submitRequestPanel.setTheTitle(titleScatter); - default:{ - DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse, viewAnnualController.getSelectedYears(), inputKPI, outputKPI, algorithm, focusID); - callDataMinerServiceForChart(dmInputParams, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab); - //callDataMinerServiceForChart(thePerformFishResponse, POPULATION_LEVEL.BATCH, inputKPI, outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab); - } + default: { + DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse, + viewAnnualController.getSelectedYears(), inputKPI, outputKPI, algorithm, focusID); + callDataMinerServiceForChart(dmInputParams, submitRequestPanel, submitRequestPanel.getContainerPanel(), + tab); + // callDataMinerServiceForChart(thePerformFishResponse, + // POPULATION_LEVEL.BATCH, inputKPI, outputKPI, algorithm, focusID, + // submitRequestPanel, submitRequestPanel.getContainerPanel(), tab); + } } } - /** * Call data miner service for chart. * - * @param dmInputParameters the dm input parameters - * @param requestPanel the request panel - * @param panelContainer the panel - * @param tab the tab + * @param dmInputParameters + * the dm input parameters + * @param requestPanel + * the request panel + * @param panelContainer + * the panel + * @param tab + * the tab */ - private void callDataMinerServiceForChart(final DataMinerInputParameters dmInputParameters, final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab) { + private void callDataMinerServiceForChart(final DataMinerInputParameters dmInputParameters, + final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab) { - GWT.log("Building DM request with input parameters: "+dmInputParameters); + GWT.log("Building DM request with input parameters: " + dmInputParameters); StringBuilder dataInputsFormatter = new StringBuilder(); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+ dmInputParameters.getChartType() +";"); - + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + dmInputParameters.getChartType() + ";"); + String yearsValue = ""; for (String year : dmInputParameters.getSelectedYears()) { - yearsValue+=year+"|"; + yearsValue += year + "|"; } - yearsValue = yearsValue.substring(0, yearsValue.length()-1); - - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM+"="+ yearsValue +";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+dmInputParameters.getFocusID()+";"); - //dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;"); + yearsValue = yearsValue.substring(0, yearsValue.length() - 1); - if(dmInputParameters.getInputKPI()!=null && dmInputParameters.getInputKPI().size()>0){ + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM + "=" + yearsValue + ";"); + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=" + dmInputParameters.getFocusID() + ";"); + // dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;"); + + if (dmInputParameters.getInputKPI() != null && dmInputParameters.getInputKPI().size() > 0) { String kpiCodes = ""; for (KPI kpi : dmInputParameters.getInputKPI()) { - kpiCodes+=kpi.getCode()+"|"; + kpiCodes += kpi.getCode() + "|"; } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); - GWT.log("Input KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM+"="+kpiCodes+";"); + GWT.log("Input KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM + "=" + kpiCodes + ";"); } - if(dmInputParameters.getOutputKPI()!=null && dmInputParameters.getOutputKPI().size()>0){ + if (dmInputParameters.getOutputKPI() != null && dmInputParameters.getOutputKPI().size() > 0) { String kpiCodes = ""; for (KPI kpi : dmInputParameters.getOutputKPI()) { - kpiCodes+=kpi.getCode()+"|"; + kpiCodes += kpi.getCode() + "|"; } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); - GWT.log("Output KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM+"="+kpiCodes+";"); + GWT.log("Output KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM + "=" + kpiCodes + ";"); } - + Map performFishResponseMap = dmInputParameters.getPerformFishResponse().getMapParameters(); - - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable); - dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable); - + + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable); + dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable); + String dataInParameters = dataInputsFormatter.toString(); - GWT.log("Calling DM service with client input parameters: "+dataInParameters); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); Map> mapParameters = new HashMap>(); mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); - final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to "+dmInputParameters.getChartType().getTitle()+" Analysis..."); + final LoaderIcon loaderIcon = new LoaderIcon( + "Submitting request to " + dmInputParameters.getChartType().getTitle() + " Analysis..."); loaderIcon.setVisible(true); panelContainer.setVisible(true); panelContainer.add(loaderIcon); @@ -706,61 +904,72 @@ public class PerformFishAnnualAnalyticsController { @Override public void execute() { loaderIcon.setFocus(true); - }}); - - PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualAnalysis(mapParameters, new AsyncCallback() { - - @Override - public void onSuccess(DataMinerResponse dmResponse) { - loaderIcon.setVisible(false); - checkTabSpinner(requestPanel, tab); - //field_unary_algorithm.setVisible(true); - GWT.log("I'm displaying: "+dmResponse); - displayOutputFilesAsStaticEntities(dmResponse, dmInputParameters.getChartType(), dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), dmInputParameters.getFocusID(), panelContainer, false); - } - - @Override - public void onFailure(Throwable caught) { - loaderIcon.setVisible(false); - checkTabSpinner(requestPanel, tab); - displayOutputFilesAsStaticEntities(null, dmInputParameters.getChartType(), dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), dmInputParameters.getFocusID(), panelContainer, true); - } }); + + PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualAnalysis(mapParameters, + new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + loaderIcon.setVisible(false); + checkTabSpinner(requestPanel, tab); + // field_unary_algorithm.setVisible(true); + GWT.log("I'm displaying: " + dmResponse); + displayOutputFilesAsStaticEntities(dmResponse, dmInputParameters.getChartType(), + dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), + dmInputParameters.getFocusID(), panelContainer, false); + } + + @Override + public void onFailure(Throwable caught) { + loaderIcon.setVisible(false); + checkTabSpinner(requestPanel, tab); + displayOutputFilesAsStaticEntities(null, dmInputParameters.getChartType(), + dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), + dmInputParameters.getFocusID(), panelContainer, true); + + } + }); } - - + /** * Append DM input table. * - * @param performFishResponseMap the perform fish response map - * @param dataInputsFormatter the data inputs formatter - * @param table the table + * @param performFishResponseMap + * the perform fish response map + * @param dataInputsFormatter + * the data inputs formatter + * @param table + * the table * @return the string builder */ - private StringBuilder appendDMInputTable(Map performFishResponseMap, StringBuilder dataInputsFormatter, PFSERVICE_TO_DM_MAPPING_TABLE table) { - + private StringBuilder appendDMInputTable(Map performFishResponseMap, + StringBuilder dataInputsFormatter, PFSERVICE_TO_DM_MAPPING_TABLE table) { + String toDMInputTable = performFishResponseMap.get(table.getPerformFishTable()); - - if(toDMInputTable!=null && !toDMInputTable.isEmpty()) { - dataInputsFormatter.append(table.getDataMinerTable()+"="+toDMInputTable+";"); + + if (toDMInputTable != null && !toDMInputTable.isEmpty()) { + dataInputsFormatter.append(table.getDataMinerTable() + "=" + toDMInputTable + ";"); } - + return dataInputsFormatter; } /** * Remove the spinner if all DM responses are returned. * - * @param requestPanel the request panel - * @param tab the tab + * @param requestPanel + * the request panel + * @param tab + * the tab */ - private void checkTabSpinner(SubmitRequestPanel requestPanel, Tab tab){ + private void checkTabSpinner(SubmitRequestPanel requestPanel, Tab tab) { requestPanel.incrementCompletedRequests(); int completed = requestPanel.getCompletedRequests(); int total = requestPanel.getTotalRequests(); - - if(completed>=total) { + + if (completed >= total) { viewAnnualController.noSpinner(tab); } } @@ -768,19 +977,28 @@ public class PerformFishAnnualAnalyticsController { /** * Display output files as static entities. * - * @param dmResponse the dm response - * @param chartType the chart type - * @param inputKPIs the input kp is - * @param outputKPIs the output kp is - * @param focusID the focus id - * @param container the container - * @param displayError the display error + * @param dmResponse + * the dm response + * @param chartType + * the chart type + * @param inputKPIs + * the input kp is + * @param outputKPIs + * the output kp is + * @param focusID + * the focus id + * @param container + * the container + * @param displayError + * the display error */ - private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, final Panel container, boolean displayError){ + private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, + final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, + final Panel container, boolean displayError) { - String title = displayError?"No results ":""; - - if(displayError){ + String title = displayError ? "No results " : ""; + + if (displayError) { Alert alert = new Alert(title); alert.setType(AlertType.ERROR); alert.setClose(false); @@ -788,116 +1006,125 @@ public class PerformFishAnnualAnalyticsController { container.add(alert); return; } - + final String toTitle = title; for (final OutputFile outputFile : dmResponse.getListOutput()) { switch (outputFile.getDataType()) { case IMAGE: - PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, new AsyncCallback() { + PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - //showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - Window.alert(caught.getMessage()); + @Override + public void onFailure(Throwable caught) { + // showAlert(caught.getMessage(), + // AlertType.ERROR, true, + // uib_vp_deanalanlysis_request_container); + Window.alert(caught.getMessage()); - } + } - @Override - public void onSuccess(String base64Content) { + @Override + public void onSuccess(String base64Content) { - String title = toTitle; - switch (chartType) { - case BOXPLOT: - //title = chartType.getName()+" - on all batches
"; - //title += "Blue dots indicate the selected batch(es): "+focusID; - title = chartType.getTitle()+" - on all farm data
"; - title += "Blue dots indicate the selected farm: "+focusID; - - ShowResult showResult = new ShowResult(title); - showResult.showImage(base64Content); - displayingOrderedBoxPlot(dmResponse, title, container, showResult); - return; - case CORRELATION: - break; - case DEA_ANALYSIS: - break; - case SCATTER: - break; - case SPEEDOMETER: - title = chartType.getTitle()+"
"; - title+= "Selected Farm: "+focusID+"
"; - title+= "Normalized with respect to all farm data in the VRE"; - break; - case DEA_CHART: - break; - } + String title = toTitle; + switch (chartType) { + case BOXPLOT: + // title = chartType.getName()+" - on all + // batches
"; + // title += "Blue dots indicate the selected + // batch(es): "+focusID; + title = chartType.getTitle() + " - on all farm data
"; + title += "Blue dots indicate the selected farm: " + focusID; - ShowResult showResult = new ShowResult(title); - showResult.showImage(base64Content); - container.add(showResult); + ShowResult showResult = new ShowResult(title); + showResult.showImage(base64Content); + displayingOrderedBoxPlot(dmResponse, title, container, showResult); + return; + case CORRELATION: + break; + case DEA_ANALYSIS: + break; + case SCATTER: + break; + case SPEEDOMETER: + title = chartType.getTitle() + "
"; + title += "Selected Farm: " + focusID + "
"; + title += "Normalized with respect to all farm data in the VRE"; + break; + case DEA_CHART: + break; + } - } - }); + ShowResult showResult = new ShowResult(title); + showResult.showImage(base64Content); + container.add(showResult); + + } + }); break; case CSV: - PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback() { + PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - //showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - Window.alert(caught.getMessage()); - } - - @Override - public void onSuccess(CSVFile result) { - GWT.log("Displaying: "+result); - String cssTableStyle = "simpletable"; - String title = toTitle; - switch (chartType) { - case BOXPLOT: - if(result.getFileName().contains("_user")){ - title = "My Batch(es)"; - return; - }else{ - title = "All farm data in the VRE (including mine)"; + @Override + public void onFailure(Throwable caught) { + // showAlert(caught.getMessage(), + // AlertType.ERROR, true, + // uib_vp_deanalanlysis_request_container); + Window.alert(caught.getMessage()); } - title+="
"; - title+="Data aggregation is performed by considering farms as base units"; - - ShowResult showResult = new ShowResult(title); - showResult.showCSVFile(result, cssTableStyle); - displayingOrderedBoxPlot(dmResponse, title, container, showResult); - return; - case CORRELATION: - break; - case DEA_ANALYSIS: - break; - case SCATTER: - break; - case SPEEDOMETER: - break; - case DEA_CHART: - break; - case PERFORMFISH_SYNOPTIC_TABLE_FARM: - if(!result.getFileName().contains("legend")) { - cssTableStyle = "synoptictable-farm"; - }else { - cssTableStyle = "simpletable-synoptic"; - } - ShowResult showResultSin = new ShowResult(title); - showResultSin.showCSVFile(result, cssTableStyle); - displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, showResultSin); - - return; - } - ShowResult showResult = new ShowResult(title); - showResult.showCSVFile(result, cssTableStyle); - container.add(showResult); - } - }); + @Override + public void onSuccess(CSVFile result) { + GWT.log("Displaying: " + result); + String cssTableStyle = "simpletable"; + String title = toTitle; + switch (chartType) { + case BOXPLOT: + if (result.getFileName().contains("_user")) { + title = "My Batch(es)"; + return; + } else { + title = "All farm data in the VRE (including mine)"; + } + title += "
"; + title += "Data aggregation is performed by considering farms as base units"; + + ShowResult showResult = new ShowResult(title); + showResult.showCSVFile(result, cssTableStyle); + displayingOrderedBoxPlot(dmResponse, title, container, showResult); + return; + case CORRELATION: + break; + case DEA_ANALYSIS: + break; + case SCATTER: + break; + case SPEEDOMETER: + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + if (!result.getFileName().contains("legend")) { + cssTableStyle = "synoptictable-farm"; + } else { + cssTableStyle = "simpletable-synoptic"; + } + ShowResult showResultSin = new ShowResult(title); + showResultSin.showCSVFile(result, cssTableStyle); + displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, + showResultSin); + + return; + } + + ShowResult showResult = new ShowResult(title); + showResult.showCSVFile(result, cssTableStyle); + container.add(showResult); + } + }); break; default: @@ -907,60 +1134,69 @@ public class PerformFishAnnualAnalyticsController { } } - + /** * Displaying ordered synoptic table. * - * @param dmResponse the dm response - * @param fileName the file name - * @param container the container - * @param showResult the show result + * @param dmResponse + * the dm response + * @param fileName + * the file name + * @param container + * the container + * @param showResult + * the show result */ - private void displayingOrderedSynopticTable(final DataMinerResponse dmResponse, String fileName, final Panel container, ShowResult showResult) { + private void displayingOrderedSynopticTable(final DataMinerResponse dmResponse, String fileName, + final Panel container, ShowResult showResult) { int hashcode = dmResponse.hashCode(); - GWT.log("The hascode is: "+hashcode); + GWT.log("The hascode is: " + hashcode); FlexTable flex = synopticOrderBy.get(hashcode); - - if(flex==null) { + + if (flex == null) { GWT.log("The flextable is null"); flex = new FlexTable(); synopticOrderBy.put(hashcode, flex); container.add(flex); } - - if(fileName.toLowerCase().contains("legend")) { + + if (fileName.toLowerCase().contains("legend")) { flex.setWidget(0, 0, showResult); - }else { - flex.setWidget(flex.getRowCount()+1,0,showResult); + } else { + flex.setWidget(flex.getRowCount() + 1, 0, showResult); } } - - + /** * Displaying ordered box plot. * - * @param dmResponse the dm response - * @param title the title - * @param container the container - * @param showResult the show result + * @param dmResponse + * the dm response + * @param title + * the title + * @param container + * the container + * @param showResult + * the show result */ - private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, ShowResult showResult) { + private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, + ShowResult showResult) { int hashcode = dmResponse.hashCode(); - GWT.log("The hascode is: "+hashcode); + GWT.log("The hascode is: " + hashcode); FlexTable flex = boxPlotOrderBy.get(hashcode); - - if(flex==null) { + + if (flex == null) { GWT.log("The flextable is null"); flex = new FlexTable(); boxPlotOrderBy.put(hashcode, flex); container.add(flex); } - - if(title.startsWith("My")) { + + if (title.startsWith("My")) { flex.setWidget(0, 0, showResult); - }else if (title.startsWith("All")){ + } else if (title.startsWith("All")) { flex.setWidget(0, 1, showResult); - }else { + } else { flex.setWidget(0, 2, showResult); } } 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 b33be92..7fa7828 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 @@ -34,11 +34,11 @@ import org.gcube.portlets.user.performfishanalytics.client.event.SubmitRequestEv import org.gcube.portlets.user.performfishanalytics.client.resources.PerformFishResources; import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.viewbinder.AnalyticsPanelResult; +import org.gcube.portlets.user.performfishanalytics.client.viewbinder.DeaPanelResult; 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.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; -import org.gcube.portlets.user.performfishanalytics.shared.Population; import org.gcube.portlets.user.performfishanalytics.shared.PopulationType; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; import org.gcube.portlets.user.performfishanalytics.shared.dataminer.DataMinerResponse; @@ -65,30 +65,26 @@ import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.VerticalPanel; - -// TODO: Auto-generated Javadoc /** * The Class PerformFishAnalyticsController. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Jan 16, 2019 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 16, 2019 */ public class PerformFishAnalyticsController { /** The Constant eventBus. */ public final static HandlerManager eventBus = new HandlerManager(null); - + /** The view controller. */ private PerformFishAnalyticsViewController viewController; /** The decrypt parameters. */ private PerformFishInitParameter decryptParameters; - - private Map boxPlotOrderBy = new HashMap(); - - private Map synopticOrderBy = new HashMap(); + private Map boxPlotOrderBy = new HashMap(); + + private Map synopticOrderBy = new HashMap(); /** * Instantiates a new perform fish analytics controller. @@ -98,17 +94,17 @@ public class PerformFishAnalyticsController { registerHandlers(); viewController = new PerformFishAnalyticsViewController(); } - + /** * Sets the inits the parmaters. * - * @param result the new inits the parmaters + * @param result + * the new inits the parmaters */ public void setInitParmaters(PerformFishInitParameter result) { this.decryptParameters = result; } - /** * Register handlers. */ @@ -117,16 +113,18 @@ public class PerformFishAnalyticsController { eventBus.addHandler(LoadPopulationTypeEvent.TYPE, new LoadPopulationTypeEventHandler() { @Override - public void onLoadPopulationType( - LoadPopulationTypeEvent loadPopulationEvent) { - - viewController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), decryptParameters); - -// if(loadPopulationEvent.getPopulationName().equals(POPULATION_LEVEL.BATCH.name())) { -// -// }else { -// viewAnnualController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), decryptParameters); -// } + public void onLoadPopulationType(LoadPopulationTypeEvent loadPopulationEvent) { + + viewController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), + decryptParameters); + + // if(loadPopulationEvent.getPopulationName().equals(POPULATION_LEVEL.BATCH.name())) + // { + // + // }else { + // viewAnnualController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), + // decryptParameters); + // } } }); @@ -135,25 +133,29 @@ public class PerformFishAnalyticsController { @Override public void onCall(CallAlgorithmEvent callAlgorithmEvent) { - callAlgorithm(callAlgorithmEvent.getAlgorithm(), callAlgorithmEvent.getFocusID(), callAlgorithmEvent.getInputKPI(), callAlgorithmEvent.getOutputKPI()); + callAlgorithm(callAlgorithmEvent.getAlgorithm(), callAlgorithmEvent.getFocusID(), + callAlgorithmEvent.getInputKPI(), callAlgorithmEvent.getOutputKPI()); } }); eventBus.addHandler(SelectedPopulationTypeEvent.TYPE, new SelectedPopulationTypeEventHandler() { @Override - public void onSelectedPopulationType( - SelectedPopulationTypeEvent selectedPopulationTypeEvent) { + public void onSelectedPopulationType(SelectedPopulationTypeEvent selectedPopulationTypeEvent) { PopulationType opt = selectedPopulationTypeEvent.getSelectedPopulationType(); viewController.setRootPopulationTypeForKPIs(selectedPopulationTypeEvent.getSelectedPopulationType()); - - if (opt.getName().equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_INDIVIDUAL_CLOSED_BATCHES.name()) - || opt.getName().equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_INDIVIDUAL.name()) - || opt.getName().equals(PerformFishAnalyticsConstant.BATCH_LEVEL.HATCHERY_INDIVIDUAL_CLOSED_BATCHES.name()) + + if (opt.getName().equalsIgnoreCase( + PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_INDIVIDUAL_CLOSED_BATCHES.name()) + || opt.getName() + .equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_INDIVIDUAL.name()) + || opt.getName().equals( + PerformFishAnalyticsConstant.BATCH_LEVEL.HATCHERY_INDIVIDUAL_CLOSED_BATCHES.name()) || opt.getName().equals(PerformFishAnalyticsConstant.BATCH_LEVEL.HATCHERY_INDIVIDUAL.name()) || opt.getName().equals(PerformFishAnalyticsConstant.BATCH_LEVEL.PRE_ONGROWING.name()) - || opt.getName().equals(PerformFishAnalyticsConstant.BATCH_LEVEL.PRE_ONGROWING_CLOSED_BATCHES.name())) { + || opt.getName() + .equals(PerformFishAnalyticsConstant.BATCH_LEVEL.PRE_ONGROWING_CLOSED_BATCHES.name())) { viewController.visibleSynopticTable(true); } else { viewController.visibleSynopticTable(false); @@ -166,26 +168,28 @@ public class PerformFishAnalyticsController { @Override public void onSelectedKPI(SelectedKPIEvent selectedKPI) { - viewController.manageKPI(selectedKPI.getKpi(), selectedKPI.isChecked(), selectedKPI.getSelectedPopulationType()); + viewController.manageKPI(selectedKPI.getKpi(), selectedKPI.isChecked(), + selectedKPI.getSelectedPopulationType()); int selectedKPIsSize = viewController.getSelectedKPIs().size(); - //viewController.manageAlgorithmsSubmit(selectedKPIsSize); + // viewController.manageAlgorithmsSubmit(selectedKPIsSize); List batchIds = viewController.getSelectedBatchID(); - if(batchIds==null || batchIds.size()==0) { + if (batchIds == null || batchIds.size() == 0) { viewController.enableAllAlgorithmsForSubmit(false); - }else + } else viewController.manageAlgorithmsSubmit(selectedKPIsSize); } }); - + eventBus.addHandler(LoadBatchesEvent.TYPE, new LoadBatchesEventHandler() { - + @Override public void onLoadBatches(LoadBatchesEvent loadBatchesEvent) { - + viewController.hideErrors(); - + final Map> mapParameters = new HashMap>(); - String farmId = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM); + String farmId = decryptParameters.getParameters() + .get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM); String batchType = viewController.getForm().getBatchType(); String species = viewController.getForm().getSpecies(); List listArea = viewController.getForm().getArea(); @@ -196,13 +200,13 @@ public class PerformFishAnalyticsController { mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM, Arrays.asList(batchType)); mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_SPECIES_ID_PARAM, Arrays.asList(species)); - if(!listArea.isEmpty()){ + if (!listArea.isEmpty()) { mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM, listArea); } - if(!listPeriod.isEmpty()){ + if (!listPeriod.isEmpty()) { mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_PERIOD_PARAM, listPeriod); } - if(!listQuarter.isEmpty()){ + if (!listQuarter.isEmpty()) { mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_QUARTER_PARAM, listQuarter); } @@ -214,46 +218,48 @@ public class PerformFishAnalyticsController { vp.add(loader); loader.show(true); modal.add(vp); - PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters, new AsyncCallback() { + PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - modal.hide(); - Window.alert(caught.getMessage()); - } + @Override + public void onFailure(Throwable caught) { + modal.hide(); + Window.alert(caught.getMessage()); + } - @Override - public void onSuccess(PerformFishResponse performFishResponse) { - modal.hide(); - viewController.managePerformFishServiceResponse(performFishResponse, mapParameters, POPULATION_LEVEL.BATCH); - } - }); + @Override + public void onSuccess(PerformFishResponse performFishResponse) { + modal.hide(); + viewController.managePerformFishServiceResponse(performFishResponse, mapParameters, + POPULATION_LEVEL.BATCH); + } + }); modal.show(); - + } }); - eventBus.addHandler(PerformFishFieldFormChangedEvent.TYPE, new PerformFishFieldFormChangedEventHandler() { @Override - public void onFieldFormChanged( - PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) { + public void onFieldFormChanged(PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) { viewController.setReloadPerformFishServiceData(true); boolean isValidForm = viewController.validatePerformFishInputFields(); - + viewController.resetBatchIdStatus(); - - if(isValidForm) { - //viewController.resetBatchIdStatus(); + + if (isValidForm) { + // viewController.resetBatchIdStatus(); viewController.setBatchIdStatus(ControlGroupType.INFO); viewController.enableLoadBatches(true); viewController.enableSynopticTable(false); - viewController.showAlertForLoadBatches("Please load your batches corresponding to the selected options, by pressing the 'Load Batches' button", AlertType.INFO, false); + viewController.showAlertForLoadBatches( + "Please load your batches corresponding to the selected options, by pressing the 'Load Batches' button", + AlertType.INFO, false); viewController.enableAllAlgorithmsForSubmit(false); - - }else { + + } else { viewController.enableLoadBatches(false); viewController.enableSynopticTable(false); viewController.enableAllAlgorithmsForSubmit(false); @@ -267,20 +273,18 @@ public class PerformFishAnalyticsController { public void onAddedBatchId(AddedBatchIdEvent checkValidBatchIdEvent) { boolean isBatchIdValid = viewController.validateBatchIdSelection(); - if(isBatchIdValid) { + if (isBatchIdValid) { viewController.enableAllAlgorithmsForSubmit(true); viewController.enableSynopticTable(true); - } - else { + } else { viewController.enableAllAlgorithmsForSubmit(false); viewController.enableSynopticTable(false); } - - //viewController.resyncSelectedKPIs(); + + // viewController.resyncSelectedKPIs(); } }); - eventBus.addHandler(SubmitRequestEvent.TYPE, new SubmitRequestEventHandler() { @Override @@ -293,52 +297,68 @@ public class PerformFishAnalyticsController { List selectedKPI = viewController.getSelectedKPIs(); viewController.manageAlgorithmsSubmit(selectedKPI.size()); - if(isValidBatchId && isValidKPI){ + if (isValidBatchId && isValidKPI) { switch (submitRequestEvent.getChartType()) { case BOXPLOT: - //UNARY - callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), selectedKPI, null); + // UNARY + callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), + selectedKPI, null); break; case SCATTER: - if(selectedKPI.size()==2) - callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), selectedKPI, null); + if (selectedKPI.size() == 2) + callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), + selectedKPI, null); else - Window.alert("Something seems wrong... You must select exactly two KPIs to execute the "+submitRequestEvent.getChartType()); + Window.alert("Something seems wrong... You must select exactly two KPIs to execute the " + + submitRequestEvent.getChartType()); break; - case CORRELATION: - callDataMinerServiceForChartTypeCorrelation(viewController.getPerformFishResponse(), viewController.getRequestMapParameters()); + callDataMinerServiceForChartTypeCorrelation(viewController.getPerformFishResponse(), + viewController.getRequestMapParameters()); break; - case SPEEDOMETER: - //UNARY - callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), selectedKPI, selectedKPI); + // UNARY + callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), + selectedKPI, selectedKPI); + break; + case DEA_ANALYSIS: + createTabToSelectIOParametersForDeaAnalysis(viewController.getPerformFishResponse(), + viewController.getRequestMapParameters()); + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + break; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: break; - default: break; } - } return; } }); - + eventBus.addHandler(LoadSynopticTableEvent.TYPE, new LoadSynopticTableEventHandler() { - + @Override public void onLoadSynopticTable(LoadSynopticTableEvent loadSynopticTableEvent) { - + boolean isValidBatchId = viewController.validateBatchIdSelection(); - - if(isValidBatchId) { - callAlgorithmSynopticTableBatch(viewController.getPerformFishResponse(), viewController.getRequestMapParameters()); + + if (isValidBatchId) { + callAlgorithmSynopticTableBatch(viewController.getPerformFishResponse(), + viewController.getRequestMapParameters()); } - + } }); @@ -347,55 +367,68 @@ public class PerformFishAnalyticsController { /** * Call algorithm synoptic table batch. * - * @param performFishResponse the perform fish response - * @param performFishRequestParameters the perform fish request parameters + * @param performFishResponse + * the perform fish response + * @param performFishRequestParameters + * the perform fish request parameters */ - private void callAlgorithmSynopticTableBatch(final PerformFishResponse performFishResponse, final Map> performFishRequestParameters) { - GWT.log("Read perform fish response: "+performFishResponse); + private void callAlgorithmSynopticTableBatch(final PerformFishResponse performFishResponse, + final Map> performFishRequestParameters) { + GWT.log("Read perform fish response: " + performFishResponse); String batchTableURL = performFishResponse.getMapParameters().get(PerformFishAnalyticsConstant.BATCHES_TABLE); - - if(batchTableURL==null || batchTableURL.isEmpty()) - Window.alert("Something seems wrong. No batches tables matching with parameter "+PerformFishAnalyticsConstant.BATCHES_TABLE+" returned from service"); - + + if (batchTableURL == null || batchTableURL.isEmpty()) + Window.alert("Something seems wrong. No batches tables matching with parameter " + + PerformFishAnalyticsConstant.BATCHES_TABLE + " returned from service"); + final Map> mapParameters = new HashMap>(); StringBuilder dataInputsFormatter = new StringBuilder(); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_TABLE+"="+ batchTableURL +";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_TABLE + "=" + batchTableURL + ";"); - //TODO READ THE INPUT FILE + // READ THE INPUT FILE String popType = viewController.getForm().getBatchType(); - + DataMinerAlgorithms chartType = null; - if(popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_INDIVIDUAL_CLOSED_BATCHES.name()) + if (popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_INDIVIDUAL_CLOSED_BATCHES.name()) || popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_INDIVIDUAL.name())) { chartType = DataMinerAlgorithms.PERFORMFISH_SYNOPTICTABLE_BATCH; - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_QUARTER_LABELS+"="+PerformFishAnalyticsConstant.DM_VALUE_ALL+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ZONE_LABELS+"="+PerformFishAnalyticsConstant.DM_VALUE_ALL+";"); - }else if(popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.HATCHERY_INDIVIDUAL_CLOSED_BATCHES.name()) + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_QUARTER_LABELS + "=" + + PerformFishAnalyticsConstant.DM_VALUE_ALL + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ZONE_LABELS + "=" + + PerformFishAnalyticsConstant.DM_VALUE_ALL + ";"); + } else if (popType + .equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.HATCHERY_INDIVIDUAL_CLOSED_BATCHES.name()) || popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.HATCHERY_INDIVIDUAL.name())) { chartType = DataMinerAlgorithms.PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY; - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_STOCKING_PERIOD+"="+PerformFishAnalyticsConstant.DM_VALUE_ALL+";"); - }else if(popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.PRE_ONGROWING.name()) - || popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.PRE_ONGROWING_CLOSED_BATCHES.name())) { + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_STOCKING_PERIOD + "=" + + PerformFishAnalyticsConstant.DM_VALUE_ALL + ";"); + } else if (popType.equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.PRE_ONGROWING.name()) || popType + .equalsIgnoreCase(PerformFishAnalyticsConstant.BATCH_LEVEL.PRE_ONGROWING_CLOSED_BATCHES.name())) { chartType = DataMinerAlgorithms.PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW; - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ZONE_LABELS+"="+PerformFishAnalyticsConstant.DM_VALUE_ALL+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_STOCKING_PERIOD+"="+PerformFishAnalyticsConstant.DM_VALUE_ALL+";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ZONE_LABELS + "=" + + PerformFishAnalyticsConstant.DM_VALUE_ALL + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_STOCKING_PERIOD + "=" + + PerformFishAnalyticsConstant.DM_VALUE_ALL + ";"); } - + String dataInParameters = dataInputsFormatter.toString(); mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); - mapParameters.put("Identifier", Arrays.asList("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers."+chartType)); - - GWT.log("Calling DM service with client input parameters: "+mapParameters); - + mapParameters.put("Identifier", Arrays.asList( + "org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers." + chartType)); + + GWT.log("Calling DM service with client input parameters: " + mapParameters); + final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); - //submitRequestPanel.getElement().addClassName("ext-horizontal-panel"); - String tabTitle = "Synoptic Table"; //CAMEL CASE - final Tab tab = viewController.createTab(tabTitle+" #"+(viewController.currentNumberOfTab()+1), PerformFishResources.INSTANCE.synopticTable().getText(), submitRequestPanel); + // submitRequestPanel.getElement().addClassName("ext-horizontal-panel"); + String tabTitle = "Synoptic Table"; // CAMEL CASE + final Tab tab = viewController.createTab(tabTitle + " #" + (viewController.currentNumberOfTab() + 1), + PerformFishResources.INSTANCE.synopticTable().getText(), submitRequestPanel); final HTMLPanel panelContainer = submitRequestPanel.getContainerPanel(); - final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to "+DataMinerAlgorithms.PERFORMFISH_SYNOPTICTABLE_BATCH.getTitle()+"..."); + final LoaderIcon loaderIcon = new LoaderIcon( + "Submitting request to " + DataMinerAlgorithms.PERFORMFISH_SYNOPTICTABLE_BATCH.getTitle() + "..."); loaderIcon.setVisible(true); panelContainer.setVisible(true); panelContainer.add(loaderIcon); @@ -403,272 +436,391 @@ public class PerformFishAnalyticsController { @Override public void execute() { loaderIcon.setFocus(true); - }}); - - final DataMinerAlgorithms toFinalChartType = chartType; - PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticTable(performFishResponse, mapParameters, new AsyncCallback() { - - @Override - public void onSuccess(DataMinerResponse dmResponse) { - loaderIcon.setVisible(false); - checkTabSpinner(submitRequestPanel, tab); - //field_unary_algorithm.setVisible(true); - GWT.log("I'm displaying: "+dmResponse); - displayOutputFilesAsStaticEntities(dmResponse, toFinalChartType, null, null, null, panelContainer, false); - } - - @Override - public void onFailure(Throwable caught) { - loaderIcon.setVisible(false); - checkTabSpinner(submitRequestPanel, tab); - displayOutputFilesAsStaticEntities(null, toFinalChartType, null, null, null, panelContainer, true); - } }); + final DataMinerAlgorithms toFinalChartType = chartType; + PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticTable(performFishResponse, + mapParameters, new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + loaderIcon.setVisible(false); + checkTabSpinner(submitRequestPanel, tab); + // field_unary_algorithm.setVisible(true); + GWT.log("I'm displaying: " + dmResponse); + displayOutputFilesAsStaticEntities(dmResponse, toFinalChartType, null, null, null, + panelContainer, false); + } + + @Override + public void onFailure(Throwable caught) { + loaderIcon.setVisible(false); + checkTabSpinner(submitRequestPanel, tab); + displayOutputFilesAsStaticEntities(null, toFinalChartType, null, null, null, panelContainer, + true); + + } + }); + } - /** - * Call data miner service for chart type correlation. - * - * @param performFishResponse the perform fish response - * @param performFishRequestParameters the perform fish request parameters - */ - private void callDataMinerServiceForChartTypeCorrelation(final PerformFishResponse performFishResponse, final Map> performFishRequestParameters) { + // + private void createTabToSelectIOParametersForDeaAnalysis(final PerformFishResponse performFishResponse, + final Map> performFishRequestParameters) { - GWT.log("Read perform fish response: "+performFishResponse); + GWT.log("Read perform fish response: " + performFishResponse); String batchTableURL = performFishResponse.getMapParameters().get(PerformFishAnalyticsConstant.BATCHES_TABLE); - if(batchTableURL==null || batchTableURL.isEmpty()) - Window.alert("Something seems wrong. No batches tables matching with parameter "+PerformFishAnalyticsConstant.BATCHES_TABLE+" returned from service"); + if (batchTableURL == null || batchTableURL.isEmpty()) + Window.alert("Something seems wrong. No batches tables matching with parameter " + + PerformFishAnalyticsConstant.BATCHES_TABLE + " returned from service"); final Map> mapParameters = new HashMap>(); StringBuilder dataInputsFormatter = new StringBuilder(); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM+"=BATCH;"); + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM + "=" + viewController.getForm().getLevel() + ";"); String theBatchType = viewController.getForm().getBatchType(); - theBatchType = theBatchType.replace("_CLOSED_BATCHES", ""); //REMOVING SUFFIX _CLOSED_BATCHES FOR DATAMINER CALL - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM+"="+theBatchType+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+ DataMinerAlgorithms.CORRELATION+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM+"="+batchTableURL+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;"); + theBatchType = theBatchType.replace("_CLOSED_BATCHES", ""); // REMOVING + // SUFFIX + // _CLOSED_BATCHES + // FOR + // DATAMINER + // CALL + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM + "=" + theBatchType + ";"); + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + DataMinerAlgorithms.CORRELATION + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM + "=" + batchTableURL + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=ID;"); String kpiCodes = ""; for (KPI kpi : viewController.getSelectedKPIs()) { - kpiCodes+=kpi.getCode()+"|"; + kpiCodes += kpi.getCode() + "|"; } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); - dataInputsFormatter.append("inputKPI="+kpiCodes+";"); - //dataInputsFormatter.append("outputKPI=;"); + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + dataInputsFormatter.append("inputKPI=" + kpiCodes + ";"); + // dataInputsFormatter.append("outputKPI=;"); String dataInParameters = dataInputsFormatter.toString(); - GWT.log("Calling DM service with client input parameters: "+dataInParameters); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); - submitRequestPanel.showLoader(true, "Submitting "+DataMinerAlgorithms.CORRELATION.getName()+" request to DM Service..."); - String tabTitle = DataMinerAlgorithms.CORRELATION.getName().substring(0,1).toUpperCase()+DataMinerAlgorithms.CORRELATION.getName().toLowerCase().substring(1, DataMinerAlgorithms.CORRELATION.getName().length()); //CAMEL CASE - final Tab tab = viewController.createTab(tabTitle+" #"+(viewController.currentNumberOfTab()+1),PerformFishResources.INSTANCE.batch_CORRELATION().getText(),submitRequestPanel); - + submitRequestPanel.showLoader(false, null); + final Tab tab = viewController.createTab("Dea #" + (viewController.currentNumberOfTab() + 1), + PerformFishResources.INSTANCE.batch_DEAANALYSIS().getText(), submitRequestPanel); + viewController.noSpinner(tab); final List selectedKPI = new ArrayList(viewController.getSelectedKPIs()); final List batchIDs = new ArrayList(viewController.getListBatchesID()); - PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishCorrelationAnalysis(performFishResponse, mapParameters, new AsyncCallback() { - @Override - public void onSuccess(DataMinerResponse dmResponse) { - submitRequestPanel.showLoader(false, null); - checkTabSpinner(submitRequestPanel, tab); - AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult(); - analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); - analyticsPanelResult.addSelectedKPIs(selectedKPI); - analyticsPanelResult.addListFocusIds(batchIDs); - analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, viewController.getForm().getBatchType()); - analyticsPanelResult.addResults(dmResponse); - submitRequestPanel.addWidget(analyticsPanelResult); - //viewController.geTabPanelView().addResult(resultPanel, "Analysis #"+(viewController.geTabPanelView().countTab()+1)); - //modal.hide(); - } - - @Override - public void onFailure(Throwable caught) { - GWT.log(caught.toString()); - submitRequestPanel.showLoader(false, null); - checkTabSpinner(submitRequestPanel, tab); - try { - AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult(); - analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); - analyticsPanelResult.addSelectedKPIs(selectedKPI); - analyticsPanelResult.addListFocusIds(batchIDs); - analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, viewController.getForm().getBatchType()); - submitRequestPanel.addWidget(analyticsPanelResult); - }catch (Exception e) { - // TODO: handle exception - } - - Alert error = new Alert(caught.getMessage()); - error.setClose(false); - error.setType(AlertType.ERROR); - submitRequestPanel.addWidget(error); - } - }); + DeaPanelResult deaPanelResult = new DeaPanelResult(); + deaPanelResult.addSelectedKPIs(selectedKPI); + deaPanelResult.addListFocusIds(batchIDs); + deaPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, + viewController.getForm().getBatchType()); + submitRequestPanel.addWidget(deaPanelResult); } + /** + * Call data miner service for chart type correlation. + * + * @param performFishResponse + * the perform fish response + * @param performFishRequestParameters + * the perform fish request parameters + */ + private void callDataMinerServiceForChartTypeCorrelation(final PerformFishResponse performFishResponse, + final Map> performFishRequestParameters) { + + GWT.log("Read perform fish response: " + performFishResponse); + + String batchTableURL = performFishResponse.getMapParameters().get(PerformFishAnalyticsConstant.BATCHES_TABLE); + + if (batchTableURL == null || batchTableURL.isEmpty()) + Window.alert("Something seems wrong. No batches tables matching with parameter " + + PerformFishAnalyticsConstant.BATCHES_TABLE + " returned from service"); + + final Map> mapParameters = new HashMap>(); + + StringBuilder dataInputsFormatter = new StringBuilder(); + + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM + "=BATCH;"); + String theBatchType = viewController.getForm().getBatchType(); + theBatchType = theBatchType.replace("_CLOSED_BATCHES", ""); // REMOVING + // SUFFIX + // _CLOSED_BATCHES + // FOR + // DATAMINER + // CALL + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM + "=" + theBatchType + ";"); + dataInputsFormatter + .append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + DataMinerAlgorithms.CORRELATION + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM + "=" + batchTableURL + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=ID;"); + + String kpiCodes = ""; + for (KPI kpi : viewController.getSelectedKPIs()) { + kpiCodes += kpi.getCode() + "|"; + } + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + dataInputsFormatter.append("inputKPI=" + kpiCodes + ";"); + // dataInputsFormatter.append("outputKPI=;"); + + String dataInParameters = dataInputsFormatter.toString(); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); + + mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); + + final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); + submitRequestPanel.showLoader(true, + "Submitting " + DataMinerAlgorithms.CORRELATION.getName() + " request to DM Service..."); + String tabTitle = DataMinerAlgorithms.CORRELATION.getName().substring(0, 1).toUpperCase() + + DataMinerAlgorithms.CORRELATION.getName().toLowerCase().substring(1, + DataMinerAlgorithms.CORRELATION.getName().length()); // CAMEL + // CASE + final Tab tab = viewController.createTab(tabTitle + " #" + (viewController.currentNumberOfTab() + 1), + PerformFishResources.INSTANCE.batch_CORRELATION().getText(), submitRequestPanel); + + final List selectedKPI = new ArrayList(viewController.getSelectedKPIs()); + final List batchIDs = new ArrayList(viewController.getListBatchesID()); + PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishCorrelationAnalysis( + performFishResponse, mapParameters, new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + submitRequestPanel.showLoader(false, null); + checkTabSpinner(submitRequestPanel, tab); + AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult(); + analyticsPanelResult.addSelectedAreas( + performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); + analyticsPanelResult.addSelectedKPIs(selectedKPI); + analyticsPanelResult.addListFocusIds(batchIDs); + analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, + viewController.getForm().getBatchType()); + analyticsPanelResult.addResults(dmResponse); + submitRequestPanel.addWidget(analyticsPanelResult); + // viewController.geTabPanelView().addResult(resultPanel, + // "Analysis + // #"+(viewController.geTabPanelView().countTab()+1)); + // modal.hide(); + } + + @Override + public void onFailure(Throwable caught) { + GWT.log(caught.toString()); + submitRequestPanel.showLoader(false, null); + checkTabSpinner(submitRequestPanel, tab); + try { + AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult(); + analyticsPanelResult.addSelectedAreas(performFishRequestParameters + .get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM)); + analyticsPanelResult.addSelectedKPIs(selectedKPI); + analyticsPanelResult.addListFocusIds(batchIDs); + analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, + viewController.getForm().getBatchType()); + submitRequestPanel.addWidget(analyticsPanelResult); + } catch (Exception e) { + GWT.log("Error in AnalyticsPanelResult: " + e.getLocalizedMessage(), e); + } + + Alert error = new Alert(caught.getMessage()); + error.setClose(false); + error.setType(AlertType.ERROR); + submitRequestPanel.addWidget(error); + } + }); + } /** * Creating new TAB and calling DM algorithm. * - * @param algorithm the algorithm - * @param focusID the focus id - * @param inputKPI the input kpi - * @param outputKPI the output kpi + * @param algorithm + * the algorithm + * @param focusID + * the focus id + * @param inputKPI + * the input kpi + * @param outputKPI + * the output kpi */ - private void callAlgorithm(DataMinerAlgorithms algorithm, String focusID, List inputKPI, final List outputKPI){ + private void callAlgorithm(DataMinerAlgorithms algorithm, String focusID, List inputKPI, + final List outputKPI) { List listBatchID = viewController.getSelectedBatchID(); - if(listBatchID==null || listBatchID.size()==0) + if (listBatchID == null || listBatchID.size() == 0) Window.alert("Something seems wrong, no selected BatchID, try again"); - final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); - - //submitRequestPanel.getElement().addClassName("ext-horizontal-panel"); - String tabTitle = algorithm.getTitle().substring(0,1).toUpperCase()+algorithm.getTitle().toLowerCase().substring(1, algorithm.getTitle().length()); //CAMEL CASE - - //TO MANAGE ALGORITHMS DESCRIPTION + // submitRequestPanel.getElement().addClassName("ext-horizontal-panel"); + String tabTitle = algorithm.getTitle().substring(0, 1).toUpperCase() + + algorithm.getTitle().toLowerCase().substring(1, algorithm.getTitle().length()); // CAMEL + // CASE + + // TO MANAGE ALGORITHMS DESCRIPTION TextResource algDescr = null; - switch(algorithm) { - case BOXPLOT: - algDescr = PerformFishResources.INSTANCE.batch_BOXPLOT(); - break; - case CORRELATION: - algDescr = PerformFishResources.INSTANCE.batch_CORRELATION(); - break; - case DEA_ANALYSIS: - break; - case DEA_CHART: - break; - case PERFORMFISH_SYNOPTIC_TABLE_FARM: - break; - case PERFORMFISH_SYNOPTICTABLE_BATCH: - break; - case SCATTER: - algDescr = PerformFishResources.INSTANCE.batch_SCATTER(); - break; - case SPEEDOMETER: - algDescr = PerformFishResources.INSTANCE.batch_SPEEDOMETER(); - break; + switch (algorithm) { + case BOXPLOT: + algDescr = PerformFishResources.INSTANCE.batch_BOXPLOT(); + break; + case CORRELATION: + algDescr = PerformFishResources.INSTANCE.batch_CORRELATION(); + break; + case DEA_ANALYSIS: + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + break; + case SCATTER: + algDescr = PerformFishResources.INSTANCE.batch_SCATTER(); + break; + case SPEEDOMETER: + algDescr = PerformFishResources.INSTANCE.batch_SPEEDOMETER(); + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + break; + default: + break; } - - String algDesrTxt = algDescr!=null?algDescr.getText():null; - Tab tab = viewController.createTab(tabTitle+" #"+(viewController.currentNumberOfTab()+1), algDesrTxt, submitRequestPanel); - + + String algDesrTxt = algDescr != null ? algDescr.getText() : null; + final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); + Tab tab = viewController.createTab(tabTitle + " #" + (viewController.currentNumberOfTab() + 1), algDesrTxt, + submitRequestPanel); + switch (algorithm) { case BOXPLOT: case SPEEDOMETER: submitRequestPanel.setTotalRequests(inputKPI.size()); for (KPI kpi : inputKPI) { - String title = "KPI: "+kpi.getName(); + String title = "KPI: " + kpi.getName(); HTML toBigTitle = new HTML(title); toBigTitle.getElement().addClassName("to-big-title"); submitRequestPanel.addWidget(toBigTitle); HorizontalPanel hp = new HorizontalPanel(); hp.getElement().addClassName("ext-horizontal-panel"); - callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, Arrays.asList(kpi), Arrays.asList(kpi), algorithm, focusID, submitRequestPanel, hp, tab); - //resultPanel.add(hp); + callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, + Arrays.asList(kpi), Arrays.asList(kpi), algorithm, focusID, submitRequestPanel, hp, tab); + // resultPanel.add(hp); submitRequestPanel.addWidget(hp); } break; case SCATTER: - if(inputKPI.get(0)==null || inputKPI.get(1)==null){ - submitRequestPanel.setTheTitle("Sorry, something seems wrong, the selected KPIs are not valid. Please try again"); + if (inputKPI.get(0) == null || inputKPI.get(1) == null) { + submitRequestPanel + .setTheTitle("Sorry, something seems wrong, the selected KPIs are not valid. Please try again"); checkTabSpinner(submitRequestPanel, tab); return; -// Window.alert("Something seems wrong, no selected BatchID, try again"); + // Window.alert("Something seems wrong, no selected BatchID, try + // again"); } - String titleScatter = "KPI: "+inputKPI.get(0).getName() +" vs "+inputKPI.get(1).getName(); + String titleScatter = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName(); submitRequestPanel.setTheTitle(titleScatter); default: - callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, inputKPI, outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab); + callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, inputKPI, + outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab); } } - /** * Call data miner service for chart. * - * @param performFishResponse the perform fish response - * @param scalePValue the scale p value - * @param inputKPI the input kpi - * @param outputKPI the output kpi - * @param chartType the chart type - * @param focusID the focus id - * @param requestPanel the request panel - * @param panelContainer the panel - * @param tab the tab + * @param performFishResponse + * the perform fish response + * @param scalePValue + * the scale p value + * @param inputKPI + * the input kpi + * @param outputKPI + * the output kpi + * @param chartType + * the chart type + * @param focusID + * the focus id + * @param requestPanel + * the request panel + * @param panelContainer + * the panel + * @param tab + * the tab */ - private void callDataMinerServiceForChart(PerformFishResponse performFishResponse, POPULATION_LEVEL scalePValue, final List inputKPI, final List outputKPI, final DataMinerAlgorithms chartType, final String focusID, final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab) { + private void callDataMinerServiceForChart(PerformFishResponse performFishResponse, POPULATION_LEVEL scalePValue, + final List inputKPI, final List outputKPI, final DataMinerAlgorithms chartType, + final String focusID, final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, + final Tab tab) { - GWT.log("Read perform fish response: "+performFishResponse); + GWT.log("Read perform fish response: " + performFishResponse); String batchTableURL = performFishResponse.getMapParameters().get(PerformFishAnalyticsConstant.BATCHES_TABLE); - if(batchTableURL==null || batchTableURL.isEmpty()) - Window.alert("Something seems wrong. No batches tables matching with parameter "+PerformFishAnalyticsConstant.BATCHES_TABLE+" returned from service"); - + if (batchTableURL == null || batchTableURL.isEmpty()) + Window.alert("Something seems wrong. No batches tables matching with parameter " + + PerformFishAnalyticsConstant.BATCHES_TABLE + " returned from service"); StringBuilder dataInputsFormatter = new StringBuilder(); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM+"="+scalePValue.name()+";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM + "=" + scalePValue.name() + ";"); String theBatchType = viewController.getForm().getBatchType(); - theBatchType = theBatchType.replace("_CLOSED_BATCHES", ""); //REMOVING SUFFIX _CLOSED_BATCHES FOR DATAMINER CALL - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM+"="+theBatchType+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+ chartType +";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM+"="+batchTableURL+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+focusID+";"); - //dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;"); + theBatchType = theBatchType.replace("_CLOSED_BATCHES", ""); // REMOVING + // SUFFIX + // _CLOSED_BATCHES + // FOR + // DATAMINER + // CALL + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM + "=" + theBatchType + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + chartType + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM + "=" + batchTableURL + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=" + focusID + ";"); + // dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;"); - if(inputKPI!=null && inputKPI.size()>0){ + if (inputKPI != null && inputKPI.size() > 0) { String kpiCodes = ""; for (KPI kpi : inputKPI) { - kpiCodes+=kpi.getCode()+"|"; + kpiCodes += kpi.getCode() + "|"; } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); - GWT.log("Input KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM+"="+kpiCodes+";"); + GWT.log("Input KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM + "=" + kpiCodes + ";"); } - if(outputKPI!=null && outputKPI.size()>0){ + if (outputKPI != null && outputKPI.size() > 0) { String kpiCodes = ""; for (KPI kpi : outputKPI) { - kpiCodes+=kpi.getCode()+"|"; + kpiCodes += kpi.getCode() + "|"; } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); - GWT.log("Output KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM+"="+kpiCodes+";"); + GWT.log("Output KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM + "=" + kpiCodes + ";"); } String dataInParameters = dataInputsFormatter.toString(); - GWT.log("Calling DM service with client input parameters: "+dataInParameters); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); Map> mapParameters = new HashMap>(); mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); - final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to "+chartType.getTitle()+" Analysis..."); + final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to " + chartType.getTitle() + " Analysis..."); loaderIcon.setVisible(true); panelContainer.setVisible(true); panelContainer.add(loaderIcon); @@ -676,41 +828,47 @@ public class PerformFishAnalyticsController { @Override public void execute() { loaderIcon.setFocus(true); - }}); - - PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters, new AsyncCallback() { - - @Override - public void onSuccess(DataMinerResponse dmResponse) { - loaderIcon.setVisible(false); - checkTabSpinner(requestPanel, tab); - //field_unary_algorithm.setVisible(true); - GWT.log("I'm displaying: "+dmResponse); - displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panelContainer, false); - } - - @Override - public void onFailure(Throwable caught) { - loaderIcon.setVisible(false); - checkTabSpinner(requestPanel, tab); - displayOutputFilesAsStaticEntities(null, chartType, inputKPI, outputKPI, focusID, panelContainer, true); - } }); + + PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters, + new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + loaderIcon.setVisible(false); + checkTabSpinner(requestPanel, tab); + // field_unary_algorithm.setVisible(true); + GWT.log("I'm displaying: " + dmResponse); + displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, + panelContainer, false); + } + + @Override + public void onFailure(Throwable caught) { + loaderIcon.setVisible(false); + checkTabSpinner(requestPanel, tab); + displayOutputFilesAsStaticEntities(null, chartType, inputKPI, outputKPI, focusID, + panelContainer, true); + + } + }); } /** * Remove the spinner if all DM responses are returned. * - * @param requestPanel the request panel - * @param tab the tab + * @param requestPanel + * the request panel + * @param tab + * the tab */ - private void checkTabSpinner(SubmitRequestPanel requestPanel, Tab tab){ + private void checkTabSpinner(SubmitRequestPanel requestPanel, Tab tab) { requestPanel.incrementCompletedRequests(); int completed = requestPanel.getCompletedRequests(); int total = requestPanel.getTotalRequests(); - - if(completed>=total) { + + if (completed >= total) { viewController.noSpinner(tab); } } @@ -718,19 +876,28 @@ public class PerformFishAnalyticsController { /** * Display output files as static entities. * - * @param dmResponse the dm response - * @param chartType the chart type - * @param inputKPIs the input kp is - * @param outputKPIs the output kp is - * @param focusID the focus id - * @param container the container - * @param displayError the display error + * @param dmResponse + * the dm response + * @param chartType + * the chart type + * @param inputKPIs + * the input kp is + * @param outputKPIs + * the output kp is + * @param focusID + * the focus id + * @param container + * the container + * @param displayError + * the display error */ - private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, final Panel container, boolean displayError){ + private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, + final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, + final Panel container, boolean displayError) { - String title = displayError?"No results ":""; - - if(displayError){ + String title = displayError ? "No results " : ""; + + if (displayError) { Alert alert = new Alert(title); alert.setType(AlertType.ERROR); alert.setClose(false); @@ -745,119 +912,133 @@ public class PerformFishAnalyticsController { switch (outputFile.getDataType()) { case IMAGE: - PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, new AsyncCallback() { + PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - //showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - Window.alert(caught.getMessage()); + @Override + public void onFailure(Throwable caught) { + // showAlert(caught.getMessage(), + // AlertType.ERROR, true, + // uib_vp_deanalanlysis_request_container); + Window.alert(caught.getMessage()); - } + } - @Override - public void onSuccess(String base64Content) { + @Override + public void onSuccess(String base64Content) { - String title = toTitle; - switch (chartType) { - case BOXPLOT: - title = chartType.getName()+" - on all batches
"; - title += "Blue dots indicate the selected batch(es): "+focusID; - - ShowResult showResult = new ShowResult(title); - showResult.showImage(base64Content); - displayingOrderedBoxPlot(dmResponse, title, container, showResult); - return; - case CORRELATION: - break; - case DEA_ANALYSIS: - break; - case SCATTER: - break; - case SPEEDOMETER: - title = chartType.getTitle()+"
"; - title+= "Selected BATCH ID: "+focusID+"
"; - title+= "Normalized with respect to all batches in the VRE"; - break; - case DEA_CHART: - break; - case PERFORMFISH_SYNOPTICTABLE_BATCH: - case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: - case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: - break; - } + String title = toTitle; + switch (chartType) { + case BOXPLOT: + title = chartType.getName() + " - on all batches
"; + title += "Blue dots indicate the selected batch(es): " + focusID; - ShowResult showResult = new ShowResult(title); - showResult.showImage(base64Content); - container.add(showResult); + ShowResult showResult = new ShowResult(title); + showResult.showImage(base64Content); + displayingOrderedBoxPlot(dmResponse, title, container, showResult); + return; + case CORRELATION: + break; + case DEA_ANALYSIS: + break; + case SCATTER: + break; + case SPEEDOMETER: + title = chartType.getTitle() + "
"; + title += "Selected BATCH ID: " + focusID + "
"; + title += "Normalized with respect to all batches in the VRE"; + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + break; + default: + break; + } - } - }); + ShowResult showResult = new ShowResult(title); + showResult.showImage(base64Content); + container.add(showResult); + + } + }); break; case CSV: - PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback() { + PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - //showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - Window.alert(caught.getMessage()); - } - - @Override - public void onSuccess(CSVFile result) { - GWT.log("Displaying: "+result); - - String cssTableStyle = "simpletable"; - - String title = toTitle; - switch (chartType) { - case BOXPLOT: - - if(result.getFileName().contains("_user")){ - title = "My Batch(es)"; - }else{ - title = "All batches in the VRE (including mine)"; + @Override + public void onFailure(Throwable caught) { + // showAlert(caught.getMessage(), + // AlertType.ERROR, true, + // uib_vp_deanalanlysis_request_container); + Window.alert(caught.getMessage()); } - title+="
"; - title+="Data aggregation is performed by considering batches as base units"; - - ShowResult showResult = new ShowResult(title); - showResult.showCSVFile(result, cssTableStyle); - displayingOrderedBoxPlot(dmResponse, title, container, showResult); - - return; - - case CORRELATION: - break; - case DEA_ANALYSIS: - break; - case SCATTER: - break; - case SPEEDOMETER: - break; - case DEA_CHART: - break; - case PERFORMFISH_SYNOPTICTABLE_BATCH: - case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: - case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: - - if(!result.getFileName().contains("legend")) { - cssTableStyle = "synoptictable-batch"; - }else { - cssTableStyle = "simpletable-synoptic"; + + @Override + public void onSuccess(CSVFile result) { + GWT.log("Displaying: " + result); + + String cssTableStyle = "simpletable"; + + String title = toTitle; + switch (chartType) { + case BOXPLOT: + + if (result.getFileName().contains("_user")) { + title = "My Batch(es)"; + } else { + title = "All batches in the VRE (including mine)"; + } + title += "
"; + title += "Data aggregation is performed by considering batches as base units"; + + ShowResult showResult = new ShowResult(title); + showResult.showCSVFile(result, cssTableStyle); + displayingOrderedBoxPlot(dmResponse, title, container, showResult); + + return; + + case CORRELATION: + break; + case DEA_ANALYSIS: + break; + case SCATTER: + break; + case SPEEDOMETER: + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + + if (!result.getFileName().contains("legend")) { + cssTableStyle = "synoptictable-batch"; + } else { + cssTableStyle = "simpletable-synoptic"; + } + + ShowResult showResultSin = new ShowResult(title); + showResultSin.showCSVFile(result, cssTableStyle); + displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, + showResultSin); + + return; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + break; + default: + break; + } + // ALL OTHER CASES + ShowResult showResult = new ShowResult(title); + showResult.showCSVFile(result, cssTableStyle); + container.add(showResult); } - - ShowResult showResultSin = new ShowResult(title); - showResultSin.showCSVFile(result, cssTableStyle); - displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, showResultSin); - - return; - } - //ALL OTHER CASES - ShowResult showResult = new ShowResult(title); - showResult.showCSVFile(result, cssTableStyle); - container.add(showResult); - } - }); + }); break; default: @@ -867,44 +1048,46 @@ public class PerformFishAnalyticsController { } } - - private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, ShowResult showResult) { + + private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, + ShowResult showResult) { int hashcode = dmResponse.hashCode(); - GWT.log("The hascode is: "+hashcode); + GWT.log("The hascode is: " + hashcode); FlexTable flex = boxPlotOrderBy.get(hashcode); - - if(flex==null) { + + if (flex == null) { GWT.log("The flextable is null"); flex = new FlexTable(); boxPlotOrderBy.put(hashcode, flex); container.add(flex); } - - if(title.startsWith("My")) { + + if (title.startsWith("My")) { flex.setWidget(0, 0, showResult); - }else if (title.startsWith("All")){ + } else if (title.startsWith("All")) { flex.setWidget(0, 1, showResult); - }else { + } else { flex.setWidget(0, 2, showResult); } } - - private void displayingOrderedSynopticTable(final DataMinerResponse dmResponse, String fileName, final Panel container, ShowResult showResult) { + + private void displayingOrderedSynopticTable(final DataMinerResponse dmResponse, String fileName, + final Panel container, ShowResult showResult) { int hashcode = dmResponse.hashCode(); - GWT.log("The hascode is: "+hashcode); + GWT.log("The hascode is: " + hashcode); FlexTable flex = synopticOrderBy.get(hashcode); - - if(flex==null) { + + if (flex == null) { GWT.log("The flextable is null"); flex = new FlexTable(); synopticOrderBy.put(hashcode, flex); container.add(flex); } - - if(fileName.toLowerCase().contains("legend")) { + + if (fileName.toLowerCase().contains("legend")) { flex.setWidget(0, 0, showResult); - }else { - flex.setWidget(flex.getRowCount()+1,0,showResult); + } else { + flex.setWidget(flex.getRowCount() + 1, 0, showResult); } } } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Batch_DEAANALYSIS b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Batch_DEAANALYSIS new file mode 100644 index 0000000..092aa6a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Batch_DEAANALYSIS @@ -0,0 +1,5 @@ +DEA is an analytical non-parametric technique used to benchmark the performance of a set of KPIs with respect to another set of KPIs, through the estimation of their technical efficiency (TE). TE is defined as the ratio of the weighted sum of outputs to the weighted sum of inputs where the weights structure is mathematically calculated (using the "variable returns to scale" - VRS - constraint, Banker, Charnes and Cooper 1984). The analysis returns: +1) A TE chart displaying the efficiency curve, which shows the KPIs performance (outputs) given the inputs. If there is more than one input or output, summed values are displayed; +2) TE statistics for all batches data in the VRE, reporting the number of batches in several TE ranges; +3) Measurements of TE per user's batch. +Reference: Banker, R. D., Charnes, A., & Cooper, W. W. (1984). Some models for estimating technical and scale inefficiencies in data envelopment analysis. Management science, 30(9), 1078-1092. \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Farm_DEAANALYSIS b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Farm_DEAANALYSIS new file mode 100644 index 0000000..1dd98e6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/Farm_DEAANALYSIS @@ -0,0 +1,5 @@ +DEA is an analytical non-parametric technique used to benchmark the performance of a set of KPIs with respect to another set of KPIs, through the estimation of their technical efficiency (TE). TE is defined as the ratio of the weighted sum of outputs to the weighted sum of inputs where the weights structure is mathematically calculated (using the "variable returns to scale" - VRS - constraint, Banker, Charnes and Cooper 1984). The analysis returns: +1) A TE chart displaying the efficiency curve, which shows the KPIs performance (outputs) given the inputs. If there is more than one input or output, summed values are displayed; +2) TE statistics for all farm data in the VRE, reporting the number of farms in several TE ranges; +3) Measurements of TE for the user's farm. +Reference: Banker, R. D., Charnes, A., & Cooper, W. W. (1984). Some models for estimating technical and scale inefficiencies in data envelopment analysis. Management science, 30(9), 1078-1092. \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/PerformFishResources.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/PerformFishResources.java index 324370d..7011515 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/PerformFishResources.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/resources/PerformFishResources.java @@ -103,6 +103,13 @@ public interface PerformFishResources extends ClientBundle { @Source("Farm_CORRELATION") public TextResource farm_CORRELATION(); + + @Source("Batch_DEAANALYSIS") + public TextResource batch_DEAANALYSIS(); + + @Source("Farm_DEAANALYSIS") + public TextResource farm_DEAANALYSIS(); + @Source("BatchFarm_SYNOPTICTABLE") public TextResource synopticTable(); } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.java index cd6682c..1c357ce 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.java @@ -3,7 +3,6 @@ */ package org.gcube.portlets.user.performfishanalytics.client.viewannualbinder; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -12,10 +11,9 @@ import java.util.Map; import org.gcube.portlets.user.performfishanalytics.client.DataMinerAlgorithms; import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsConstant; import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsServiceAsync; +import org.gcube.portlets.user.performfishanalytics.client.controllers.PerformFishAnalyticsController; import org.gcube.portlets.user.performfishanalytics.client.event.CallAlgorithmEvent; -import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.view.util.CorrelationValueToColourUtil; -import org.gcube.portlets.user.performfishanalytics.client.viewbinder.ShowResult; import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; import org.gcube.portlets.user.performfishanalytics.shared.OutputFile; @@ -24,14 +22,11 @@ import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVRow; import org.gcube.portlets.user.performfishanalytics.shared.dataminer.DataMinerResponse; import com.github.gwtbootstrap.client.ui.Alert; -import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.CheckBox; import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -47,16 +42,13 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; - /** * The Class AnalyticsPanelResult. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Jan 29, 2019 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 29, 2019 */ public class AnalyticsAnnualPanelResult extends Composite { @@ -64,18 +56,15 @@ public class AnalyticsAnnualPanelResult extends Composite { * */ - - private static AnalyticsPanelResultUiBinder uiBinder = - GWT.create(AnalyticsPanelResultUiBinder.class); + private static AnalyticsPanelResultUiBinder uiBinder = GWT.create(AnalyticsPanelResultUiBinder.class); /** * The Interface AnalyticsPanelResultUiBinder. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Jan 30, 2019 + * @author Francesco Mangiacrapa at ISTI-CNR + * (francesco.mangiacrapa@isti.cnr.it) Jan 30, 2019 */ - interface AnalyticsPanelResultUiBinder - extends UiBinder { + interface AnalyticsPanelResultUiBinder extends UiBinder { } @UiField @@ -99,165 +88,49 @@ public class AnalyticsAnnualPanelResult extends Composite { @UiField VerticalPanel field_unary_algorithm; - @UiField - ControlGroup cg_list_dea_input_kpi; - - @UiField - ControlGroup cg_list_dea_output_kpi; - - @UiField - ListBox list_dea_input_kpi; - - @UiField - ListBox list_dea_output_kpi; - @UiField Label uib_label_focus_id; -// @UiField -// ControlGroup cg_focus_id_dea; - - @UiField - HorizontalPanel uib_vp_deanalanlysis_request_container; - @UiField ControlGroup cg_focus_id_correlation; -// @UiField -// ListBox field_list_focus_id_dea; - - @UiField - VerticalPanel uib_vp_deanalanlysis_algorithm; - - @UiField - VerticalPanel uib_vp_deanalanlysis_algorithm_container; - @UiField ListBox field_list_focus_id_correlation; - @UiField - Button button_dea_analys_request; - - @UiField - CheckBox uib_check_all_input_kpi; - - @UiField - CheckBox uib_check_all_output_kpi; - - private Map dataInputParameters; + private Map dataInputParameters; private DataMinerResponse dmResponse; - private Map> kpiMapPointers = new HashMap>(); + private Map> kpiMapPointers = new HashMap>(); private List selectedKPIs; private List selectedAreas; - private HandlerManager theEventBus; - + // private HandlerManager theEventBus; + private Map csvGenerated = new HashMap(); /** - * Because this class has a default constructor, it can - * be used as a binder template. In other words, it can be used in other - * *.ui.xml files as follows: - * - * Hello! - * - * Note that depending on the widget that is used, it may be necessary to - * implement HasHTML instead of HasText. + * Because this class has a default constructor, it can be used as a binder + * template. In other words, it can be used in other *.ui.xml files as + * follows: + * Hello! Note that + * depending on the widget that is used, it may be necessary to implement + * HasHTML instead of HasText. */ public AnalyticsAnnualPanelResult(HandlerManager eventBus) { initWidget(uiBinder.createAndBindUi(this)); - this.theEventBus = eventBus; - - button_dea_analys_request.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - cg_list_dea_input_kpi.setType(ControlGroupType.NONE); - cg_list_dea_output_kpi.setType(ControlGroupType.NONE); - - if(list_dea_input_kpi.getSelectedIndex()==-1){ - showAlert("You must select at least one Input KPI", AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - cg_list_dea_input_kpi.setType(ControlGroupType.ERROR); - return; - } - - if(list_dea_output_kpi.getSelectedIndex()==-1){ - showAlert("You must select at least one Output KPI", AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - cg_list_dea_output_kpi.setType(ControlGroupType.ERROR); - return; - } - - List inputKPINames = getSelected(list_dea_input_kpi); - List outputKPINames = getSelected(list_dea_output_kpi); - callDeaAnalysis(inputKPINames, outputKPINames, button_dea_analys_request); - } - }); - - uib_check_all_input_kpi.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - boolean isChecked = uib_check_all_input_kpi.getValue(); - selectAllFields(list_dea_input_kpi, isChecked); - } - }); - - uib_check_all_output_kpi.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - boolean isChecked = uib_check_all_output_kpi.getValue(); - selectAllFields(list_dea_output_kpi, isChecked); - } - }); + // this.theEventBus = eventBus; } - /** - * Select all fields. - * - * @param listBox the list box - * @param selected the selected - */ - private void selectAllFields(ListBox listBox, boolean selected){ - - for (int i=0; i getSelected(ListBox listBox){ - List selected = new ArrayList(); - for (int i=0; i listAreas) { @@ -265,18 +138,15 @@ public class AnalyticsAnnualPanelResult extends Composite { } - /** * Gets the data miner response. * * @return the data miner response */ - public DataMinerResponse getDataMinerResponse(){ + public DataMinerResponse getDataMinerResponse() { return dmResponse; } - - /** * Gets the data input parameters. * @@ -290,12 +160,16 @@ public class AnalyticsAnnualPanelResult extends Composite { /** * Show alert. * - * @param error the error - * @param type the type - * @param closable the closable - * @param panel the panel + * @param error + * the error + * @param type + * the type + * @param closable + * the closable + * @param panel + * the panel */ - private void showAlert(String error, AlertType type, boolean closable, ComplexPanel panel){ + private void showAlert(String error, AlertType type, boolean closable, ComplexPanel panel) { Alert alert = new Alert(error); alert.setType(type); alert.setClose(closable); @@ -303,11 +177,11 @@ public class AnalyticsAnnualPanelResult extends Composite { panel.add(alert); } - /** * Adds the selected kp is. * - * @param selectedKPIs the selected kp is + * @param selectedKPIs + * the selected kp is */ public void addSelectedKPIs(List selectedKPIs) { @@ -315,70 +189,45 @@ public class AnalyticsAnnualPanelResult extends Composite { } + public KPI getKPIForName(String name) { -// /** -// * Gets the KPI for name. -// * -// * @param name the name -// * @return the KPI for name -// */ -// public KPI getKPIForName(String name){ -// -// //GWT.log("Selected KPIs: "+selectedKPIs); -// GWT.log("Searching KPI name: "+name); -// KPI foundKPI = null; -// //String purgedName = name.replaceAll("\\%", "").trim(); -// String purgedName = name.trim(); -// for (KPI kpi : selectedKPIs) { -// //String purgedKPIName = kpi.getName().replaceAll("\\%", "").trim(); -// String purgedKPIName = kpi.getName().trim(); -// if(purgedKPIName.compareToIgnoreCase(purgedName)==0) { -// foundKPI = kpi; -// break; -// } -// -// } -// GWT.log("FOUND KPI: "+foundKPI); -// return foundKPI; -// } - - public KPI getKPIForName(String name){ - - GWT.log("Searching KPI name: "+name+ " into: "); + GWT.log("Searching KPI name: " + name + " into: "); for (KPI kpi : selectedKPIs) { - GWT.log("selected: "+kpi.getName()); + GWT.log("selected: " + kpi.getName()); } - + KPI foundKPI = null; String purgedName = name.trim(); for (KPI kpi : selectedKPIs) { String purgedKPIName = kpi.getName().trim(); - if(purgedKPIName.compareToIgnoreCase(purgedName)==0) { + if (purgedKPIName.compareToIgnoreCase(purgedName) == 0) { foundKPI = kpi; break; } } - GWT.log("FOUND KPI: "+foundKPI); + GWT.log("FOUND KPI: " + foundKPI); return foundKPI; } /** * Adds the parameters. * - * @param keyToGet the key to get - * @param parameters the parameters - * @param toShowBatchTypeValue label to show batch type value + * @param keyToGet + * the key to get + * @param parameters + * the parameters + * @param toShowBatchTypeValue + * label to show batch type value */ public void addParameters(String keyToGet, Map> parameters, String toShowBatchTypeValue) { - final FlexTable flexTable = new FlexTable(); flexTable.setStyleName("colgrouptable"); - try{ + try { List dataInputs = parameters.get(keyToGet); - if(dataInputs==null || dataInputs.isEmpty()) + if (dataInputs == null || dataInputs.isEmpty()) return; dataInputParameters = new HashMap(); @@ -387,58 +236,43 @@ public class AnalyticsAnnualPanelResult extends Composite { String[] splittedParams = theDataInputs.split(";"); for (String splitParam : splittedParams) { - try{ + try { String[] keyvalue = splitParam.split("="); dataInputParameters.put(keyvalue[0], keyvalue[1]); - }catch(Exception e){ + } catch (Exception e) { } } - flexTable.setWidget(0, 0, new HTML(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM))); - flexTable.setWidget(1, 0, new HTML(toShowBatchTypeValue)); + flexTable.setWidget(0, 0, new HTML("Batch Type:")); + flexTable.setWidget(0, 1, new HTML(toShowBatchTypeValue)); + //flexTable.setWidget(1, 0, new HTML("Level:")); + //flexTable.setWidget(1, 1, new HTML(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM))); String KPINames = ""; - for (KPI kpi: selectedKPIs) { - KPINames+=kpi.getName() +", "; + for (KPI kpi : selectedKPIs) { + KPINames += kpi.getName() + ", "; } - KPINames = KPINames.substring(0, KPINames.length()-2); - flexTable.setWidget(2,0, new HTML(KPINames)); + KPINames = KPINames.substring(0, KPINames.length() - 2); + flexTable.setWidget(2, 0, new HTML("KPI:")); + flexTable.setWidget(2, 1, new HTML(KPINames)); - fillDeaListBoxes(); - - //TODO MUST BE REVISITED - //CHANGING LABEL TEXT TO SCAPE_PARAM - //uib_label_focus_id.setText(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM) + " ID"); - uib_label_focus_id.setText("FOCUS ID"); - }catch(Exception e){ - //silent + } catch (Exception e) { + // silent } field_parameters_container.add(flexTable); } - - /** - * Fill dea list boxes. - */ - private void fillDeaListBoxes(){ - - for (KPI kpi: selectedKPIs) { - list_dea_input_kpi.addItem(kpi.getName()); - list_dea_output_kpi.addItem(kpi.getName()); - } - } - - /** * Adds the list batch ids. * - * @param listBatchesID the list batches id + * @param listBatchesID + * the list batches id */ - public void addListBatchIds(List listBatchesID){ + public void addListBatchIds(List listBatchesID) { for (String batchID : listBatchesID) { field_list_focus_id_correlation.addItem(batchID, batchID); } @@ -447,177 +281,147 @@ public class AnalyticsAnnualPanelResult extends Composite { /** * Adds the results. * - * @param dmResponse the dm response + * @param dmResponse + * the dm response */ public void addResults(DataMinerResponse dmResponse) { - + this.dmResponse = dmResponse; - + for (final OutputFile outputFile : dmResponse.getListOutput()) { - - if(outputFile.getDataType().equals(FileContentType.CSV)){ - PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_correlation_results_container); + if (outputFile.getDataType().equals(FileContentType.CSV)) { + PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, + new AsyncCallback() { - } + @Override + public void onFailure(Throwable caught) { + showAlert(caught.getMessage(), AlertType.ERROR, true, + uib_vp_correlation_results_container); - @Override - public void onSuccess(CSVFile result) { - - csvGenerated.put(result.getFileName(), result); - fillCorrelationMatrix(); - } - }); + } + + @Override + public void onSuccess(CSVFile result) { + + csvGenerated.put(result.getFileName(), result); + fillCorrelationMatrix(); + } + }); } - + } } - - + /** * Fill correlation matrix. */ private void fillCorrelationMatrix() { - - if(csvGenerated.size()<2) + + if (csvGenerated.size() < 2) return; - + String corrIndexFilename = null; String corrFilename = null; for (String fileName : csvGenerated.keySet()) { - if(fileName.contains("index")) { + if (fileName.contains("index")) { corrIndexFilename = fileName; - }else { + } else { corrFilename = fileName; } } - - GWT.log("Correlation Matrix Index File: "+corrIndexFilename); - GWT.log("Correlation Matrix File: "+corrFilename); + + GWT.log("Correlation Matrix Index File: " + corrIndexFilename); + GWT.log("Correlation Matrix File: " + corrFilename); CSVFile corrIndexCsvFile = csvGenerated.get(corrIndexFilename); CSVFile corrCsvFile = csvGenerated.get(corrFilename); - GWT.log("Correlation Matrix Index CSV: "+corrIndexCsvFile); - GWT.log("Correlation Matrix CSV: "+corrCsvFile); + GWT.log("Correlation Matrix Index CSV: " + corrIndexCsvFile); + GWT.log("Correlation Matrix CSV: " + corrCsvFile); HorizontalPanel hp = new HorizontalPanel(); final FlexTable flexTable = new FlexTable(); flexTable.setStyleName("fixedtable"); flexTable.getElement().getStyle().setMarginBottom(10, Unit.PX); - flexTable.setWidget(0, 0,new Label("")); - - + flexTable.setWidget(0, 0, new Label("")); + CSVRow headerRow = corrIndexCsvFile.getHeaderRow(); - //HEADER - for (int i=1; i 0 - }else{ - KPI columnKPI = getKPIForName(headerRow.getListValues().get(columnIndex)); - //Here the first index is the KPI name - KPI rowKPI = getKPIForName(row.getListValues().get(0)); - fillKPIReferenceForIndex(rowIndex, columnIndex, Arrays.asList(columnKPI, rowKPI)); - //button.setText(" "); - //button.setIcon(IconType.COMPASS); - //button.setSize(ButtonSize.LARGE); + } else { + if (rowIndex == j) { // diagonal + HTML dg = new HTML(rowValue); + dg.getElement().getStyle().setFontSize(18, Unit.PX); + flexTable.setWidget(rowIndex, j, dg); + continue; + // j > 0 + } else { + KPI columnKPI = getKPIForName(headerRow.getListValues().get(columnIndex)); + // Here the first index is the KPI name + KPI rowKPI = getKPIForName(row.getListValues().get(0)); + fillKPIReferenceForIndex(rowIndex, columnIndex, Arrays.asList(columnKPI, rowKPI)); - buttonHTML.addClickHandler(new ClickHandler() { + buttonHTML.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { + @Override + public void onClick(ClickEvent event) { - //callScatterAndDeaChart(rowIndex, columnIndex, button); - callScatter(rowIndex, columnIndex, buttonHTML); - } - }); + // callScatterAndDeaChart(rowIndex, columnIndex, + // button); + callScatter(rowIndex, columnIndex, buttonHTML); + } + }); + } } - //button.setType(ButtonType.LINK); - //APPLYING STYLE ONLY ON INTERNAL VALUES OF CSV - if(j>0) + if (j > 0) buttonHTML.getElement().getStyle().setColor("#000"); buttonHTML.addAttachHandler(new AttachEvent.Handler() { - @Override - public void onAttachOrDetach(AttachEvent event) { - if(theColor.startsWith("#")){ - GWT.log("Setting backgrounf color: "+theColor); - buttonHTML.getElement().getParentElement().getStyle().setBackgroundColor(theColor); - } - } + @Override + public void onAttachOrDetach(AttachEvent event) { + if (theColor.startsWith("#")) { + GWT.log("Setting backgrounf color: " + theColor); + buttonHTML.getElement().getParentElement().getStyle().setBackgroundColor(theColor); + } + } }); - flexTable.setWidget(rowIndex, j,buttonHTML); + flexTable.setWidget(rowIndex, j, buttonHTML); } } @@ -626,7 +430,6 @@ public class AnalyticsAnnualPanelResult extends Composite { final FlexTable flexLegend = new FlexTable(); flexLegend.setStyleName("simpletable"); - //flexLegend.getElement().getStyle().setBorderWidth(0, Unit.PX); Map map = CorrelationValueToColourUtil.getMap(); flexLegend.setWidget(0, 0, new Label("Legend")); flexLegend.setWidget(0, 1, new HTML("")); @@ -638,10 +441,10 @@ public class AnalyticsAnnualPanelResult extends Composite { flexLegend.setWidget(i, 1, new HTML(key)); theLegendColor.addAttachHandler(new AttachEvent.Handler() { - @Override - public void onAttachOrDetach(AttachEvent event) { - theLegendColor.getElement().getParentElement().getStyle().setBackgroundColor(rgbColor); - } + @Override + public void onAttachOrDetach(AttachEvent event) { + theLegendColor.getElement().getParentElement().getStyle().setBackgroundColor(rgbColor); + } }); i++; @@ -649,112 +452,60 @@ public class AnalyticsAnnualPanelResult extends Composite { flexLegend.getElement().getStyle().setMarginLeft(15, Unit.PX); hp.add(flexLegend); - uib_vp_correlation_results_container.insert(hp,0); - + uib_vp_correlation_results_container.insert(hp, 0); + } /** * Fill kpi reference for index. * - * @param rowIndex the row index - * @param columnIndex the column index - * @param listKPI the list kpi + * @param rowIndex + * the row index + * @param columnIndex + * the column index + * @param listKPI + * the list kpi */ - private void fillKPIReferenceForIndex(int rowIndex, int columnIndex, List listKPI){ + private void fillKPIReferenceForIndex(int rowIndex, int columnIndex, List listKPI) { String key = generateKey(rowIndex, columnIndex); kpiMapPointers.put(key, listKPI); - -// String kpiNames = ""; -// if(listKPI!=null && listKPI.size()>0){ -// for (KPI kpi : listKPI) { -// -// if(kpi!=null){ -// kpiNames+=" "+kpi.getName() +";"; -// }else -// GWT.log("KPI NULL for "+key); -// -// -// } -// GWT.log("FILLING kpiMapPointers with key: "+key +" and value: "+kpiNames); -// }else -// GWT.log("FILLING kpiMapPointers with key: "+key +" and value: "+listKPI); - } /** * Gets the KPI for indexes. * - * @param rowIndex the row index - * @param columnIndex the column index + * @param rowIndex + * the row index + * @param columnIndex + * the column index * @return the KPI for indexes */ - public List getKPIForIndexes(int rowIndex, int columnIndex){ + public List getKPIForIndexes(int rowIndex, int columnIndex) { String key = generateKey(rowIndex, columnIndex); return kpiMapPointers.get(key); } - + private String generateKey(int rowIndex, int columnIndex) { - return rowIndex+"-"+columnIndex; + return rowIndex + "-" + columnIndex; } - - /** - * Call box plot and speedo meter. - * - * @param rowIndex the row index - * @param columnIndex the column index - * @param button the button - */ - private void callBoxPlotAndSpeedoMeter(int rowIndex, int columnIndex, Button button){ - - String focusID = checkValidFocusID(); - - if(focusID==null) - return; - - GWT.log("Called BoxPlotAndSpeedoMeter at rowIndex: "+rowIndex +", columnIndex: "+columnIndex); - HorizontalPanel hp = new HorizontalPanel(); - hp.getElement().addClassName("ext-horizontal-panel"); - HorizontalPanel boxPlot = new HorizontalPanel(); - HorizontalPanel speedometer = new HorizontalPanel(); - hp.add(boxPlot); - hp.add(speedometer); - //hp.getElement().addClassName("ext-horizontal-panel"); - field_unary_algorithm_container.add(hp); - //KPI selectKPI = getKPIForName(button.getText()); - List selectedKPI = getKPIForIndexes(rowIndex, columnIndex); - GWT.log("Selected KPI: "+selectedKPI); - field_unary_algorithm.setVisible(true); - callDataMinerServiceForChart(dataInputParameters, selectedKPI, null, DataMinerAlgorithms.BOXPLOT, focusID, boxPlot); - callDataMinerServiceForChart(dataInputParameters, selectedKPI, null, DataMinerAlgorithms.SPEEDOMETER, focusID, speedometer); - } - - /** * Check valid focus id. * * @return the FocusID if it is valid, null otherwise. */ - public String checkValidFocusID(){ + public String checkValidFocusID() { cg_focus_id_correlation.setType(ControlGroupType.NONE); - //CHECK THE FOCUS ID VALUE + // CHECK THE FOCUS ID VALUE String focusID = field_list_focus_id_correlation.getSelectedItemText(); - if(focusID==null || focusID.isEmpty()){ + if (focusID == null || focusID.isEmpty()) { String msgError = "Could not execute a valid Analysis."; - //TODO TO BE REVISITED - /* - if(selectedAreas==null || selectedAreas.isEmpty()){ - msgError+=" Please select another parameters computation"; - }else{ - msgError+=" Select at least the Area of your FARM"; - }*/ - showAlert(msgError, AlertType.ERROR, true, uib_vp_correlation_results_container); cg_focus_id_correlation.setType(ControlGroupType.ERROR); return null; @@ -763,293 +514,28 @@ public class AnalyticsAnnualPanelResult extends Composite { return focusID; } - - /** - * Call scatter and dea chart. - * - * @param rowIndex the row index - * @param columnIndex the column index - * @param button the button - */ - private void callScatterAndDeaChart(int rowIndex, int columnIndex, Button button){ - - String focusID = checkValidFocusID(); - - if(focusID==null) - return; - - GWT.log("Called ScatterAndDeaChart at rowIndex: "+rowIndex +", columnIndex: "+columnIndex); - HorizontalPanel hp = new HorizontalPanel(); - hp.getElement().addClassName("ext-horizontal-panel"); - HorizontalPanel scatter = new HorizontalPanel(); - HorizontalPanel deaChart = new HorizontalPanel(); - hp.add(scatter); - hp.add(deaChart); - //hp.getElement().addClassName("ext-horizontal-panel"); - field_binary_algorithm_container.add(hp); - List selectedKPI = getKPIForIndexes(rowIndex, columnIndex); - GWT.log("Selected KPI: "+selectedKPI); - field_binary_algorithm.setVisible(true); - callDataMinerServiceForChart(dataInputParameters, selectedKPI, null, DataMinerAlgorithms.SCATTER, focusID, scatter); - callDataMinerServiceForChart(dataInputParameters, selectedKPI, null, DataMinerAlgorithms.DEA_CHART, focusID, deaChart); - } - - /** * Call scatter. * - * @param rowIndex the row index - * @param columnIndex the column index - * @param buttonHTML the button + * @param rowIndex + * the row index + * @param columnIndex + * the column index + * @param button + * the button */ - private void callScatter(int rowIndex, int columnIndex, HTML buttonHTML){ + private void callScatter(int rowIndex, int columnIndex, HTML button) { String focusID = checkValidFocusID(); - if(focusID==null) + if (focusID == null) return; - GWT.log("Called ScatterChart at rowIndex: "+rowIndex +", columnIndex: "+columnIndex); + GWT.log("Called ScatterChart at rowIndex: " + rowIndex + ", columnIndex: " + columnIndex); List selectedKPI = getKPIForIndexes(rowIndex, columnIndex); - GWT.log("Selected KPI: "+selectedKPI); - theEventBus.fireEvent(new CallAlgorithmEvent(DataMinerAlgorithms.SCATTER, focusID, selectedKPI, null)); + GWT.log("Selected KPI: " + selectedKPI); + PerformFishAnalyticsController.eventBus + .fireEvent(new CallAlgorithmEvent(DataMinerAlgorithms.SCATTER, focusID, selectedKPI, null)); } - - /** - * Call dea analysis. - * - * @param inputKPINames the input kpi names - * @param outputKPINames the output kpi names - * @param button the button - */ - private void callDeaAnalysis(List inputKPINames, List outputKPINames, Button button){ - - HorizontalPanel hp = new HorizontalPanel(); - hp.getElement().addClassName("ext-horizontal-panel"); - HorizontalPanel deaAnalysis = new HorizontalPanel(); - hp.add(deaAnalysis); - //hp.getElement().addClassName("ext-horizontal-panel"); - uib_vp_deanalanlysis_algorithm_container.add(hp); - - List inputKPI = new ArrayList(); - for (String kpiName : inputKPINames) { - inputKPI.add(getKPIForName(kpiName)); - } - - List outputKPI = new ArrayList(); - for (String kpiName : outputKPINames) { - outputKPI.add(getKPIForName(kpiName)); - } - - - GWT.log("Calling Dea Analysys... with input: "+inputKPI+" and output: "+outputKPI); - uib_vp_deanalanlysis_algorithm.setVisible(true); - callDataMinerServiceForChart(dataInputParameters, inputKPI, outputKPI, DataMinerAlgorithms.DEA_ANALYSIS, "ID", deaAnalysis); - } - - - /** - * Display output files as static entities. - * - * @param dmResponse the dm response - * @param chartType the chart type - * @param inputKPIs the input kp is - * @param outputKPIs the output kp is - * @param focusID the focus id - * @param container the container - * @param displayError the display error - */ - private void displayOutputFilesAsStaticEntities(DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, final Panel container, boolean displayError){ - - String title = displayError?"No results ":""; - title+=chartType.getTitle(); - title+=inputKPIs.size()>1?" [Input KPIs: ":" [Input KPI: "; - - for (KPI kpi : inputKPIs) { - title+=" "+kpi.getName()+","; - } - - title = title.substring(0,title.length()-1)+"]"; - - - if(outputKPIs!=null && outputKPIs.size()>0){ - title+=inputKPIs.size()>1?" [Output KPIs: ":" [Output KPI: "; - for (KPI kpi : outputKPIs) { - title+=" "+kpi.getName()+","; - } - title = title.substring(0,title.length()-1)+"]"; - } - - //title+= " Focus "+focusID; - - if(displayError){ - Alert alert = new Alert(title); - alert.setType(AlertType.ERROR); - alert.setClose(false); - alert.getElement().getStyle().setMargin(10, Unit.PX); - container.add(alert); - return; - } - - final String toTitle = title; - - for (final OutputFile outputFile : dmResponse.getListOutput()) { - - switch (outputFile.getDataType()) { - case IMAGE: - PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - - } - - @Override - public void onSuccess(String base64Content) { - - String title = toTitle; - switch (chartType) { - case BOXPLOT: - break; - case SPEEDOMETER: - title+= " "+uib_label_focus_id.getText()+": "+focusID; - break; - default: - break; - } - - - ShowResult showResult = new ShowResult(title); - showResult.showImage(base64Content); - container.add(showResult); - - } - }); - break; - case CSV: - PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - } - - @Override - public void onSuccess(CSVFile result) { - GWT.log("Displaying: "+result); - String cssTableStyle = "simpletable"; - String title = toTitle; - switch (chartType) { - case BOXPLOT: - title+= " Statistics on all data"; - break; - case SPEEDOMETER: - title+= " "+uib_label_focus_id.getText()+": "+focusID; - break; - default: - break; - } - - ShowResult showResult = new ShowResult(title); - showResult.showCSVFile(result, cssTableStyle); - container.add(showResult); - } - }); - break; - - default: - break; - } - - } - - } - - /** - * Call data miner service for chart. - * - * @param dataInputParameters the data input parameters - * @param inputKPI the input kpi - * @param outputKPI the output kpi - * @param chartType the chart type - * @param focusID the focus id - * @param panel the panel - */ - private void callDataMinerServiceForChart(Map dataInputParameters, final List inputKPI, final List outputKPI, final DataMinerAlgorithms chartType, final String focusID, final ComplexPanel panel) { - - GWT.log("Call DM wiht Selected KPI: "+inputKPI); - StringBuilder dataInputsFormatter = new StringBuilder(); - String scalePValue = dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM+"="+scalePValue+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM+"="+dataInputParameters.get(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM)+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+chartType+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM+"="+dataInputParameters.get(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM)+";"); - - - if(inputKPI!=null && inputKPI.size()>0){ - String kpiCodes = ""; - for (KPI kpi : inputKPI) { - kpiCodes+=kpi.getCode()+"|"; - } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); - - GWT.log("Input KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM+"="+kpiCodes+";"); - - } - - if(outputKPI!=null && outputKPI.size()>0){ - String kpiCodes = ""; - for (KPI kpi : outputKPI) { - kpiCodes+=kpi.getCode()+"|"; - } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); - - GWT.log("Output KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM+"="+kpiCodes+";"); - - } - - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+focusID+";"); - - String dataInParameters = dataInputsFormatter.toString(); - GWT.log("Calling DM service with client input parameters: "+dataInParameters); - - Map> mapParameters = new HashMap>(); - mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); - - final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to "+chartType.getTitle()+" Analysis..."); - loaderIcon.setVisible(true); - panel.setVisible(true); - panel.add(loaderIcon); - Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { - @Override - public void execute() { - loaderIcon.setFocus(true); - }}); - - PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters, new AsyncCallback() { - - @Override - public void onSuccess(DataMinerResponse dmResponse) { - loaderIcon.setVisible(false); - //field_unary_algorithm.setVisible(true); - GWT.log("I'm displaying: "+dmResponse); - displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, false); - } - - @Override - public void onFailure(Throwable caught) { - loaderIcon.setVisible(false); - displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, true); - - } - }); - } } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.ui.xml b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.ui.xml index 7a5e3a9..067c4da 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.ui.xml +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/AnalyticsAnnualPanelResult.ui.xml @@ -14,11 +14,6 @@ addStyleNames="the_margin_top_bottom"> - - - - Focus ID @@ -30,51 +25,15 @@ + + + + - - - - Input KPI - - - - - - - - - - - - Output - KPI - - - - - - - - - - - - - - - - @@ -91,14 +50,6 @@ addStyleNames="the_margin"> - - - - - - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.java new file mode 100644 index 0000000..0049c37 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.java @@ -0,0 +1,971 @@ +/** + * + */ +package org.gcube.portlets.user.performfishanalytics.client.viewannualbinder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.gcube.portlets.user.performfishanalytics.client.DataMinerAlgorithms; +import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsConstant; +import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsServiceAsync; +import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; +import org.gcube.portlets.user.performfishanalytics.client.viewbinder.ShowResult; +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; +import org.gcube.portlets.user.performfishanalytics.shared.dataminer.DataMinerResponse; + +import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.ControlGroup; +import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.dom.client.Style.TextAlign; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.ComplexPanel; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlexTable; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Panel; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + +/** + * The Class AnalyticsPanelResult. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 29, 2019 + */ +public class DeaAnnualPanelResult extends Composite { + + /** + * + */ + + private static DeaAnnualPanelResultUiBinder uiBinder = GWT.create(DeaAnnualPanelResultUiBinder.class); + + /** + * The Interface DeaAnnualPanelResultUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR + * (francesco.mangiacrapa@isti.cnr.it) Jan 30, 2019 + */ + interface DeaAnnualPanelResultUiBinder extends UiBinder { + } + + @UiField + HTMLPanel field_html_panel; + + @UiField + VerticalPanel field_parameters_container; + + @UiField + Label uib_label_focus_id; + + @UiField + ControlGroup cg_focus_id_correlation; + + @UiField + ListBox field_list_focus_id_correlation; + + @UiField + ComplexPanel alert_info; + + @UiField + ComplexPanel alert_error; + + @UiField + ControlGroup cg_list_dea_kpi; + + @UiField + ControlGroup cg_list_dea_input_kpi; + + @UiField + ControlGroup cg_list_dea_output_kpi; + + @UiField + ListBox list_dea_kpi; + + @UiField + ListBox list_dea_input_kpi; + + @UiField + ListBox list_dea_output_kpi; + + // @UiField + // ControlGroup cg_focus_id_dea; + + @UiField + HorizontalPanel uib_vp_deanalanlysis_request_container; + + // @UiField + // ListBox field_list_focus_id_dea; + + @UiField + VerticalPanel uib_vp_deanalanlysis_algorithm; + + @UiField + VerticalPanel uib_vp_deanalanlysis_algorithm_container; + + @UiField + Button button_dea_analys_request; + + @UiField + Button uib_add_to_input_kpi; + @UiField + Button uib_remove_from_input_kpi; + @UiField + Button uib_add_to_output_kpi; + @UiField + Button uib_remove_from_output_kpi; + + @UiField + Button uib_reset_input_kpi; + + @UiField + Button uib_reset_output_kpi; + + private enum KpiButtonType { + KPI, INPUT_KPI, OUTPUT_KPI + } + + private Map dataInputParameters; + + private DataMinerResponse dmResponse; + + private Map> kpiMapPointers = new HashMap>(); + + private List selectedKPIs; + + // private List selectedAreas; + + /** + * Because this class has a default constructor, it can be used as a binder + * template. In other words, it can be used in other *.ui.xml files as + * follows: + * Hello! Note that + * depending on the widget that is used, it may be necessary to implement + * HasHTML instead of HasText. + */ + public DeaAnnualPanelResult() { + GWT.log("DeaPanelResult"); + + initWidget(uiBinder.createAndBindUi(this)); + + button_dea_analys_request.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + alert_error.clear(); + cg_list_dea_input_kpi.setType(ControlGroupType.NONE); + cg_list_dea_output_kpi.setType(ControlGroupType.NONE); + + if (list_dea_input_kpi.getItemCount() < 1) { + showAlert("You must select at least one Input KPI", AlertType.ERROR, true, alert_error); + cg_list_dea_input_kpi.setType(ControlGroupType.ERROR); + return; + } + + if (list_dea_output_kpi.getItemCount() < 1) { + showAlert("You must select at least one Output KPI", AlertType.ERROR, true, alert_error); + cg_list_dea_output_kpi.setType(ControlGroupType.ERROR); + return; + } + + List inputKPINames = new ArrayList(); + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + inputKPINames.add(list_dea_input_kpi.getItemText(i)); + } + + List outputKPINames = new ArrayList(); + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + outputKPINames.add(list_dea_output_kpi.getItemText(i)); + } + + callDeaAnalysis(inputKPINames, outputKPINames, button_dea_analys_request); + } + }); + + uib_add_to_input_kpi.setIcon(IconType.BACKWARD); + uib_add_to_input_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + addListFields(KpiButtonType.INPUT_KPI); + } + }); + + uib_remove_from_input_kpi.setIcon(IconType.FORWARD); + uib_remove_from_input_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + removeListFields(KpiButtonType.INPUT_KPI); + } + }); + + uib_add_to_output_kpi.setIcon(IconType.FORWARD); + uib_add_to_output_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + addListFields(KpiButtonType.OUTPUT_KPI); + } + }); + + uib_remove_from_output_kpi.setIcon(IconType.BACKWARD); + uib_remove_from_output_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + removeListFields(KpiButtonType.OUTPUT_KPI); + } + }); + + uib_reset_input_kpi.setIcon(IconType.REMOVE_CIRCLE); + uib_reset_input_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + resetListFields(KpiButtonType.INPUT_KPI); + } + }); + + uib_reset_output_kpi.setIcon(IconType.REMOVE_CIRCLE); + uib_reset_output_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + resetListFields(KpiButtonType.OUTPUT_KPI); + } + }); + + validateKPIList(); + } + + private void validateKPIList() { + if (list_dea_output_kpi.getItemCount() > 0 && list_dea_input_kpi.getItemCount() > 0) { + alert_info.clear(); + alert_error.clear(); + cg_list_dea_input_kpi.setType(ControlGroupType.NONE); + cg_list_dea_output_kpi.setType(ControlGroupType.NONE); + button_dea_analys_request.setEnabled(true); + + } else { + alert_info.clear(); + button_dea_analys_request.setEnabled(false); + showAlert("Please select Input and Output KPI", AlertType.INFO, true, alert_info); + } + } + + /** + * Add to Input or Output KPI selected + * + * @param kpiButtonType + * kpi button type + * + */ + private void addListFields(KpiButtonType kpiButtonType) { + List notSelected = null; + + switch (kpiButtonType) { + case INPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_kpi.getItemCount(); i++) { + if (list_dea_kpi.isItemSelected(i)) { + list_dea_input_kpi.addItem(list_dea_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_kpi.getItemText(i)); + } + } + list_dea_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_kpi.addItem(notSelected.get(i)); + } + break; + case KPI: + break; + case OUTPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_kpi.getItemCount(); i++) { + if (list_dea_kpi.isItemSelected(i)) { + list_dea_output_kpi.addItem(list_dea_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_kpi.getItemText(i)); + } + } + list_dea_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_kpi.addItem(notSelected.get(i)); + } + break; + default: + break; + } + + validateKPIList(); + + } + + /** + * Remove from Input or Output KPI selected + * + * @param kpiButtonType + * kpi button type + */ + private void removeListFields(KpiButtonType kpiButtonType) { + List notSelected = null; + + switch (kpiButtonType) { + case INPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + if (list_dea_input_kpi.isItemSelected(i)) { + list_dea_kpi.addItem(list_dea_input_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_input_kpi.getItemText(i)); + } + } + list_dea_input_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_input_kpi.addItem(notSelected.get(i)); + } + break; + case KPI: + break; + case OUTPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + if (list_dea_output_kpi.isItemSelected(i)) { + list_dea_kpi.addItem(list_dea_output_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_output_kpi.getItemText(i)); + } + } + list_dea_output_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_output_kpi.addItem(notSelected.get(i)); + } + break; + default: + break; + } + + validateKPIList(); + + } + + /** + * Reset Input or Output KPI selected + * + * @param kpiButtonType + * kpi button type + */ + private void resetListFields(KpiButtonType kpiButtonType) { + + switch (kpiButtonType) { + case INPUT_KPI: + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_input_kpi.getItemText(i)); + } + list_dea_input_kpi.clear(); + break; + case KPI: + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_input_kpi.getItemText(i)); + } + list_dea_input_kpi.clear(); + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_output_kpi.getItemText(i)); + } + list_dea_output_kpi.clear(); + break; + case OUTPUT_KPI: + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_output_kpi.getItemText(i)); + } + list_dea_output_kpi.clear(); + break; + default: + break; + } + + validateKPIList(); + } + + /** + * Gets the data miner response. + * + * @return the data miner response + */ + public DataMinerResponse getDataMinerResponse() { + return dmResponse; + } + + /** + * Gets the data input parameters. + * + * @return the data input parameters + */ + public Map getDataInputParameters() { + + return dataInputParameters; + } + + /** + * Adds the list focus ids. + * + * @param listFocusIDs + * the list focus I ds + */ + public void addListFocusIds(List listFocusIDs) { + for (String batchID : listFocusIDs) { + field_list_focus_id_correlation.addItem(batchID, batchID); + } + } + + /** + * Show alert. + * + * @param error + * the error + * @param type + * the type + * @param closable + * the closable + * @param panel + * the panel + */ + private void showAlert(String error, AlertType type, boolean closable, ComplexPanel panel) { + Alert alert = new Alert(error); + alert.setType(type); + alert.setClose(closable); + alert.getElement().getStyle().setMargin(10, Unit.PX); + panel.add(alert); + } + + /** + * Adds the selected kp is. + * + * @param selectedKPIs + * the selected kp is + */ + public void addSelectedKPIs(List selectedKPIs) { + + this.selectedKPIs = selectedKPIs; + + } + + /** + * Adds the selected areas. + * + * @param listAreas + * the list areas + */ + /* + * public void addSelectedAreas(List listAreas) { + * + * this.selectedAreas = listAreas; + * + * } + */ + + /** + * Gets the KPI for name. + * + * @param name + * the name + * @return the KPI for name + */ + public KPI getKPIForName(String name) { + + GWT.log("Searching KPI name: " + name); + KPI foundKPI = null; + String purgedName = name.trim(); + for (KPI kpi : selectedKPIs) { + String purgedKPIName = kpi.getName().trim(); + if (purgedKPIName.compareToIgnoreCase(purgedName) == 0) { + foundKPI = kpi; + break; + } + } + GWT.log("FOUND KPI: " + foundKPI); + return foundKPI; + } + + /** + * Adds the parameters. + * + * @param keyToGet + * the key to get + * @param parameters + * the parameters + * @param toShowBatchTypeValue + * label to show batch type value + */ + public void addParameters(String keyToGet, Map> parameters, String toShowBatchTypeValue) { + + final FlexTable flexTable = new FlexTable(); + flexTable.setStyleName("colgrouptable"); + + try { + List dataInputs = parameters.get(keyToGet); + + if (dataInputs == null || dataInputs.isEmpty()) + return; + + dataInputParameters = new HashMap(); + + String theDataInputs = dataInputs.get(0); + String[] splittedParams = theDataInputs.split(";"); + + for (String splitParam : splittedParams) { + try { + String[] keyvalue = splitParam.split("="); + dataInputParameters.put(keyvalue[0], keyvalue[1]); + } catch (Exception e) { + + } + } + + flexTable.setWidget(0, 0, new HTML("Batch Type:")); + flexTable.setWidget(0, 1, new HTML(toShowBatchTypeValue)); + //flexTable.setWidget(1, 0, new HTML("Level:")); + //flexTable.setWidget(1, 1, new HTML(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM))); + + String KPINames = ""; + for (KPI kpi : selectedKPIs) { + KPINames += kpi.getName() + ", "; + } + KPINames = KPINames.substring(0, KPINames.length() - 2); + flexTable.setWidget(2, 0, new HTML("KPI:")); + flexTable.setWidget(2, 1, new HTML(KPINames)); + + // CHANGING LABEL TEXT TO SCAPE_PARAM + // uib_label_focus_id.setText(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM) + // + " ID"); + + fillDeaListBoxes(); + + } catch (Exception e) { + // silent + } + + field_parameters_container.add(flexTable); + } + + /** + * Fill dea list boxes. + */ + private void fillDeaListBoxes() { + list_dea_kpi.clear(); + for (KPI kpi : selectedKPIs) { + list_dea_kpi.addItem(kpi.getName()); + } + list_dea_input_kpi.clear(); + list_dea_output_kpi.clear(); + + } + + /** + * Gets the KPI for indexes. + * + * @param rowIndex + * the row index + * @param columnIndex + * the column index + * @return the KPI for indexes + */ + public List getKPIForIndexes(int rowIndex, int columnIndex) { + String key = generateKey(rowIndex, columnIndex); + return kpiMapPointers.get(key); + } + + /** + * Generate key. + * + * @param rowIndex + * the row index + * @param columnIndex + * the column index + * @return the string + */ + private String generateKey(int rowIndex, int columnIndex) { + return rowIndex + "-" + columnIndex; + } + + /** + * Call dea analysis. + * + * @param inputKPINames + * the input kpi names + * @param outputKPINames + * the output kpi names + * @param button + * the button + */ + private void callDeaAnalysis(List inputKPINames, List outputKPINames, Button button) { + + HorizontalPanel hp = new HorizontalPanel(); + hp.getElement().addClassName("ext-horizontal-panel-without-margin"); + VerticalPanel deaAnalysis = new VerticalPanel(); + hp.add(deaAnalysis); + uib_vp_deanalanlysis_algorithm_container.add(hp); + + // TODO + final FlexTable flexTable = new FlexTable(); + flexTable.setStyleName("colgrouptable"); + + StringBuilder stringInputKPINamesBuilder = new StringBuilder(); + List inputKPI = new ArrayList(); + for (String kpiName : inputKPINames) { + inputKPI.add(getKPIForName(kpiName)); + if (stringInputKPINamesBuilder.toString() == null || stringInputKPINamesBuilder.toString().isEmpty()) { + stringInputKPINamesBuilder.append(kpiName); + } else { + stringInputKPINamesBuilder.append(","); + stringInputKPINamesBuilder.append(kpiName); + } + + } + + StringBuilder stringOutputKPINamesBuilder = new StringBuilder(); + List outputKPI = new ArrayList(); + for (String kpiName : outputKPINames) { + outputKPI.add(getKPIForName(kpiName)); + if (stringOutputKPINamesBuilder.toString() == null || stringOutputKPINamesBuilder.toString().isEmpty()) { + stringOutputKPINamesBuilder.append(kpiName); + } else { + stringOutputKPINamesBuilder.append(","); + stringOutputKPINamesBuilder.append(kpiName); + } + } + + ///// + + flexTable.setWidget(0, 0, new HTML("Selected Input KPI:")); + flexTable.setWidget(0, 1, new HTML(stringInputKPINamesBuilder.toString())); + flexTable.setWidget(1, 0, new HTML("Selected Output KPI:")); + flexTable.setWidget(1, 1, new HTML(stringOutputKPINamesBuilder.toString())); + flexTable.addStyleName("the_margin_top_bottom"); + + deaAnalysis.add(flexTable); + + ///// + + GWT.log("Calling Dea Analysys..."); + GWT.log("KPI Input: " + inputKPI); + GWT.log("KPI Output: " + outputKPI); + uib_vp_deanalanlysis_algorithm.setVisible(true); + callDataMinerServiceForChart(dataInputParameters, inputKPI, outputKPI, DataMinerAlgorithms.DEA_ANALYSIS, + deaAnalysis); + } + + /** + * Display output files as static entities. + * + * @param dmResponse + * the dm response + * @param chartType + * the chart type + * @param inputKPIs + * the input kp is + * @param outputKPIs + * the output kp is + * @param focusID + * the focus id + * @param container + * the container + * @param displayError + * the display error + */ + private void displayOutputFilesAsStaticEntities(DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, + List inputKPIs, List outputKPIs, final String focusID, final Panel container, + boolean displayError) { + + String title = displayError ? "No results " : ""; + title += chartType.getTitle(); + title += inputKPIs.size() > 1 ? " [Input KPIs: " : " [Input KPI: "; + + for (KPI kpi : inputKPIs) { + title += " " + kpi.getName() + ","; + } + + title = title.substring(0, title.length() - 1) + "]"; + + if (outputKPIs != null && outputKPIs.size() > 0) { + title += inputKPIs.size() > 1 ? " [Output KPIs: " : " [Output KPI: "; + for (KPI kpi : outputKPIs) { + title += " " + kpi.getName() + ","; + } + title = title.substring(0, title.length() - 1) + "]"; + } + + // title+= " Focus "+focusID; + + if (displayError) { + Alert alert = new Alert(title); + alert.setType(AlertType.ERROR); + alert.setClose(false); + alert.getElement().getStyle().setMargin(10, Unit.PX); + container.add(alert); + return; + } + + final String toTitle = title; + + for (final OutputFile outputFile : dmResponse.getListOutput()) { + + switch (outputFile.getDataType()) { + case IMAGE: + PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + showAlert(caught.getMessage(), AlertType.ERROR, true, + uib_vp_deanalanlysis_request_container); + + } + + @Override + public void onSuccess(String base64Content) { + + String title = toTitle; + switch (chartType) { + case BOXPLOT: + break; + case SPEEDOMETER: + title += " " + uib_label_focus_id.getText() + ": " + focusID; + break; + case CORRELATION: + break; + case DEA_ANALYSIS: + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + break; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + break; + case SCATTER: + break; + default: + break; + + } + + ShowResult showResult = new ShowResult(title,TextAlign.LEFT); + showResult.showImage(base64Content); + container.add(showResult); + + } + }); + break; + case CSV: + PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + showAlert(caught.getMessage(), AlertType.ERROR, true, + uib_vp_deanalanlysis_request_container); + } + + @Override + public void onSuccess(CSVFile result) { + GWT.log("Displaying: " + result); + String cssTableStyle = "simpletable"; + String title = toTitle; + switch (chartType) { + case BOXPLOT: + title += " Statistics on all data"; + break; + case SPEEDOMETER: + title += " " + uib_label_focus_id.getText() + ": " + focusID; + break; + case CORRELATION: + break; + case DEA_ANALYSIS: + break; + case DEA_CHART: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY: + break; + case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW: + break; + case PERFORMFISH_SYNOPTIC_TABLE_FARM: + break; + case SCATTER: + break; + default: + break; + + } + + ShowResult showResult = new ShowResult(title,TextAlign.LEFT); + showResult.showCSVFile(result, cssTableStyle); + container.add(showResult); + } + }); + break; + + default: + break; + } + + } + + } + + /** + * Call data miner service for chart. + * + * @param dataInputParameters + * the data input parameters + * @param inputKPI + * the input kpi + * @param outputKPI + * the output kpi + * @param chartType + * the chart type + * @param focusID + * the focus id + * @param panel + * the panel + */ + private void callDataMinerServiceForChart(Map dataInputParameters, final List inputKPI, + final List outputKPI, final DataMinerAlgorithms chartType, final ComplexPanel panel) { + + GWT.log("Call DM wiht Selected KPI"); + StringBuilder dataInputsFormatter = new StringBuilder(); + // String scalePValue = + // dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM); + // dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM+"="+scalePValue+";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + chartType + ";"); + + String years = dataInputParameters.get(PerformFishAnalyticsConstant.DM_YEARS_PARAM); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM + "=" + years + ";"); + + if (inputKPI != null && inputKPI.size() > 0) { + String kpiCodes = ""; + for (KPI kpi : inputKPI) { + kpiCodes += kpi.getCode() + "|"; + } + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + + GWT.log("Input KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM + "=" + kpiCodes + ";"); + + } + + if (outputKPI != null && outputKPI.size() > 0) { + String kpiCodes = ""; + for (KPI kpi : outputKPI) { + kpiCodes += kpi.getCode() + "|"; + } + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + + GWT.log("Output KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM + "=" + kpiCodes + ";"); + + } + + final String focusID = dataInputParameters.get(PerformFishAnalyticsConstant.DM_FOCUS_PARAM); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=" + focusID + ";"); + + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_APDISEASES + "=null;"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ABDISEASES + "=null;"); + + dataInputsFormatter.append( + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable.getDataMinerTable() + + "=" + + dataInputParameters + .get(PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable + .getDataMinerTable()) + + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable + .getDataMinerTable() + + "=" + + dataInputParameters + .get(PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable.getDataMinerTable()) + + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable + .getDataMinerTable() + + "=" + + dataInputParameters.get( + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable.getDataMinerTable()) + + ";"); + dataInputsFormatter.append( + PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable.getDataMinerTable() + "=" + + dataInputParameters + .get(PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable + .getDataMinerTable()) + + ";"); + + String dataInParameters = dataInputsFormatter.toString(); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); + + Map> mapParameters = new HashMap>(); + mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); + + final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to Dea Analysis..."); + loaderIcon.getElement().getStyle().setMarginTop(10, Unit.PX); + loaderIcon.setVisible(true); + panel.setVisible(true); + panel.add(loaderIcon); + Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { + @Override + public void execute() { + loaderIcon.setFocus(true); + } + }); + + PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualAnalysis(mapParameters, + new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + loaderIcon.setVisible(false); + // field_unary_algorithm.setVisible(true); + GWT.log("I'm displaying: " + dmResponse); + displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, + false); + } + + @Override + public void onFailure(Throwable caught) { + loaderIcon.setVisible(false); + displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, + true); + + } + }); + } +} diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.ui.xml b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.ui.xml new file mode 100644 index 0000000..a24e4ba --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewannualbinder/DeaAnnualPanelResult.ui.xml @@ -0,0 +1,119 @@ + + + + .paddingLeft { + padding-left: 10px; + } + + + + + + + + + + Focus + ID + + + + + + + + + + + + + + + + + + Input KPI + + + + + + + + + + + + + + + + + + KPI + + + + + + + + + + + + + + + + + + Output KPI + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.java index 84829ca..593e9a9 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.java @@ -3,7 +3,6 @@ */ package org.gcube.portlets.user.performfishanalytics.client.viewbinder; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -14,7 +13,6 @@ import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsC import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsServiceAsync; import org.gcube.portlets.user.performfishanalytics.client.controllers.PerformFishAnalyticsController; import org.gcube.portlets.user.performfishanalytics.client.event.CallAlgorithmEvent; -import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.client.view.util.CorrelationValueToColourUtil; import org.gcube.portlets.user.performfishanalytics.shared.FileContentType; import org.gcube.portlets.user.performfishanalytics.shared.KPI; @@ -24,14 +22,11 @@ import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVRow; import org.gcube.portlets.user.performfishanalytics.shared.dataminer.DataMinerResponse; import com.github.gwtbootstrap.client.ui.Alert; -import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.CheckBox; import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -46,7 +41,6 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; @@ -98,50 +92,15 @@ public class AnalyticsPanelResult extends Composite { @UiField VerticalPanel field_unary_algorithm; - @UiField - ControlGroup cg_list_dea_input_kpi; - - @UiField - ControlGroup cg_list_dea_output_kpi; - - @UiField - ListBox list_dea_input_kpi; - - @UiField - ListBox list_dea_output_kpi; - @UiField Label uib_label_focus_id; -// @UiField -// ControlGroup cg_focus_id_dea; - - @UiField - HorizontalPanel uib_vp_deanalanlysis_request_container; - @UiField ControlGroup cg_focus_id_correlation; -// @UiField -// ListBox field_list_focus_id_dea; - - @UiField - VerticalPanel uib_vp_deanalanlysis_algorithm; - - @UiField - VerticalPanel uib_vp_deanalanlysis_algorithm_container; - @UiField ListBox field_list_focus_id_correlation; - @UiField - Button button_dea_analys_request; - - @UiField - CheckBox uib_check_all_input_kpi; - - @UiField - CheckBox uib_check_all_output_kpi; private Map dataInputParameters; @@ -169,83 +128,6 @@ public class AnalyticsPanelResult extends Composite { public AnalyticsPanelResult() { initWidget(uiBinder.createAndBindUi(this)); - - button_dea_analys_request.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - cg_list_dea_input_kpi.setType(ControlGroupType.NONE); - cg_list_dea_output_kpi.setType(ControlGroupType.NONE); - - if(list_dea_input_kpi.getSelectedIndex()==-1){ - showAlert("You must select at least one Input KPI", AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - cg_list_dea_input_kpi.setType(ControlGroupType.ERROR); - return; - } - - if(list_dea_output_kpi.getSelectedIndex()==-1){ - showAlert("You must select at least one Output KPI", AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - cg_list_dea_output_kpi.setType(ControlGroupType.ERROR); - return; - } - - List inputKPINames = getSelected(list_dea_input_kpi); - List outputKPINames = getSelected(list_dea_output_kpi); - callDeaAnalysis(inputKPINames, outputKPINames, button_dea_analys_request); - } - }); - - uib_check_all_input_kpi.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - boolean isChecked = uib_check_all_input_kpi.getValue(); - selectAllFields(list_dea_input_kpi, isChecked); - } - }); - - uib_check_all_output_kpi.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - boolean isChecked = uib_check_all_output_kpi.getValue(); - selectAllFields(list_dea_output_kpi, isChecked); - } - }); - } - - /** - * Select all fields. - * - * @param listBox the list box - * @param selected the selected - */ - private void selectAllFields(ListBox listBox, boolean selected){ - - for (int i=0; i getSelected(ListBox listBox){ - List selected = new ArrayList(); - for (int i=0; i0){ -// for (KPI kpi : listKPI) { -// -// if(kpi!=null){ -// kpiNames+=" "+kpi.getName() +";"; -// }else -// GWT.log("KPI NULL for "+key); -// -// -// } -// GWT.log("FILLING kpiMapPointers with key: "+key +" and value: "+kpiNames); -// }else -// GWT.log("FILLING kpiMapPointers with key: "+key +" and value: "+listKPI); - } /** @@ -728,37 +560,6 @@ public class AnalyticsPanelResult extends Composite { } -// /** -// * Call scatter and dea chart. -// * -// * @param rowIndex the row index -// * @param columnIndex the column index -// * @param button the button -// */ -// private void callScatterAndDeaChart(int rowIndex, int columnIndex, Button button){ -// -// String focusID = checkValidFocusID(); -// -// if(focusID==null) -// return; -// -// GWT.log("Called ScatterAndDeaChart at rowIndex: "+rowIndex +", columnIndex: "+columnIndex); -// HorizontalPanel hp = new HorizontalPanel(); -// hp.getElement().addClassName("ext-horizontal-panel"); -// HorizontalPanel scatter = new HorizontalPanel(); -// HorizontalPanel deaChart = new HorizontalPanel(); -// hp.add(scatter); -// hp.add(deaChart); -// //hp.getElement().addClassName("ext-horizontal-panel"); -// field_binary_algorithm_container.add(hp); -// List selectedKPI = getKPIForIndexes(rowIndex, columnIndex); -// GWT.log("Selected KPI: "+selectedKPI); -// field_binary_algorithm.setVisible(true); -// callDataMinerServiceForChart(dataInputParameters, selectedKPI, null, DataMinerAlgorithms.SCATTER, focusID, scatter); -// callDataMinerServiceForChart(dataInputParameters, selectedKPI, null, DataMinerAlgorithms.DEA_CHART, focusID, deaChart); -// } - - /** * Call scatter. * @@ -780,240 +581,9 @@ public class AnalyticsPanelResult extends Composite { } - /** - * Call dea analysis. - * - * @param inputKPINames the input kpi names - * @param outputKPINames the output kpi names - * @param button the button - */ - private void callDeaAnalysis(List inputKPINames, List outputKPINames, Button button){ - - HorizontalPanel hp = new HorizontalPanel(); - hp.getElement().addClassName("ext-horizontal-panel"); - HorizontalPanel deaAnalysis = new HorizontalPanel(); - hp.add(deaAnalysis); - //hp.getElement().addClassName("ext-horizontal-panel"); - uib_vp_deanalanlysis_algorithm_container.add(hp); - - List inputKPI = new ArrayList(); - for (String kpiName : inputKPINames) { - inputKPI.add(getKPIForName(kpiName)); - } - - List outputKPI = new ArrayList(); - for (String kpiName : outputKPINames) { - outputKPI.add(getKPIForName(kpiName)); - } + - GWT.log("Calling Dea Analysys... with input: "+inputKPI+" and output: "+outputKPI); - uib_vp_deanalanlysis_algorithm.setVisible(true); - callDataMinerServiceForChart(dataInputParameters, inputKPI, outputKPI, DataMinerAlgorithms.DEA_ANALYSIS, "ID", deaAnalysis); - } - - /** - * Display output files as static entities. - * - * @param dmResponse the dm response - * @param chartType the chart type - * @param inputKPIs the input kp is - * @param outputKPIs the output kp is - * @param focusID the focus id - * @param container the container - * @param displayError the display error - */ - private void displayOutputFilesAsStaticEntities(DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, List inputKPIs, List outputKPIs, final String focusID, final Panel container, boolean displayError){ - - String title = displayError?"No results ":""; - title+=chartType.getTitle(); - title+=inputKPIs.size()>1?" [Input KPIs: ":" [Input KPI: "; - - for (KPI kpi : inputKPIs) { - title+=" "+kpi.getName()+","; - } - - title = title.substring(0,title.length()-1)+"]"; - - - if(outputKPIs!=null && outputKPIs.size()>0){ - title+=inputKPIs.size()>1?" [Output KPIs: ":" [Output KPI: "; - for (KPI kpi : outputKPIs) { - title+=" "+kpi.getName()+","; - } - title = title.substring(0,title.length()-1)+"]"; - } - - //title+= " Focus "+focusID; - - if(displayError){ - Alert alert = new Alert(title); - alert.setType(AlertType.ERROR); - alert.setClose(false); - alert.getElement().getStyle().setMargin(10, Unit.PX); - container.add(alert); - return; - } - - final String toTitle = title; - - for (final OutputFile outputFile : dmResponse.getListOutput()) { - - switch (outputFile.getDataType()) { - case IMAGE: - PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - - } - - @Override - public void onSuccess(String base64Content) { - - String title = toTitle; - switch (chartType) { - case BOXPLOT: - break; - case SPEEDOMETER: - title+= " "+uib_label_focus_id.getText()+": "+focusID; - break; - default: - break; - } - - - ShowResult showResult = new ShowResult(title); - showResult.showImage(base64Content); - container.add(showResult); - - } - }); - break; - case CSV: - PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container); - } - - @Override - public void onSuccess(CSVFile result) { - GWT.log("Displaying: "+result); - String cssTableStyle = "simpletable"; - String title = toTitle; - switch (chartType) { - case BOXPLOT: - title+= " Statistics on all data"; - break; - case SPEEDOMETER: - title+= " "+uib_label_focus_id.getText()+": "+focusID; - break; - default: - break; - } - - ShowResult showResult = new ShowResult(title); - showResult.showCSVFile(result, cssTableStyle); - container.add(showResult); - } - }); - break; - - default: - break; - } - - } - - } - - /** - * Call data miner service for chart. - * - * @param dataInputParameters the data input parameters - * @param inputKPI the input kpi - * @param outputKPI the output kpi - * @param chartType the chart type - * @param focusID the focus id - * @param panel the panel - */ - private void callDataMinerServiceForChart(Map dataInputParameters, final List inputKPI, final List outputKPI, final DataMinerAlgorithms chartType, final String focusID, final ComplexPanel panel) { - - GWT.log("Call DM wiht Selected KPI: "+inputKPI); - StringBuilder dataInputsFormatter = new StringBuilder(); - String scalePValue = dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM+"="+scalePValue+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM+"="+dataInputParameters.get(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM)+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+chartType+";"); - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM+"="+dataInputParameters.get(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM)+";"); - - - if(inputKPI!=null && inputKPI.size()>0){ - String kpiCodes = ""; - for (KPI kpi : inputKPI) { - kpiCodes+=kpi.getCode()+"|"; - } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); - - GWT.log("Input KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM+"="+kpiCodes+";"); - - } - - if(outputKPI!=null && outputKPI.size()>0){ - String kpiCodes = ""; - for (KPI kpi : outputKPI) { - kpiCodes+=kpi.getCode()+"|"; - } - //remove last | - kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1); - - GWT.log("Output KPICodes: "+kpiCodes); - //ADDING KPIs code - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM+"="+kpiCodes+";"); - - } - - dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+focusID+";"); - - String dataInParameters = dataInputsFormatter.toString(); - GWT.log("Calling DM service with client input parameters: "+dataInParameters); - - Map> mapParameters = new HashMap>(); - mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); - - final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to "+chartType.getTitle()+" Analysis..."); - loaderIcon.setVisible(true); - panel.setVisible(true); - panel.add(loaderIcon); - Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { - @Override - public void execute() { - loaderIcon.setFocus(true); - }}); - - PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters, new AsyncCallback() { - - @Override - public void onSuccess(DataMinerResponse dmResponse) { - loaderIcon.setVisible(false); - //field_unary_algorithm.setVisible(true); - GWT.log("I'm displaying: "+dmResponse); - displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, false); - } - - @Override - public void onFailure(Throwable caught) { - loaderIcon.setVisible(false); - displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, true); - - } - }); - } + } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.ui.xml b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.ui.xml index 7a5e3a9..739f5b4 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.ui.xml +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/AnalyticsPanelResult.ui.xml @@ -14,13 +14,9 @@ addStyleNames="the_margin_top_bottom"> - - - - - Focus ID + Focus + ID + + + + - - - - Input KPI - - - - - - - - - - - - Output - KPI - - - - - - - - - - - - - - - - - @@ -92,13 +51,6 @@ - - - - - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.java new file mode 100644 index 0000000..35df777 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.java @@ -0,0 +1,876 @@ +/** + * + */ +package org.gcube.portlets.user.performfishanalytics.client.viewbinder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.gcube.portlets.user.performfishanalytics.client.DataMinerAlgorithms; +import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsConstant; +import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsServiceAsync; +import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; +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; +import org.gcube.portlets.user.performfishanalytics.shared.dataminer.DataMinerResponse; + +import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.ControlGroup; +import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.constants.AlertType; +import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; +import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.dom.client.Style.TextAlign; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.ComplexPanel; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlexTable; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Panel; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; + +/** + * The Class AnalyticsPanelResult. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 29, 2019 + */ +public class DeaPanelResult extends Composite { + + /** + * + */ + + private static DeaPanelResultUiBinder uiBinder = GWT.create(DeaPanelResultUiBinder.class); + + /** + * The Interface AnalyticsPanelResultUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR + * (francesco.mangiacrapa@isti.cnr.it) Jan 30, 2019 + */ + interface DeaPanelResultUiBinder extends UiBinder { + } + + @UiField + HTMLPanel field_html_panel; + + @UiField + VerticalPanel field_parameters_container; + + @UiField + Label uib_label_focus_id; + + @UiField + ControlGroup cg_focus_id_correlation; + + @UiField + ListBox field_list_focus_id_correlation; + + @UiField + ComplexPanel alert_info; + + @UiField + ComplexPanel alert_error; + + @UiField + ControlGroup cg_list_dea_kpi; + + @UiField + ControlGroup cg_list_dea_input_kpi; + + @UiField + ControlGroup cg_list_dea_output_kpi; + + @UiField + ListBox list_dea_kpi; + + @UiField + ListBox list_dea_input_kpi; + + @UiField + ListBox list_dea_output_kpi; + + @UiField + HorizontalPanel uib_vp_deanalanlysis_request_container; + + @UiField + VerticalPanel uib_vp_deanalanlysis_algorithm; + + @UiField + VerticalPanel uib_vp_deanalanlysis_algorithm_container; + + @UiField + Button button_dea_analys_request; + + @UiField + Button uib_add_to_input_kpi; + @UiField + Button uib_remove_from_input_kpi; + @UiField + Button uib_add_to_output_kpi; + @UiField + Button uib_remove_from_output_kpi; + + @UiField + Button uib_reset_input_kpi; + + @UiField + Button uib_reset_output_kpi; + + private enum KpiButtonType { + KPI, INPUT_KPI, OUTPUT_KPI + } + + private Map dataInputParameters; + + private DataMinerResponse dmResponse; + + private Map> kpiMapPointers = new HashMap>(); + + private List selectedKPIs; + + //private List selectedAreas; + + /** + * Because this class has a default constructor, it can be used as a binder + * template. In other words, it can be used in other *.ui.xml files as + * follows: + * Hello! Note that + * depending on the widget that is used, it may be necessary to implement + * HasHTML instead of HasText. + */ + public DeaPanelResult() { + GWT.log("DeaPanelResult"); + + initWidget(uiBinder.createAndBindUi(this)); + + button_dea_analys_request.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + alert_error.clear(); + cg_list_dea_input_kpi.setType(ControlGroupType.NONE); + cg_list_dea_output_kpi.setType(ControlGroupType.NONE); + + if (list_dea_input_kpi.getItemCount() < 1) { + showAlert("You must select at least one Input KPI", AlertType.ERROR, true, alert_error); + cg_list_dea_input_kpi.setType(ControlGroupType.ERROR); + return; + } + + if (list_dea_output_kpi.getItemCount() < 1) { + showAlert("You must select at least one Output KPI", AlertType.ERROR, true, alert_error); + cg_list_dea_output_kpi.setType(ControlGroupType.ERROR); + return; + } + + List inputKPINames = new ArrayList(); + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + inputKPINames.add(list_dea_input_kpi.getItemText(i)); + } + + List outputKPINames = new ArrayList(); + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + outputKPINames.add(list_dea_output_kpi.getItemText(i)); + } + + callDeaAnalysis(inputKPINames, outputKPINames, button_dea_analys_request); + } + }); + + uib_add_to_input_kpi.setIcon(IconType.BACKWARD); + uib_add_to_input_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + addListFields(KpiButtonType.INPUT_KPI); + } + }); + + uib_remove_from_input_kpi.setIcon(IconType.FORWARD); + uib_remove_from_input_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + removeListFields(KpiButtonType.INPUT_KPI); + } + }); + + uib_add_to_output_kpi.setIcon(IconType.FORWARD); + uib_add_to_output_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + addListFields(KpiButtonType.OUTPUT_KPI); + } + }); + + uib_remove_from_output_kpi.setIcon(IconType.BACKWARD); + uib_remove_from_output_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + removeListFields(KpiButtonType.OUTPUT_KPI); + } + }); + + uib_reset_input_kpi.setIcon(IconType.REMOVE_CIRCLE); + uib_reset_input_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + resetListFields(KpiButtonType.INPUT_KPI); + } + }); + + uib_reset_output_kpi.setIcon(IconType.REMOVE_CIRCLE); + uib_reset_output_kpi.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + resetListFields(KpiButtonType.OUTPUT_KPI); + } + }); + + validateKPIList(); + } + + private void validateKPIList() { + if (list_dea_output_kpi.getItemCount() > 0 && list_dea_input_kpi.getItemCount() > 0) { + alert_info.clear(); + alert_error.clear(); + cg_list_dea_input_kpi.setType(ControlGroupType.NONE); + cg_list_dea_output_kpi.setType(ControlGroupType.NONE); + button_dea_analys_request.setEnabled(true); + + } else { + alert_info.clear(); + button_dea_analys_request.setEnabled(false); + showAlert("Please select Input and Output KPI", AlertType.INFO, true, alert_info); + } + } + + /** + * Add to Input or Output KPI selected + * + * @param kpiButtonType + * kpi button type + * + */ + private void addListFields(KpiButtonType kpiButtonType) { + List notSelected = null; + + switch (kpiButtonType) { + case INPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_kpi.getItemCount(); i++) { + if (list_dea_kpi.isItemSelected(i)) { + list_dea_input_kpi.addItem(list_dea_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_kpi.getItemText(i)); + } + } + list_dea_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_kpi.addItem(notSelected.get(i)); + } + break; + case KPI: + break; + case OUTPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_kpi.getItemCount(); i++) { + if (list_dea_kpi.isItemSelected(i)) { + list_dea_output_kpi.addItem(list_dea_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_kpi.getItemText(i)); + } + } + list_dea_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_kpi.addItem(notSelected.get(i)); + } + break; + default: + break; + } + + validateKPIList(); + + } + + /** + * Remove from Input or Output KPI selected + * + * @param kpiButtonType + * kpi button type + */ + private void removeListFields(KpiButtonType kpiButtonType) { + List notSelected = null; + + switch (kpiButtonType) { + case INPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + if (list_dea_input_kpi.isItemSelected(i)) { + list_dea_kpi.addItem(list_dea_input_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_input_kpi.getItemText(i)); + } + } + list_dea_input_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_input_kpi.addItem(notSelected.get(i)); + } + break; + case KPI: + break; + case OUTPUT_KPI: + notSelected = new ArrayList(); + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + if (list_dea_output_kpi.isItemSelected(i)) { + list_dea_kpi.addItem(list_dea_output_kpi.getItemText(i)); + } else { + notSelected.add(list_dea_output_kpi.getItemText(i)); + } + } + list_dea_output_kpi.clear(); + for (int i = 0; i < notSelected.size(); i++) { + list_dea_output_kpi.addItem(notSelected.get(i)); + } + break; + default: + break; + } + + validateKPIList(); + + } + + /** + * Reset Input or Output KPI selected + * + * @param kpiButtonType + * kpi button type + */ + private void resetListFields(KpiButtonType kpiButtonType) { + + switch (kpiButtonType) { + case INPUT_KPI: + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_input_kpi.getItemText(i)); + } + list_dea_input_kpi.clear(); + break; + case KPI: + for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_input_kpi.getItemText(i)); + } + list_dea_input_kpi.clear(); + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_output_kpi.getItemText(i)); + } + list_dea_output_kpi.clear(); + break; + case OUTPUT_KPI: + for (int i = 0; i < list_dea_output_kpi.getItemCount(); i++) { + list_dea_kpi.addItem(list_dea_output_kpi.getItemText(i)); + } + list_dea_output_kpi.clear(); + break; + default: + break; + } + + validateKPIList(); + } + + /** + * Gets the data miner response. + * + * @return the data miner response + */ + public DataMinerResponse getDataMinerResponse() { + return dmResponse; + } + + /** + * Gets the data input parameters. + * + * @return the data input parameters + */ + public Map getDataInputParameters() { + + return dataInputParameters; + } + + /** + * Adds the list focus ids. + * + * @param listFocusIDs + * the list focus I ds + */ + public void addListFocusIds(List listFocusIDs) { + for (String batchID : listFocusIDs) { + field_list_focus_id_correlation.addItem(batchID, batchID); + } + } + + /** + * Show alert. + * + * @param error + * the error + * @param type + * the type + * @param closable + * the closable + * @param panel + * the panel + */ + private void showAlert(String error, AlertType type, boolean closable, ComplexPanel panel) { + Alert alert = new Alert(error); + alert.setType(type); + alert.setClose(closable); + alert.getElement().getStyle().setMargin(10, Unit.PX); + panel.add(alert); + } + + /** + * Adds the selected kp is. + * + * @param selectedKPIs + * the selected kp is + */ + public void addSelectedKPIs(List selectedKPIs) { + + this.selectedKPIs = selectedKPIs; + + } + + /** + * Adds the selected areas. + * + * @param listAreas + * the list areas + */ + /*public void addSelectedAreas(List listAreas) { + + this.selectedAreas = listAreas; + + }*/ + + /** + * Gets the KPI for name. + * + * @param name + * the name + * @return the KPI for name + */ + public KPI getKPIForName(String name) { + + GWT.log("Searching KPI name: " + name); + KPI foundKPI = null; + String purgedName = name.trim(); + for (KPI kpi : selectedKPIs) { + String purgedKPIName = kpi.getName().trim(); + if (purgedKPIName.compareToIgnoreCase(purgedName) == 0) { + foundKPI = kpi; + break; + } + } + GWT.log("FOUND KPI: " + foundKPI); + return foundKPI; + } + + /** + * Adds the parameters. + * + * @param keyToGet + * the key to get + * @param parameters + * the parameters + * @param toShowBatchTypeValue + * label to show batch type value + */ + public void addParameters(String keyToGet, Map> parameters, String toShowBatchTypeValue) { + + final FlexTable flexTable = new FlexTable(); + flexTable.setStyleName("colgrouptable"); + + try { + List dataInputs = parameters.get(keyToGet); + + if (dataInputs == null || dataInputs.isEmpty()) + return; + + dataInputParameters = new HashMap(); + + String theDataInputs = dataInputs.get(0); + String[] splittedParams = theDataInputs.split(";"); + + for (String splitParam : splittedParams) { + try { + String[] keyvalue = splitParam.split("="); + dataInputParameters.put(keyvalue[0], keyvalue[1]); + } catch (Exception e) { + + } + } + + flexTable.setWidget(0, 0, new HTML("Batch Type:")); + flexTable.setWidget(0, 1, new HTML(toShowBatchTypeValue)); + flexTable.setWidget(1, 0, new HTML("Level:")); + flexTable.setWidget(1, 1, new HTML(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM))); + + String KPINames = ""; + for (KPI kpi : selectedKPIs) { + KPINames += kpi.getName() + ", "; + } + KPINames = KPINames.substring(0, KPINames.length() - 2); + flexTable.setWidget(2, 0, new HTML("KPI:")); + flexTable.setWidget(2, 1, new HTML(KPINames)); + + // CHANGING LABEL TEXT TO SCAPE_PARAM + uib_label_focus_id.setText(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM) + " ID"); + + fillDeaListBoxes(); + + } catch (Exception e) { + // silent + } + + field_parameters_container.add(flexTable); + } + + /** + * Fill dea list boxes. + */ + private void fillDeaListBoxes() { + list_dea_kpi.clear(); + for (KPI kpi : selectedKPIs) { + list_dea_kpi.addItem(kpi.getName()); + } + list_dea_input_kpi.clear(); + list_dea_output_kpi.clear(); + + } + + /** + * Gets the KPI for indexes. + * + * @param rowIndex + * the row index + * @param columnIndex + * the column index + * @return the KPI for indexes + */ + public List getKPIForIndexes(int rowIndex, int columnIndex) { + String key = generateKey(rowIndex, columnIndex); + return kpiMapPointers.get(key); + } + + /** + * Generate key. + * + * @param rowIndex + * the row index + * @param columnIndex + * the column index + * @return the string + */ + private String generateKey(int rowIndex, int columnIndex) { + return rowIndex + "-" + columnIndex; + } + + /** + * Call dea analysis. + * + * @param inputKPINames + * the input kpi names + * @param outputKPINames + * the output kpi names + * @param button + * the button + */ + private void callDeaAnalysis(List inputKPINames, List outputKPINames, Button button) { + + HorizontalPanel hp = new HorizontalPanel(); + hp.getElement().addClassName("ext-horizontal-panel-without-margin"); + VerticalPanel deaAnalysis = new VerticalPanel(); + hp.add(deaAnalysis); + uib_vp_deanalanlysis_algorithm_container.add(hp); + + // TODO + final FlexTable flexTable = new FlexTable(); + flexTable.setStyleName("colgrouptable"); + + StringBuilder stringInputKPINamesBuilder = new StringBuilder(); + List inputKPI = new ArrayList(); + for (String kpiName : inputKPINames) { + inputKPI.add(getKPIForName(kpiName)); + if (stringInputKPINamesBuilder.toString() == null || stringInputKPINamesBuilder.toString().isEmpty()) { + stringInputKPINamesBuilder.append(kpiName); + } else { + stringInputKPINamesBuilder.append(","); + stringInputKPINamesBuilder.append(kpiName); + } + + } + + StringBuilder stringOutputKPINamesBuilder = new StringBuilder(); + List outputKPI = new ArrayList(); + for (String kpiName : outputKPINames) { + outputKPI.add(getKPIForName(kpiName)); + if (stringOutputKPINamesBuilder.toString() == null || stringOutputKPINamesBuilder.toString().isEmpty()) { + stringOutputKPINamesBuilder.append(kpiName); + } else { + stringOutputKPINamesBuilder.append(","); + stringOutputKPINamesBuilder.append(kpiName); + } + } + + ///// + + flexTable.setWidget(0, 0, new HTML("Selected Input KPI:")); + flexTable.setWidget(0, 1, new HTML(stringInputKPINamesBuilder.toString())); + flexTable.setWidget(1, 0, new HTML("Selected Output KPI:")); + flexTable.setWidget(1, 1, new HTML(stringOutputKPINamesBuilder.toString())); + flexTable.addStyleName("the_margin_top_bottom"); + + deaAnalysis.add(flexTable); + + ///// + + GWT.log("Calling Dea Analysys... with input: " + inputKPI + " and output: " + outputKPI); + uib_vp_deanalanlysis_algorithm.setVisible(true); + callDataMinerServiceForChart(dataInputParameters, inputKPI, outputKPI, DataMinerAlgorithms.DEA_ANALYSIS, "ID", + deaAnalysis); + } + + /** + * Display output files as static entities. + * + * @param dmResponse + * the dm response + * @param chartType + * the chart type + * @param inputKPIs + * the input kp is + * @param outputKPIs + * the output kp is + * @param focusID + * the focus id + * @param container + * the container + * @param displayError + * the display error + */ + private void displayOutputFilesAsStaticEntities(DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, + List inputKPIs, List outputKPIs, final String focusID, final Panel container, + boolean displayError) { + + String title = displayError ? "No results " : ""; + title += chartType.getTitle(); + title += inputKPIs.size() > 1 ? " [Input KPIs: " : " [Input KPI: "; + + for (KPI kpi : inputKPIs) { + title += " " + kpi.getName() + ","; + } + + title = title.substring(0, title.length() - 1) + "]"; + + if (outputKPIs != null && outputKPIs.size() > 0) { + title += inputKPIs.size() > 1 ? " [Output KPIs: " : " [Output KPI: "; + for (KPI kpi : outputKPIs) { + title += " " + kpi.getName() + ","; + } + title = title.substring(0, title.length() - 1) + "]"; + } + + // title+= " Focus "+focusID; + + if (displayError) { + Alert alert = new Alert(title); + alert.setType(AlertType.ERROR); + alert.setClose(false); + alert.getElement().getStyle().setMargin(10, Unit.PX); + container.add(alert); + return; + } + + final String toTitle = title; + + for (final OutputFile outputFile : dmResponse.getListOutput()) { + + switch (outputFile.getDataType()) { + case IMAGE: + PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + showAlert(caught.getMessage(), AlertType.ERROR, true, + uib_vp_deanalanlysis_request_container); + + } + + @Override + public void onSuccess(String base64Content) { + + String title = toTitle; + ShowResult showResult = new ShowResult(title,TextAlign.LEFT); + showResult.showImage(base64Content); + container.add(showResult); + + } + }); + break; + case CSV: + PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + showAlert(caught.getMessage(), AlertType.ERROR, true, + uib_vp_deanalanlysis_request_container); + } + + @Override + public void onSuccess(CSVFile result) { + GWT.log("Displaying: " + result); + String cssTableStyle = "simpletable"; + String title = toTitle; + + ShowResult showResult = new ShowResult(title,TextAlign.LEFT); + showResult.showCSVFile(result, cssTableStyle); + container.add(showResult); + } + }); + break; + + default: + break; + } + + } + + } + + /** + * Call data miner service for chart. + * + * @param dataInputParameters + * the data input parameters + * @param inputKPI + * the input kpi + * @param outputKPI + * the output kpi + * @param chartType + * the chart type + * @param focusID + * the focus id + * @param panel + * the panel + */ + private void callDataMinerServiceForChart(Map dataInputParameters, final List inputKPI, + final List outputKPI, final DataMinerAlgorithms chartType, final String focusID, + final ComplexPanel panel) { + + GWT.log("Call DM wiht Selected KPI: " + inputKPI); + StringBuilder dataInputsFormatter = new StringBuilder(); + String scalePValue = dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM + "=" + scalePValue + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM + "=" + + dataInputParameters.get(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM) + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM + "=" + chartType + ";"); + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM + "=" + + dataInputParameters.get(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM) + ";"); + + if (inputKPI != null && inputKPI.size() > 0) { + String kpiCodes = ""; + for (KPI kpi : inputKPI) { + kpiCodes += kpi.getCode() + "|"; + } + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + + GWT.log("Input KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM + "=" + kpiCodes + ";"); + + } + + if (outputKPI != null && outputKPI.size() > 0) { + String kpiCodes = ""; + for (KPI kpi : outputKPI) { + kpiCodes += kpi.getCode() + "|"; + } + // remove last | + kpiCodes = kpiCodes.substring(0, kpiCodes.length() - 1); + + GWT.log("Output KPICodes: " + kpiCodes); + // ADDING KPIs code + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM + "=" + kpiCodes + ";"); + + } + + dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=" + focusID + ";"); + + String dataInParameters = dataInputsFormatter.toString(); + GWT.log("Calling DM service with client input parameters: " + dataInParameters); + + Map> mapParameters = new HashMap>(); + mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters)); + + final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to Dea Analysis..."); + loaderIcon.getElement().getStyle().setMarginTop(10, Unit.PX); + loaderIcon.setVisible(true); + panel.setVisible(true); + panel.add(loaderIcon); + Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { + @Override + public void execute() { + loaderIcon.setFocus(true); + } + }); + + PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters, + new AsyncCallback() { + + @Override + public void onSuccess(DataMinerResponse dmResponse) { + loaderIcon.setVisible(false); + // field_unary_algorithm.setVisible(true); + GWT.log("I'm displaying: " + dmResponse); + displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, + false); + } + + @Override + public void onFailure(Throwable caught) { + loaderIcon.setVisible(false); + displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panel, + true); + + } + }); + } +} diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.ui.xml b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.ui.xml new file mode 100644 index 0000000..a24e4ba --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/DeaPanelResult.ui.xml @@ -0,0 +1,119 @@ + + + + .paddingLeft { + padding-left: 10px; + } + + + + + + + + + + Focus + ID + + + + + + + + + + + + + + + + + + Input KPI + + + + + + + + + + + + + + + + + + KPI + + + + + + + + + + + + + + + + + + Output KPI + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.java index 476e054..5f59620 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.java @@ -51,6 +51,9 @@ public class RecapSubmitPage extends Composite { @UiField Button uib_butt_correlation_analysis; + @UiField + Button uib_butt_dea_analysis; + @UiField VerticalPanel recapPanel; @@ -146,6 +149,18 @@ public class RecapSubmitPage extends Composite { } }); + + uib_butt_dea_analysis.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + DataMinerAlgorithms chartType = DataMinerAlgorithms.valueOf(uib_butt_dea_analysis.getName()); + + theEventBus.fireEvent(new SubmitRequestEvent(chartType)); + } + }); + uib_button_load_synoptic_table.addClickHandler(new ClickHandler() { @Override @@ -205,6 +220,15 @@ public class RecapSubmitPage extends Composite { public void activeCorrelationAnalysis(boolean active){ uib_butt_correlation_analysis.setEnabled(active); } + + /** + * Active dea analysis. + * + * @param active the active + */ + public void activeDeaAnalysis(boolean active){ + uib_butt_dea_analysis.setEnabled(active); + } /** * Active scatter plot. @@ -227,7 +251,7 @@ public class RecapSubmitPage extends Composite { activeSpeedometer(active); activeCorrelationAnalysis(active); activeBoxPlot(active); - + activeDeaAnalysis(active); } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.ui.xml b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.ui.xml index e4c4467..7b2f608 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.ui.xml +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/RecapSubmitPage.ui.xml @@ -34,6 +34,9 @@ + diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ShowResult.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ShowResult.java index bcca8c8..f2b9efe 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ShowResult.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/ShowResult.java @@ -52,12 +52,17 @@ public class ShowResult extends Composite { * @param title the title */ public ShowResult(String title) { + this(title, TextAlign.CENTER); + } + + public ShowResult(String title, TextAlign textAlign) { initWidget(uiBinder.createAndBindUi(this)); theTitle.getElement().addClassName("theSubTitle"); - theTitle.getElement().getStyle().setTextAlign(TextAlign.CENTER); + theTitle.getElement().getStyle().setTextAlign(textAlign); theTitle.setHTML(title); } + /** * Show image. diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/server/PerformFishAnalyticsServiceImpl.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/server/PerformFishAnalyticsServiceImpl.java index ff12f88..55b4c37 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/server/PerformFishAnalyticsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/server/PerformFishAnalyticsServiceImpl.java @@ -656,8 +656,13 @@ public class PerformFishAnalyticsServiceImpl extends RemoteServiceServlet DMServiceResponse dmResponse = null; String response; PortalContextInfo pContext = ContextUtil.getPortalContext(this.getThreadLocalRequest()); + String token= pContext.getUserToken(); + if(token==null || token.isEmpty()){ + log.error("Error retrieving the token: "+token); + throw new Exception("Error retrieving the token: "+token); + } try{ - response = new HttpCallerUtil(dataMinerService.getUrl(), null, null).performGETRequestWithRetry(dmServiceRequestParameters, pContext.getUserToken(), 5); + response = new HttpCallerUtil(dataMinerService.getUrl(), null, null).performGETRequestWithRetry(dmServiceRequestParameters,token, 5); if(response==null){ log.error("The presponse returned is null"); throw new Exception("The presponse returned is null"); diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/server/util/ContextUtil.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/server/util/ContextUtil.java index fa00ec0..1ec9217 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/server/util/ContextUtil.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/server/util/ContextUtil.java @@ -15,13 +15,11 @@ import org.slf4j.LoggerFactory; import com.liferay.portal.service.UserLocalServiceUtil; - - /** * The Class WsUtil. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Jan 11, 2019 + * Jan 11, 2019 */ public class ContextUtil { @@ -34,7 +32,6 @@ public class ContextUtil { public static String SERVICE_ENDPOINT_CATEGORY = "DataAnalysis"; public static String SERVICE_ENDPOINT_NAME = "DataMiner"; - /** * Checks if is within portal. * @@ -44,73 +41,76 @@ public class ContextUtil { try { UserLocalServiceUtil.getService(); return true; - } - catch (Exception ex) { - log.trace("Development Mode ON"); + } catch (Throwable ex) { + log.debug("Development Mode ON"); return false; } } - /** * Gets the portal context. * - * @param httpServletRequest the http servlet request + * @param httpServletRequest + * the http servlet request * @return the portal context */ - public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest){ + public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest) { PortalContext pContext = PortalContext.getConfiguration(); - //USER + // USER GCubeUser user = pContext.getCurrentUser(httpServletRequest); String username = user.getUsername(); String fullName = user.getFullname(); String email = user.getEmail(); String avatarID = user.getUserAvatarId(); String avatarURL = user.getUserAvatarURL(); - //SESSION + // SESSION String currentScope = pContext.getCurrentScope(httpServletRequest); String userToken = pContext.getCurrentUserToken(httpServletRequest); long currGroupId = pContext.getCurrentGroupId(httpServletRequest); - return new PortalContextInfo(username, fullName, email, avatarID, avatarURL, currentScope, userToken, currGroupId); + return new PortalContextInfo(username, fullName, email, avatarID, avatarURL, currentScope, userToken, + currGroupId); } - /** * Gets the portal context. * - * @param httpServletRequest the http servlet request - * @param overrideScope the override scope + * @param httpServletRequest + * the http servlet request + * @param overrideScope + * the override scope * @return the portal context */ - public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest, String overrideScope){ + public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest, String overrideScope) { PortalContextInfo info = getPortalContext(httpServletRequest); info.setCurrentScope(overrideScope); return info; } - /** * Checks if is session expired. * - * @param httpServletRequest the http servlet request + * @param httpServletRequest + * the http servlet request * @return true, if is session expired - * @throws Exception the exception + * @throws Exception + * the exception */ public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception { log.trace("workspace session validating..."); - return PortalContext.getConfiguration().getCurrentUser(httpServletRequest)==null; + return PortalContext.getConfiguration().getCurrentUser(httpServletRequest) == null; } - /** * Gets the entity factory. * - * @param request the request + * @param request + * the request * @return the entity factory - * @throws Exception the exception + * @throws Exception + * the exception */ - private EntityManagerFactory getEntityFactory(HttpServletRequest request) throws Exception{ + private EntityManagerFactory getEntityFactory(HttpServletRequest request) throws Exception { PortalContextInfo pContext = getPortalContext(request); EntityManagerFactoryCreator.instanceLocalMode(); return EntityManagerFactoryCreator.getEntityManagerFactory(); @@ -119,77 +119,83 @@ public class ContextUtil { /** * Gets the perform fish service. * - * @param httpServletRequest the http servlet request + * @param httpServletRequest + * the http servlet request * @return the perform fish service - * @throws Exception the exception + * @throws Exception + * the exception */ - public static ServiceParameters getPerformFishService(HttpServletRequest httpServletRequest) throws Exception - { + public static ServiceParameters getPerformFishService(HttpServletRequest httpServletRequest) throws Exception { PortalContextInfo pContext = getPortalContext(httpServletRequest); - log.trace("PortalContextInfo: "+pContext); + log.trace("PortalContextInfo: " + pContext); HttpSession session = httpServletRequest.getSession(); ServiceParameters performFishService = (ServiceParameters) session.getAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE); - if (performFishService == null){ - log.info("Initializing the "+PERFORM_FISH_SERVICE_ATTRIBUTE+"..."); - GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(), PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService"); + if (performFishService == null) { + log.info("Initializing the " + PERFORM_FISH_SERVICE_ATTRIBUTE + "..."); + GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(), + PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService"); performFishService = new ServiceParameters(gcoreEndPointReader.getEndpointValue(), null, null, null); - log.debug("Instancied peform-fish service: "+performFishService); + log.debug("Instancied peform-fish service: " + performFishService); session.setAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE, performFishService); } return performFishService; } - /** * Save perform fish response. * - * @param httpServletRequest the http servlet request + * @param httpServletRequest + * the http servlet request * @return the service parameters - * @throws Exception the exception + * @throws Exception + * the exception */ - public static ServiceParameters savePerformFishResponse(HttpServletRequest httpServletRequest) throws Exception - { + public static ServiceParameters savePerformFishResponse(HttpServletRequest httpServletRequest) throws Exception { PortalContextInfo pContext = getPortalContext(httpServletRequest); - log.trace("PortalContextInfo: "+pContext); + log.trace("PortalContextInfo: " + pContext); HttpSession session = httpServletRequest.getSession(); - ServiceParameters performFishService = (ServiceParameters) session.getAttribute(PERFORM_FISH_RESPONSE_ATTRIBUTE); - if (performFishService == null){ - log.info("Initializing the "+PERFORM_FISH_SERVICE_ATTRIBUTE+"..."); - GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(), PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService"); + ServiceParameters performFishService = (ServiceParameters) session + .getAttribute(PERFORM_FISH_RESPONSE_ATTRIBUTE); + if (performFishService == null) { + log.info("Initializing the " + PERFORM_FISH_SERVICE_ATTRIBUTE + "..."); + GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(), + PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService"); performFishService = new ServiceParameters(gcoreEndPointReader.getEndpointValue(), null, null, null); - log.debug("Instancied peform-fish service: "+performFishService); + log.debug("Instancied peform-fish service: " + performFishService); session.setAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE, performFishService); } return performFishService; } - /** * Gets the data miner service. * - * @param httpServletRequest the http servlet request + * @param httpServletRequest + * the http servlet request * @return the data miner service - * @throws Exception the exception + * @throws Exception + * the exception */ public static ServiceParameters getDataMinerService(HttpServletRequest httpServletRequest) throws Exception { PortalContextInfo pContext = getPortalContext(httpServletRequest); - log.trace("PortalContextInfo: "+pContext); + log.trace("PortalContextInfo: " + pContext); HttpSession session = httpServletRequest.getSession(); ServiceParameters dataminerService = (ServiceParameters) session.getAttribute(DATAMINER_SERVICE_ATTRIBUTE); - if (dataminerService == null){ - log.info("Initializing the "+DATAMINER_SERVICE_ATTRIBUTE+"..."); - ServiceEndpointReader reader = new ServiceEndpointReader(pContext.getCurrentScope(), SERVICE_ENDPOINT_NAME, SERVICE_ENDPOINT_CATEGORY); + if (dataminerService == null) { + log.info("Initializing the " + DATAMINER_SERVICE_ATTRIBUTE + "..."); + ServiceEndpointReader reader = new ServiceEndpointReader(pContext.getCurrentScope(), SERVICE_ENDPOINT_NAME, + SERVICE_ENDPOINT_CATEGORY); dataminerService = reader.readResource(false); - log.debug("Instancied dataminer-service: "+dataminerService); + log.debug("Instancied dataminer-service: " + dataminerService); session.setAttribute(DATAMINER_SERVICE_ATTRIBUTE, dataminerService); } @@ -197,6 +203,4 @@ public class ContextUtil { } - - } diff --git a/src/main/webapp/PerformFishAnalytics.css b/src/main/webapp/PerformFishAnalytics.css index a6e7436..f4203f9 100644 --- a/src/main/webapp/PerformFishAnalytics.css +++ b/src/main/webapp/PerformFishAnalytics.css @@ -31,6 +31,12 @@ body { margin: 0 auto; } +.center { + margin:auto; + padding:auto; + display:block; +} + table.simpletable { font-family: verdana, arial, sans-serif; font-size: 10px; @@ -96,6 +102,14 @@ table.ext-horizontal-panel { margin: 0 auto; } +table.ext-horizontal-panel-without-margin { + border-collapse: separate; + border-spacing: 5px; + padding: 10px; + border: 1px solid #e3e3e3; + background-color: #FFF; +} + .the_margin { margin-left: 20px; margin-right: 20px;