fixing read annual parameter
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/performfish-analytics-portlet@179298 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fb3aadcfe3
commit
6dd76780df
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/performfish-analytics-portlet-0.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/performfish-analytics-portlet-0.2.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.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/performfish-analytics-portlet-0.2.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.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/performfish-analytics-portlet-0.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/eclipse-workspace/performfish-analytics-portlet-TRUNK/target/performfish-analytics-portlet-0.1.0-SNAPSHOT
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/eclipse-workspace/performfish-analytics-portlet-TRUNK/target/performfish-analytics-portlet-0.2.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="performfish-analytics-portlet-0.1.0-SNAPSHOT">
|
||||
<wb-module deploy-name="performfish-analytics-portlet-0.2.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"/>
|
||||
<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.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<property name="java-output-path" value="/performfish-analytics-portlet/target/performfish-analytics-portlet-0.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
|
|
@ -13,8 +13,9 @@ 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 QUERY_STRING_FARMID_PARAM = "farmid";
|
||||
public static final String QUERY_STRING_BATCHTYPE_PARAM = "batchtype";
|
||||
public static final String QUERY_STRING_ANNUAL_PARAMETER = "annual";
|
||||
// PERFORM-FISH SERVICE KEYS
|
||||
public static final String BATCHES_TABLE_INTERNAL = "BatchesTable_internal";
|
||||
public static final String BATCHES_TABLE = "BatchesTable";
|
||||
|
@ -36,7 +37,7 @@ public class PerformFishAnalyticsConstant {
|
|||
public static final String PERFORM_FISH_FARMID_PARAM = "farmid";
|
||||
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 PERFORM_FISH_ANNUAL_PARAMETER = "annual";
|
||||
|
||||
|
||||
|
||||
public static final String DM_FOCUS_ID_ALL_VALUE = "ALL";
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
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,54 +104,81 @@ public class PerformFishAnalyticsController {
|
|||
|
||||
GWT.log("Decoded parameters: "+initParams);
|
||||
|
||||
final String annual = initParams.get(PerformFishAnalyticsConstant.PERFORM_FISH_ANNUAL_PARAMETER);
|
||||
|
||||
final String farmidParam = initParams.get(PerformFishAnalyticsConstant.QUERY_STRING_FARMID_PARAM);
|
||||
|
||||
if(farmidParam==null || farmidParam.isEmpty()){
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.QUERY_STRING_FARMID_PARAM+"' param detected");
|
||||
return;
|
||||
}
|
||||
|
||||
final String annual = initParams.get(PerformFishAnalyticsConstant.QUERY_STRING_ANNUAL_PARAMETER);
|
||||
|
||||
boolean isAnnualCall = false;
|
||||
|
||||
try {
|
||||
isAnnualCall = Boolean.parseBoolean(annual);
|
||||
GWT.log("Read decoded isAnnual at: "+isAnnualCall);
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
GWT.log("Forcing isAnnual at TRUE");
|
||||
isAnnualCall = false;
|
||||
}
|
||||
|
||||
final String farmidParam = initParams.get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM);
|
||||
|
||||
if(farmidParam==null || farmidParam.isEmpty()){
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM+"' param detected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String batchtypeParam = initParams.get(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM);
|
||||
|
||||
if(batchtypeParam==null || batchtypeParam.isEmpty()){
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM+"' param detected");
|
||||
return;
|
||||
}
|
||||
String batchtypeParam = initParams.get(PerformFishAnalyticsConstant.QUERY_STRING_BATCHTYPE_PARAM);
|
||||
|
||||
//IS ANNUAL CALL
|
||||
if(isAnnualCall) {
|
||||
|
||||
//CALLING THE PORTLET WITH ANNUAL CONFIGURATION
|
||||
batchtypeParam = PerformFishAnalyticsConstant.BATCH_LEVEL.GROW_OUT_AGGREGATED_CLOSED_BATCHES.name();
|
||||
GWT.log("Hard cabling batchtypeParam as: "+batchtypeParam);
|
||||
}
|
||||
|
||||
PerformFishInitParameter performFishInitParams = new PerformFishInitParameter();
|
||||
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>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(PerformFishInitParameter result) {
|
||||
decryptParameters = result;
|
||||
eventBus.fireEvent(new LoadPopulationTypeEvent(POPULATION_LEVEL.FARM.name(), null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}else {
|
||||
|
||||
PerformFishInitParameter performFishInitParams = new PerformFishInitParameter();
|
||||
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>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(PerformFishInitParameter result) {
|
||||
decryptParameters = result;
|
||||
eventBus.fireEvent(new LoadPopulationTypeEvent(POPULATION_LEVEL.BATCH.name(), null));
|
||||
//CALLING THE PORTLET WITHOUT ANNUAL CONFIGURATION
|
||||
if(batchtypeParam==null || batchtypeParam.isEmpty()){
|
||||
Window.alert("Error: no '"+PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM+"' param detected");
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
PerformFishInitParameter performFishInitParams = new PerformFishInitParameter();
|
||||
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>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(PerformFishInitParameter result) {
|
||||
decryptParameters = result;
|
||||
eventBus.fireEvent(new LoadPopulationTypeEvent(POPULATION_LEVEL.BATCH.name(), null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -203,10 +203,11 @@ public class PerformFishAnalyticsViewController {
|
|||
@Override
|
||||
public void onSuccess(List<PopulationType> result) {
|
||||
|
||||
GWT.log("Loaded list of "+PopulationType.class.getSimpleName()+ ": "+result);
|
||||
headerPage.showLoading(false);
|
||||
|
||||
if(result.size()>0){
|
||||
String passedBatchType = decodedParameters.getParameters().get(PerformFishQueryParameter.batchtype.name());
|
||||
String passedBatchType = decodedParameters.getParameters().get(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM);
|
||||
for (PopulationType populationType : result) {
|
||||
|
||||
if(populationType.getName().compareToIgnoreCase(passedBatchType)==0){
|
||||
|
|
|
@ -138,6 +138,7 @@ public class PerformFishAnalyticsServiceImpl extends RemoteServiceServlet
|
|||
new GenericPersistenceDaoBuilder<Population>(
|
||||
dbFactory, Population.class.getSimpleName());
|
||||
List<Population> listPopulation = builderPopulation.getPersistenceEntity().getList();
|
||||
log.info("List of {} are: {}",Population.class.getSimpleName(),listPopulation);
|
||||
List<PopulationType> listPopulationType;
|
||||
for (Population population : listPopulation) {
|
||||
if (population.getName().equalsIgnoreCase(populationName)) {
|
||||
|
@ -329,10 +330,10 @@ public class PerformFishAnalyticsServiceImpl extends RemoteServiceServlet
|
|||
public PerformFishInitParameter validParameters(PerformFishInitParameter initParams) throws Exception{
|
||||
|
||||
Map<String, String> inputParameters = initParams.getParameters();
|
||||
/*String farmID = inputParameters.get(PerformFishAnalyticsConstant.FARMID_PARAM);
|
||||
String farmID = inputParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM);
|
||||
boolean grantAccess = checkGrantToAccessFarmID(farmID);
|
||||
if(!grantAccess)
|
||||
throw new Exception("You have no rights to access to this FARM. You does not belong to it.");*/
|
||||
throw new Exception("You have no rights to access to this FARM. You does not belong to it.");
|
||||
|
||||
return initParams;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.gcube.portlets.user.performfishanalytics.shared.PopulationTypePropert
|
|||
import org.gcube.portlets.user.performfishanalytics.shared.Quarter;
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.ReferencePopulationType;
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.Species;
|
||||
import org.gcube.portlets.user.performfishanalytics.shared.Year;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -64,12 +65,16 @@ public class ToAvoidIndirectSerialization {
|
|||
|
||||
List<Period> listPeriod = populationType.getListPeriod();
|
||||
populationType.setListPeriod((List<Period>) toListPopulationProperties(listPeriod, null));
|
||||
|
||||
List<Year> listYears = populationType.getListYears();
|
||||
populationType.setListYears((List<Year>) toListPopulationProperties(listYears, null));
|
||||
|
||||
}else{
|
||||
populationType.setListSpecies(null);
|
||||
populationType.setListQuarter(null);
|
||||
populationType.setListArea(null);
|
||||
populationType.setListPeriod(null);
|
||||
populationType.setListYears(null);
|
||||
}
|
||||
|
||||
populationType.setListKPI(null);
|
||||
|
@ -142,6 +147,8 @@ public class ToAvoidIndirectSerialization {
|
|||
return (T) new Quarter(object.getId(), object.getName(), object.getDescription(), type);
|
||||
}else if(object instanceof Period){
|
||||
return (T) new Period(object.getId(), object.getName(), object.getDescription(), type);
|
||||
}else if(object instanceof Year){
|
||||
return (T) new Year(object.getId(), ((Year) object).getValue(), type);
|
||||
}else if(object instanceof KPI){
|
||||
KPI toKPI = (KPI) object;
|
||||
KPI gwtKPI = new KPI(toKPI.getId(),toKPI.getCode(),toKPI.getName(),toKPI.getDescription(), null,type,toKPI.getDeepIndex());
|
||||
|
|
|
@ -57,7 +57,7 @@ public class FillDatabasePerBatchType {
|
|||
*/
|
||||
public static void printDatabaseData(EntityManagerFactory entityManagerFactory) throws Exception {
|
||||
|
||||
GenericPersistenceDaoBuilder<Population> builderPopulation = new GenericPersistenceDaoBuilder<Population>(entityManagerFactory, "Population");
|
||||
GenericPersistenceDaoBuilder<Population> builderPopulation = new GenericPersistenceDaoBuilder<Population>(entityManagerFactory, Population.class.getSimpleName());
|
||||
|
||||
for(Population population: builderPopulation.getPersistenceEntity().getList()){
|
||||
log.debug("\n\n#### Population: "+population.getName());
|
||||
|
@ -195,7 +195,7 @@ public class FillDatabasePerBatchType {
|
|||
}
|
||||
|
||||
//INSERTING BATCH LEVEL/POPULATIONS
|
||||
GenericPersistenceDaoBuilder<Population> builderPopulation = new GenericPersistenceDaoBuilder<Population>(entityManagerFactory, "Population");
|
||||
GenericPersistenceDaoBuilder<Population> builderPopulation = new GenericPersistenceDaoBuilder<Population>(entityManagerFactory, Population.class.getSimpleName());
|
||||
batchPopulation.setListPopulationType(new ArrayList<PopulationType>(listBatchLevels));
|
||||
builderPopulation.getPersistenceEntity().insert(batchPopulation);
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ public class PopulationType implements GenericDao, Serializable {
|
|||
@OrderColumn
|
||||
private List<KPI> listKPI = new ArrayList<KPI>();
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "populationType", orphanRemoval = true, cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
|
||||
@OneToMany(mappedBy = "populationType", orphanRemoval = true, cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
|
||||
@CascadeOnDelete
|
||||
@OrderColumn
|
||||
private List<Year> listYears = new ArrayList<Year>();
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
|||
*/
|
||||
@Entity
|
||||
@CascadeOnDelete
|
||||
public class Year implements GenericDao, ReferencePopulationType, Serializable{
|
||||
public class Year implements GenericDao, ReferencePopulationType, PopulationTypeProperties, Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -54,8 +54,34 @@ public class Year implements GenericDao, ReferencePopulationType, Serializable{
|
|||
this.value = value;
|
||||
this.populationType = populationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
setValue(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDescription(String description) {
|
||||
//empty
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portles.user.performfishannual.shared.GenericDao#getId()
|
||||
*/
|
||||
|
@ -82,6 +108,7 @@ public class Year implements GenericDao, ReferencePopulationType, Serializable{
|
|||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -124,6 +151,4 @@ public class Year implements GenericDao, ReferencePopulationType, Serializable{
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue