Enhancement on Algorithms

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/performfish-analytics-portlet@179316 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2019-05-08 14:53:36 +00:00
parent 0c046b256b
commit fcfcf9ff83
8 changed files with 431 additions and 120 deletions

View File

@ -24,6 +24,7 @@ public class PerformFishAnalyticsConstant {
public static final String DM_SCALEP_PARAM = "scaleP";
public static final String DM_BATCHTYPE_PARAM = "batchtype";
public static final String DM_CHARTTYPE_PARAM = "charttype";
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_INPUT_KPI_PARAM = "inputKPI";
@ -81,13 +82,13 @@ public class PerformFishAnalyticsConstant {
*/
public static enum PFSERVICE_TO_DM_MAPPING_TABLE{
LethalIncidentsTable("LethalIncidentsTable", ""),
AntibioticsTable_internal("AntibioticsTable_internal", ""),
AntibioticsTable("AntibioticsTable", ""),
AnnualTable_internal("AnnualTable_internal", ""),
AnnualTable("AnnualTable", ""),
AntiparasiticTable("AntiparasiticTable", ""),
AntiparasiticTable_internal("AntiparasiticTable_internal", "");
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);
/**

View File

@ -51,8 +51,8 @@ public interface PerformFishAnalyticsService extends RemoteService {
*/
PerformFishResponse submitRequestToPerformFishService(Map<String, List<String>> mapParameters) throws Exception;
DataMinerResponse callingDataMinerPerformFishCorrelationAnalysis(
PerformFishResponse result, Map<String, List<String>> mapParameters) throws Exception;
DataMinerResponse callingDataMinerPerformFishCorrelationAnalysis(PerformFishResponse result,
Map<String, List<String>> mapParameters) throws Exception;
/**
* @param file
@ -94,4 +94,10 @@ public interface PerformFishAnalyticsService extends RemoteService {
*/
boolean checkGrantToAccessFarmID(String farmID)
throws Exception;
DataMinerResponse callingDataMinerPerformFishAnnualAnalysis(Map<String, List<String>> algorithmMapParameters)
throws Exception;
DataMinerResponse callingDataMinerPerformFishAnnualCorrelationAnalysis(PerformFishResponse peformFishReponse,
Map<String, List<String>> mapParameters) throws Exception;
}

View File

@ -77,4 +77,12 @@ public interface PerformFishAnalyticsServiceAsync
void checkGrantToAccessFarmID(String farmID, AsyncCallback<Boolean> callback);
void callingDataMinerPerformFishAnnualAnalysis(Map<String, List<String>> algorithmMapParameters,
AsyncCallback<DataMinerResponse> callback);
void callingDataMinerPerformFishAnnualCorrelationAnalysis(PerformFishResponse peformFishReponse,
Map<String, List<String>> mapParameters, AsyncCallback<DataMinerResponse> callback);
}

View File

