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}">

24
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>
@ -159,7 +159,7 @@
<artifactId>commons-io</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
@ -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,7 +235,21 @@
<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>
<groupId>org.codehaus.mojo</groupId>

View File

@ -4,7 +4,6 @@
package org.gcube.portlets.user.performfishanalytics.client;
/**
* The Class PerformFishAnalyticsConstant.
*
@ -27,11 +26,13 @@ public class PerformFishAnalyticsConstant {
public static final String DM_YEARS_PARAM = "years";
public static final String DM_FARMFILE_PARAM = "farmFile";
public static final String DM_FOCUS_PARAM = "focus";
public static final String DM_APDISEASES = "apdiseases";
public static final String DM_ABDISEASES = "abdiseases";
public static final String DM_INPUT_KPI_PARAM = "inputKPI";
public static final String DM_OUTPUT_KPI_PARAM = "outputKPI";
public static final int CSV_BATCHES_TABLE_MINIMUM_SIZE = 4;
//SYNOPTIC TABLE
// SYNOPTIC TABLE
public static final String DM_INPUT_TABLE = "inputTable";
public static final String DM_ZONE_LABELS = "zonesLabels";
public static final String DM_STOCKING_PERIOD = "stockingPeriod";
@ -39,7 +40,6 @@ public class PerformFishAnalyticsConstant {
public static final String DM_ALLYEARS_PARAM = "allyears";
public static final String DM_VALUE_ALL = "ALL";
public static final String PERFORM_FISH_AREA_PARAM = "area";
public static final String PERFORM_FISH_QUARTER_PARAM = "quarter";
public static final String PERFORM_FISH_PERIOD_PARAM = "period";
@ -48,83 +48,72 @@ public class PerformFishAnalyticsConstant {
public static final String PERFORM_FISH_BATCH_TYPE_PARAM = "batch_type";
public static final String PERFORM_FISH_SPECIES_ID_PARAM = "speciesid";
public static final String DM_FOCUS_ID_ALL_ITEM_VALUE = "ALL";
public static final String DM_FOCUS_ID_ALL_ITEM_TEXT = "ALL the above";
/**
* The Enum POPULATION_LEVEL.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* @author Francesco Mangiacrapa at ISTI-CNR
* (francesco.mangiacrapa@isti.cnr.it)
*
* May 8, 2019
* May 8, 2019
*/
public static enum POPULATION_LEVEL{BATCH, FARM};
public static enum POPULATION_LEVEL {
BATCH, FARM
};
/**
* The Enum BATCH_LEVEL.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Feb 27, 2019
* @author Francesco Mangiacrapa at ISTI-CNR
* (francesco.mangiacrapa@isti.cnr.it) Feb 27, 2019
*/
public static enum BATCH_LEVEL{
PRE_ONGROWING,
PRE_ONGROWING_CLOSED_BATCHES,
HATCHERY_INDIVIDUAL,
HATCHERY_INDIVIDUAL_CLOSED_BATCHES,
GROW_OUT_INDIVIDUAL,
GROW_OUT_INDIVIDUAL_CLOSED_BATCHES,
GROW_OUT_AGGREGATED,
GROW_OUT_AGGREGATED_CLOSED_BATCHES
public static enum BATCH_LEVEL {
PRE_ONGROWING, PRE_ONGROWING_CLOSED_BATCHES, HATCHERY_INDIVIDUAL, HATCHERY_INDIVIDUAL_CLOSED_BATCHES, GROW_OUT_INDIVIDUAL, GROW_OUT_INDIVIDUAL_CLOSED_BATCHES, GROW_OUT_AGGREGATED, GROW_OUT_AGGREGATED_CLOSED_BATCHES
}
/**
* The Enum PFServiceToDMMappingTable.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* @author Francesco Mangiacrapa at ISTI-CNR
* (francesco.mangiacrapa@isti.cnr.it)
*
* May 8, 2019
* May 8, 2019
*/
public static enum PFSERVICE_TO_DM_MAPPING_TABLE{
public static enum PFSERVICE_TO_DM_MAPPING_TABLE {
LethalIncidentsTable("LethalIncidentsTable", "lethalIncidentsFile"),
AntibioticsTable_internal("AntibioticsTable_internal", null),
AntibioticsTable("AntibioticsTable", "antibioticFile"),
AnnualTable_internal("AnnualTable_internal", null),
AnnualTable("AnnualTable", "annualFile"),
AntiparasiticTable("AntiparasiticTable", "antiparasiticFile"),
AntiparasiticTable_internal("AntiparasiticTable_internal", null);
LethalIncidentsTable("LethalIncidentsTable", "lethalIncidentsFile"), AntibioticsTable_internal(
"AntibioticsTable_internal",
null), AntibioticsTable("AntibioticsTable", "antibioticFile"), AnnualTable_internal(
"AnnualTable_internal",
null), AnnualTable("AnnualTable", "annualFile"), AntiparasiticTable("AntiparasiticTable",
"antiparasiticFile"), AntiparasiticTable_internal("AntiparasiticTable_internal", null);
/**
* Instantiates a new PF service to DM mapping table.
*
* @param performFishTable the perform fish table
* @param dataMinerTable the data miner table
* @param performFishTable
* the perform fish table
* @param dataMinerTable
* the data miner table
*/
PFSERVICE_TO_DM_MAPPING_TABLE(String performFishTable, String dataMinerTable){
PFSERVICE_TO_DM_MAPPING_TABLE(String performFishTable, String dataMinerTable) {
this.performFishTable = performFishTable;
this.dataMinerTable=dataMinerTable;
this.dataMinerTable = dataMinerTable;
}
String performFishTable;
String dataMinerTable;
public String getPerformFishTable() {
return performFishTable;
}
public String getDataMinerTable() {
return dataMinerTable;
}
}
}

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

@ -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,51 +25,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">
@ -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));
fillDeaListBoxes();
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");
@ -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
@ -205,6 +220,15 @@ public class RecapSubmitPage extends Composite {
public void activeCorrelationAnalysis(boolean active){
uib_butt_correlation_analysis.setEnabled(active);
}
/**
* Active dea analysis.
*
* @param active the active
*/
public void activeDeaAnalysis(boolean active){
uib_butt_dea_analysis.setEnabled(active);
}
/**
* Active scatter plot.
@ -227,7 +251,7 @@ public class RecapSubmitPage extends Composite {
activeSpeedometer(active);
activeCorrelationAnalysis(active);
activeBoxPlot(active);
activeDeaAnalysis(active);
}

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,12 +52,17 @@ public class ShowResult extends Composite {
* @param title the title
*/
public ShowResult(String title) {
this(title, TextAlign.CENTER);
}
public ShowResult(String title, TextAlign textAlign) {
initWidget(uiBinder.createAndBindUi(this));
theTitle.getElement().addClassName("theSubTitle");
theTitle.getElement().getStyle().setTextAlign(TextAlign.CENTER);
theTitle.getElement().getStyle().setTextAlign(textAlign);
theTitle.setHTML(title);
}
/**
* Show image.

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,13 +15,11 @@ import org.slf4j.LoggerFactory;
import com.liferay.portal.service.UserLocalServiceUtil;
/**
* The Class WsUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jan 11, 2019
* Jan 11, 2019
*/
public class ContextUtil {
@ -34,7 +32,6 @@ public class ContextUtil {
public static String SERVICE_ENDPOINT_CATEGORY = "DataAnalysis";
public static String SERVICE_ENDPOINT_NAME = "DataMiner";
/**
* Checks if is within portal.
*
@ -44,73 +41,76 @@ public class ContextUtil {
try {
UserLocalServiceUtil.getService();
return true;
}
catch (Exception ex) {
log.trace("Development Mode ON");
} catch (Throwable ex) {
log.debug("Development Mode ON");
return false;
}
}
/**
* Gets the portal context.
*
* @param httpServletRequest the http servlet request
* @param httpServletRequest
* the http servlet request
* @return the portal context
*/
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest){
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest) {
PortalContext pContext = PortalContext.getConfiguration();
//USER
// USER
GCubeUser user = pContext.getCurrentUser(httpServletRequest);
String username = user.getUsername();
String fullName = user.getFullname();
String email = user.getEmail();
String avatarID = user.getUserAvatarId();
String avatarURL = user.getUserAvatarURL();
//SESSION
// SESSION
String currentScope = pContext.getCurrentScope(httpServletRequest);
String userToken = pContext.getCurrentUserToken(httpServletRequest);
long currGroupId = pContext.getCurrentGroupId(httpServletRequest);
return new PortalContextInfo(username, fullName, email, avatarID, avatarURL, currentScope, userToken, currGroupId);
return new PortalContextInfo(username, fullName, email, avatarID, avatarURL, currentScope, userToken,
currGroupId);
}
/**
* Gets the portal context.
*
* @param httpServletRequest the http servlet request
* @param overrideScope the override scope
* @param httpServletRequest
* the http servlet request
* @param overrideScope
* the override scope
* @return the portal context
*/
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest, String overrideScope){
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest, String overrideScope) {
PortalContextInfo info = getPortalContext(httpServletRequest);
info.setCurrentScope(overrideScope);
return info;
}
/**
* Checks if is session expired.
*
* @param httpServletRequest the http servlet request
* @param httpServletRequest
* the http servlet request
* @return true, if is session expired
* @throws Exception the exception
* @throws Exception
* the exception
*/
public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception {
log.trace("workspace session validating...");
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest)==null;
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest) == null;
}
/**
* Gets the entity factory.
*
* @param request the request
* @param request
* the request
* @return the entity factory
* @throws Exception the exception
* @throws Exception
* the exception
*/
private EntityManagerFactory getEntityFactory(HttpServletRequest request) throws Exception{
private EntityManagerFactory getEntityFactory(HttpServletRequest request) throws Exception {
PortalContextInfo pContext = getPortalContext(request);
EntityManagerFactoryCreator.instanceLocalMode();
return EntityManagerFactoryCreator.getEntityManagerFactory();
@ -119,77 +119,83 @@ public class ContextUtil {
/**
* Gets the perform fish service.
*
* @param httpServletRequest the http servlet request
* @param httpServletRequest
* the http servlet request
* @return the perform fish service
* @throws Exception the exception
* @throws Exception
* the exception
*/
public static ServiceParameters getPerformFishService(HttpServletRequest httpServletRequest) throws Exception
{
public static ServiceParameters getPerformFishService(HttpServletRequest httpServletRequest) throws Exception {
PortalContextInfo pContext = getPortalContext(httpServletRequest);
log.trace("PortalContextInfo: "+pContext);
log.trace("PortalContextInfo: " + pContext);
HttpSession session = httpServletRequest.getSession();
ServiceParameters performFishService = (ServiceParameters) session.getAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE);
if (performFishService == null){
log.info("Initializing the "+PERFORM_FISH_SERVICE_ATTRIBUTE+"...");
GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(), PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService");
if (performFishService == null) {
log.info("Initializing the " + PERFORM_FISH_SERVICE_ATTRIBUTE + "...");
GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(),
PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService");
performFishService = new ServiceParameters(gcoreEndPointReader.getEndpointValue(), null, null, null);
log.debug("Instancied peform-fish service: "+performFishService);
log.debug("Instancied peform-fish service: " + performFishService);
session.setAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE, performFishService);
}
return performFishService;
}
/**
* Save perform fish response.
*
* @param httpServletRequest the http servlet request
* @param httpServletRequest
* the http servlet request
* @return the service parameters
* @throws Exception the exception
* @throws Exception
* the exception
*/
public static ServiceParameters savePerformFishResponse(HttpServletRequest httpServletRequest) throws Exception
{
public static ServiceParameters savePerformFishResponse(HttpServletRequest httpServletRequest) throws Exception {
PortalContextInfo pContext = getPortalContext(httpServletRequest);
log.trace("PortalContextInfo: "+pContext);
log.trace("PortalContextInfo: " + pContext);
HttpSession session = httpServletRequest.getSession();
ServiceParameters performFishService = (ServiceParameters) session.getAttribute(PERFORM_FISH_RESPONSE_ATTRIBUTE);
if (performFishService == null){
log.info("Initializing the "+PERFORM_FISH_SERVICE_ATTRIBUTE+"...");
GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(), PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService");
ServiceParameters performFishService = (ServiceParameters) session
.getAttribute(PERFORM_FISH_RESPONSE_ATTRIBUTE);
if (performFishService == null) {
log.info("Initializing the " + PERFORM_FISH_SERVICE_ATTRIBUTE + "...");
GcoreEndpointReader gcoreEndPointReader = new GcoreEndpointReader(pContext.getCurrentScope(),
PERFORM_SERVICE, "Application", "org.gcube.application.perform.service.PerformService");
performFishService = new ServiceParameters(gcoreEndPointReader.getEndpointValue(), null, null, null);
log.debug("Instancied peform-fish service: "+performFishService);
log.debug("Instancied peform-fish service: " + performFishService);
session.setAttribute(PERFORM_FISH_SERVICE_ATTRIBUTE, performFishService);
}
return performFishService;
}
/**
* Gets the data miner service.
*
* @param httpServletRequest the http servlet request
* @param httpServletRequest
* the http servlet request
* @return the data miner service
* @throws Exception the exception
* @throws Exception
* the exception
*/
public static ServiceParameters getDataMinerService(HttpServletRequest httpServletRequest) throws Exception {
PortalContextInfo pContext = getPortalContext(httpServletRequest);
log.trace("PortalContextInfo: "+pContext);
log.trace("PortalContextInfo: " + pContext);
HttpSession session = httpServletRequest.getSession();
ServiceParameters dataminerService = (ServiceParameters) session.getAttribute(DATAMINER_SERVICE_ATTRIBUTE);
if (dataminerService == null){
log.info("Initializing the "+DATAMINER_SERVICE_ATTRIBUTE+"...");
ServiceEndpointReader reader = new ServiceEndpointReader(pContext.getCurrentScope(), SERVICE_ENDPOINT_NAME, SERVICE_ENDPOINT_CATEGORY);
if (dataminerService == null) {
log.info("Initializing the " + DATAMINER_SERVICE_ATTRIBUTE + "...");
ServiceEndpointReader reader = new ServiceEndpointReader(pContext.getCurrentScope(), SERVICE_ENDPOINT_NAME,
SERVICE_ENDPOINT_CATEGORY);
dataminerService = reader.readResource(false);
log.debug("Instancied dataminer-service: "+dataminerService);
log.debug("Instancied dataminer-service: " + dataminerService);
session.setAttribute(DATAMINER_SERVICE_ATTRIBUTE, dataminerService);
}
@ -197,6 +203,4 @@ public class ContextUtil {
}
}

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;