git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/performfish-analytics-portlet@179292 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bb408dc6ab
commit
c36b5a418b
|
@ -5,6 +5,6 @@
|
|||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<property name="context-root" value="performfish-analytics-portlet"/>
|
||||
<property name="java-output-path" value="/performfish-analytics-portlet/target/performfish-analytics-portlet-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
<property name="java-output-path" value="/performfish-analytics-portlet/target/performfish-analytics-portlet-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>performfish-analytics-portlet</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
<name>Maven Archetype for GWT</name>
|
||||
|
||||
<scm>
|
||||
|
|
|
@ -13,8 +13,8 @@ package org.gcube.portlets.user.performfishanalytics.client;
|
|||
*/
|
||||
public class PerformFishAnalyticsConstant {
|
||||
|
||||
public static final String FARMID_PARAM = "farmid";
|
||||
public static final String BATCHTYPE_PARAM = "batchtype";
|
||||
// public static final String FARMID_PARAM = "farmid";
|
||||
// public static final String BATCHTYPE_PARAM = "batchtype";
|
||||
// PERFORM-FISH SERVICE KEYS
|
||||
public static final String BATCHES_TABLE_INTERNAL = "BatchesTable_internal";
|
||||
public static final String BATCHES_TABLE = "BatchesTable";
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.portlets.user.performfishanalytics.client;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Enum PerformFishQueryParameter.
|
||||
*/
|
||||
public enum PerformFishQueryParameter {
|
||||
|
||||
farmid,
|
||||
batchtype
|
||||
|
||||
|
||||
// /** The farmid param. */
|
||||
// FARMID_PARAM("farmid"),
|
||||
//
|
||||
// /** The batchtype param. */
|
||||
// BATCHTYPE_PARAM("batchtype");
|
||||
//
|
||||
// /** The id. */
|
||||
// private String id;
|
||||
//
|
||||
// /**
|
||||
// * Instantiates a new perform fish query parameter.
|
||||
// *
|
||||
// * @param id the id
|
||||
// */
|
||||
// PerformFishQueryParameter(String id){
|
||||
// this.id = id;
|
||||
// }
|
||||
//
|
||||
// public String getId() {
|
||||
// return id;
|
||||
// }
|
||||
|
||||
}
|
|
@ -104,22 +104,22 @@ public class PerformFishAnalyticsController {
|
|||
|
||||
GWT.log("Decoded parameters: "+initParams);
|
||||
|
||||
final String batchtypeParam = initParams.get(PerformFishAnalyticsConstant.BATCHTYPE_PARAM);
|
||||
final String farmidParam = initParams.get(PerformFishAnalyticsConstant.FARMID_PARAM);
|
||||
final String batchtypeParam = initParams.get(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM);
|
||||
final String farmidParam = initParams.get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM);
|
||||
|
||||
if(batchtypeParam==null || batchtypeParam.isEmpty()){
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.BATCHTYPE_PARAM+"' param detected");
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM+"' param detected");
|
||||
return;
|
||||
}
|
||||
|
||||
if(farmidParam==null || farmidParam.isEmpty()){
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.FARMID_PARAM+"' param detected");
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM+"' param detected");
|
||||
return;
|
||||
}
|
||||
|
||||
PerformFishInitParameter performFishInitParams = new PerformFishInitParameter();
|
||||
performFishInitParams.addParameter(PerformFishAnalyticsConstant.BATCHTYPE_PARAM, batchtypeParam);
|
||||
performFishInitParams.addParameter(PerformFishAnalyticsConstant.FARMID_PARAM, farmidParam);
|
||||
performFishInitParams.addParameter(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM, batchtypeParam);
|
||||
performFishInitParams.addParameter(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM, farmidParam);
|
||||
|
||||
PerformFishAnalyticsServiceAsync.Util.getInstance().validParameters(performFishInitParams, new AsyncCallback<PerformFishInitParameter>() {
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class PerformFishAnalyticsController {
|
|||
viewController.hideErrors();
|
||||
|
||||
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
|
||||
String farmId = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.FARMID_PARAM);
|
||||
String farmId = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM);
|
||||
String batchType = viewController.getForm().getBatchType();
|
||||
String species = viewController.getForm().getSpecies();
|
||||
List<String> listArea = viewController.getForm().getArea();
|
||||
|
|
|
@ -7,9 +7,9 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.PerformFishAnalyticsServiceAsync;
|
||||
import org.gcube.portlets.user.performfishanalytics.client.PerformFishQueryParameter;
|
||||
import org.gcube.portlets.user.performfishanalytics.client.view.BaseDockLayoutPanel;
|
||||
import org.gcube.portlets.user.performfishanalytics.client.view.BodyPanel;
|
||||
import org.gcube.portlets.user.performfishanalytics.client.view.CustomTreeModel;
|
||||
|
@ -189,13 +189,14 @@ public class PerformFishAnalyticsViewController {
|
|||
return baseDockLayoutPanel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load population type for population name.
|
||||
* Load population type for level and batch type.
|
||||
*
|
||||
* @param populationName the population name
|
||||
* @param decryptParameters the decrypt parameters
|
||||
* @param decodedParameters the decoded parameters
|
||||
*/
|
||||
public void loadPopulationTypeForLevelAndBatchType(final String populationName, final PerformFishInitParameter decryptParameters){
|
||||
public void loadPopulationTypeForLevelAndBatchType(final String populationName, final PerformFishInitParameter decodedParameters){
|
||||
|
||||
PerformFishAnalyticsServiceAsync.Util.getInstance().getListPopulationType(populationName, new AsyncCallback<List<PopulationType>>() {
|
||||
|
||||
|
@ -205,7 +206,7 @@ public class PerformFishAnalyticsViewController {
|
|||
headerPage.showLoading(false);
|
||||
|
||||
if(result.size()>0){
|
||||
String passedBatchType = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.BATCHTYPE_PARAM);
|
||||
String passedBatchType = decodedParameters.getParameters().get(PerformFishQueryParameter.batchtype.name());
|
||||
for (PopulationType populationType : result) {
|
||||
|
||||
if(populationType.getName().compareToIgnoreCase(passedBatchType)==0){
|
||||
|
@ -268,6 +269,11 @@ public class PerformFishAnalyticsViewController {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand all tree node.
|
||||
*
|
||||
* @param rootNode the root node
|
||||
*/
|
||||
private void expandAllTreeNode(TreeNode rootNode) {
|
||||
|
||||
if(rootNode==null || rootNode.getChildCount()==0)
|
||||
|
|
|
@ -5,11 +5,14 @@ package org.gcube.portlets.user.performfishanalytics.server.util;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class UrlEncoderUtil.
|
||||
*
|
||||
|
@ -18,32 +21,11 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class UrlEncoderUtil {
|
||||
|
||||
/** The charset. */
|
||||
public static String charset = "UTF-8";
|
||||
|
||||
public static Logger logger = Logger.getLogger(UrlEncoderUtil.class);
|
||||
|
||||
// /**
|
||||
// * Encode query.
|
||||
// *
|
||||
// * @param parameters the parameters
|
||||
// * @return the string
|
||||
// */
|
||||
// public static String encodeQuery(String... parameters){
|
||||
//
|
||||
// String query = "";
|
||||
// for (String string : parameters) {
|
||||
//
|
||||
// try {
|
||||
// query+=URLEncoder.encode(string, charset)+"&";
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// logger.error(e);
|
||||
// return query;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return removeLastChar(query);
|
||||
// }
|
||||
|
||||
/** The logger. */
|
||||
public static final Logger logger = LoggerFactory.getLogger(UrlEncoderUtil.class);
|
||||
|
||||
/**
|
||||
* Encode query.
|
||||
|
@ -65,7 +47,7 @@ public class UrlEncoderUtil {
|
|||
query+=String.format(key+"=%s", URLEncoder.encode(value, charset))+"&";
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error(e);
|
||||
logger.error("Error:", e);
|
||||
return query;
|
||||
}
|
||||
|
||||
|
@ -91,5 +73,20 @@ public class UrlEncoderUtil {
|
|||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Base 64 decode.
|
||||
*
|
||||
* @param valueToDecode the value to decode
|
||||
* @return the long
|
||||
*/
|
||||
public static String base64Decode(String valueToDecode) throws Exception{
|
||||
try {
|
||||
return new String(Base64.getDecoder().decode(valueToDecode));
|
||||
}catch (Exception e) {
|
||||
throw new Exception("Error on decoding the parameter: "+ valueToDecode, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class CSVReader {
|
|||
|
||||
List<String> result = new ArrayList<>();
|
||||
// if empty, return!
|
||||
if (cvsLine == null && cvsLine.isEmpty()) {
|
||||
if (cvsLine == null || cvsLine.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
if (customQuote == ' ') {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.gcube.portlets.user.performfishanalytics.server.util.database.data.KP
|
|||
import org.gcube.portlets.user.performfishanalytics.server.util.database.data.PeriodData;
|
||||
import org.gcube.portlets.user.performfishanalytics.server.util.database.data.QuarterData;
|
||||
import org.gcube.portlets.user.performfishanalytics.server.util.database.data.SpeciesData;
|
||||
import org.gcube.portlets.user.performfishanalytics.server.util.database.data.YearData;
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.Area;
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.KPI;
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.Period;
|
||||
|
@ -61,7 +62,7 @@ public class FillDatabasePerBatchType {
|
|||
GROW_OUT_INDIVIDUAL_CLOSED_BATCHES,
|
||||
GROW_OUT_AGGREGATED,
|
||||
GROW_OUT_AGGREGATED_CLOSED_BATCHES
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the database data.
|
||||
|
@ -197,7 +198,8 @@ public class FillDatabasePerBatchType {
|
|||
batchType.setListQuarter(QuarterData.getListQuarter(batchType));
|
||||
//Areas
|
||||
batchType.setListArea(AreaData.getListArea(batchType));
|
||||
|
||||
//Years
|
||||
batchType.setListYears(YearData.getListYears(batchType));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.portlets.user.performfishanalytics.server.util.database.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.PopulationType;
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.Year;
|
||||
|
||||
/**
|
||||
* The Class YearData.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* May 6, 2019
|
||||
*/
|
||||
public class YearData {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list years.
|
||||
*
|
||||
* @param batchType the batch type
|
||||
* @return the list years
|
||||
*/
|
||||
public static ArrayList<Year> getListYears(PopulationType batchType){
|
||||
|
||||
List<Year> listSpecies = new ArrayList<Year>();
|
||||
listSpecies.add(new Year(java.util.UUID.randomUUID().toString(), "2016", batchType));
|
||||
listSpecies.add(new Year(java.util.UUID.randomUUID().toString(), "2017", batchType));
|
||||
listSpecies.add(new Year(java.util.UUID.randomUUID().toString(), "2018", batchType));
|
||||
|
||||
return (ArrayList<Year>) listSpecies;
|
||||
}
|
||||
|
||||
}
|
|
@ -83,7 +83,9 @@ public final class NamespaceContextMap implements NamespaceContext {
|
|||
XMLConstants.XML_NS_URI);
|
||||
addConstant(prefixMap, XMLConstants.XMLNS_ATTRIBUTE,
|
||||
XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
|
||||
return Collections.unmodifiableMap(prefixMap);
|
||||
//return Collections.unmodifiableMap(prefixMap);
|
||||
|
||||
return prefixMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
|||
@Entity
|
||||
@CascadeOnDelete
|
||||
public class PopulationType implements GenericDao, Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -68,6 +68,12 @@ public class PopulationType implements GenericDao, Serializable {
|
|||
@CascadeOnDelete
|
||||
@OrderColumn
|
||||
private List<KPI> listKPI = new ArrayList<KPI>();
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "populationType", orphanRemoval = true, cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
|
||||
@CascadeOnDelete
|
||||
@OrderColumn
|
||||
private List<Year> listYears = new ArrayList<Year>();
|
||||
|
||||
/**
|
||||
* Instantiates a new population type.
|
||||
|
@ -362,6 +368,25 @@ public class PopulationType implements GenericDao, Serializable {
|
|||
|
||||
this.listSpecies = listSpecies;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list years.
|
||||
*
|
||||
* @return the list years
|
||||
*/
|
||||
public List<Year> getListYears() {
|
||||
return listYears;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list years.
|
||||
*
|
||||
* @param listYears the new list years
|
||||
*/
|
||||
public void setListYears(List<Year> listYears) {
|
||||
this.listYears = listYears;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
package org.gcube.portlets.user.performfishanalytics.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.eclipse.persistence.annotations.CascadeOnDelete;
|
||||
|
||||
/**
|
||||
* The Class Year.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* May 6, 2019
|
||||
*/
|
||||
@Entity
|
||||
@CascadeOnDelete
|
||||
public class Year implements GenericDao, ReferencePopulationType, Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int internalId; // PRIMARY KEY
|
||||
private String id;
|
||||
private String value;
|
||||
|
||||
@CascadeOnDelete
|
||||
private PopulationType populationType;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new year.
|
||||
*/
|
||||
public Year() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new year.
|
||||
*
|
||||
* @param id the id
|
||||
* @param value the value
|
||||
* @param populationType the population type
|
||||
*/
|
||||
public Year(String id, String value, PopulationType populationType) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.value = value;
|
||||
this.populationType = populationType;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portles.user.performfishannual.shared.GenericDao#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param value the new value
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.performfishanalytics.shared.ReferencePopulationType#getPopulationType()
|
||||
*/
|
||||
public PopulationType getPopulationType() {
|
||||
return populationType;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.performfishanalytics.shared.ReferencePopulationType#setPopulationType(org.gcube.portlets.user.performfishanalytics.shared.PopulationType)
|
||||
*/
|
||||
@Override
|
||||
public void setPopulationType(PopulationType populationType) {
|
||||
this.populationType = populationType;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Year [internalId=");
|
||||
builder.append(internalId);
|
||||
builder.append(", id=");
|
||||
builder.append(id);
|
||||
builder.append(", value=");
|
||||
builder.append(value);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
KPI CODE,KPI NAME - LEVEL 1,KPI NAME – LEVEL 2,KPI NAME - LEVEL 3
|
||||
,Dependency on treatments KPIs,,
|
||||
,,Number of therapeutic treatments,
|
||||
G9,,,Total number of antiparasitic treatments - at harvest
|
||||
G10,,,Total number of antibiotic treatments - at harvest
|
||||
,Productivity KPIs,,
|
||||
G20,,Biomass produced per number of FTE employees ,
|
||||
G21,,Biomass produced per volumes of sea water used ,
|
||||
,Environmental KPIs,,
|
||||
,,Preservation of biodiversity and habitats KPIs,
|
||||
G22,,,Oxygen depletion persistence days
|
||||
G23,,,Escapes - Number of episodes
|
||||
G24,,,Escapes - Estimated number of escaped fish
|
||||
,,Use of resources,
|
||||
G28,,,Marine space use for farming
|
||||
G29,,,Land use
|
||||
G30,,,Freshwater use
|
||||
G31,,,Energy use
|
||||
G32,,,Fuel (Diesel) for transport
|
||||
G33,,,Fuel (Diesel) for other uses
|
||||
G35,,,Use of renewable energy
|
|
|
@ -11,6 +11,7 @@
|
|||
<class>org.gcube.portlets.user.performfishanalytics.shared.Area</class>
|
||||
<class>org.gcube.portlets.user.performfishanalytics.shared.Period</class>
|
||||
<class>org.gcube.portlets.user.performfishanalytics.shared.KPI</class>
|
||||
<class>org.gcube.portlets.user.performfishanalytics.shared.Year</class>
|
||||
<properties>
|
||||
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
|
||||
<!-- <property name="eclipselink.ddl-generation" value="create-tables"
|
||||
|
|
Loading…
Reference in New Issue