@ -0,0 +1,122 @@
package org.gcube.portlets.user.performfishanalytics.client.annualcontrollers;
import java.util.List;
import org.gcube.portlets.user.performfishanalytics.client.DataMinerAlgorithms;
import org.gcube.portlets.user.performfishanalytics.shared.KPI;
import org.gcube.portlets.user.performfishanalytics.shared.performfishservice.PerformFishResponse;
/**
* The Class DataMinerInputParameters.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* May 8, 2019
*/
public class DataMinerInputParameters {
private PerformFishResponse performFishResponse;
private List<String> selectedYears;
private List<KPI> inputKPI;
private List<KPI> outputKPI;
private DataMinerAlgorithms chartType;
private String focusID;
public DataMinerInputParameters() {
}
public DataMinerInputParameters(PerformFishResponse performFishResponse, List<String> selectedYears,
List<KPI> inputKPI, List<KPI> outputKPI, DataMinerAlgorithms chartType, String focusID) {
super();
this.performFishResponse = performFishResponse;
this.selectedYears = selectedYears;
this.inputKPI = inputKPI;
this.outputKPI = outputKPI;
this.chartType = chartType;
this.focusID = focusID;
}
public PerformFishResponse getPerformFishResponse() {
return performFishResponse;
}
public void setPerformFishResponse(PerformFishResponse performFishResponse) {
this.performFishResponse = performFishResponse;
}
public List<String> getSelectedYears() {
return selectedYears;
}
public void setSelectedYears(List<String> selectedYears) {
this.selectedYears = selectedYears;
}
public List<KPI> getInputKPI() {
return inputKPI;
}
public void setInputKPI(List<KPI> inputKPI) {
this.inputKPI = inputKPI;
}
public List<KPI> getOutputKPI() {
return outputKPI;
}
public void setOutputKPI(List<KPI> outputKPI) {
this.outputKPI = outputKPI;
}
public DataMinerAlgorithms getChartType() {
return chartType;
}
public void setChartType(DataMinerAlgorithms chartType) {
this.chartType = chartType;
}
public String getFocusID() {
return focusID;
}
public void setFocusID(String focusID) {
this.focusID = focusID;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("DataMinerInputParameters [performFishResponse=");
builder.append(performFishResponse);
builder.append(", selectedYears=");
builder.append(selectedYears);
builder.append(", inputKPI=");
builder.append(inputKPI);
builder.append(", outputKPI=");
builder.append(outputKPI);
builder.append(", chartType=");
builder.append(chartType);
builder.append(", focusID=");
builder.append(focusID);
builder.append("]");
return builder.toString();
}
}

View File

