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
This commit is contained in:
Giancarlo Panichi 2019-11-07 16:39:24 +00:00
parent 5aacca488d
commit 69836bacba
25 changed files with 3859 additions and 2316 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/performfish-analytics-portlet-0.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/performfish-analytics-portlet-0.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/performfish-analytics-portlet-0.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/performfish-analytics-portlet-0.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -35,5 +35,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/performfish-analytics-portlet-0.3.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/performfish-analytics-portlet-0.4.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -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

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="performfish-analytics-portlet-0.3.0-SNAPSHOT">
<wb-module deploy-name="performfish-analytics-portlet-0.4.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>

View File

@ -1,4 +1,9 @@
<ReleaseNotes>
<Changeset
component="org.gcube.portlets-user.performfish-analytics-portlet.0-4-0"
date="2019-11-07">
<Change>[Task #17252] Enabled DEA Analysis</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-user.performfish-analytics-portlet.0-3-0"
date="${buildDate}">

20
pom.xml
View File

@ -11,7 +11,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>performfish-analytics-portlet</artifactId>
<packaging>war</packaging>
<version>0.3.0-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
<name>Maven Archetype for GWT</name>
<scm>
@ -203,12 +203,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
@ -235,6 +235,20 @@
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- -->
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.10.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>

View File

@ -4,7 +4,6 @@
package org.gcube.portlets.user.performfishanalytics.client;
/**
* The Class PerformFishAnalyticsConstant.
*
@ -27,6 +26,8 @@ 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;
@ -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,64 +48,55 @@ 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
*/
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
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
*/
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) {
this.performFishTable = performFishTable;
@ -115,7 +106,6 @@ public class PerformFishAnalyticsConstant {
String performFishTable;
String dataMinerTable;
public String getPerformFishTable() {
return performFishTable;
}
@ -126,5 +116,4 @@ public class PerformFishAnalyticsConstant {
}
}

View File

@ -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,13 +61,11 @@ 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 {
@ -79,7 +79,6 @@ public class PerformFishAnnualAnalyticsController {
/** The decrypt parameters. */
private PerformFishInitParameter decryptParameters;
private PerformFishResponse thePerformFishResponse;
/** The focus. */
@ -91,7 +90,6 @@ public class PerformFishAnnualAnalyticsController {
private Map<Integer, FlexTable> synopticOrderBy = new HashMap<Integer, FlexTable>();
/**
* Instantiates a new perform fish analytics controller.
*/
@ -103,14 +101,14 @@ public class PerformFishAnnualAnalyticsController {
/**
* 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,10 +117,10 @@ public class PerformFishAnnualAnalyticsController {
eventBus.addHandler(LoadPopulationTypeEvent.TYPE, new LoadPopulationTypeEventHandler() {
@Override
public void onLoadPopulationType(
LoadPopulationTypeEvent loadPopulationEvent) {
public void onLoadPopulationType(LoadPopulationTypeEvent loadPopulationEvent) {
viewAnnualController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), decryptParameters);
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());
}
});
@ -151,7 +150,8 @@ public class PerformFishAnnualAnalyticsController {
@Override
public void onSelectedKPI(SelectedKPIEvent selectedKPI) {
GWT.log("Selected KPI: " + selectedKPI);
viewAnnualController.manageKPI(selectedKPI.getKpi(), selectedKPI.isChecked(), selectedKPI.getSelectedPopulationType());
viewAnnualController.manageKPI(selectedKPI.getKpi(), selectedKPI.isChecked(),
selectedKPI.getSelectedPopulationType());
eventBus.fireEvent(new PerformFishFieldFormChangedEvent(null));
// viewController.manageAlgorithmsSubmit(selectedKPIsSize);
@ -167,14 +167,14 @@ public class PerformFishAnnualAnalyticsController {
eventBus.addHandler(PerformFishFieldFormChangedEvent.TYPE, new PerformFishFieldFormChangedEventHandler() {
@Override
public void onFieldFormChanged(
PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) {
public void onFieldFormChanged(PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) {
// viewAnnualController.setReloadPerformFishServiceData(true);
boolean isValidForm = viewAnnualController.validatePerformFishInputFields();
if (isValidForm) {
//boolean isKPIsSelected = viewAnnualController.validateKPIFields();
// boolean isKPIsSelected =
// viewAnnualController.validateKPIFields();
int selectedKPIsSize = viewAnnualController.getSelectedKPIs().size();
viewAnnualController.manageAlgorithmsSubmit(selectedKPIsSize);
viewAnnualController.enableSynopticTable(true);
@ -192,17 +192,22 @@ public class PerformFishAnnualAnalyticsController {
public void onLoadFocusEvent(LoadFocusEvent loadFocusEvent) {
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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();
// String batchType =
// viewAnnualController.getForm().getBatchType();
//List<String> listYear = viewAnnualController.getForm().getYear();
// List<String> 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<PerformFishResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters,
new AsyncCallback<PerformFishResponse>() {
@Override
public void onFailure(Throwable caught) {
@ -215,7 +220,8 @@ public class PerformFishAnnualAnalyticsController {
thePerformFishResponse = performFishResponse;
GWT.log("PerformFish Response: " + performFishResponse);
final String pfTableName = PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable_internal.getPerformFishTable();
final String pfTableName = PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable_internal
.getPerformFishTable();
String fileURL = performFishResponse.getMapParameters().get(pfTableName);
@ -223,11 +229,14 @@ public class PerformFishAnnualAnalyticsController {
// Managing the Perform Fish Service Response
if (fileURL == null) {
viewAnnualController.showAlert("No table found by searching for name: "+PerformFishAnalyticsConstant.BATCHES_TABLE_INTERNAL, AlertType.ERROR);
viewAnnualController.showAlert(
"No table found by searching for name: "
+ PerformFishAnalyticsConstant.BATCHES_TABLE_INTERNAL,
AlertType.ERROR);
} else {
PerformFishAnalyticsServiceAsync.Util.getInstance().readCSVFile(fileURL, new AsyncCallback<CSVFile>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().readCSVFile(fileURL,
new AsyncCallback<CSVFile>() {
@Override
public void onFailure(Throwable caught) {
@ -239,24 +248,34 @@ public class PerformFishAnnualAnalyticsController {
public void onSuccess(CSVFile result) {
if (result == null) {
viewAnnualController.showAlert("The focus was not found in the table "+pfTableName, AlertType.ERROR);
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());
int indexOfFARM = result.getHeaderRow().getListValues().indexOf(
PerformFishAnalyticsConstant.POPULATION_LEVEL.FARM.name());
GWT.log("The index of column "+PerformFishAnalyticsConstant.POPULATION_LEVEL.FARM.name()+" is "+indexOfFARM);
GWT.log("The index of column "
+ PerformFishAnalyticsConstant.POPULATION_LEVEL.FARM.name()
+ " is " + indexOfFARM);
if (indexOfFARM > -1) {
List<CSVRow> rows = result.getValueRows();
if (rows == null || rows.isEmpty()) {
viewAnnualController.showAlert("No valid focus was found in the table "+pfTableName, AlertType.ERROR);
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
// 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())
@ -264,7 +283,9 @@ public class PerformFishAnnualAnalyticsController {
}
if (focusValue == null) {
viewAnnualController.showAlert("No valid focus was found in the table "+pfTableName, AlertType.ERROR);
viewAnnualController
.showAlert("No valid focus was found in the table "
+ pfTableName, AlertType.ERROR);
return;
}
@ -287,7 +308,8 @@ public class PerformFishAnnualAnalyticsController {
@Override
public void onSubmitRequest(SubmitRequestEvent submitRequestEvent) {
//boolean isValidBatchId = viewAnnualController.validateBatchIdSelection();
// boolean isValidBatchId =
// viewAnnualController.validateBatchIdSelection();
boolean isValidKPI = viewAnnualController.validateKPIFields();
@ -325,15 +347,20 @@ public class PerformFishAnnualAnalyticsController {
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<String, String> 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()) {
@ -343,7 +370,8 @@ public class PerformFishAnnualAnalyticsController {
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM + "=" + yearsValue + ";");
//dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"="+ PerformFishAnalyticsConstant.DM_VALUE_ALL +";");
// dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"="+
// PerformFishAnalyticsConstant.DM_VALUE_ALL +";");
// dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_ALLYEARS_PARAM+"=2016;");
String dataInParameters = dataInputsFormatter.toString();
@ -361,9 +389,11 @@ public class PerformFishAnnualAnalyticsController {
@Override
public void execute() {
loaderIcon.setFocus(true);
}});
}
});
PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticAnnualTable(thePerformFishResponse, mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticAnnualTable(
thePerformFishResponse, mapParameters, new AsyncCallback<DataMinerResponse>() {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
@ -371,7 +401,8 @@ public class PerformFishAnnualAnalyticsController {
checkTabSpinner(submitRequestPanel, tab);
// field_unary_algorithm.setVisible(true);
GWT.log("I'm displaying: " + dmResponse);
displayOutputFilesAsStaticEntities(dmResponse, algorithm, null, null, null, panelContainer, false);
displayOutputFilesAsStaticEntities(dmResponse, algorithm, null, null, null, panelContainer,
false);
}
@Override
@ -388,7 +419,8 @@ public class PerformFishAnnualAnalyticsController {
/**
* Submit request to DM.
*
* @param dmAlgorithm the dm algorithm
* @param dmAlgorithm
* the dm algorithm
*/
private void submitRequestToDM(DataMinerAlgorithms dmAlgorithm) {
@ -405,20 +437,34 @@ public class PerformFishAnnualAnalyticsController {
else
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
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;
}
}
@ -426,18 +472,25 @@ public class PerformFishAnnualAnalyticsController {
/**
* 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<KPI> inputKPI, final List<KPI> outputKPI) {
private void createTabToSelectIOParametersForDeaAnnualAnalysis(String focusID, final List<KPI> listKPI) {
DataMinerInputParameters dmInputParameters = new DataMinerInputParameters(thePerformFishResponse, viewAnnualController.getSelectedYears(), inputKPI, outputKPI, DataMinerAlgorithms.CORRELATION, focusID);
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()) {
@ -446,7 +499,107 @@ public class PerformFishAnnualAnalyticsController {
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 + "=" + 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() + "|";
}
// 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<String, String> 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 for annual with client input parameters: " + dataInParameters);
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters));
final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1);
submitRequestPanel.showLoader(false, null);
final Tab tab = viewAnnualController.createTab("Dea #" + (viewAnnualController.currentNumberOfTab() + 1),
PerformFishResources.INSTANCE.farm_DEAANALYSIS().getText(), submitRequestPanel);
viewAnnualController.noSpinner(tab);
final List<KPI> selectedKPI = new ArrayList<KPI>(viewAnnualController.getSelectedKPIs());
final List<String> focusIds = new ArrayList<String>();
focusIds.add(focusID);
DeaAnnualPanelResult deaAnnualPanelResult = new DeaAnnualPanelResult();
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<KPI> inputKPI,
final List<KPI> 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) {
@ -478,10 +631,14 @@ public class PerformFishAnnualAnalyticsController {
Map<String, String> 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);
@ -490,13 +647,19 @@ public class PerformFishAnnualAnalyticsController {
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
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);
final Tab tab = viewAnnualController.createTab(tabTitle+" #"+(viewAnnualController.currentNumberOfTab()+1),PerformFishResources.INSTANCE.farm_CORRELATION().getText(),submitRequestPanel);
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualCorrelationAnalysis(dmInputParameters.getPerformFishResponse(), mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualCorrelationAnalysis(
dmInputParameters.getPerformFishResponse(), mapParameters, new AsyncCallback<DataMinerResponse>() {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
@ -509,10 +672,13 @@ public class PerformFishAnnualAnalyticsController {
// TODO COMMENTED NOW
analyticsPanelResult.addListBatchIds(Arrays.asList(theFocusValue));
analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, viewAnnualController.getForm().getBatchType());
analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters,
viewAnnualController.getForm().getBatchType());
analyticsPanelResult.addResults(dmResponse);
submitRequestPanel.addWidget(analyticsPanelResult);
//viewController.geTabPanelView().addResult(resultPanel, "Analysis #"+(viewController.geTabPanelView().countTab()+1));
// viewController.geTabPanelView().addResult(resultPanel,
// "Analysis
// #"+(viewController.geTabPanelView().countTab()+1));
// modal.hide();
}
@ -529,8 +695,8 @@ public class PerformFishAnnualAnalyticsController {
// TODO COMMENTED NOW
analyticsPanelResult.addListFocusIds(Arrays.asList(theFocusValue));
analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, viewAnnualController.getForm().getBatchType());
analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters,
viewAnnualController.getForm().getBatchType());
submitRequestPanel.addWidget(analyticsPanelResult);
} catch (Exception e) {
// TODO: handle exception
@ -544,25 +710,32 @@ public class PerformFishAnnualAnalyticsController {
});
}
/**
* 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<KPI> inputKPI, final List<KPI> outputKPI){
private void callAlgorithm(DataMinerAlgorithms algorithm, String focusID, List<KPI> inputKPI,
final List<KPI> outputKPI) {
// List<String> listBatchID = viewController.getSelectedBatchID();
//
// if(listBatchID==null || listBatchID.size()==0)
// Window.alert("Something seems wrong, no selected BatchID, try again");
// 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
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;
@ -587,11 +760,18 @@ public class PerformFishAnnualAnalyticsController {
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);
Tab tab = viewAnnualController.createTab(tabTitle + " #" + (viewAnnualController.currentNumberOfTab() + 1),
algDesrTxt, submitRequestPanel);
switch (algorithm) {
case BOXPLOT:
@ -606,7 +786,8 @@ public class PerformFishAnnualAnalyticsController {
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);
submitRequestPanel.addWidget(hp);
@ -615,38 +796,49 @@ public class PerformFishAnnualAnalyticsController {
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");
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();
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);
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);
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()) {
@ -655,7 +847,8 @@ public class PerformFishAnnualAnalyticsController {
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 + "=" + dmInputParameters.getFocusID() + ";");
// dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;");
if (dmInputParameters.getInputKPI() != null && dmInputParameters.getInputKPI().size() > 0) {
@ -687,10 +880,14 @@ public class PerformFishAnnualAnalyticsController {
Map<String, String> 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);
@ -698,7 +895,8 @@ public class PerformFishAnnualAnalyticsController {
Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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,9 +904,11 @@ public class PerformFishAnnualAnalyticsController {
@Override
public void execute() {
loaderIcon.setFocus(true);
}});
}
});
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualAnalysis(mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualAnalysis(mapParameters,
new AsyncCallback<DataMinerResponse>() {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
@ -716,29 +916,36 @@ public class PerformFishAnnualAnalyticsController {
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);
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);
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<String, String> performFishResponseMap, StringBuilder dataInputsFormatter, PFSERVICE_TO_DM_MAPPING_TABLE table) {
private StringBuilder appendDMInputTable(Map<String, String> performFishResponseMap,
StringBuilder dataInputsFormatter, PFSERVICE_TO_DM_MAPPING_TABLE table) {
String toDMInputTable = performFishResponseMap.get(table.getPerformFishTable());
@ -752,8 +959,10 @@ public class PerformFishAnnualAnalyticsController {
/**
* 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) {
requestPanel.incrementCompletedRequests();
@ -768,15 +977,24 @@ 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<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID, final Panel container, boolean displayError){
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
final Panel container, boolean displayError) {
String title = displayError ? "No results " : "";
@ -795,11 +1013,14 @@ public class PerformFishAnnualAnalyticsController {
switch (outputFile.getDataType()) {
case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, new AsyncCallback<String>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
//showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container);
// showAlert(caught.getMessage(),
// AlertType.ERROR, true,
// uib_vp_deanalanlysis_request_container);
Window.alert(caught.getMessage());
}
@ -810,8 +1031,10 @@ public class PerformFishAnnualAnalyticsController {
String title = toTitle;
switch (chartType) {
case BOXPLOT:
//title = chartType.getName()+" - on all batches<br>";
//title += "Blue dots indicate the selected batch(es): "+focusID;
// title = chartType.getName()+" - on all
// batches<br>";
// title += "Blue dots indicate the selected
// batch(es): "+focusID;
title = chartType.getTitle() + " - on all farm data<br>";
title += "Blue dots indicate the selected farm: " + focusID;
@ -842,11 +1065,14 @@ public class PerformFishAnnualAnalyticsController {
});
break;
case CSV:
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback<CSVFile>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true,
new AsyncCallback<CSVFile>() {
@Override
public void onFailure(Throwable caught) {
//showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container);
// showAlert(caught.getMessage(),
// AlertType.ERROR, true,
// uib_vp_deanalanlysis_request_container);
Window.alert(caught.getMessage());
}
@ -888,7 +1114,8 @@ public class PerformFishAnnualAnalyticsController {
}
ShowResult showResultSin = new ShowResult(title);
showResultSin.showCSVFile(result, cssTableStyle);
displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, showResultSin);
displayingOrderedSynopticTable(dmResponse, result.getFileName(), container,
showResultSin);
return;
}
@ -911,12 +1138,17 @@ 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);
FlexTable flex = synopticOrderBy.get(hashcode);
@ -935,16 +1167,20 @@ public class PerformFishAnnualAnalyticsController {
}
}
/**
* 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);
FlexTable flex = boxPlotOrderBy.get(hashcode);

View File

@ -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,13 +65,10 @@ 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 {
@ -89,7 +86,6 @@ public class PerformFishAnalyticsController {
private Map<Integer, FlexTable> synopticOrderBy = new HashMap<Integer, FlexTable>();
/**
* Instantiates a new perform fish analytics controller.
*/
@ -102,13 +98,13 @@ public class PerformFishAnalyticsController {
/**
* 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,15 +113,17 @@ public class PerformFishAnalyticsController {
eventBus.addHandler(LoadPopulationTypeEvent.TYPE, new LoadPopulationTypeEventHandler() {
@Override
public void onLoadPopulationType(
LoadPopulationTypeEvent loadPopulationEvent) {
public void onLoadPopulationType(LoadPopulationTypeEvent loadPopulationEvent) {
viewController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), decryptParameters);
viewController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(),
decryptParameters);
// if(loadPopulationEvent.getPopulationName().equals(POPULATION_LEVEL.BATCH.name())) {
// if(loadPopulationEvent.getPopulationName().equals(POPULATION_LEVEL.BATCH.name()))
// {
//
// }else {
// viewAnnualController.loadPopulationTypeForLevelAndBatchType(loadPopulationEvent.getPopulationName(), decryptParameters);
// 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,7 +168,8 @@ 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);
List<String> batchIds = viewController.getSelectedBatchID();
@ -185,7 +188,8 @@ public class PerformFishAnalyticsController {
viewController.hideErrors();
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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<String> listArea = viewController.getForm().getArea();
@ -214,7 +218,8 @@ public class PerformFishAnalyticsController {
vp.add(loader);
loader.show(true);
modal.add(vp);
PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters, new AsyncCallback<PerformFishResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters,
new AsyncCallback<PerformFishResponse>() {
@Override
public void onFailure(Throwable caught) {
@ -225,7 +230,8 @@ public class PerformFishAnalyticsController {
@Override
public void onSuccess(PerformFishResponse performFishResponse) {
modal.hide();
viewController.managePerformFishServiceResponse(performFishResponse, mapParameters, POPULATION_LEVEL.BATCH);
viewController.managePerformFishServiceResponse(performFishResponse, mapParameters,
POPULATION_LEVEL.BATCH);
}
});
modal.show();
@ -233,12 +239,10 @@ public class PerformFishAnalyticsController {
}
});
eventBus.addHandler(PerformFishFieldFormChangedEvent.TYPE, new PerformFishFieldFormChangedEventHandler() {
@Override
public void onFieldFormChanged(
PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) {
public void onFieldFormChanged(PerformFishFieldFormChangedEvent performFishFieldFormChangedEvent) {
viewController.setReloadPerformFishServiceData(true);
boolean isValidForm = viewController.validatePerformFishInputFields();
@ -250,7 +254,9 @@ public class PerformFishAnalyticsController {
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 {
@ -270,8 +276,7 @@ public class PerformFishAnalyticsController {
if (isBatchIdValid) {
viewController.enableAllAlgorithmsForSubmit(true);
viewController.enableSynopticTable(true);
}
else {
} else {
viewController.enableAllAlgorithmsForSubmit(false);
viewController.enableSynopticTable(false);
}
@ -280,7 +285,6 @@ public class PerformFishAnalyticsController {
}
});
eventBus.addHandler(SubmitRequestEvent.TYPE, new SubmitRequestEventHandler() {
@Override
@ -299,29 +303,44 @@ public class PerformFishAnalyticsController {
case BOXPLOT:
// UNARY
callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), selectedKPI, null);
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);
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);
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;
@ -336,7 +355,8 @@ public class PerformFishAnalyticsController {
boolean isValidBatchId = viewController.validateBatchIdSelection();
if (isValidBatchId) {
callAlgorithmSynopticTableBatch(viewController.getPerformFishResponse(), viewController.getRequestMapParameters());
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<String, List<String>> performFishRequestParameters) {
private void callAlgorithmSynopticTableBatch(final PerformFishResponse performFishResponse,
final Map<String, List<String>> 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");
Window.alert("Something seems wrong. No batches tables matching with parameter "
+ PerformFishAnalyticsConstant.BATCHES_TABLE + " returned from service");
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
StringBuilder dataInputsFormatter = new StringBuilder();
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())
|| 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));
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);
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,10 +436,12 @@ public class PerformFishAnalyticsController {
@Override
public void execute() {
loaderIcon.setFocus(true);
}});
}
});
final DataMinerAlgorithms toFinalChartType = chartType;
PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticTable(performFishResponse, mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callDMServiceToLoadSynopticTable(performFishResponse,
mapParameters, new AsyncCallback<DataMinerResponse>() {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
@ -414,44 +449,50 @@ public class PerformFishAnalyticsController {
checkTabSpinner(submitRequestPanel, tab);
// field_unary_algorithm.setVisible(true);
GWT.log("I'm displaying: " + dmResponse);
displayOutputFilesAsStaticEntities(dmResponse, toFinalChartType, null, null, null, panelContainer, false);
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);
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<String, List<String>> performFishRequestParameters) {
//
private void createTabToSelectIOParametersForDeaAnalysis(final PerformFishResponse performFishResponse,
final Map<String, List<String>> 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");
Window.alert("Something seems wrong. No batches tables matching with parameter "
+ PerformFishAnalyticsConstant.BATCHES_TABLE + " returned from service");
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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
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_CHARTTYPE_PARAM + "=" + DataMinerAlgorithms.CORRELATION + ";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM + "=" + batchTableURL + ";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM + "=ID;");
@ -470,26 +511,103 @@ public class PerformFishAnalyticsController {
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<KPI> selectedKPI = new ArrayList<KPI>(viewController.getSelectedKPIs());
final List<String> batchIDs = new ArrayList<String>(viewController.getListBatchesID());
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<String, List<String>> 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<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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<KPI> selectedKPI = new ArrayList<KPI>(viewController.getSelectedKPIs());
final List<String> batchIDs = new ArrayList<String>(viewController.getListBatchesID());
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishCorrelationAnalysis(performFishResponse, mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishCorrelationAnalysis(
performFishResponse, mapParameters, new AsyncCallback<DataMinerResponse>() {
@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.addSelectedAreas(
performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
analyticsPanelResult.addSelectedKPIs(selectedKPI);
analyticsPanelResult.addListFocusIds(batchIDs);
analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters, viewController.getForm().getBatchType());
analyticsPanelResult.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters,
viewController.getForm().getBatchType());
analyticsPanelResult.addResults(dmResponse);
submitRequestPanel.addWidget(analyticsPanelResult);
//viewController.geTabPanelView().addResult(resultPanel, "Analysis #"+(viewController.geTabPanelView().countTab()+1));
// viewController.geTabPanelView().addResult(resultPanel,
// "Analysis
// #"+(viewController.geTabPanelView().countTab()+1));
// modal.hide();
}
@ -500,13 +618,15 @@ public class PerformFishAnalyticsController {
checkTabSpinner(submitRequestPanel, tab);
try {
AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult();
analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
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.addParameters(PerformFishAnalyticsConstant.DATA_INPUTS, mapParameters,
viewController.getForm().getBatchType());
submitRequestPanel.addWidget(analyticsPanelResult);
} catch (Exception e) {
// TODO: handle exception
GWT.log("Error in AnalyticsPanelResult: " + e.getLocalizedMessage(), e);
}
Alert error = new Alert(caught.getMessage());
@ -517,26 +637,30 @@ public class PerformFishAnalyticsController {
});
}
/**
* 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<KPI> inputKPI, final List<KPI> outputKPI){
private void callAlgorithm(DataMinerAlgorithms algorithm, String focusID, List<KPI> inputKPI,
final List<KPI> outputKPI) {
List<String> listBatchID = viewController.getSelectedBatchID();
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
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;
@ -561,10 +685,18 @@ public class PerformFishAnalyticsController {
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);
final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1);
Tab tab = viewController.createTab(tabTitle + " #" + (viewController.currentNumberOfTab() + 1), algDesrTxt,
submitRequestPanel);
switch (algorithm) {
case BOXPLOT:
@ -578,7 +710,8 @@ public class PerformFishAnalyticsController {
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);
callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH,
Arrays.asList(kpi), Arrays.asList(kpi), algorithm, focusID, submitRequestPanel, hp, tab);
// resultPanel.add(hp);
submitRequestPanel.addWidget(hp);
}
@ -586,48 +719,67 @@ public class PerformFishAnalyticsController {
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");
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();
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<KPI> inputKPI, final List<KPI> 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<KPI> inputKPI, final List<KPI> outputKPI, final DataMinerAlgorithms chartType,
final String focusID, final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer,
final Tab tab) {
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");
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() + ";");
String theBatchType = viewController.getForm().getBatchType();
theBatchType = theBatchType.replace("_CLOSED_BATCHES", ""); //REMOVING SUFFIX _CLOSED_BATCHES FOR DATAMINER CALL
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 + ";");
@ -676,9 +828,11 @@ public class PerformFishAnalyticsController {
@Override
public void execute() {
loaderIcon.setFocus(true);
}});
}
});
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters,
new AsyncCallback<DataMinerResponse>() {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
@ -686,14 +840,16 @@ public class PerformFishAnalyticsController {
checkTabSpinner(requestPanel, tab);
// field_unary_algorithm.setVisible(true);
GWT.log("I'm displaying: " + dmResponse);
displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panelContainer, false);
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);
displayOutputFilesAsStaticEntities(null, chartType, inputKPI, outputKPI, focusID,
panelContainer, true);
}
});
@ -702,8 +858,10 @@ public class PerformFishAnalyticsController {
/**
* 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) {
requestPanel.incrementCompletedRequests();
@ -718,15 +876,24 @@ 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<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID, final Panel container, boolean displayError){
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
final Panel container, boolean displayError) {
String title = displayError ? "No results " : "";
@ -745,11 +912,14 @@ public class PerformFishAnalyticsController {
switch (outputFile.getDataType()) {
case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, new AsyncCallback<String>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
//showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container);
// showAlert(caught.getMessage(),
// AlertType.ERROR, true,
// uib_vp_deanalanlysis_request_container);
Window.alert(caught.getMessage());
}
@ -783,6 +953,9 @@ public class PerformFishAnalyticsController {
case PERFORMFISH_SYNOPTICTABLE_BATCH:
case PERFORMFISH_SYNOPTICTABLE_BATCH_HATCHERY:
case PERFORMFISH_SYNOPTICTABLE_BATCH_PREGROW:
case PERFORMFISH_SYNOPTIC_TABLE_FARM:
break;
default:
break;
}
@ -794,11 +967,14 @@ public class PerformFishAnalyticsController {
});
break;
case CSV:
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback<CSVFile>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true,
new AsyncCallback<CSVFile>() {
@Override
public void onFailure(Throwable caught) {
//showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_deanalanlysis_request_container);
// showAlert(caught.getMessage(),
// AlertType.ERROR, true,
// uib_vp_deanalanlysis_request_container);
Window.alert(caught.getMessage());
}
@ -848,9 +1024,14 @@ public class PerformFishAnalyticsController {
ShowResult showResultSin = new ShowResult(title);
showResultSin.showCSVFile(result, cssTableStyle);
displayingOrderedSynopticTable(dmResponse, result.getFileName(), container, showResultSin);
displayingOrderedSynopticTable(dmResponse, result.getFileName(), container,
showResultSin);
return;
case PERFORMFISH_SYNOPTIC_TABLE_FARM:
break;
default:
break;
}
// ALL OTHER CASES
ShowResult showResult = new ShowResult(title);
@ -868,7 +1049,8 @@ 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);
FlexTable flex = boxPlotOrderBy.get(hashcode);
@ -889,7 +1071,8 @@ public class PerformFishAnalyticsController {
}
}
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);
FlexTable flex = synopticOrderBy.get(hashcode);

View File

@ -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.

View File

@ -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.

View File

@ -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();
}

View File

@ -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<Widget, AnalyticsAnnualPanelResult> {
interface AnalyticsPanelResultUiBinder extends UiBinder<Widget, AnalyticsAnnualPanelResult> {
}
@UiField
@ -99,51 +88,15 @@ 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<String, String> dataInputParameters;
private DataMinerResponse dmResponse;
@ -154,110 +107,30 @@ public class AnalyticsAnnualPanelResult extends Composite {
private List<String> selectedAreas;
private HandlerManager theEventBus;
// private HandlerManager theEventBus;
private Map<String, CSVFile> csvGenerated = new HashMap<String, CSVFile>();
/**
* 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:
* <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
* xmlns:g="urn:import:**user's package**">
* <g:**UserClassName**>Hello!</g:**UserClassName>
* </ui:UiBinder>
* 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: <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g=
* "urn:import:**user's package**">
* <g:**UserClassName**>Hello!</g:**UserClassName> </ui:UiBinder> 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;
// this.theEventBus = eventBus;
}
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<String> inputKPINames = getSelected(list_dea_input_kpi);
List<String> 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<listBox.getItemCount(); i++) {
listBox.setItemSelected(i, selected);
}
}
/**
* Gets the selected.
*
* @param listBox the list box
* @return the selected
*/
private List<String> getSelected(ListBox listBox){
List<String> selected = new ArrayList<String>();
for (int i=0; i<listBox.getItemCount(); i++) {
if (listBox.isItemSelected(i)) {
selected.add(listBox.getItemText(i));
}
}
return selected;
}
/**
* Adds the selected areas.
*
* @param listAreas the list areas
* @param listAreas
* the list areas
*/
public void addSelectedAreas(List<String> listAreas) {
@ -265,7 +138,6 @@ public class AnalyticsAnnualPanelResult extends Composite {
}
/**
* Gets the data miner response.
*
@ -275,8 +147,6 @@ public class AnalyticsAnnualPanelResult extends Composite {
return dmResponse;
}
/**
* Gets the data input parameters.
*
@ -290,10 +160,14 @@ 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) {
Alert alert = new Alert(error);
@ -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<KPI> selectedKPIs) {
@ -315,33 +189,6 @@ public class AnalyticsAnnualPanelResult extends Composite {
}
// /**
// * 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: ");
@ -365,13 +212,15 @@ public class AnalyticsAnnualPanelResult extends Composite {
/**
* 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<String, List<String>> parameters, String toShowBatchTypeValue) {
final FlexTable flexTable = new FlexTable();
flexTable.setStyleName("colgrouptable");
@ -395,21 +244,18 @@ public class AnalyticsAnnualPanelResult extends Composite {
}
}
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() + ", ";
}
KPINames = KPINames.substring(0, KPINames.length() - 2);
flexTable.setWidget(2,0, 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");
flexTable.setWidget(2, 0, new HTML("KPI:"));
flexTable.setWidget(2, 1, new HTML(KPINames));
uib_label_focus_id.setText("FOCUS ID");
@ -420,23 +266,11 @@ public class AnalyticsAnnualPanelResult extends Composite {
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<String> listBatchesID) {
for (String batchID : listBatchesID) {
@ -447,7 +281,8 @@ public class AnalyticsAnnualPanelResult extends Composite {
/**
* Adds the results.
*
* @param dmResponse the dm response
* @param dmResponse
* the dm response
*/
public void addResults(DataMinerResponse dmResponse) {
@ -456,11 +291,13 @@ public class AnalyticsAnnualPanelResult extends Composite {
for (final OutputFile outputFile : dmResponse.getListOutput()) {
if (outputFile.getDataType().equals(FileContentType.CSV)) {
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, new AsyncCallback<CSVFile>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true,
new AsyncCallback<CSVFile>() {
@Override
public void onFailure(Throwable caught) {
showAlert(caught.getMessage(), AlertType.ERROR, true, uib_vp_correlation_results_container);
showAlert(caught.getMessage(), AlertType.ERROR, true,
uib_vp_correlation_results_container);
}
@ -476,7 +313,6 @@ public class AnalyticsAnnualPanelResult extends Composite {
}
}
/**
* Fill correlation matrix.
*/
@ -509,29 +345,17 @@ public class AnalyticsAnnualPanelResult extends Composite {
flexTable.setWidget(0, 0, new Label(""));
CSVRow headerRow = corrIndexCsvFile.getHeaderRow();
// HEADER
for (int i = 1; i < headerRow.getListValues().size(); i++) {
final String headerValue = headerRow.getListValues().get(i);
// final Button button = new Button(headerValue);
// button.setType(ButtonType.LINK);
HTML label = new HTML(headerValue);
label.getElement().getStyle().setFontSize(16, Unit.PX);
final int columnIndex = i;
KPI kpi = getKPIForName(headerValue);
fillKPIReferenceForIndex(0, columnIndex, Arrays.asList(kpi));
// button.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// //calling unary operator
// callBoxPlotAndSpeedoMeter(0,columnIndex,button);
//
// }
// });
flexTable.setWidget(0, i, label);
}
// DATA
@ -547,8 +371,6 @@ public class AnalyticsAnnualPanelResult extends Composite {
// final Button button = new Button(rowValue);
final HTML buttonHTML = new HTML(rowValue);
buttonHTML.addStyleName("my-active-html");
// button.setType(ButtonType.LINK);
// button.setSize(ButtonSize.LARGE);
// only the first column
if (j == 0) {
@ -559,23 +381,8 @@ public class AnalyticsAnnualPanelResult extends Composite {
KPI kpi = getKPIForName(rowValue);
fillKPIReferenceForIndex(rowIndex, columnIndex, Arrays.asList(kpi));
continue;
//rowValue is a KPI name
// KPI kpi = getKPIForName(rowValue);
// fillKPIReferenceForIndex(rowIndex, columnIndex, Arrays.asList(kpi));
// button.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// //calling unary operator
// callBoxPlotAndSpeedoMeter(rowIndex, columnIndex, button);
//
// }
// });
}
//diagonal
else if(rowIndex==j){
//rowValue should be 1
//HTML dg = new HTML("1");
} else {
if (rowIndex == j) { // diagonal
HTML dg = new HTML(rowValue);
dg.getElement().getStyle().setFontSize(18, Unit.PX);
flexTable.setWidget(rowIndex, j, dg);
@ -586,23 +393,20 @@ public class AnalyticsAnnualPanelResult extends Composite {
// 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);
buttonHTML.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
//callScatterAndDeaChart(rowIndex, columnIndex, button);
// callScatterAndDeaChart(rowIndex, columnIndex,
// button);
callScatter(rowIndex, columnIndex, buttonHTML);
}
});
}
}
//button.setType(ButtonType.LINK);
//APPLYING STYLE ONLY ON INTERNAL VALUES OF CSV
if (j > 0)
buttonHTML.getElement().getStyle().setColor("#000");
@ -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<String, String> map = CorrelationValueToColourUtil.getMap();
flexLegend.setWidget(0, 0, new Label("Legend"));
flexLegend.setWidget(0, 1, new HTML(""));
@ -656,37 +459,26 @@ public class AnalyticsAnnualPanelResult extends Composite {
/**
* 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<KPI> 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<KPI> getKPIForIndexes(int rowIndex, int columnIndex) {
@ -698,39 +490,6 @@ public class AnalyticsAnnualPanelResult extends Composite {
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<KPI> 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.
*
@ -747,14 +506,6 @@ public class AnalyticsAnnualPanelResult extends Composite {
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,46 +514,17 @@ 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<KPI> 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();
@ -812,244 +534,8 @@ public class AnalyticsAnnualPanelResult extends Composite {
GWT.log("Called ScatterChart at rowIndex: " + rowIndex + ", columnIndex: " + columnIndex);
List<KPI> selectedKPI = getKPIForIndexes(rowIndex, columnIndex);
GWT.log("Selected KPI: " + selectedKPI);
theEventBus.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<String> inputKPINames, List<String> 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<KPI> inputKPI = new ArrayList<KPI>();
for (String kpiName : inputKPINames) {
inputKPI.add(getKPIForName(kpiName));
}
List<KPI> outputKPI = new ArrayList<KPI>();
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<KPI> inputKPIs, List<KPI> 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<String>() {
@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<CSVFile>() {
@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;
PerformFishAnalyticsController.eventBus
.fireEvent(new CallAlgorithmEvent(DataMinerAlgorithms.SCATTER, focusID, selectedKPI, null));
}
}
}
/**
* 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<String, String> dataInputParameters, final List<KPI> inputKPI, final List<KPI> 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<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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<DataMinerResponse>() {
@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);
}
});
}
}

View File

@ -14,11 +14,6 @@
addStyleNames="the_margin_top_bottom">
<b:Label text="Parameters"></b:Label>
</g:VerticalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_results"
addStyleNames="the_margin_top_bottom">
<b:Label text="CORRELATION Matrix"></b:Label>
<g:HorizontalPanel addStyleNames="the_margin_top">
<g:Label ui:field="uib_label_focus_id">Focus ID</g:Label>
<b:ControlGroup ui:field="cg_focus_id_correlation">
@ -30,49 +25,13 @@
</b:Controls>
</b:ControlGroup>
</g:HorizontalPanel>
<g:VerticalPanel ui:field="uib_vp_correlation_results_container"
addStyleNames="the_margin_left">
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_deanalanlysis_algorithm_request"
<g:VerticalPanel ui:field="field_results"
addStyleNames="the_margin_top_bottom">
<b:Label text="DEA ANALYSIS Request"></b:Label>
<g:HorizontalPanel ui:field="uib_vp_deanalanlysis_request_container"
addStyleNames="the_margin_top_bottom the_margin_left">
<g:Label>Input KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_input_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox ui:field="list_dea_input_kpi"
multipleSelect="true" addStyleNames="the_margin_left the_select_custom"
height="100px">
</b:ListBox>
<b:appendWidget>
<b:CheckBox ui:field="uib_check_all_input_kpi"
title="Select/Unselect All" />
</b:appendWidget>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
<g:Label addStyleNames="the_margin_left" styleName="{style.paddingLeft}">Output
KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_output_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox addStyleNames="the_margin_left the_select_custom"
ui:field="list_dea_output_kpi" multipleSelect="true" height="100px">
</b:ListBox>
<b:appendWidget>
<b:CheckBox ui:field="uib_check_all_output_kpi"
title="Select/Unselect All" />
</b:appendWidget>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
<b:Button type="DEFAULT" text="Submit DEA Analysis Request"
ui:field="button_dea_analys_request" addStyleNames="the_margin_left">
</b:Button>
</g:HorizontalPanel>
<b:Label text="CORRELATION Matrix"></b:Label>
<g:VerticalPanel ui:field="uib_vp_correlation_results_container"
addStyleNames="the_margin_left">
</g:VerticalPanel>
@ -91,14 +50,6 @@
addStyleNames="the_margin">
</g:VerticalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm"
addStyleNames="the_margin_top_bottom" visible="false">
<b:Label text="DEA ANALYSIS Results" type="INFO"></b:Label>
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm_container"
addStyleNames="the_margin">
</g:VerticalPanel>
</g:VerticalPanel>
</g:VerticalPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -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<Widget, DeaAnnualPanelResult> {
}
@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<String, String> dataInputParameters;
private DataMinerResponse dmResponse;
private Map<String, List<KPI>> kpiMapPointers = new HashMap<String, List<KPI>>();
private List<KPI> selectedKPIs;
// private List<String> 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: <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g=
* "urn:import:**user's package**">
* <g:**UserClassName**>Hello!</g:**UserClassName> </ui:UiBinder> 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<String> inputKPINames = new ArrayList<String>();
for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) {
inputKPINames.add(list_dea_input_kpi.getItemText(i));
}
List<String> outputKPINames = new ArrayList<String>();
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<String> notSelected = null;
switch (kpiButtonType) {
case INPUT_KPI:
notSelected = new ArrayList<String>();
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<String>();
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<String> notSelected = null;
switch (kpiButtonType) {
case INPUT_KPI:
notSelected = new ArrayList<String>();
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<String>();
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<String, String> getDataInputParameters() {
return dataInputParameters;
}
/**
* Adds the list focus ids.
*
* @param listFocusIDs
* the list focus I ds
*/
public void addListFocusIds(List<String> 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<KPI> selectedKPIs) {
this.selectedKPIs = selectedKPIs;
}
/**
* Adds the selected areas.
*
* @param listAreas
* the list areas
*/
/*
* public void addSelectedAreas(List<String> 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<String, List<String>> parameters, String toShowBatchTypeValue) {
final FlexTable flexTable = new FlexTable();
flexTable.setStyleName("colgrouptable");
try {
List<String> dataInputs = parameters.get(keyToGet);
if (dataInputs == null || dataInputs.isEmpty())
return;
dataInputParameters = new HashMap<String, String>();
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<KPI> 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<String> inputKPINames, List<String> 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<KPI> inputKPI = new ArrayList<KPI>();
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<KPI> outputKPI = new ArrayList<KPI>();
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<KPI> inputKPIs, List<KPI> 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<String>() {
@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<CSVFile>() {
@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<String, String> dataInputParameters, final List<KPI> inputKPI,
final List<KPI> 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<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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<DataMinerResponse>() {
@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);
}
});
}
}

View File

@ -0,0 +1,119 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.paddingLeft {
padding-left: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="field_html_panel" addStyleNames="the_margin">
<g:VerticalPanel ui:field="field_parameters">
<g:VerticalPanel ui:field="field_parameters_container"
addStyleNames="the_margin_top_bottom">
<b:Label text="Parameters"></b:Label>
</g:VerticalPanel>
<g:HorizontalPanel addStyleNames="the_margin_top">
<g:Label ui:field="uib_label_focus_id" addStyleNames="the_margin_left">Focus
ID</g:Label>
<b:ControlGroup ui:field="cg_focus_id_correlation">
<b:Controls>
<b:ListBox name="Select Focus ID" b:id="field_list_focus_id_correlation"
ui:field="field_list_focus_id_correlation" multipleSelect="false"
addStyleNames="the_margin_left">
</b:ListBox>
</b:Controls>
</b:ControlGroup>
</g:HorizontalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_results"
addStyleNames="the_margin_top_bottom">
<g:VerticalPanel ui:field="field_deanalanlysis_algorithm_request"
addStyleNames="the_margin_top_bottom">
<b:Label text="DEA ANALYSIS Request"></b:Label>
<g:FlowPanel ui:field="alert_info" />
<g:HorizontalPanel ui:field="uib_vp_deanalanlysis_request_container"
verticalAlignment="ALIGN_MIDDLE">
<g:VerticalPanel>
<g:Label addStyleNames="the_margin_left">Input KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_input_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox ui:field="list_dea_input_kpi"
multipleSelect="true" addStyleNames="the_margin_left the_select_custom"
height="100px">
</b:ListBox>
<b:appendWidget>
</b:appendWidget>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:VerticalPanel>
<g:VerticalPanel horizontalAlignment="ALIGN_CENTER"
width="36px">
<b:Button size="MINI" ui:field="uib_add_to_input_kpi"
title="Add to input KPI" />
<b:Button size="MINI" ui:field="uib_remove_from_input_kpi"
title="Remove from input KPI" />
<b:Button size="MINI" ui:field="uib_reset_input_kpi"
title="Reset input KPI" />
</g:VerticalPanel>
<g:VerticalPanel>
<g:Label>KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_kpi">
<b:Controls>
<b:InputAddOn>
<g:HorizontalPanel verticalAlignment="ALIGN_MIDDLE">
<b:ListBox ui:field="list_dea_kpi" multipleSelect="true"
addStyleNames="the_select_custom" height="100px">
</b:ListBox>
</g:HorizontalPanel>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:VerticalPanel>
<g:VerticalPanel horizontalAlignment="ALIGN_CENTER"
verticalAlignment="ALIGN_MIDDLE" width="36px">
<b:Button size="MINI" ui:field="uib_add_to_output_kpi"
title="Add to output KPI" />
<b:Button size="MINI" ui:field="uib_remove_from_output_kpi"
title="Remove from output KPI" />
<b:Button size="MINI" ui:field="uib_reset_output_kpi"
title="Reset output KPI" />
</g:VerticalPanel>
<g:VerticalPanel>
<g:Label>Output KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_output_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox addStyleNames="the_select_custom"
ui:field="list_dea_output_kpi" multipleSelect="true" height="100px">
</b:ListBox>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:VerticalPanel>
</g:HorizontalPanel>
<g:HorizontalPanel width="100%"
horizontalAlignment="ALIGN_CENTER">
<b:Button type="DEFAULT" text="Run Analysis" ui:field="button_dea_analys_request" />
</g:HorizontalPanel>
<g:FlowPanel ui:field="alert_error" />
</g:VerticalPanel>
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm"
addStyleNames="the_margin_top_bottom" visible="false">
<b:Label text="DEA ANALYSIS Results" type="INFO"></b:Label>
<g:HorizontalPanel verticalAlignment="ALIGN_TOP" horizontalAlignment="ALIGN_LEFT">
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm_container"
addStyleNames="the_margin_left" horizontalAlignment="ALIGN_LEFT">
</g:VerticalPanel>
</g:HorizontalPanel>
</g:VerticalPanel>
</g:VerticalPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -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<String,String> 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<String> inputKPINames = getSelected(list_dea_input_kpi);
List<String> 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<listBox.getItemCount(); i++) {
listBox.setItemSelected(i, selected);
}
}
/**
* Gets the selected.
*
* @param listBox the list box
* @return the selected
*/
private List<String> getSelected(ListBox listBox){
List<String> selected = new ArrayList<String>();
for (int i=0; i<listBox.getItemCount(); i++) {
if (listBox.isItemSelected(i)) {
selected.add(listBox.getItemText(i));
}
}
return selected;
}
@ -333,33 +215,7 @@ public class AnalyticsPanelResult extends Composite {
return foundKPI;
}
/**
* 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();
GWT.log("Searching pureged KPI name: "+purgedName);
//String purgedName = name.trim();
for (KPI kpi : selectedKPIs) {
String purgedKPIName = kpi.getName().replaceAll("\\%", "").trim();
//String purgedKPIName = kpi.getName().trim();
GWT.log("The purged KPI name: "+purgedName);
if(purgedKPIName.compareToIgnoreCase(purgedName)==0) {
foundKPI = kpi;
break;
}
}
GWT.log("FOUND KPI: "+foundKPI);
return foundKPI;
}*/
/**
* Adds the parameters.
@ -394,17 +250,20 @@ public class AnalyticsPanelResult extends Composite {
}
}
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() +", ";
}
KPINames = KPINames.substring(0, KPINames.length()-2);
flexTable.setWidget(2,0, new HTML(KPINames));
flexTable.setWidget(2, 0, new HTML("KPI:"));
flexTable.setWidget(2, 1, new HTML(KPINames));
fillDeaListBoxes();
//CHANGING LABEL TEXT TO SCAPE_PARAM
uib_label_focus_id.setText(dataInputParameters.get(PerformFishAnalyticsConstant.DM_SCALEP_PARAM) + " ID");
@ -417,17 +276,6 @@ public class AnalyticsPanelResult extends Composite {
}
/**
* 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 focus ids.
@ -655,22 +503,6 @@ public class AnalyticsPanelResult extends Composite {
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);
}
/**
@ -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<KPI> 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<String> inputKPINames, List<String> 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<KPI> inputKPI = new ArrayList<KPI>();
for (String kpiName : inputKPINames) {
inputKPI.add(getKPIForName(kpiName));
}
List<KPI> outputKPI = new ArrayList<KPI>();
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<KPI> inputKPIs, List<KPI> 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<String>() {
@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<CSVFile>() {
@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<String, String> dataInputParameters, final List<KPI> inputKPI, final List<KPI> 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<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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<DataMinerResponse>() {
@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);
}
});
}
}

View File

@ -14,13 +14,9 @@
addStyleNames="the_margin_top_bottom">
<b:Label text="Parameters"></b:Label>
</g:VerticalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_results"
addStyleNames="the_margin_top_bottom">
<b:Label text="CORRELATION Matrix"></b:Label>
<g:HorizontalPanel addStyleNames="the_margin_top">
<g:Label ui:field="uib_label_focus_id">Focus ID</g:Label>
<g:Label ui:field="uib_label_focus_id" addStyleNames="the_margin_left">Focus
ID</g:Label>
<b:ControlGroup ui:field="cg_focus_id_correlation">
<b:Controls>
<b:ListBox name="Select Focus ID" b:id="field_list_focus_id_correlation"
@ -30,52 +26,15 @@
</b:Controls>
</b:ControlGroup>
</g:HorizontalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_results"
addStyleNames="the_margin_top_bottom">
<b:Label text="CORRELATION Matrix"></b:Label>
<g:VerticalPanel ui:field="uib_vp_correlation_results_container"
addStyleNames="the_margin_left">
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_deanalanlysis_algorithm_request"
addStyleNames="the_margin_top_bottom">
<b:Label text="DEA ANALYSIS Request"></b:Label>
<g:HorizontalPanel ui:field="uib_vp_deanalanlysis_request_container"
addStyleNames="the_margin_top_bottom the_margin_left">
<g:Label>Input KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_input_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox ui:field="list_dea_input_kpi"
multipleSelect="true" addStyleNames="the_margin_left the_select_custom"
height="100px">
</b:ListBox>
<b:appendWidget>
<b:CheckBox ui:field="uib_check_all_input_kpi"
title="Select/Unselect All" />
</b:appendWidget>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
<g:Label addStyleNames="the_margin_left" styleName="{style.paddingLeft}">Output
KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_output_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox addStyleNames="the_margin_left the_select_custom"
ui:field="list_dea_output_kpi" multipleSelect="true" height="100px">
</b:ListBox>
<b:appendWidget>
<b:CheckBox ui:field="uib_check_all_output_kpi"
title="Select/Unselect All" />
</b:appendWidget>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
<b:Button type="DEFAULT" text="Submit DEA Analysis Request"
ui:field="button_dea_analys_request" addStyleNames="the_margin_left">
</b:Button>
</g:HorizontalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_unary_algorithm"
addStyleNames="the_margin_top_bottom" visible="false">
<b:Label text="BOXPLOT and SPEEDOMETER Results" type="INFO"></b:Label>
@ -92,13 +51,6 @@
</g:VerticalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm"
addStyleNames="the_margin_top_bottom" visible="false">
<b:Label text="DEA ANALYSIS Results" type="INFO"></b:Label>
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm_container"
addStyleNames="the_margin">
</g:VerticalPanel>
</g:VerticalPanel>
</g:VerticalPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -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<Widget, DeaPanelResult> {
}
@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<String, String> dataInputParameters;
private DataMinerResponse dmResponse;
private Map<String, List<KPI>> kpiMapPointers = new HashMap<String, List<KPI>>();
private List<KPI> selectedKPIs;
//private List<String> 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: <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g=
* "urn:import:**user's package**">
* <g:**UserClassName**>Hello!</g:**UserClassName> </ui:UiBinder> 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<String> inputKPINames = new ArrayList<String>();
for (int i = 0; i < list_dea_input_kpi.getItemCount(); i++) {
inputKPINames.add(list_dea_input_kpi.getItemText(i));
}
List<String> outputKPINames = new ArrayList<String>();
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<String> notSelected = null;
switch (kpiButtonType) {
case INPUT_KPI:
notSelected = new ArrayList<String>();
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<String>();
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<String> notSelected = null;
switch (kpiButtonType) {
case INPUT_KPI:
notSelected = new ArrayList<String>();
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<String>();
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<String, String> getDataInputParameters() {
return dataInputParameters;
}
/**
* Adds the list focus ids.
*
* @param listFocusIDs
* the list focus I ds
*/
public void addListFocusIds(List<String> 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<KPI> selectedKPIs) {
this.selectedKPIs = selectedKPIs;
}
/**
* Adds the selected areas.
*
* @param listAreas
* the list areas
*/
/*public void addSelectedAreas(List<String> 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<String, List<String>> parameters, String toShowBatchTypeValue) {
final FlexTable flexTable = new FlexTable();
flexTable.setStyleName("colgrouptable");
try {
List<String> dataInputs = parameters.get(keyToGet);
if (dataInputs == null || dataInputs.isEmpty())
return;
dataInputParameters = new HashMap<String, String>();
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<KPI> 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<String> inputKPINames, List<String> 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<KPI> inputKPI = new ArrayList<KPI>();
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<KPI> outputKPI = new ArrayList<KPI>();
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<KPI> inputKPIs, List<KPI> 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<String>() {
@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<CSVFile>() {
@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<String, String> dataInputParameters, final List<KPI> inputKPI,
final List<KPI> 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<String, List<String>> mapParameters = new HashMap<String, List<String>>();
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<DataMinerResponse>() {
@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);
}
});
}
}

View File

@ -0,0 +1,119 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.paddingLeft {
padding-left: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="field_html_panel" addStyleNames="the_margin">
<g:VerticalPanel ui:field="field_parameters">
<g:VerticalPanel ui:field="field_parameters_container"
addStyleNames="the_margin_top_bottom">
<b:Label text="Parameters"></b:Label>
</g:VerticalPanel>
<g:HorizontalPanel addStyleNames="the_margin_top">
<g:Label ui:field="uib_label_focus_id" addStyleNames="the_margin_left">Focus
ID</g:Label>
<b:ControlGroup ui:field="cg_focus_id_correlation">
<b:Controls>
<b:ListBox name="Select Focus ID" b:id="field_list_focus_id_correlation"
ui:field="field_list_focus_id_correlation" multipleSelect="false"
addStyleNames="the_margin_left">
</b:ListBox>
</b:Controls>
</b:ControlGroup>
</g:HorizontalPanel>
</g:VerticalPanel>
<g:VerticalPanel ui:field="field_results"
addStyleNames="the_margin_top_bottom">
<g:VerticalPanel ui:field="field_deanalanlysis_algorithm_request"
addStyleNames="the_margin_top_bottom">
<b:Label text="DEA ANALYSIS Request"></b:Label>
<g:FlowPanel ui:field="alert_info" />
<g:HorizontalPanel ui:field="uib_vp_deanalanlysis_request_container"
verticalAlignment="ALIGN_MIDDLE">
<g:VerticalPanel>
<g:Label addStyleNames="the_margin_left">Input KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_input_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox ui:field="list_dea_input_kpi"
multipleSelect="true" addStyleNames="the_margin_left the_select_custom"
height="100px">
</b:ListBox>
<b:appendWidget>
</b:appendWidget>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:VerticalPanel>
<g:VerticalPanel horizontalAlignment="ALIGN_CENTER"
width="36px">
<b:Button size="MINI" ui:field="uib_add_to_input_kpi"
title="Add to input KPI" />
<b:Button size="MINI" ui:field="uib_remove_from_input_kpi"
title="Remove from input KPI" />
<b:Button size="MINI" ui:field="uib_reset_input_kpi"
title="Reset input KPI" />
</g:VerticalPanel>
<g:VerticalPanel>
<g:Label>KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_kpi">
<b:Controls>
<b:InputAddOn>
<g:HorizontalPanel verticalAlignment="ALIGN_MIDDLE">
<b:ListBox ui:field="list_dea_kpi" multipleSelect="true"
addStyleNames="the_select_custom" height="100px">
</b:ListBox>
</g:HorizontalPanel>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:VerticalPanel>
<g:VerticalPanel horizontalAlignment="ALIGN_CENTER"
verticalAlignment="ALIGN_MIDDLE" width="36px">
<b:Button size="MINI" ui:field="uib_add_to_output_kpi"
title="Add to output KPI" />
<b:Button size="MINI" ui:field="uib_remove_from_output_kpi"
title="Remove from output KPI" />
<b:Button size="MINI" ui:field="uib_reset_output_kpi"
title="Reset output KPI" />
</g:VerticalPanel>
<g:VerticalPanel>
<g:Label>Output KPI</g:Label>
<b:ControlGroup ui:field="cg_list_dea_output_kpi">
<b:Controls>
<b:InputAddOn>
<b:ListBox addStyleNames="the_select_custom"
ui:field="list_dea_output_kpi" multipleSelect="true" height="100px">
</b:ListBox>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:VerticalPanel>
</g:HorizontalPanel>
<g:HorizontalPanel width="100%"
horizontalAlignment="ALIGN_CENTER">
<b:Button type="DEFAULT" text="Run Analysis" ui:field="button_dea_analys_request" />
</g:HorizontalPanel>
<g:FlowPanel ui:field="alert_error" />
</g:VerticalPanel>
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm"
addStyleNames="the_margin_top_bottom" visible="false">
<b:Label text="DEA ANALYSIS Results" type="INFO"></b:Label>
<g:HorizontalPanel verticalAlignment="ALIGN_TOP" horizontalAlignment="ALIGN_LEFT">
<g:VerticalPanel ui:field="uib_vp_deanalanlysis_algorithm_container"
addStyleNames="the_margin_left" horizontalAlignment="ALIGN_LEFT">
</g:VerticalPanel>
</g:HorizontalPanel>
</g:VerticalPanel>
</g:VerticalPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -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
@ -206,6 +221,15 @@ public class RecapSubmitPage extends Composite {
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);
}

View File

@ -34,6 +34,9 @@
<b:Button ui:field="uib_butt_correlation_analysis"
text="Correlation Analysis" name="CORRELATION"
addStyleNames="the_margin_top" enabled="false"></b:Button>
<b:Button ui:field="uib_butt_dea_analysis"
text="Dea Analysis" name="DEA_ANALYSIS"
addStyleNames="the_margin_top" enabled="false"></b:Button>
</g:VerticalPanel>
<g:VerticalPanel ui:field="synopsisPanel"
styleName="{style.theMarginTop50}">

View File

@ -52,13 +52,18 @@ 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.
*

View File

@ -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");

View File

@ -15,8 +15,6 @@ import org.slf4j.LoggerFactory;
import com.liferay.portal.service.UserLocalServiceUtil;
/**
* The Class WsUtil.
*
@ -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,18 +41,17 @@ 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) {
@ -72,15 +68,17 @@ public class ContextUtil {
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) {
@ -89,26 +87,28 @@ public class ContextUtil {
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;
}
/**
* 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 {
PortalContextInfo pContext = getPortalContext(request);
@ -119,12 +119,13 @@ 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);
@ -133,7 +134,8 @@ public class ContextUtil {
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");
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);
session.setAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE, performFishService);
@ -142,25 +144,27 @@ public class ContextUtil {
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);
HttpSession session = httpServletRequest.getSession();
ServiceParameters performFishService = (ServiceParameters) session.getAttribute(PERFORM_FISH_RESPONSE_ATTRIBUTE);
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");
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);
session.setAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE, performFishService);
@ -169,13 +173,14 @@ public class ContextUtil {
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 {
@ -187,7 +192,8 @@ public class ContextUtil {
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);
ServiceEndpointReader reader = new ServiceEndpointReader(pContext.getCurrentScope(), SERVICE_ENDPOINT_NAME,
SERVICE_ENDPOINT_CATEGORY);
dataminerService = reader.readResource(false);
log.debug("Instancied dataminer-service: " + dataminerService);
session.setAttribute(DATAMINER_SERVICE_ATTRIBUTE, dataminerService);
@ -197,6 +203,4 @@ public class ContextUtil {
}
}

View File

@ -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;