@ -10,16 +10,14 @@ 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.PerformFishAnalyticsConstant.POPULATION_LEVEL;
import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE;
import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsServiceAsync;
import org.gcube.portlets.user.performfishanalytics.client.event.AddedBatchIdEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.AddedBatchIdEventHandler;
import org.gcube.portlets.user.performfishanalytics.client.event.CallAlgorithmEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.CallAlgorithmEventHandler;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEventHandler;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadFocusEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadFocusEventHandler;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEventHandler;
import org.gcube.portlets.user.performfishanalytics.client.event.PerformFishFieldFormChangedEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.PerformFishFieldFormChangedEventHandler;
import org.gcube.portlets.user.performfishanalytics.client.event.SelectedKPIEvent;
@ -271,7 +269,7 @@ public class PerformFishAnnualAnalyticsController {
}
});
//
eventBus.addHandler(SubmitRequestEvent.TYPE, new SubmitRequestEventHandler() {
@Override
@ -304,23 +302,25 @@ public class PerformFishAnnualAnalyticsController {
case BOXPLOT:
//UNARY
//callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), selectedKPI, null);
callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null);
break;
case SCATTER:
// if(selectedKPI.size()==2)
// callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), selectedKPI, null);
// else
// Window.alert("Something seems wrong... You must select exactly two KPIs to execute the "+submitRequestEvent.getChartType());
if(viewAnnualController.getSelectedKPIs().size()==2)
callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null);
else
Window.alert("Something seems wrong... You must select exactly two KPIs to execute the "+dmAlgorithm);
break;
case CORRELATION:
//callDataMinerServiceForChartTypeCorrelation(viewController.getPerformFishResponse(), viewController.getRequestMapParameters());
//callDataMinerServiceForChartTypeCorrelation(thePerformFishResponse, viewController.getRequestMapParameters());
callDataMinerServiceForChartTypeCorrelation(theFocusValue, viewAnnualController.getSelectedKPIs(), viewAnnualController.getSelectedKPIs());
//callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null);
break;
case SPEEDOMETER:
//UNARY
//callAlgorithm(submitRequestEvent.getChartType(), viewController.getSelectedBatchID().get(0), selectedKPI, selectedKPI);
callAlgorithm(dmAlgorithm, theFocusValue, viewAnnualController.getSelectedKPIs(), null);
break;
default:
@ -335,9 +335,9 @@ public class PerformFishAnnualAnalyticsController {
* @param performFishResponse the perform fish response
* @param performFishRequestParameters the perform fish request parameters
*/
private void callDataMinerServiceForChartTypeCorrelation(final PerformFishResponse performFishResponse, final Map<String, List<String>> performFishRequestParameters) {
private void callDataMinerServiceForChartTypeCorrelation(String focusID, List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("Read perform fish response: "+performFishResponse);
/*GWT.log("Read perform fish response: "+performFishResponse);
String batchTableURL = performFishResponse.getMapParameters().get(PerformFishAnalyticsConstant.BATCHES_TABLE);
@ -365,9 +365,63 @@ public class PerformFishAnnualAnalyticsController {
dataInputsFormatter.append("inputKPI="+kpiCodes+";");
//dataInputsFormatter.append("outputKPI=;");
String dataInParameters = dataInputsFormatter.toString();*/
DataMinerInputParameters dmInputParameters = new DataMinerInputParameters(thePerformFishResponse, viewAnnualController.getSelectedYears(), inputKPI, outputKPI, DataMinerAlgorithms.CORRELATION, focusID);
GWT.log("Building DM request with input parameters: "+dmInputParameters);
StringBuilder dataInputsFormatter = new StringBuilder();
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+ dmInputParameters.getChartType() +";");
String yearsValue = "";
for (String year : dmInputParameters.getSelectedYears()) {
yearsValue+=year+"|";
}
yearsValue = yearsValue.substring(0, yearsValue.length()-1);
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM+"="+ yearsValue +";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+dmInputParameters.getFocusID()+";");
//dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;");
if(dmInputParameters.getInputKPI()!=null && dmInputParameters.getInputKPI().size()>0){
String kpiCodes = "";
for (KPI kpi : dmInputParameters.getInputKPI()) {
kpiCodes+=kpi.getCode()+"|";
}
//remove last |
kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1);
GWT.log("Input KPICodes: "+kpiCodes);
//ADDING KPIs code
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_INPUT_KPI_PARAM+"="+kpiCodes+";");
}
if(dmInputParameters.getOutputKPI()!=null && dmInputParameters.getOutputKPI().size()>0){
String kpiCodes = "";
for (KPI kpi : dmInputParameters.getOutputKPI()) {
kpiCodes+=kpi.getCode()+"|";
}
//remove last |
kpiCodes = kpiCodes.substring(0, kpiCodes.length()-1);
GWT.log("Output KPICodes: "+kpiCodes);
//ADDING KPIs code
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM+"="+kpiCodes+";");
}
Map<String, String> performFishResponseMap = dmInputParameters.getPerformFishResponse().getMapParameters();
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable);
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable);
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable);
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable);
String dataInParameters = dataInputsFormatter.toString();
GWT.log("Calling DM service with client input parameters: "+dataInParameters);
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters));
final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1);
@ -375,14 +429,14 @@ public class PerformFishAnnualAnalyticsController {
String tabTitle = DataMinerAlgorithms.CORRELATION.getName().substring(0,1).toUpperCase()+DataMinerAlgorithms.CORRELATION.getName().toLowerCase().substring(1, DataMinerAlgorithms.CORRELATION.getName().length()); //CAMEL CASE
final Tab tab = viewAnnualController.createTab(submitRequestPanel, tabTitle+" #"+(viewAnnualController.currentNumberOfTab()+1));
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishCorrelationAnalysis(performFishResponse, mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualCorrelationAnalysis(dmInputParameters.getPerformFishResponse(), mapParameters, new AsyncCallback<DataMinerResponse>() {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
submitRequestPanel.showLoader(false, null);
checkTabSpinner(submitRequestPanel, tab);
AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult();
analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
//analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
analyticsPanelResult.addSelectedKPIs(viewAnnualController.getSelectedKPIs());
@ -406,7 +460,7 @@ public class PerformFishAnnualAnalyticsController {
checkTabSpinner(submitRequestPanel, tab);
try {
AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult();
analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
//analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
analyticsPanelResult.addSelectedKPIs(viewAnnualController.getSelectedKPIs());
//TODO COMMENTED NOW
@ -460,7 +514,9 @@ public class PerformFishAnnualAnalyticsController {
submitRequestPanel.addWidget(toBigTitle);
HorizontalPanel hp = new HorizontalPanel();
hp.getElement().addClassName("ext-horizontal-panel");
callDataMinerServiceForChart(thePerformFishResponse, POPULATION_LEVEL.BATCH, Arrays.asList(kpi), Arrays.asList(kpi), algorithm, focusID, submitRequestPanel, hp, tab);
DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse, viewAnnualController.getSelectedYears(), Arrays.asList(kpi), null, algorithm, focusID);
callDataMinerServiceForChart(dmInputParams, submitRequestPanel, hp, tab);
//resultPanel.add(hp);
submitRequestPanel.addWidget(hp);
}
@ -477,8 +533,11 @@ public class PerformFishAnnualAnalyticsController {
String titleScatter = "KPI: "+inputKPI.get(0).getName() +" vs "+inputKPI.get(1).getName();
submitRequestPanel.setTheTitle(titleScatter);
default:
callDataMinerServiceForChart(thePerformFishResponse, POPULATION_LEVEL.BATCH, inputKPI, outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab);
default:{
DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse, viewAnnualController.getSelectedYears(), inputKPI, outputKPI, algorithm, focusID);
callDataMinerServiceForChart(dmInputParams, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab);
//callDataMinerServiceForChart(thePerformFishResponse, POPULATION_LEVEL.BATCH, inputKPI, outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab);
}
}
}
@ -486,39 +545,31 @@ public class PerformFishAnnualAnalyticsController {
/**
* Call data miner service for chart.
*
* @param performFishResponse the perform fish response
* @param scalePValue the scale p value
* @param inputKPI the input kpi
* @param outputKPI the output kpi
* @param chartType the chart type
* @param focusID the focus id
* @param dmInputParameters the dm input parameters
* @param requestPanel the request panel
* @param panelContainer the panel
* @param tab the tab
*/
private void callDataMinerServiceForChart(PerformFishResponse performFishResponse, POPULATION_LEVEL scalePValue, final List<KPI> inputKPI, final List<KPI> outputKPI, final DataMinerAlgorithms chartType, final String focusID, final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab) {
GWT.log("Read perform fish response: "+performFishResponse);
String batchTableURL = performFishResponse.getMapParameters().get(PerformFishAnalyticsConstant.BATCHES_TABLE);
if(batchTableURL==null || batchTableURL.isEmpty())
Window.alert("Something seems wrong. No batches tables matching with parameter "+PerformFishAnalyticsConstant.BATCHES_TABLE+" returned from service");
private void callDataMinerServiceForChart(final DataMinerInputParameters dmInputParameters, final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab) {
GWT.log("Building DM request with input parameters: "+dmInputParameters);
StringBuilder dataInputsFormatter = new StringBuilder();
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_SCALEP_PARAM+"="+scalePValue.name()+";");
String theBatchType = viewAnnualController.getForm().getBatchType();
theBatchType = theBatchType.replace("_CLOSED_BATCHES", ""); //REMOVING SUFFIX _CLOSED_BATCHES FOR DATAMINER CALL
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_BATCHTYPE_PARAM+"="+theBatchType+";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+ chartType +";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FARMFILE_PARAM+"="+batchTableURL+";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+focusID+";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_CHARTTYPE_PARAM+"="+ dmInputParameters.getChartType() +";");
String yearsValue = "";
for (String year : dmInputParameters.getSelectedYears()) {
yearsValue+=year+"|";
}
yearsValue = yearsValue.substring(0, yearsValue.length()-1);
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_YEARS_PARAM+"="+ yearsValue +";");
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"="+dmInputParameters.getFocusID()+";");
//dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_FOCUS_PARAM+"=ID;");
if(inputKPI!=null && inputKPI.size()>0){
if(dmInputParameters.getInputKPI()!=null && dmInputParameters.getInputKPI().size()>0){
String kpiCodes = "";
for (KPI kpi : inputKPI) {
for (KPI kpi : dmInputParameters.getInputKPI()) {
kpiCodes+=kpi.getCode()+"|";
}
//remove last |
@ -530,9 +581,9 @@ public class PerformFishAnnualAnalyticsController {
}
if(outputKPI!=null && outputKPI.size()>0){
if(dmInputParameters.getOutputKPI()!=null && dmInputParameters.getOutputKPI().size()>0){
String kpiCodes = "";
for (KPI kpi : outputKPI) {
for (KPI kpi : dmInputParameters.getOutputKPI()) {
kpiCodes+=kpi.getCode()+"|";
}
//remove last |
@ -541,16 +592,22 @@ public class PerformFishAnnualAnalyticsController {
GWT.log("Output KPICodes: "+kpiCodes);
//ADDING KPIs code
dataInputsFormatter.append(PerformFishAnalyticsConstant.DM_OUTPUT_KPI_PARAM+"="+kpiCodes+";");
}
Map<String, String> performFishResponseMap = dmInputParameters.getPerformFishResponse().getMapParameters();
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.LethalIncidentsTable);
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AnnualTable);
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntibioticsTable);
dataInputsFormatter = appendDMInputTable(performFishResponseMap, dataInputsFormatter, PerformFishAnalyticsConstant.PFSERVICE_TO_DM_MAPPING_TABLE.AntiparasiticTable);
String dataInParameters = dataInputsFormatter.toString();
GWT.log("Calling DM service 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+" Analysis...");
final LoaderIcon loaderIcon = new LoaderIcon("Submitting request to "+dmInputParameters.getChartType()+" Analysis...");
loaderIcon.setVisible(true);
panelContainer.setVisible(true);
panelContainer.add(loaderIcon);
@ -560,7 +617,7 @@ public class PerformFishAnnualAnalyticsController {
loaderIcon.setFocus(true);
}});
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnalysis(mapParameters, new AsyncCallback<DataMinerResponse>() {
PerformFishAnalyticsServiceAsync.Util.getInstance().callingDataMinerPerformFishAnnualAnalysis(mapParameters, new AsyncCallback<DataMinerResponse>() {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
@ -568,18 +625,38 @@ public class PerformFishAnnualAnalyticsController {
checkTabSpinner(requestPanel, tab);
//field_unary_algorithm.setVisible(true);
GWT.log("I'm displaying: "+dmResponse);
displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panelContainer, false);
displayOutputFilesAsStaticEntities(dmResponse, dmInputParameters.getChartType(), dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), dmInputParameters.getFocusID(), panelContainer, false);
}
@Override
public void onFailure(Throwable caught) {
loaderIcon.setVisible(false);
checkTabSpinner(requestPanel, tab);
displayOutputFilesAsStaticEntities(null, chartType, inputKPI, outputKPI, focusID, panelContainer, true);
displayOutputFilesAsStaticEntities(null, dmInputParameters.getChartType(), dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), dmInputParameters.getFocusID(), panelContainer, true);
}
});
}
/**
* Append DM input table.
*
* @param performFishResponseMap the perform fish response map
* @param dataInputsFormatter the data inputs formatter
* @param table the table
* @return
*/
private StringBuilder appendDMInputTable(Map<String, String> performFishResponseMap, StringBuilder dataInputsFormatter, PFSERVICE_TO_DM_MAPPING_TABLE table) {
String toDMInputTable = performFishResponseMap.get(table.getPerformFishTable());
if(toDMInputTable!=null && !toDMInputTable.isEmpty()) {
dataInputsFormatter.append(table.getDataMinerTable()+"="+toDMInputTable+";");
}
return dataInputsFormatter;
}
/**
* Remove the spinner if all DM responses are returned.
@ -715,7 +792,4 @@ public class PerformFishAnnualAnalyticsController {
}
}
}

View File

@ -328,45 +328,6 @@ public class PerformFishAnnualAnalyticsViewController {
recapPage.activeAllAlgorithms(bool);
}
// /**
// * Manage perform fish service response.
// *
// * @param performFishResponse the perform fish response
// * @param mapParameters the map parameters
// * @param populationLevel the population level
// */
// public void managePerformFishServiceResponse(
// PerformFishResponse performFishResponse,
// Map<String, List<String>> mapParameters, POPULATION_LEVEL populationLevel) {
//
// annualListKPIView.managePerformFishServiceResponse(performFishResponse, mapParameters, populationLevel);
//
// }
// /**
// * Gets the perform fish response.
// *
// * @return the perform fish response
// */
// public PerformFishResponse getPerformFishResponse() {
//
// return annualListKPIView.getPerformFishResponse();
// }
//
//
// /**
// * Gets the map parameters.
// *
// * @return the map parameters
// */
// public Map<String, List<String>> getRequestMapParameters() {
//
// return annualListKPIView.getMapParameters();
// }
/**
* Validate kpi fields.
*
@ -464,6 +425,17 @@ public class PerformFishAnnualAnalyticsViewController {
return recapPage.getSelectedKPIs();
}
/**
* Gets the selected years.
*
* @return the selected years
*/
public List<String> getSelectedYears(){
return form.getYear();
}
/**

View File

@ -8,8 +8,8 @@ import java.util.Map;
import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsConstant;
import org.gcube.portlets.user.performfishanalytics.client.annualcontrollers.PerformFishAnnualAnalyticsController;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadFocusEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.PerformFishFieldFormChangedEvent;
import org.gcube.portlets.user.performfishanalytics.client.event.SelectedPopulationTypeEvent;
import org.gcube.portlets.user.performfishanalytics.shared.Population;

View File

@ -436,11 +436,8 @@ public class PerformFishAnalyticsServiceImpl extends RemoteServiceServlet
throw new Exception("Your request does not produce enough data for the analysis, please change your selection and try again");
}
log.info("Calling the DM service with client parameters: "+mapParameters.toString());
PortalContextInfo pContext = ContextUtil.getPortalContext(this.getThreadLocalRequest());
//PortalContextInfo pContext = ContextUtil.getPortalContext(this.getThreadLocalRequest());
Map<String, List<String>> dmRequestParameters = new HashMap<String, List<String>>();
dmRequestParameters.put("request", Arrays.asList("Execute"));
dmRequestParameters.put("service", Arrays.asList("WPS"));
@ -448,6 +445,110 @@ public class PerformFishAnalyticsServiceImpl extends RemoteServiceServlet
//dmRequestParameters.put("gcube-token", Arrays.asList(pContext.getUserToken()));
dmRequestParameters.put("lang", Arrays.asList("en-US"));
dmRequestParameters.put("Identifier", Arrays.asList("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.PERFORMFISH_ANALYSIS"));
dmRequestParameters.putAll(mapParameters);
return callTheDataMinerPerformFishCorrelationAnalysis(peformFishReponse,dmRequestParameters);
//CALL HERE
/*
ServiceParameters dataMinerService = ContextUtil.getDataMinerService(this.getThreadLocalRequest());
log.info("Found DM service: "+dataMinerService.getUrl() + " int this scope: "+pContext.getCurrentScope());
// if(!ContextUtil.isWithinPortal()){
// dataMinerService = new ServiceParameters("http://dataminer-prototypes.d4science.org/wps/WebProcessingService", null, null, dmRequestParameters);
// log.info("I'm in TEST MODE replacing it with HARD CODED: "+dataMinerService);
// }
dataMinerService.setProperties(dmRequestParameters);
//Addding client parameters to DM service request
DMServiceResponse dmResponse = null;
String response;
try{
response = new HttpCallerUtil(dataMinerService.getUrl(), null, null).performGETRequestWithRetry(dmRequestParameters, pContext.getUserToken(), 5);
if(response==null){
log.error("The presponse returned is null");
throw new Exception("The presponse returned is null");
}
dmResponse = DataMinerUtil.parseResult(dataMinerService.getUrl(), response);
}catch(Exception e){
throw new Exception("The service did not produce any result. Change your selection and try again.");
}
if(dmResponse == null || dmResponse.isWithError())
throw new Exception("The response returned by DM service contains an Exception Status. (The call is: "+dmResponse.getHttpRequestURL()+"). Please report this issue at www.d4science.org/contact-us");
try{
DataMinerOutputData toDMOutputData = null;
List<DataMinerOutputData> listOut = dmResponse.getListDMOutputData();
for (DataMinerOutputData dataMinerOutputData : listOut) {
//I'm using this specific output data of DM
if(dataMinerOutputData.getFileDescription().contains("outputCharts")){
log.info("The output: "+dataMinerOutputData.getFileDescription()+ " with: "+dataMinerOutputData.getMimeType()+" is the candidate to unzip");
toDMOutputData = dataMinerOutputData;
break;
}
}
if(toDMOutputData==null || toDMOutputData.getPublicURL()==null)
throw new Exception("The response returned by DM service does not contain a file to unzip with name: 'outputCharts'. Please report this issue at www.d4science.org/contact-us");
String theZipFileURL = toDMOutputData.getPublicURL();
log.info("I'm using the file: "+theZipFileURL);
FileContentType filter = FileContentType.CSV;
ZipExtractorUtil zipExt = new ZipExtractorUtil(theZipFileURL, Arrays.asList(filter));
List<OutputFile> output = zipExt.getOutputFiles();
log.info("Extracted output of type {} as list {}: ",filter,output);
output = manageOutputsForPerformFishAnalysis(output);
log.info("Managed output of type {} as list {}: ",filter,output);
DataMinerResponse theDMResponse = new DataMinerResponse(peformFishReponse, output);
log.debug("Returning {}",theDMResponse);
return theDMResponse;
}catch(Exception e){
log.error("There was an error extracting the DataMiner response from your request: ", e);
throw new Exception("The service did not produce any result. Change your request and try again.");
} */
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsService#callingDataMinerPerformFishCorrelationAnalysis(org.gcube.portlets.user.performfishanalytics.shared.performfishservice.PerformFishResponse, java.util.Map)
*/
@Override
public DataMinerResponse callingDataMinerPerformFishAnnualCorrelationAnalysis(PerformFishResponse peformFishReponse, Map<String, List<String>> mapParameters) throws Exception{
log.info("Calling the DM service with client parameters: "+mapParameters.toString());
//PortalContextInfo pContext = ContextUtil.getPortalContext(this.getThreadLocalRequest());
Map<String, List<String>> dmRequestParameters = new HashMap<String, List<String>>();
dmRequestParameters.put("request", Arrays.asList("Execute"));
dmRequestParameters.put("service", Arrays.asList("WPS"));
dmRequestParameters.put("Version", Arrays.asList("1.0.0"));
//dmRequestParameters.put("gcube-token", Arrays.asList(pContext.getUserToken()));
dmRequestParameters.put("lang", Arrays.asList("en-US"));
dmRequestParameters.put("Identifier", Arrays.asList("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.PERFORMFISH_ANALYSIS_ANNUAL"));
dmRequestParameters.putAll(mapParameters);
return callTheDataMinerPerformFishCorrelationAnalysis(peformFishReponse,dmRequestParameters);
}
/**
* Call the data miner perform fish correlation analysis.
*
* @param peformFishReponse the peform fish reponse
* @param mapParameters the map parameters
* @return the data miner response
* @throws Exception the exception
*/
private DataMinerResponse callTheDataMinerPerformFishCorrelationAnalysis(PerformFishResponse peformFishReponse, Map<String, List<String>> dmRequestParameters) throws Exception{
PortalContextInfo pContext = ContextUtil.getPortalContext(this.getThreadLocalRequest());
ServiceParameters dataMinerService = ContextUtil.getDataMinerService(this.getThreadLocalRequest());
log.info("Found DM service: "+dataMinerService.getUrl() + " int this scope: "+pContext.getCurrentScope());
@ -455,11 +556,8 @@ public class PerformFishAnalyticsServiceImpl extends RemoteServiceServlet
// dataMinerService = new ServiceParameters("http://dataminer-prototypes.d4science.org/wps/WebProcessingService", null, null, dmRequestParameters);
// log.info("I'm in TEST MODE replacing it with HARD CODED: "+dataMinerService);
// }
dataMinerService.setProperties(dmRequestParameters);
//Addding client parameters to DM service request
dmRequestParameters.putAll(mapParameters);
//Asdding client parameters to DM service request
DMServiceResponse dmResponse = null;
String response;
try{
@ -520,31 +618,61 @@ public class PerformFishAnalyticsServiceImpl extends RemoteServiceServlet
* @see org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsService#callingDataMinerPerformFishAnalysis(org.gcube.portlets.user.performfishanalytics.shared.performfishservice.PerformFishResponse, java.util.Map)
*/
@Override
public DataMinerResponse callingDataMinerPerformFishAnalysis(Map<String, List<String>> mapParameters) throws Exception{
public DataMinerResponse callingDataMinerPerformFishAnalysis(Map<String, List<String>> algorithmMapParameters) throws Exception{
log.info("Calling the DM service with client parameters: "+mapParameters.toString());
PortalContextInfo pContext = ContextUtil.getPortalContext(this.getThreadLocalRequest());
log.info("Calling the DM service with algorithm parameters: "+algorithmMapParameters.toString());
Map<String, List<String>> dmRequestParameters = new HashMap<String, List<String>>();
dmRequestParameters.put("request", Arrays.asList("Execute"));
dmRequestParameters.put("service", Arrays.asList("WPS"));
dmRequestParameters.put("Version", Arrays.asList("1.0.0"));
//dmRequestParameters.put("gcube-token", Arrays.asList(pContext.getUserToken()));
dmRequestParameters.put("lang", Arrays.asList("en-US"));
dmRequestParameters.put("Identifier", Arrays.asList("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.PERFORMFISH_ANALYSIS"));
dmRequestParameters.putAll(algorithmMapParameters);
return callTheDataMiner(dmRequestParameters);
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsService#callingDataMinerPerformFishAnalysis(org.gcube.portlets.user.performfishanalytics.shared.performfishservice.PerformFishResponse, java.util.Map)
*/
@Override
public DataMinerResponse callingDataMinerPerformFishAnnualAnalysis(Map<String, List<String>> algorithmMapParameters) throws Exception{
log.info("Calling the DM service with algorithm parameters: "+algorithmMapParameters.toString());
Map<String, List<String>> dmRequestParameters = new HashMap<String, List<String>>();
dmRequestParameters.put("request", Arrays.asList("Execute"));
dmRequestParameters.put("service", Arrays.asList("WPS"));
dmRequestParameters.put("Version", Arrays.asList("1.0.0"));
dmRequestParameters.put("lang", Arrays.asList("en-US"));
dmRequestParameters.put("Identifier", Arrays.asList("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.PERFORMFISH_ANALYSIS_ANNUAL"));
dmRequestParameters.putAll(algorithmMapParameters);
return callTheDataMiner(dmRequestParameters);
}
/**
* Call the data miner.
*
* @param dmServiceRequestParameters the dm request parameters
* @return the data miner response
* @throws Exception the exception
*/
private DataMinerResponse callTheDataMiner(Map<String, List<String>> dmServiceRequestParameters) throws Exception {
ServiceParameters dataMinerService = ContextUtil.getDataMinerService(this.getThreadLocalRequest());
log.info("Found DM service: "+dataMinerService.getUrl() + " int this scope: "+ContextUtil.getPortalContext(this.getThreadLocalRequest()).getCurrentScope());
dataMinerService.setProperties(dmRequestParameters);
dataMinerService.setProperties(dmServiceRequestParameters);
//Addding client parameters to DM service request
dmRequestParameters.putAll(mapParameters);
DMServiceResponse dmResponse = null;
String response;
PortalContextInfo pContext = ContextUtil.getPortalContext(this.getThreadLocalRequest());
try{
response = new HttpCallerUtil(dataMinerService.getUrl(), null, null).performGETRequestWithRetry(dmRequestParameters, pContext.getUserToken(), 5);
response = new HttpCallerUtil(dataMinerService.getUrl(), null, null).performGETRequestWithRetry(dmServiceRequestParameters, pContext.getUserToken(), 5);
if(response==null){
log.error("The presponse returned is null");
throw new Exception("The presponse returned is null");