Working on Task #7001

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@142456 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-02-10 14:18:57 +00:00
parent e055612cd2
commit 6f0417e86e
35 changed files with 3265 additions and 1130 deletions

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.user.speciesdiscovery.client; package org.gcube.portlets.user.speciesdiscovery.client;
public final class ConstantsSpeciesDiscovery { public final class ConstantsSpeciesDiscovery {
//USED IN MODEL CLASS //USED IN MODEL CLASS
public static final String ID = "id"; public static final String ID = "id";
public static final String NAME = "name"; public static final String NAME = "name";
@ -11,7 +11,7 @@ public final class ConstantsSpeciesDiscovery {
public static final String COUNTOF = "CountOf"; public static final String COUNTOF = "CountOf";
public static final String RANK = "Rank"; public static final String RANK = "Rank";
// public static final String GROUPEDIDLIST = "GroupedIDList"; // public static final String GROUPEDIDLIST = "GroupedIDList";
//USED IN CLASSIFICATION FILTER //USED IN CLASSIFICATION FILTER
public static final String BIOTACLASSID = "BiotaID"; public static final String BIOTACLASSID = "BiotaID";
public static final String BIOTACLASS = "Biota"; public static final String BIOTACLASS = "Biota";
@ -30,30 +30,30 @@ public final class ConstantsSpeciesDiscovery {
public static final String VIEWDETAILS = "View Details (Only selected)"; public static final String VIEWDETAILS = "View Details (Only selected)";
public static final String SELECTALL = "Check All Rows"; public static final String SELECTALL = "Check All Rows";
public static final String DESELECTALL = "Uncheck All Rows"; public static final String DESELECTALL = "Uncheck All Rows";
//USED IN CLASSIFICATION FILTER //USED IN CLASSIFICATION FILTER
// public static final String[] MAIN_TAXONOMIC_RANK = new String[]{"kingdom", "phylum", "class", "order", "family", "genus", "species"}; // public static final String[] MAIN_TAXONOMIC_RANK = new String[]{"kingdom", "phylum", "class", "order", "family", "genus", "species"};
public static final String GROUPBYRANK = "Group results by"; public static final String GROUPBYRANK = "Group results by";
public static final String LOADINGSTYLE = "x-mask-loading"; public static final String LOADINGSTYLE = "x-mask-loading";
public static final String SORTMESSAGE = "Sort filter in alphabetical order (from A to Z)"; public static final String SORTMESSAGE = "Sort filter in alphabetical order (from A to Z)";
public static final String REQUEST_DATA = "request data..."; public static final String REQUEST_DATA = "request data...";
//USED IN SEARCH BORDER LAYPUT PANEL //USED IN SEARCH BORDER LAYPUT PANEL
public final static int JOBPOLLINGMILLISECONDS = 20000; public final static int JOBPOLLINGMILLISECONDS = 20000;
//USED IN SEARCH FORM PANEL //USED IN SEARCH FORM PANEL
protected static final String OCCURENCES = "Occurences"; protected static final String OCCURENCES = "Occurences";
protected static final String CLASSIFICATION = "Classification"; protected static final String CLASSIFICATION = "Classification";
protected static final String COMMON_NAME = "Common name"; protected static final String COMMON_NAME = "Common name";
protected static final String SCIENTIFIC_NAME = "Scientific name"; protected static final String SCIENTIFIC_NAME = "Scientific name";
//USED IN ADAVANCED FILTERT //USED IN ADAVANCED FILTERT
public static final String AVAILABLEFILTERBOUND = "Bounds filters (lower-upper) are available with following plug-in"; public static final String AVAILABLEFILTERBOUND = "Bounds filters (lower-upper) are available with following plug-in";
public static final String AVAILABLEFILTERDATE = "Date filter (from-to) is available with following plug-in"; public static final String AVAILABLEFILTERDATE = "Date filter (from-to) is available with following plug-in";
public static final String AVAILABLEDATASOURCES = "Occurence points and classification search are available with following plug-in"; public static final String AVAILABLEDATASOURCES = "Occurence points and classification search are available with following plug-in";
//USED IN GISVIEWER //USED IN GISVIEWER
public static final String LME = "lme"; public static final String LME = "lme";
public static final String FAOAREA = "faoarea"; public static final String FAOAREA = "faoarea";
@ -64,18 +64,18 @@ public final class ConstantsSpeciesDiscovery {
public static final String ENVIRONMENTS = "environments"; public static final String ENVIRONMENTS = "environments";
public static final String DEPTH_MEAN_ANNUAL = "DepthMeanAnnual"; public static final String DEPTH_MEAN_ANNUAL = "DepthMeanAnnual";
public static final String WORLD_BORDERS = "worldborders"; public static final String WORLD_BORDERS = "worldborders";
//ELAPSED TIME FORMATTER //ELAPSED TIME FORMATTER
public static final String TIME_ZONE_UTC = "UTC"; public static final String TIME_ZONE_UTC = "UTC";
public static final String TIMEFORMAT_HH_MM_SS = "HH:mm:ss"; public static final String TIMEFORMAT_HH_MM_SS = "HH:mm:ss";
//USED IN SERVER/SHARED PACKAGE //USED IN SERVER/SHARED PACKAGE
public static final String NULL = "null"; public static final String NULL = "null";
public static final String UNDEFINED = "Undefined"; public static final String UNDEFINED = "Undefined";
public static final String NOT_FOUND = "not found"; public static final String NOT_FOUND = "not found";
public static int RESULT_ROW_LIMIT_ITEM_DETAILS = 250; public static int RESULT_ROW_LIMIT_ITEM_DETAILS = 250;
public static int TAXONOMY_LIMIT_ITEMS_DETAILS = 100; public static int TAXONOMY_LIMIT_ITEMS_DETAILS = 100;
//USED IN VIEW DETAILSWINDOW //USED IN VIEW DETAILSWINDOW
public static final String THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS = "The max number of items displayable is "; public static final String THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS = "The max number of items displayable is ";
public static final String ROW_LIMIT_REACHED = "Row limit reached"; public static final String ROW_LIMIT_REACHED = "Row limit reached";
@ -89,7 +89,7 @@ public final class ConstantsSpeciesDiscovery {
public static final String PLAIN_CSV_BY_DATA_SOURCE = "plain CSV (by Data Source)"; public static final String PLAIN_CSV_BY_DATA_SOURCE = "plain CSV (by Data Source)";
public static final String PLAIN_CSV = "plain CSV"; public static final String PLAIN_CSV = "plain CSV";
public static final String SAVE_OCCURRENCES = "Save Occurrences"; public static final String SAVE_OCCURRENCES = "Save Occurrences";
public static final String SHOW_IN_GIS_VIEWER = "Show in Gis Viewer"; public static final String CREATE_GIS_LAYER = "Create Gis Layer";
// public static final String SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT = "Saves in Darwin Core Archive format"; // public static final String SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT = "Saves in Darwin Core Archive format";
// public static final String DARWIN_CORE_ARCHIVE = "Darwin Core Archive"; // public static final String DARWIN_CORE_ARCHIVE = "Darwin Core Archive";
public static final String SAVE_TAXONOMY_ITEMS = "Save Taxonomy Items"; public static final String SAVE_TAXONOMY_ITEMS = "Save Taxonomy Items";
@ -106,13 +106,13 @@ public final class ConstantsSpeciesDiscovery {
public static final String CONFIRM_DELETE = "Confirm delete"; public static final String CONFIRM_DELETE = "Confirm delete";
public static final String ALERT = "Alert"; public static final String ALERT = "Alert";
public static final String IS_NOT_COMPLETED = "can not be saved until it has completed!"; public static final String IS_NOT_COMPLETED = "can not be saved until it has completed!";
//USED IN TABLE FOR TAXONOMY ROW //USED IN TABLE FOR TAXONOMY ROW
public static final String SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT = "Saves in Darwin Core Archive format"; public static final String SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT = "Saves in Darwin Core Archive format";
public static final String DARWIN_CORE_ARCHIVE = "Darwin Core Archive"; public static final String DARWIN_CORE_ARCHIVE = "Darwin Core Archive";
public static final String SAVES_TAXONOMY_CHILDREN_FROM_RESULT = "Saves taxonomy children from result."; public static final String SAVES_TAXONOMY_CHILDREN_FROM_RESULT = "Saves taxonomy children from result.";
public static final String SAVE_TAXONOMY_CHILDREN = "Save Taxonomy Children"; public static final String SAVE_TAXONOMY_CHILDREN = "Save Taxonomy Children";
//SERVLETS //SERVLETS
public static final String RESULT_ROW_TABLE = "ResultRowTable"; public static final String RESULT_ROW_TABLE = "ResultRowTable";
public static final String TAXONOMY_ROW_TABLE = "TaxonomyRowTable"; public static final String TAXONOMY_ROW_TABLE = "TaxonomyRowTable";

View File

@ -51,8 +51,6 @@ import org.gcube.portlets.user.speciesdiscovery.client.event.SetCommonNamesEvent
import org.gcube.portlets.user.speciesdiscovery.client.event.SetCommonNamesEventHandler; import org.gcube.portlets.user.speciesdiscovery.client.event.SetCommonNamesEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesEventHandler; import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesMapEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesMapEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOnlySelectedRowEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOnlySelectedRowEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOnlySelectedRowEventHandler; import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOnlySelectedRowEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.event.UpdateAllRowSelectionEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.UpdateAllRowSelectionEvent;
@ -64,6 +62,7 @@ import org.gcube.portlets.user.speciesdiscovery.client.event.UpdateRowSelectionE
import org.gcube.portlets.user.speciesdiscovery.client.event.ViewDetailsOfSelectedEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.ViewDetailsOfSelectedEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.ViewDetailsOfSelectedEventHandler; import org.gcube.portlets.user.speciesdiscovery.client.event.ViewDetailsOfSelectedEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.filterresult.ResultFilterPanelManager; import org.gcube.portlets.user.speciesdiscovery.client.filterresult.ResultFilterPanelManager;
import org.gcube.portlets.user.speciesdiscovery.client.job.gislayer.GisLayerJobSpeciesPanel;
import org.gcube.portlets.user.speciesdiscovery.client.job.occurrence.OccurrenceJobSpeciesPanel; import org.gcube.portlets.user.speciesdiscovery.client.job.occurrence.OccurrenceJobSpeciesPanel;
import org.gcube.portlets.user.speciesdiscovery.client.job.taxonomy.TaxonomyJobSpeciesPanel; import org.gcube.portlets.user.speciesdiscovery.client.job.taxonomy.TaxonomyJobSpeciesPanel;
import org.gcube.portlets.user.speciesdiscovery.client.util.SpeciesGridFields; import org.gcube.portlets.user.speciesdiscovery.client.util.SpeciesGridFields;
@ -276,7 +275,7 @@ public class SearchController {
// TODO Auto-generated method stub // TODO Auto-generated method stub
SpeciesDiscovery.taxonomySearchService.createGisLayerJobFromSelectedOccurrenceKeys(createGisLayerJobEvent.getJobName(), createGisLayerJobEvent.getJobDescription(), new AsyncCallback<JobGisLayerModel>() { SpeciesDiscovery.taxonomySearchService.createGisLayerJobFromSelectedOccurrenceKeys(createGisLayerJobEvent.getJobName(), createGisLayerJobEvent.getJobDescription(), createGisLayerJobEvent.getTotalPoints(), new AsyncCallback<JobGisLayerModel>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -289,7 +288,11 @@ public class SearchController {
@Override @Override
public void onSuccess(JobGisLayerModel jobId) { public void onSuccess(JobGisLayerModel jobId) {
//Info.display("Gis Layer Occurrence Job", result.size() + " occurrence job "+msg+" submitted"); Info.display("Gis Layer Occurrence Job", "Generating Gis layer: "+jobId.getJobName()+" submitted");
excecuteGetJobs(SearchResultType.GIS_LAYER_POINT, false);
searchBorderLayoutPanel.getSpeciesSouthPanel().setIconGisLayerByCounter(1);
// progress.close(); // progress.close();
// showMap(layerName); // showMap(layerName);
} }
@ -649,46 +652,6 @@ public class SearchController {
} }
}); });
eventBus.addHandler(ShowOccurrencesMapEvent.TYPE, new ShowOccurrencesMapEventHandler() {
@Override
public void onShowOccurrencesMap(final ShowOccurrencesMapEvent event) {
/*
* Moved INTO GisLayerJob
* SpeciesDiscovery.taxonomySearchService.getCountOfOccurrencesBatch(new AsyncCallback<OccurrencesStatus>() {
@Override
public void onFailure(Throwable caught) {
Log.error("Error on loading", "An error occurred on count of occurrence point, retry." +caught.getMessage());
}
@Override
public void onSuccess(OccurrencesStatus result) {
MessageDialog dialog;
if(event.getExpectedPoints()>result.getSize()){
dialog = new MessageDialog("Info", "Loading in progress", "On server are available only "+result.getSize()+" of "+event.getExpectedPoints()+" occurrences points. Do you want continue?");
dialog.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
//IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES))
showOccurrencesMap();
}
});
}
else
showOccurrencesMap();
}
});
*/
}
});
eventBus.addHandler(ShowOnlySelectedRowEvent.TYPE, new ShowOnlySelectedRowEventHandler() { eventBus.addHandler(ShowOnlySelectedRowEvent.TYPE, new ShowOnlySelectedRowEventHandler() {
@ -1750,7 +1713,39 @@ public class SearchController {
} }
}); });
}else if(type.equals(SearchResultType.GIS_LAYER_POINT)){
if(resetStructures)
GisLayerJobSpeciesPanel.getInstance(eventBus).getGridJob().mask("Loading", ConstantsSpeciesDiscovery.LOADINGSTYLE);
SpeciesDiscovery.taxonomySearchService.getListGisLayerJob(new AsyncCallback<List<JobGisLayerModel>>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(List<JobGisLayerModel> result) {
if(resetStructures)
GisLayerJobSpeciesPanel.getInstance(eventBus).getGridJob().unmask();
if(result.size()>0){
if(resetStructures)
GisLayerJobSpeciesPanel.getInstance(eventBus).resetStructures();
GisLayerJobSpeciesPanel.getInstance(eventBus).addListJob(result);
}
}
});
} }
} }

View File

@ -215,10 +215,8 @@ public class SpeciesSearchFormPanel extends ContentPanel {
initSimpleSearchPanel(); initSimpleSearchPanel();
initQuerySearchPanel(); initQuerySearchPanel();
createAdvancedSeachLinks(); createAdvancedSeachLinks();
horizontalQueryPanel.add(simpleSearchPanel); horizontalQueryPanel.add(simpleSearchPanel);
horizontalQueryPanel.add(querySeachPanel); horizontalQueryPanel.add(querySeachPanel);
@ -237,18 +235,15 @@ public class SpeciesSearchFormPanel extends ContentPanel {
horizontalQueryPanel.add(buttSearchBy); horizontalQueryPanel.add(buttSearchBy);
add(horizontalQueryPanel); add(horizontalQueryPanel);
add(hpAdvancedSearchLinks); add(hpAdvancedSearchLinks);
} }
private void initQuerySearchPanel() { private void initQuerySearchPanel() {
querySeachPanel.setSpacing(5);
querySeachPanel.setSpacing(5);
buttQuerySearch = new Button("Search"); buttQuerySearch = new Button("Search");
buttQuerySearch.setStyleName("wizardButton"); buttQuerySearch.setStyleName("wizardButton");
buttQuerySearch.addClickHandler(new ClickHandler() { buttQuerySearch.addClickHandler(new ClickHandler() {
@Override @Override

View File

@ -35,17 +35,30 @@ public class CreateGisLayerJobEvent extends GwtEvent<CreateGisLayerJobEventHandl
} }
private String jobDescription; private String jobDescription;
private long totalPoints;
/** /**
* @param jobName * @param jobName
* @param string * @param string
*/ */
public CreateGisLayerJobEvent(String jobName, String descr) { public CreateGisLayerJobEvent(String jobName, String descr, long totalPoints) {
this.jobName = jobName; this.jobName = jobName;
this.jobDescription = descr; this.jobDescription = descr;
this.totalPoints = totalPoints;
} }
/**
* @return the totalPoints
*/
public long getTotalPoints() {
return totalPoints;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/ */

View File

@ -1,8 +1,9 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.speciesdiscovery.client.event; package org.gcube.portlets.user.speciesdiscovery.client.event;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
@ -15,7 +16,7 @@ import com.google.gwt.event.shared.GwtEvent;
* *
*/ */
public class ReSubmitJobEvent extends GwtEvent<ReSubmitJobEventHandler> { public class ReSubmitJobEvent extends GwtEvent<ReSubmitJobEventHandler> {
public static final GwtEvent.Type<ReSubmitJobEventHandler> TYPE = new Type<ReSubmitJobEventHandler>(); public static final GwtEvent.Type<ReSubmitJobEventHandler> TYPE = new Type<ReSubmitJobEventHandler>();
private SearchResultType loadType; private SearchResultType loadType;
@ -23,16 +24,19 @@ public class ReSubmitJobEvent extends GwtEvent<ReSubmitJobEventHandler> {
private JobOccurrencesModel jobOccurrenceModel; private JobOccurrencesModel jobOccurrenceModel;
private JobTaxonomyModel jobTaxonomyModel; private JobTaxonomyModel jobTaxonomyModel;
private JobGisLayerModel jobGisModel;
@Override @Override
public Type<ReSubmitJobEventHandler> getAssociatedType() { public Type<ReSubmitJobEventHandler> getAssociatedType() {
return TYPE; return TYPE;
} }
public ReSubmitJobEvent(SearchResultType loadType, JobOccurrencesModel jobOccurrenceModel, JobTaxonomyModel jobTaxonomyModel){ public ReSubmitJobEvent(SearchResultType loadType, JobOccurrencesModel jobOccurrenceModel, JobTaxonomyModel jobTaxonomyModel, JobGisLayerModel jobGisModel){
this.loadType = loadType; this.loadType = loadType;
this.jobOccurrenceModel = jobOccurrenceModel; this.jobOccurrenceModel = jobOccurrenceModel;
this.jobTaxonomyModel = jobTaxonomyModel; this.jobTaxonomyModel = jobTaxonomyModel;
this.jobGisModel = jobGisModel;
} }
public SearchResultType getLoadType() { public SearchResultType getLoadType() {
@ -42,7 +46,7 @@ public class ReSubmitJobEvent extends GwtEvent<ReSubmitJobEventHandler> {
@Override @Override
protected void dispatch(ReSubmitJobEventHandler handler) { protected void dispatch(ReSubmitJobEventHandler handler) {
handler.onResubmitJob(this); handler.onResubmitJob(this);
} }
public JobOccurrencesModel getJobOccurrenceModel() { public JobOccurrencesModel getJobOccurrenceModel() {
@ -52,5 +56,5 @@ public class ReSubmitJobEvent extends GwtEvent<ReSubmitJobEventHandler> {
public JobTaxonomyModel getJobTaxonomyModel() { public JobTaxonomyModel getJobTaxonomyModel() {
return jobTaxonomyModel; return jobTaxonomyModel;
} }
} }

View File

@ -1,11 +1,12 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.speciesdiscovery.client.event; package org.gcube.portlets.user.speciesdiscovery.client.event;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSource; import org.gcube.portlets.user.speciesdiscovery.shared.DataSource;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
@ -13,12 +14,12 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/** /**
* * The Class SaveJobErrorEvent.
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*/ */
public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> { public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> {
public static final GwtEvent.Type<SaveJobErrorEventHandler> TYPE = new Type<SaveJobErrorEventHandler>(); public static final GwtEvent.Type<SaveJobErrorEventHandler> TYPE = new Type<SaveJobErrorEventHandler>();
private String jobIdentifier; private String jobIdentifier;
private String scientificName; private String scientificName;
@ -27,26 +28,35 @@ public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> {
private List<DataSource> listDataSources; private List<DataSource> listDataSources;
private JobTaxonomyModel jobTaxonomyModel; private JobTaxonomyModel jobTaxonomyModel;
private JobOccurrencesModel jobOccurrenceModel; private JobOccurrencesModel jobOccurrenceModel;
private String layerTitle;
private JobGisLayerModel jobGisLayer;
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override @Override
public Type<SaveJobErrorEventHandler> getAssociatedType() { public Type<SaveJobErrorEventHandler> getAssociatedType() {
return TYPE; return TYPE;
} }
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override @Override
protected void dispatch(SaveJobErrorEventHandler handler) { protected void dispatch(SaveJobErrorEventHandler handler) {
handler.onSaveJobError(this); handler.onSaveJobError(this);
} }
/** /**
* * Instantiates a new save job error event.
* @param jobIdentifier *
* @param scientificName * @param jobIdentifier the job identifier
* @param listDataSource * @param scientificName the scientific name
* @param rank * @param dataSourceList the data source list
* @param type * @param rank the rank
* @param jobTaxonomyModel * @param type the type
* @param jobTaxonomyModel the job taxonomy model
*/ */
public SaveJobErrorEvent(String jobIdentifier, String scientificName, List<DataSource> dataSourceList, String rank, SearchResultType type, JobTaxonomyModel jobTaxonomyModel) { public SaveJobErrorEvent(String jobIdentifier, String scientificName, List<DataSource> dataSourceList, String rank, SearchResultType type, JobTaxonomyModel jobTaxonomyModel) {
this.jobIdentifier = jobIdentifier; this.jobIdentifier = jobIdentifier;
@ -55,16 +65,33 @@ public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> {
this.rank = rank; this.rank = rank;
this.itemType = type; this.itemType = type;
this.jobTaxonomyModel = jobTaxonomyModel; this.jobTaxonomyModel = jobTaxonomyModel;
} }
/** /**
* * Instantiates a new save job error event.
* @param jobIdentifier *
* @param scientificName * @param jobIdentifier the job identifier
* @param dataSourceList * @param layerTitle the layer title
* @param type * @param jobGisLayer the job gis layer
* @param jobOccurrenceModel * @param type the type
*/
public SaveJobErrorEvent(String jobIdentifier, String layerTitle, JobGisLayerModel jobGisLayer, SearchResultType type) {
this.jobIdentifier = jobIdentifier;
this.layerTitle = layerTitle;
this.jobGisLayer = jobGisLayer;
this.itemType = type;
}
/**
* Instantiates a new save job error event.
*
* @param jobIdentifier the job identifier
* @param scientificName the scientific name
* @param dataSourceList the data source list
* @param type the type
* @param jobOccurrenceModel the job occurrence model
*/ */
public SaveJobErrorEvent(String jobIdentifier, String scientificName, List<DataSource> dataSourceList, SearchResultType type, JobOccurrencesModel jobOccurrenceModel) { public SaveJobErrorEvent(String jobIdentifier, String scientificName, List<DataSource> dataSourceList, SearchResultType type, JobOccurrencesModel jobOccurrenceModel) {
this.jobIdentifier = jobIdentifier; this.jobIdentifier = jobIdentifier;
@ -73,48 +100,103 @@ public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> {
this.itemType = type; this.itemType = type;
this.jobOccurrenceModel = jobOccurrenceModel; this.jobOccurrenceModel = jobOccurrenceModel;
} }
/**
* Gets the job identifier.
*
* @return the job identifier
*/
public String getJobIdentifier() { public String getJobIdentifier() {
return jobIdentifier; return jobIdentifier;
} }
/**
* Sets the job identifier.
*
* @param jobIdentifier the new job identifier
*/
public void setJobIdentifier(String jobIdentifier) { public void setJobIdentifier(String jobIdentifier) {
this.jobIdentifier = jobIdentifier; this.jobIdentifier = jobIdentifier;
} }
/**
* Gets the scientific name.
*
* @return the scientific name
*/
public String getScientificName() { public String getScientificName() {
return scientificName; return scientificName;
} }
/**
* Gets the rank.
*
* @return the rank
*/
public String getRank() { public String getRank() {
return rank; return rank;
} }
/**
* Gets the item type.
*
* @return the item type
*/
public SearchResultType getItemType() { public SearchResultType getItemType() {
return itemType; return itemType;
} }
/**
* Gets the job taxonomy model.
*
* @return the job taxonomy model
*/
public JobTaxonomyModel getJobTaxonomyModel() { public JobTaxonomyModel getJobTaxonomyModel() {
return jobTaxonomyModel; return jobTaxonomyModel;
} }
/**
* Gets the job occurrence model.
*
* @return the job occurrence model
*/
public JobOccurrencesModel getJobOccurrenceModel() { public JobOccurrencesModel getJobOccurrenceModel() {
return jobOccurrenceModel; return jobOccurrenceModel;
} }
/**
* Sets the job taxonomy model.
*
* @param jobTaxonomyModel the new job taxonomy model
*/
public void setJobTaxonomyModel(JobTaxonomyModel jobTaxonomyModel) { public void setJobTaxonomyModel(JobTaxonomyModel jobTaxonomyModel) {
this.jobTaxonomyModel = jobTaxonomyModel; this.jobTaxonomyModel = jobTaxonomyModel;
} }
/**
* Sets the job occurrence model.
*
* @param jobOccurrenceModel the new job occurrence model
*/
public void setJobOccurrenceModel(JobOccurrencesModel jobOccurrenceModel) { public void setJobOccurrenceModel(JobOccurrencesModel jobOccurrenceModel) {
this.jobOccurrenceModel = jobOccurrenceModel; this.jobOccurrenceModel = jobOccurrenceModel;
} }
/**
* Gets the list data sources.
*
* @return the list data sources
*/
public List<DataSource> getListDataSources() { public List<DataSource> getListDataSources() {
return listDataSources; return listDataSources;
} }
/**
* Sets the list data sources.
*
* @param listDataSources the new list data sources
*/
public void setListDataSources(List<DataSource> listDataSources) { public void setListDataSources(List<DataSource> listDataSources) {
this.listDataSources = listDataSources; this.listDataSources = listDataSources;
} }

View File

@ -1,11 +1,12 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.speciesdiscovery.client.event; package org.gcube.portlets.user.speciesdiscovery.client.event;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSource; import org.gcube.portlets.user.speciesdiscovery.shared.DataSource;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
@ -13,12 +14,12 @@ import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* *
*/ */
public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> { public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> {
public static final GwtEvent.Type<SaveJobEventHandler> TYPE = new Type<SaveJobEventHandler>(); public static final GwtEvent.Type<SaveJobEventHandler> TYPE = new Type<SaveJobEventHandler>();
private String jobIdentifier; private String jobIdentifier;
private String scientificName; private String scientificName;
@ -27,6 +28,8 @@ public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> {
private List<DataSource> listDataSources; private List<DataSource> listDataSources;
private JobTaxonomyModel jobTaxonomyModel; private JobTaxonomyModel jobTaxonomyModel;
private JobOccurrencesModel jobOccurrenceModel; private JobOccurrencesModel jobOccurrenceModel;
private String layerTitle;
private JobGisLayerModel jobGisLayer;
@Override @Override
public Type<SaveJobEventHandler> getAssociatedType() { public Type<SaveJobEventHandler> getAssociatedType() {
@ -35,12 +38,12 @@ public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> {
@Override @Override
protected void dispatch(SaveJobEventHandler handler) { protected void dispatch(SaveJobEventHandler handler) {
handler.onSaveJob(this); handler.onSaveJob(this);
} }
/** /**
* *
* @param jobIdentifier * @param jobIdentifier
* @param scientificName * @param scientificName
* @param listDataSource * @param listDataSource
@ -55,11 +58,11 @@ public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> {
this.rank = rank; this.rank = rank;
this.itemType = type; this.itemType = type;
this.jobTaxonomyModel = jobTaxonomyModel; this.jobTaxonomyModel = jobTaxonomyModel;
} }
/** /**
* *
* @param jobIdentifier * @param jobIdentifier
* @param scientificName * @param scientificName
* @param dataSourceList * @param dataSourceList
@ -73,7 +76,26 @@ public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> {
this.itemType = type; this.itemType = type;
this.jobOccurrenceModel = jobOccurrenceModel; this.jobOccurrenceModel = jobOccurrenceModel;
} }
/**
*
* @param jobIdentifier
* @param scientificName
* @param dataSourceList
* @param type
* @param jobOccurrenceModel
*/
public SaveJobEvent(String jobIdentifier, String layerTitle, SearchResultType type, JobGisLayerModel jobGisLayer) {
this.jobIdentifier = jobIdentifier;
this.itemType = type;
this.layerTitle = layerTitle;
this.itemType = type;
this.jobGisLayer = jobGisLayer;
}
public String getJobIdentifier() { public String getJobIdentifier() {
return jobIdentifier; return jobIdentifier;
@ -94,7 +116,7 @@ public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> {
public SearchResultType getItemType() { public SearchResultType getItemType() {
return itemType; return itemType;
} }
public JobTaxonomyModel getJobTaxonomyModel() { public JobTaxonomyModel getJobTaxonomyModel() {
return jobTaxonomyModel; return jobTaxonomyModel;
} }

View File

@ -1,45 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.client.event;
import com.google.gwt.event.shared.GwtEvent;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public class ShowOccurrencesMapEvent extends GwtEvent<ShowOccurrencesMapEventHandler> {
public static final GwtEvent.Type<ShowOccurrencesMapEventHandler> TYPE = new Type<ShowOccurrencesMapEventHandler>();
private int expectedPoints;
public ShowOccurrencesMapEvent(int expectedPoints) {
this.expectedPoints = expectedPoints;
}
@Override
public Type<ShowOccurrencesMapEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(ShowOccurrencesMapEventHandler handler) {
handler.onShowOccurrencesMap(this);
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ShowOccurrencesMapEvent []");
return builder.toString();
}
public int getExpectedPoints() {
return expectedPoints;
}
}

View File

@ -1,16 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public interface ShowOccurrencesMapEventHandler extends EventHandler {
public void onShowOccurrencesMap(ShowOccurrencesMapEvent event);
}

View File

@ -1,17 +1,6 @@
package org.gcube.portlets.user.speciesdiscovery.client.gridview; package org.gcube.portlets.user.speciesdiscovery.client.gridview;
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateGisLayerJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.window.MessageDialog;
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
import com.allen_sauer.gwt.log.client.Log;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.rpc.AsyncCallback;
public class GisLayerJobGridManager { public class GisLayerJobGridManager {
@ -29,53 +18,53 @@ public class GisLayerJobGridManager {
this.isSearchByCommonName = isSearchByCommonName; this.isSearchByCommonName = isSearchByCommonName;
} }
public void saveOccurrence(){ // public void saveOccurrence(){
//
// SpeciesDiscovery.taxonomySearchService.getCountOfOccurrencesBatch(new AsyncCallback<OccurrencesStatus>() {
//
// @Override
// public void onFailure(Throwable caught) {
// Log.error("Error on loading", "An error occurred on count of occurrence point, retry." +caught.getMessage());
//
// }
//
// @Override
// public void onSuccess(final OccurrencesStatus result) {
// MessageDialog dialog;
// if(expectedOccurrences>result.getSize()){
//
// dialog = new MessageDialog("Info", "Loading in progress", "On server are available only "+result.getSize()+" of "+expectedOccurrences+" occurrences points. Do you want continue?");
// dialog.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
//
// public void handleEvent(MessageBoxEvent be) {
// //IF NOT CANCELLED
// String clickedButton = be.getButtonClicked().getItemId();
// if(clickedButton.equals(Dialog.YES))
// createGisLayerJobEventCallback(result.getSize());
// }
// });
// }
//
// else
// createGisLayerJobEventCallback(result.getSize());
// }
// });
//
// }
SpeciesDiscovery.taxonomySearchService.getCountOfOccurrencesBatch(new AsyncCallback<OccurrencesStatus>() { // private void createGisLayerJobEventCallback(int totalPoints) {
//
// String jobName = getSearchTermBySearchType(isSearchByCommonName, searchTerm);
// eventBus.fireEvent(new CreateGisLayerJobEvent(jobName, "Gis Layer generated from SPD Portlet by gCube Framework", totalPoints));
// }
@Override // public static String getSearchTermBySearchType(boolean isSearchByCommonName, String searchTerm){
public void onFailure(Throwable caught) { //
Log.error("Error on loading", "An error occurred on count of occurrence point, retry." +caught.getMessage()); // if(isSearchByCommonName)
// return NormalizeString.lowerCaseUpFirstChar(searchTerm) + " " + COMMON_NAME;
} // else
// return NormalizeString.lowerCaseUpFirstChar(searchTerm) + " " + SCIENTIFIC_NAME;
@Override // }
public void onSuccess(OccurrencesStatus result) {
MessageDialog dialog;
if(expectedOccurrences>result.getSize()){
dialog = new MessageDialog("Info", "Loading in progress", "On server are available only "+result.getSize()+" of "+expectedOccurrences+" occurrences points. Do you want continue?");
dialog.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
//IF NOT CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES))
createGisLayerJobEventCallback();
}
});
}
else
createGisLayerJobEventCallback();
}
});
}
private void createGisLayerJobEventCallback() {
String jobName = getSearchTermBySearchType(isSearchByCommonName, searchTerm);
eventBus.fireEvent(new CreateGisLayerJobEvent(jobName, "Gis Layer generated from SPD Portlet by gCube Framework"));
}
public static String getSearchTermBySearchType(boolean isSearchByCommonName, String searchTerm){
if(isSearchByCommonName)
return NormalizeString.lowerCaseUpFirstChar(searchTerm) + " " + COMMON_NAME;
else
return NormalizeString.lowerCaseUpFirstChar(searchTerm) + " " + SCIENTIFIC_NAME;
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.speciesdiscovery.client.job; package org.gcube.portlets.user.speciesdiscovery.client.job;
import org.gcube.portlets.user.speciesdiscovery.client.job.gislayer.GisLayerJobSpeciesPanel;
import org.gcube.portlets.user.speciesdiscovery.client.job.occurrence.OccurrenceJobSpeciesPanel; import org.gcube.portlets.user.speciesdiscovery.client.job.occurrence.OccurrenceJobSpeciesPanel;
import org.gcube.portlets.user.speciesdiscovery.client.job.taxonomy.TaxonomyJobSpeciesPanel; import org.gcube.portlets.user.speciesdiscovery.client.job.taxonomy.TaxonomyJobSpeciesPanel;
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources; import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
@ -23,56 +24,57 @@ public class SpeciesJobPanel extends ContentPanel{
protected static final String EMPTY = "Empty"; protected static final String EMPTY = "Empty";
protected static final String CURRENT_QUERY = "Current query: "; protected static final String CURRENT_QUERY = "Current query: ";
private ToolBar toolbar = new ToolBar(); private ToolBar toolbar = new ToolBar();
private TaxonomyJobSpeciesPanel taxonomyJobPanelInstance; private TaxonomyJobSpeciesPanel taxonomyJobPanelInstance;
private OccurrenceJobSpeciesPanel occurrenceJobPanelInstance; private OccurrenceJobSpeciesPanel occurrenceJobPanelInstance;
private GisLayerJobSpeciesPanel gisLayerJobPanelInstance;
private Button btnTaxonomyJobs; private Button btnTaxonomyJobs;
private Button btnOccurrenceJobs; private Button btnOccurrenceJobs;
private Button btnGisLayerJobs;
private int jobOccurrenceCount = 0; private int jobOccurrenceCount = 0;
private int jobTaxonomyCount = 0; private int jobTaxonomyCount = 0;
private int jobGisLayerCount = 0;
private TextField<String> currentQuery; private TextField<String> currentQuery;
public SpeciesJobPanel(EventBus eventBus) { public SpeciesJobPanel(EventBus eventBus) {
this.setTopComponent(toolbar); this.setTopComponent(toolbar);
setLayout(new FitLayout()); setLayout(new FitLayout());
setHeaderVisible(false); setHeaderVisible(false);
taxonomyJobPanelInstance = TaxonomyJobSpeciesPanel.getInstance(eventBus); taxonomyJobPanelInstance = TaxonomyJobSpeciesPanel.getInstance(eventBus);
occurrenceJobPanelInstance = OccurrenceJobSpeciesPanel.getInstance(eventBus); occurrenceJobPanelInstance = OccurrenceJobSpeciesPanel.getInstance(eventBus);
gisLayerJobPanelInstance = GisLayerJobSpeciesPanel.getInstance(eventBus);
createOccurrencesToolBar(); createOccurrencesToolBar();
toolbar.add(new SeparatorToolItem()); toolbar.add(new SeparatorToolItem());
createTaxonomyToolBar(); createTaxonomyToolBar();
toolbar.add(new SeparatorToolItem());
createGisLayerToolBar();
Text txtLastQuery = new Text(CURRENT_QUERY); Text txtLastQuery = new Text(CURRENT_QUERY);
txtLastQuery.setStyleAttribute("padding-right", "2px"); txtLastQuery.setStyleAttribute("padding-right", "2px");
txtLastQuery.setStyleAttribute("color", "gray"); txtLastQuery.setStyleAttribute("color", "gray");
currentQuery = new TextField<String>(); currentQuery = new TextField<String>();
currentQuery.setReadOnly(true); currentQuery.setReadOnly(true);
currentQuery.setWidth(400); currentQuery.setWidth(400);
currentQuery.setValue(EMPTY); currentQuery.setValue(EMPTY);
toolbar.add(new FillToolItem()); toolbar.add(new FillToolItem());
toolbar.add(txtLastQuery); toolbar.add(txtLastQuery);
toolbar.add(currentQuery); toolbar.add(currentQuery);
RenderTextFieldUtil.setTextFieldAttr(currentQuery, "background", "none"); RenderTextFieldUtil.setTextFieldAttr(currentQuery, "background", "none");
// RenderTextFieldUtil.setTextFieldAttr(lastQuery, "text-align", "right"); // RenderTextFieldUtil.setTextFieldAttr(lastQuery, "text-align", "right");
} }
private void createOccurrencesToolBar(){ private void createOccurrencesToolBar(){
btnTaxonomyJobs = new Button("Species Taxonomy Jobs"); btnTaxonomyJobs = new Button("Species Taxonomy Jobs");
btnTaxonomyJobs.setScale(ButtonScale.MEDIUM); btnTaxonomyJobs.setScale(ButtonScale.MEDIUM);
setIconTaxonomyByCounter(0); setIconTaxonomyByCounter(0);
btnTaxonomyJobs.addSelectionListener(new SelectionListener<ButtonEvent>() { btnTaxonomyJobs.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
@ -81,117 +83,156 @@ public class SpeciesJobPanel extends ContentPanel{
resetTaxonoyCouter(); resetTaxonoyCouter();
taxonomyJobPanelInstance.getSpeciesJobWindow().show(); taxonomyJobPanelInstance.getSpeciesJobWindow().show();
} }
}); });
toolbar.add(btnTaxonomyJobs); toolbar.add(btnTaxonomyJobs);
} }
private void resetTaxonoyCouter(){ private void resetTaxonoyCouter(){
jobTaxonomyCount = 0; jobTaxonomyCount = 0;
setIconTaxonomyByCounter(0); setIconTaxonomyByCounter(0);
} }
private void createTaxonomyToolBar(){ private void createTaxonomyToolBar(){
btnOccurrenceJobs = new Button("Species Occurrence Jobs"); btnOccurrenceJobs = new Button("Species Occurrence Jobs");
btnOccurrenceJobs.setScale(ButtonScale.MEDIUM); btnOccurrenceJobs.setScale(ButtonScale.MEDIUM);
setIconOccurrenceByCounter(0); setIconOccurrenceByCounter(0);
btnOccurrenceJobs.addSelectionListener(new SelectionListener<ButtonEvent>() { btnOccurrenceJobs.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
resetOccurrenceCounter(); resetOccurrenceCounter();
occurrenceJobPanelInstance.getSpeciesJobWindow().show(); occurrenceJobPanelInstance.getSpeciesJobWindow().show();
} }
}); });
toolbar.add(btnOccurrenceJobs); toolbar.add(btnOccurrenceJobs);
} }
private void createGisLayerToolBar(){
btnGisLayerJobs = new Button("Gis Layer Jobs");
btnGisLayerJobs.setScale(ButtonScale.MEDIUM);
setIconGisLayerByCounter(0);
btnGisLayerJobs.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
resetOccurrenceCounter();
gisLayerJobPanelInstance.getGisLayerJobWindow().show();
}
});
toolbar.add(btnGisLayerJobs);
}
public void setLastQuery(String query){ public void setLastQuery(String query){
this.currentQuery.setValue(query); this.currentQuery.setValue(query);
} }
public void setLastQueryAsEmpty(){ public void setLastQueryAsEmpty(){
this.currentQuery.setValue(EMPTY); this.currentQuery.setValue(EMPTY);
} }
private void resetOccurrenceCounter(){ private void resetOccurrenceCounter(){
jobOccurrenceCount = 0; jobOccurrenceCount = 0;
setIconOccurrenceByCounter(0); setIconOccurrenceByCounter(0);
} }
public void setIconOccurrenceByCounter(int count){ public void setIconOccurrenceByCounter(int count){
this.jobOccurrenceCount += count; this.jobOccurrenceCount += count;
switch (jobOccurrenceCount) { switch (jobOccurrenceCount) {
case 0: case 0:
btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace())); btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace()));
break; break;
case 1: case 1:
btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace1())); btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace1()));
break; break;
case 2: case 2:
btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace2())); btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace2()));
break; break;
case 3: case 3:
btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace3())); btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace3()));
break; break;
case 4: case 4:
btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace4())); btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace4()));
break; break;
default: default:
btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace4More())); btnOccurrenceJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace4More()));
} }
toolbar.layout(); toolbar.layout();
} }
public void setIconGisLayerByCounter(int count){
public void setIconTaxonomyByCounter(int count){ this.jobGisLayerCount += count;
this.jobTaxonomyCount += count;
switch (jobGisLayerCount) {
switch (jobTaxonomyCount) {
case 0: case 0:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getGlobe()));
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy()));
break; break;
case 1: case 1:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace1()));
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy1()));
break; break;
case 2: case 2:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace2()));
break;
case 3:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace3()));
break;
case 4:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace4()));
break;
default:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace4More()));
}
toolbar.layout();
}
public void setIconTaxonomyByCounter(int count){
this.jobTaxonomyCount += count;
switch (jobTaxonomyCount) {
case 0:
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy()));
break;
case 1:
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy1()));
break;
case 2:
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy2())); btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy2()));
break; break;
case 3: case 3:
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy3())); btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy3()));
break; break;
case 4: case 4:
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy4())); btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy4()));
break; break;
default: default:
btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy4More())); btnTaxonomyJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getTaxonomy4More()));
} }
toolbar.layout(); toolbar.layout();
} }

View File

@ -0,0 +1,667 @@
package org.gcube.portlets.user.speciesdiscovery.client.job.gislayer;
import java.util.Arrays;
import java.util.HashMap;
import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery;
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
import org.gcube.portlets.user.speciesdiscovery.client.event.ReLoadListJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.ReSubmitJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.SaveJobErrorEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.SaveJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
import org.gcube.portlets.user.speciesdiscovery.client.window.MessageBoxConfirm;
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
//import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
//import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobTaxonomyModel;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
import com.allen_sauer.gwt.log.client.Log;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MenuEvent;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.grid.filters.DateFilter;
import com.extjs.gxt.ui.client.widget.grid.filters.GridFilters;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
* The Class GisLayerGridJob.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 10, 2017
*/
public class GisLayerGridJob extends ContentPanel{
private static final String REFRESH_LIST = "Refresh List";
private static final String RE_SUBMIT = "Re-submit";
private static final String SAVE = "Save";
private static final String SAVEERROR = "Save Errors";
private static final String CANCEL = "Cancel";
private static final String INFO = "Info";
// public static final String DATE_TIME_FORMAT = "yyyy.MM.dd 'at' HH:mm:ss";
// private ListStore<FileModel> store = ListStoreModel.getInstance().getStore();
private ListStore<BaseModelData> store;
private ToolBar toolBar = new ToolBar();
private Grid<BaseModelData> grid;
private HashMap<String,GisLayerWindowInfoJobsSpecies> listWindowInfo = new HashMap<String, GisLayerWindowInfoJobsSpecies>();
private EventBus eventBus;
private Button buttonInfo;
private Button buttonCancel;
private Button buttonSave;
private Button buttonSaveError;
private Button buttonReSubmit;
private Button buttonRefreshList;
private Menu menu = new Menu();
/**
* Instantiates a new gis layer grid job.
*
* @param eventBus the event bus
*/
public GisLayerGridJob(EventBus eventBus) {
this.eventBus = eventBus;
ColumnConfig name = new ColumnConfig(JobGisLayerModel.JOBNAME, JobGisLayerModel.JOBNAME, 220);
ColumnConfig progress = new ColumnConfig(JobGisLayerModel.PROGRESS, JobGisLayerModel.PROGRESS, 150);
ColumnConfig startDate = new ColumnConfig(JobGisLayerModel.STARTTIME, JobGisLayerModel.STARTTIME, 140);
ColumnConfig submitDate = new ColumnConfig(JobGisLayerModel.SUBMITTIME, JobGisLayerModel.SUBMITTIME, 140);
// creationDate.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig endTime = new ColumnConfig(JobGisLayerModel.ENDTIME, JobGisLayerModel.ENDTIME, 140);
// endTime.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig elapsedTime = new ColumnConfig(JobGisLayerModel.ELAPSEDTIME, JobGisLayerModel.ELAPSEDTIME + " Days, " + ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS, 100);
// elapsedTime.setHidden(true);
ColumnConfig status = new ColumnConfig(JobGisLayerModel.STATUS, JobGisLayerModel.STATUS, 80);
final ColumnModel cm = new ColumnModel(Arrays.asList(name, progress, submitDate, startDate, endTime, elapsedTime, status));
setBodyBorder(false);
setHeaderVisible(false);
setLayout(new FitLayout());
GridFilters filters = new GridFilters();
filters.setLocal(true);
DateFilter dateFilterStartDate = new DateFilter(JobGisLayerModel.STARTTIME);
DateFilter dateFilterSubmitDate = new DateFilter(JobGisLayerModel.SUBMITTIME);
DateFilter dateFilterEnd = new DateFilter(JobGisLayerModel.ENDTIME);
filters.addFilter(dateFilterStartDate);
filters.addFilter(dateFilterSubmitDate);
filters.addFilter(dateFilterEnd);
store = new ListStore<BaseModelData>();
grid = new Grid<BaseModelData>(store, cm);
grid.setLoadMask(true);
GridCellRenderer<BaseModelData> downloadStateRenderer = new GridCellRenderer<BaseModelData>() {
@Override
public String render(BaseModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
String val = model.get(property).toString();
String color="black";
// ONGOING, ONGOINGWITHFAILURES, FAILED, COMPLETED, COMPLETEDWITHFAILURES
if(val!=null){
if(val.compareTo(DownloadState.SAVING.toString())==0){
color = "#7093DB";
}else if(val.compareTo(DownloadState.FAILED.toString())==0){
color = "#f00";
}
}
else
val = "";
return "<span qtitle='" + cm.getColumnById(property).getHeader() + "' qtip='" + val + "' style='color:" + color + "'>" + val + "</span>";
}
};
GridCellRenderer<BaseModelData> jobSpeciesRenderer = new GridCellRenderer<BaseModelData>() {
public Object render(final BaseModelData model, String property, ColumnData config, final int rowIndex,
final int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
grid.addListener(Events.ColumnResize, new Listener<GridEvent<BaseModelData>>() {
public void handleEvent(GridEvent<BaseModelData> be) {
for (int i = 0; i < be.getGrid().getStore().getCount(); i++) {
if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null
&& be.getGrid().getView().getWidget(i, be.getColIndex()) instanceof GisLayerJobSpeciesProgressBar) {
((GisLayerJobSpeciesProgressBar) be.getGrid().getView().getWidget(i, be.getColIndex())).setWidth(be.getWidth() - 10);
}
}
}
});
return model.get(property);
}
};
progress.setRenderer(jobSpeciesRenderer);
status.setRenderer(downloadStateRenderer);
grid.getView().setEmptyText("Empty");
grid.getView().setShowDirtyCells(false);
grid.getView().setShowInvalidCells(false);
grid.setBorders(false);
grid.setColumnLines(true);
grid.addPlugin(filters);
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<BaseModelData>() {
@Override
public void selectionChanged(SelectionChangedEvent<BaseModelData> se) {
// System.out.println("selection grid change");
ModelData target = se.getSelectedItem();
if(target!=null)
enableButtonOnClick(true);
else
enableButtonOnClick(false);
}
});
add(grid);
createGridToolBar();
createMenuItemsOnGrid();
}
/**
* Adds the job into grid.
*
* @param jobModel the job model
* @param jobProgressBar the job progress bar
*/
public void addJobIntoGrid(JobGisLayerModel jobModel, GisLayerJobSpeciesProgressBar jobProgressBar) {
BaseModelData baseModelData = new BaseModelData();
baseModelData.set(JobGisLayerModel.JOBINDENTIFIER, jobModel.getJobIdentifier());
baseModelData.set(JobGisLayerModel.JOBNAME, jobModel.getJobName());
baseModelData.set(JobGisLayerModel.PROGRESS, jobProgressBar);
baseModelData.set(JobGisLayerModel.STATUS, jobModel.getDownloadState().toString());
baseModelData.set(JobGisLayerModel.SUBMITTIME, jobModel.getSubmitTime());
baseModelData.set(JobGisLayerModel.ENDTIME, jobModel.getEndTime());
baseModelData.set(JobGisLayerModel.STARTTIME, jobModel.getStartTime());
baseModelData.set(JobGisLayerModel.ELAPSEDTIME, jobModel.getElapsedTime());
baseModelData.set(jobModel.getJobIdentifier(), jobModel); //store object JobOccurrencesModel
store.add(baseModelData);
updateJobInfo(jobModel);
}
/**
* Update job info.
*
* @param jobModel the job model
*/
private void updateJobInfo(JobGisLayerModel jobModel){
GisLayerWindowInfoJobsSpecies win=listWindowInfo.get(jobModel.getJobIdentifier());
if(win==null){
win = new GisLayerWindowInfoJobsSpecies();
win.setWindowTitle("Job " + jobModel.getJobName() + " description:");
}
win.updateDescription(jobModel);
listWindowInfo.put(jobModel.getJobIdentifier(), win);
}
/**
* Update status.
*
* @param jobModel the job model
* @param jobProgressBar the job progress bar
*/
public void updateStatus(JobGisLayerModel jobModel, GisLayerJobSpeciesProgressBar jobProgressBar){
BaseModelData job = store.findModel(JobGisLayerModel.JOBINDENTIFIER, jobModel.getJobIdentifier());
if(job!=null){
job.set(JobGisLayerModel.PROGRESS, jobProgressBar);
job.set(JobGisLayerModel.SUBMITTIME, jobModel.getSubmitTime());
job.set(JobGisLayerModel.STATUS, jobModel.getDownloadState().toString());
job.set(JobGisLayerModel.ENDTIME, jobModel.getEndTime());
job.set(JobGisLayerModel.ELAPSEDTIME, jobModel.getElapsedTime());
job.set(JobGisLayerModel.STARTTIME, jobModel.getStartTime());
updateJobInfo(jobModel);
store.update(job);
}
}
/**
* Removes the species job by identifier.
*
* @param jobIdentifier the job identifier
*/
public void removeSpeciesJobByIdentifier(String jobIdentifier) {
BaseModelData job = store.findModel(JobGisLayerModel.JOBINDENTIFIER, jobIdentifier);
if(job!=null){
store.remove(job);
}
}
/**
* View info job.
*/
private void viewInfoJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){
GisLayerWindowInfoJobsSpecies win = listWindowInfo.get(baseModelData.get(JobGisLayerModel.JOBINDENTIFIER));
win.show();
}
}
/**
* Cancel job.
*/
private void cancelJob() {
final BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){
String name = baseModelData.get(JobGisLayerModel.JOBNAME);
MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsSpeciesDiscovery.CONFIRM_DELETE, ConstantsSpeciesDiscovery.MESSAGE_CONFIRM_DELETE_JOB + " "+ name+"?");
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
//IF CANCELLED
String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES)){
final String jobIdentifier = baseModelData.get(JobGisLayerModel.JOBINDENTIFIER);
SpeciesDiscovery.taxonomySearchService.cancelOccurrenceJob(jobIdentifier, new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if(result)
removeSpeciesJobByIdentifier(jobIdentifier);
}
@Override
public void onFailure(Throwable caught) {
Info.display("Error", "An error occurred during the cancel");
Log.error("Error during the cancel", caught.getMessage());
}
});
}
}
});
}
}
/**
* Save job.
*/
private void saveJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){
String load = baseModelData.get(JobGisLayerModel.STATUS).toString();
if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){
String jobIdentifier = baseModelData.get(JobGisLayerModel.JOBINDENTIFIER);
JobGisLayerModel jobModel = baseModelData.get(jobIdentifier);
eventBus.fireEvent(new SaveJobEvent(jobIdentifier, jobModel.getJobName(), SearchResultType.GIS_LAYER_POINT, jobModel));
}
else{
String name = baseModelData.get(JobGisLayerModel.JOBNAME);
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The job "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
}
}
}
/**
* Save error job.
*/
private void saveErrorJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){
String load = baseModelData.get(JobGisLayerModel.STATUS).toString();
if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 || load.compareTo(DownloadState.FAILED.toString())==0){
String jobIdentifier = baseModelData.get(JobGisLayerModel.JOBINDENTIFIER);
JobGisLayerModel jobModel = baseModelData.get(jobIdentifier);
eventBus.fireEvent(new SaveJobErrorEvent(jobIdentifier, jobModel.getJobName(), jobModel, SearchResultType.GIS_LAYER_POINT));
}
else{
String name = baseModelData.get(JobGisLayerModel.JOBNAME);
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The error file "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
}
}
}
/**
* Resubmit job.
*/
private void resubmitJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){
String load = baseModelData.get(JobTaxonomyModel.STATUS).toString();
if(load.compareTo(DownloadState.FAILED.toString())==0 || load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){
String jobIdentifier = baseModelData.get(JobGisLayerModel.JOBINDENTIFIER);
JobGisLayerModel jobModel = (JobGisLayerModel) baseModelData.get(jobIdentifier); //get object JobOccurrencesModel
eventBus.fireEvent(new ReSubmitJobEvent(SearchResultType.GIS_LAYER_POINT, null, null, jobModel));
}
else{
String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
MessageBox.alert(INFO, "The job "+ name+ " " + ConstantsSpeciesDiscovery.CAN_NOT_BE_RE_SUBMITTED_UNTIL_IT_HAS_COMPLETED, null);
}
}
}
/**
* Creates the grid tool bar.
*/
private void createGridToolBar(){
buttonInfo = new Button(INFO);
buttonInfo.setScale(ButtonScale.MEDIUM);
buttonInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon()));
buttonInfo.setStyleAttribute("margin-left", "5px");
buttonInfo.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
viewInfoJob();
}
});
buttonCancel = new Button(CANCEL);
buttonCancel.setScale(ButtonScale.MEDIUM);
buttonCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete()));
buttonCancel.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
cancelJob();
}
});
buttonSave = new Button(SAVE);
buttonSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
buttonSave.setScale(ButtonScale.MEDIUM);
buttonSave.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
saveJob();
}
});
buttonSaveError = new Button(SAVEERROR);
buttonSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
buttonSaveError.setScale(ButtonScale.MEDIUM);
buttonSaveError.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
saveErrorJob();
}
});
buttonReSubmit = new Button(RE_SUBMIT);
buttonReSubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit()));
buttonReSubmit.setScale(ButtonScale.MEDIUM);
buttonReSubmit.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
resubmitJob();
}
});
buttonRefreshList = new Button(REFRESH_LIST);
buttonRefreshList.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getRefresh()));
buttonRefreshList.setScale(ButtonScale.MEDIUM);
buttonRefreshList.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
// resetStore();
eventBus.fireEvent(new ReLoadListJobEvent(SearchResultType.OCCURRENCE_POINT));
}
});
toolBar.add(buttonInfo);
toolBar.add(new SeparatorToolItem());
toolBar.add(buttonSave);
toolBar.add(new SeparatorToolItem());
toolBar.add(buttonSaveError);
toolBar.add(new SeparatorToolItem());
toolBar.add(buttonCancel);
toolBar.add(new SeparatorToolItem());
toolBar.add(buttonReSubmit);
toolBar.add(new SeparatorToolItem());
toolBar.add(new FillToolItem());
toolBar.add(new SeparatorToolItem());
toolBar.add(buttonRefreshList);
setTopComponent(toolBar);
enableButtonOnClick(false);
}
/**
* Enable tool bar.
*
* @param bool the bool
*/
public void enableToolBar(boolean bool){
this.toolBar.setEnabled(bool);
}
/**
* Reset store.
*/
public void resetStore(){
store.removeAll();
}
/**
* Enable button on click.
*
* @param bool the bool
*/
public void enableButtonOnClick(boolean bool){
this.buttonCancel.setEnabled(bool);
this.buttonInfo.setEnabled(bool);
this.buttonSave.setEnabled(bool);
this.buttonReSubmit.setEnabled(bool);
this.buttonSaveError.setEnabled(bool);
}
/**
* Creates the menu items on grid.
*/
public void createMenuItemsOnGrid(){
MenuItem menuInfo = new MenuItem();
menuInfo.setText(INFO);
menuInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon()));
menuInfo.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
viewInfoJob();
}
});
menu.add(menuInfo);
MenuItem menuSave= new MenuItem();
menuSave.setText(SAVE);
menuSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
menuSave.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
saveJob();
}
});
menu.add(menuSave);
MenuItem menuSaveError = new MenuItem();
menuSaveError.setText(SAVEERROR);
menuSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
menuSaveError.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
saveErrorJob();
}
});
menu.add(menuSaveError);
MenuItem menuCancel= new MenuItem();
menuCancel.setText(CANCEL);
menuCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete()));
menuCancel.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
cancelJob();
}
});
menu.add(menuCancel);
MenuItem menuResubmit= new MenuItem();
menuResubmit.setText(RE_SUBMIT);
menuResubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit()));
menuResubmit.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override
public void componentSelected(MenuEvent ce) {
resubmitJob();
}
});
menu.add(menuResubmit);
grid.setContextMenu(menu);
}
}

View File

@ -0,0 +1,32 @@
package org.gcube.portlets.user.speciesdiscovery.client.job.gislayer;
import org.gcube.portlets.user.speciesdiscovery.client.util.GridField;
public enum GisLayerJobInfoFields implements GridField{
NAME("name","Name"),
LOADING("loading","Loading");
private String id;
private String name;
private GisLayerJobInfoFields(String id, String name) {
this.id=id;
this.name=name;
}
@Override
public String getId() {
return this.id;
}
@Override
public String getName() {
return this.name;
}
@Override
public boolean isSortable() {
return false;
}
}

View File

@ -0,0 +1,335 @@
package org.gcube.portlets.user.speciesdiscovery.client.job.gislayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
* The Class OccurrenceJobSpeciesPanel.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*/
public class GisLayerJobSpeciesPanel extends ContentPanel {
/**
* This is a singleton
*/
private static GisLayerJobSpeciesPanel instance;
private static ContentPanel cp;
private ContentPanel vp;
private static HashMap<String, GisLayerJobSpeciesProgressBar> hashProgressBars;
private static HashMap<String, Boolean> hashLoadCompletedNotify;
private static HashMap<String, ContentPanel> hashTableContentPanels;
private static String LASTOPERATION = "Last Operation: ";
private Html lastOperation = new Html(LASTOPERATION);
private LayoutContainer lc;
private static String WINDOWTITLE = "Species Occurrence Jobs";
private static final String FAILED = "failed";
private static final String COMPLETED = "completed";
private static final String LOADING = "loading";
private static final String PENDING = "pending";
private static final String OPERATIONONE = "none";
private static final String SAVING = "saving";
private GisLayerGridJob gridJob;
private EventBus eventBus;
protected Window gisLayerJobWindow = new Window();
/**
* Gets the single instance of OccurrenceJobSpeciesPanel.
*
* @param eventBus the event bus
* @return single instance of OccurrenceJobSpeciesPanel
*/
public static synchronized GisLayerJobSpeciesPanel getInstance(EventBus eventBus) {
if (instance == null)
instance = new GisLayerJobSpeciesPanel(eventBus);
return instance;
}
/**
* Instantiates a new occurrence job species panel.
*
* @param eventBus the event bus
*/
private GisLayerJobSpeciesPanel(EventBus eventBus) {
this.eventBus = eventBus;
this.gridJob = new GisLayerGridJob(eventBus);
this.setHeaderVisible(false);
this.setLayout(new FitLayout());
createSpeciesJobWindow();
// createToolBar();
}
/**
* Creates the species job window.
*/
private void createSpeciesJobWindow(){
lc = new LayoutContainer();
lc.setStyleAttribute("margin", "5px");
cp = new ContentPanel();
cp.setBodyBorder(true);
cp.setStyleAttribute("padding", "5px");
cp.setLayout(new FitLayout());
cp.add(gridJob);
cp.setHeight(550);
cp.setHeaderVisible(false);
hashProgressBars = new HashMap<String, GisLayerJobSpeciesProgressBar>();
hashTableContentPanels = new HashMap<String, ContentPanel>();
hashLoadCompletedNotify = new HashMap<String, Boolean>();
cp.setScrollMode(Scroll.AUTO);
lastOperation.setHtml(LASTOPERATION + OPERATIONONE);
lc.add(lastOperation);
lc.add(cp);
gisLayerJobWindow.setHeading(WINDOWTITLE);
gisLayerJobWindow.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace16px()));
gisLayerJobWindow.setSize(1020, 600);
gisLayerJobWindow.setResizable(true);
gisLayerJobWindow.setScrollMode(Scroll.AUTOX);
gisLayerJobWindow.add(lc);
}
/**
* Adds the list job.
*
* @param jobsModel the jobs model
*/
public void addListJob(List<JobGisLayerModel> jobsModel){
for(final JobGisLayerModel jobModel : jobsModel)
addJob(jobModel);
}
/**
* Adds the job.
*
* @param jobModel the job model
* @return true, if successful
*/
public boolean addJob(final JobGisLayerModel jobModel){
boolean isLoading = false;
GisLayerJobSpeciesProgressBar jobsBar = hashProgressBars.get(jobModel.getJobIdentifier());
if(jobsBar!=null){ //is update
GisLayerWindowInfoJobsSpecies win = (GisLayerWindowInfoJobsSpecies) jobsBar.getData("win");
if(win!=null){
win.updateDescription(jobModel);
win.layout();
jobsBar.setData("win", win);
}
//IF job is COMPLETED OR FAILED OR COMPLETED WITH ERROR, IS NOT UPDATE
if(jobsBar.isCompleted()){
//FOR DEBUG
// Log.trace("jobsBar " +jobModel.getName() + " completed, return" );
return true;
}
updateProgressBarView(jobsBar, jobModel);
gridJob.updateStatus(jobModel, jobsBar);
}
else{ //create new grid item that contains new progress bar
GisLayerJobSpeciesProgressBar jobProgressBar = new GisLayerJobSpeciesProgressBar(jobModel.getJobIdentifier(), jobModel.getDownloadState().toString());
gridJob.addJobIntoGrid(jobModel, jobProgressBar);
updateProgressBarView(jobProgressBar, jobModel);
hashProgressBars.put(jobModel.getJobIdentifier(), jobProgressBar); //add progressBar into hashProgressBars
hashLoadCompletedNotify.put(jobModel.getJobIdentifier(), false); //add false (at load completed event) into hashLoadCompletedNotify
}
gridJob.layout();
cp.layout();
return isLoading;
}
/**
* Update progress bar view.
*
* @param jobsBar the jobs bar
* @param jobModel the job model
* @return true, if successful
*/
private boolean updateProgressBarView(GisLayerJobSpeciesProgressBar jobsBar, JobGisLayerModel jobModel){
switch (jobModel.getDownloadState()) {
case PENDING:{
jobsBar.setProgressText(PENDING);
break;
}
case SAVING:{
lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " saving");
jobsBar.getElement().getStyle().setBorderColor("#7093DB");
jobsBar.setProgressText(SAVING);
break;
}
case COMPLETED:{
lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " completed");
jobsBar.getElement().getStyle().setBorderColor("#000000");
jobsBar.updateProgressWithoutPercentage(100);
jobsBar.setCompleted(true);
jobsBar.updateText(COMPLETED);
break;
}
case ONGOING:{
if(jobModel.getPercentage()<100)
jobsBar.setProgressText(LOADING);
else
jobsBar.setProgressText(SAVING);
jobsBar.updateProgressWithPercentage(jobModel.getPercentage());
return true;
}
case SAVED:{
lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " saved");
jobsBar.getElement().getStyle().setBorderColor("#000000");
jobsBar.updateProgressWithoutPercentage(100);
jobsBar.setCompleted(true);
jobsBar.updateText(COMPLETED);
break;
}
case ONGOINGWITHFAILURES: {
jobsBar.getElement().getStyle().setBorderColor("#f00");
jobsBar.updateText("loading " + jobModel.getJobName() + " with failures");
break;
}
case FAILED:{
jobsBar.getElement().getStyle().setBorderColor("#f00");
jobsBar.setProgressText(FAILED);
jobsBar.updateProgressWithPercentage(jobModel.getPercentage());
jobsBar.setCompleted(true);
jobsBar.updateText(FAILED);
break;
}
case COMPLETEDWITHFAILURES:{
jobsBar.getElement().getStyle().setBorderColor("#f00");
jobsBar.updateText("loading " + jobModel.getJobName() + " with failures");
jobsBar.updateProgressWithoutPercentage(100);
jobsBar.setCompleted(true);
break;
}
}
return false;
}
/**
* Removes the species job.
*
* @param hashHPKey the hash hp key
*/
public void removeSpeciesJob(String hashHPKey) {
ContentPanel cp = hashTableContentPanels.get(hashHPKey);
vp.remove(cp);
lastOperation.setHtml(LASTOPERATION + cp.getId() + " deleted");
hashProgressBars.remove(hashHPKey); //remove progress bar from hash
hashTableContentPanels.remove(hashHPKey); //remove hp from hash
hashLoadCompletedNotify.remove(hashHPKey); //remove notify event
vp.layout();
}
/**
* Delete progress completed.
*
* @param progressIdFound the progress id found
*/
@SuppressWarnings("unused")
private void deleteProgressCompleted(List<String> progressIdFound){
List<String> progressIdNotFound = new ArrayList<String>();
for(String key : hashTableContentPanels.keySet()){
if(!progressIdFound.contains(key)){ //if key isn't not found - progress is completed so is removed
GisLayerJobSpeciesProgressBar bulkPB = hashProgressBars.get(key);
lastOperation.setHtml(LASTOPERATION + bulkPB.getProgressText() + " uploading completed");
progressIdNotFound.add(key);
}
}
for(String key : progressIdNotFound){
GisLayerJobSpeciesProgressBar bulkPB = hashProgressBars.get(key);
lastOperation.setHtml(LASTOPERATION + bulkPB.getProgressText() + " uploading completed");
hashProgressBars.remove(key); //remove progress bar from hash
hashTableContentPanels.remove(key); //remove hp from hash
}
vp.layout();
cp.layout();
}
/**
* Gets the species job window.
*
* @return the species job window
*/
public Window getGisLayerJobWindow() {
return gisLayerJobWindow;
}
/**
* Reset structures.
*/
public void resetStructures(){
this.gridJob.resetStore();
hashProgressBars.clear();
lastOperation.setHtml(LASTOPERATION);
hashTableContentPanels.clear();
hashLoadCompletedNotify.clear();
}
/**
* Gets the grid job.
*
* @return the grid job
*/
public GisLayerGridJob getGridJob() {
return gridJob;
}
}

View File

@ -0,0 +1,47 @@
package org.gcube.portlets.user.speciesdiscovery.client.job.gislayer;
import com.extjs.gxt.ui.client.widget.ProgressBar;
public class GisLayerJobSpeciesProgressBar extends ProgressBar {
private String progressText;
private float progress;
private boolean isCompleted = false;
public GisLayerJobSpeciesProgressBar(String idJob, final String text) {
this.progressText = text;
setSize(140, 20);
updateProgress(progress, text);
}
public void updateProgressWithoutPercentage(float counter) {
progress = counter / 100;
updateProgress(progress, progressText);
}
public void updateProgressWithPercentage(float counter) {
progress = counter / 100;
updateProgress(progress, counter +"% " + progressText);
}
public String getProgressText() {
return progressText;
}
public void setProgressText(String progressText) {
this.progressText = progressText;
}
public float getProgress() {
return progress;
}
public boolean isCompleted() {
return isCompleted;
}
public void setCompleted(boolean isCompleted) {
this.isCompleted = isCompleted;
}
}

View File

@ -0,0 +1,108 @@
package org.gcube.portlets.user.speciesdiscovery.client.job.gislayer;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class GisLayerJobTable {
public static ContentPanel getJobTableWithoutHeading(String name, String startTime, String endTime, GisLayerJobSpeciesProgressBar status, String elapsedTime, Button btnInfo, Button btnCancel, Button btnSave){
ContentPanel cpTableLayout = new ContentPanel();
cpTableLayout.setHeaderVisible(false);
cpTableLayout.setStyleAttribute("margin-top", "10px");
cpTableLayout.setAutoHeight(true);
cpTableLayout.setWidth(964);
cpTableLayout.setScrollMode(Scroll.AUTO);
TableLayout tablelayout = new TableLayout(5);
tablelayout.setCellHorizontalAlign(HorizontalAlignment.CENTER);
cpTableLayout.setLayout(tablelayout);
ContentPanel panel;
//NAME
TableData layoutData = new TableData();
layoutData.setWidth("300px");
panel = new ContentPanel();
panel.setScrollMode(Scroll.AUTO);
panel.setHeading("Name");
panel.setHeight(55);
panel.add(new Label(name));
panel.setWidth(300);
cpTableLayout.add(panel, layoutData);
//Status
layoutData = new TableData();
layoutData.setWidth("302px");
panel = new ContentPanel();
panel.setHeight(55);
panel.setHeading("Status");
panel.setScrollMode(Scroll.AUTO);
panel.add(status);
panel.setWidth(302);
cpTableLayout.add(panel, layoutData);
//Start Time
layoutData = new TableData();
layoutData.setWidth("120px");
panel = new ContentPanel();
panel.setScrollMode(Scroll.AUTO);
panel.setHeight(55);
panel.setHeading("Start Time");
panel.addText(startTime);
panel.setWidth(120);
cpTableLayout.add(panel, layoutData);
//End Time
layoutData = new TableData();
layoutData.setWidth("120px");
panel = new ContentPanel();
panel.setHeading("End Time");
panel.setScrollMode(Scroll.AUTO);
panel.setHeight(55);
if(endTime!=null)
panel.addText(endTime);
panel.setWidth(120);
cpTableLayout.add(panel, layoutData);
//Elapsed Time
layoutData = new TableData();
layoutData.setWidth("120px");
panel = new ContentPanel();
panel.setHeading("Elapsed Time");
panel.setScrollMode(Scroll.AUTO);
panel.setHeight(55);
if(elapsedTime!=null)
panel.addText(elapsedTime);
panel.setWidth(120);
cpTableLayout.add(panel, layoutData);
ToolBar toolBar = new ToolBar();
toolBar.add(btnInfo);
toolBar.add(new SeparatorToolItem());
toolBar.add(btnSave);
toolBar.add(new SeparatorToolItem());
toolBar.add(btnCancel);
toolBar.add(new SeparatorToolItem());
cpTableLayout.setBottomComponent(toolBar);
return cpTableLayout;
}
}

View File

@ -0,0 +1,51 @@
package org.gcube.portlets.user.speciesdiscovery.client.job.gislayer;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
public class GisLayerJobsInfoContainer extends LayoutContainer {
private ContentPanel cp;
private TextArea textArea = new TextArea();
private String description;
public GisLayerJobsInfoContainer(String description) {
textArea.setReadOnly(true);
initContentPanel();
updateDescription(description);
}
private void initContentPanel() {
setLayout(new FitLayout());
getAriaSupport().setPresentation(true);
cp = new ContentPanel();
cp.setHeaderVisible(false);
cp.setBodyBorder(true);
cp.setLayout(new FitLayout());
cp.setButtonAlign(HorizontalAlignment.CENTER);
cp.setLayout(new FitLayout());
// cp.getHeader().setIconAltText("Grid Icon");
cp.setSize(400, 250);
cp.add(textArea);
add(cp);
}
public void updateDescription(String description){
this.description = description;
textArea.reset();
textArea.setValue(this.description);
cp.layout();
}
public void setHeaderTitle(String title) {
cp.setHeading(title);
cp.layout();
}
}

View File

@ -0,0 +1,43 @@
package org.gcube.portlets.user.speciesdiscovery.client.job.gislayer;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
public class GisLayerWindowInfoJobsSpecies extends Window{
private GisLayerJobsInfoContainer jobInfo = new GisLayerJobsInfoContainer("");
public GisLayerWindowInfoJobsSpecies(GisLayerJobsInfoContainer jobInfoContainer) {
setModal(true);
setSize(450, 300);
this.jobInfo = jobInfoContainer;
add(jobInfo);
}
public GisLayerWindowInfoJobsSpecies() {
setModal(true);
setSize(450, 300);
setLayout(new FitLayout());
add(jobInfo);
}
public void setWindowTitle(String title) {
this.setHeading(title);
}
public void updateDescription(JobGisLayerModel jobModel) {
String description = "\nName: \n" + jobModel.getJobName() + "\n";
description += "\n\nStart Time: \n" + jobModel.getSubmitTime();
description += "\n\nEnd Time: \n" + jobModel.getEndTime();
this.jobInfo.updateDescription(description);
}
}

View File

@ -57,12 +57,12 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.user.client.ui.AbstractImagePrototype;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* *
*/ */
public class OccurrenceGridJob extends ContentPanel{ public class OccurrenceGridJob extends ContentPanel{
private static final String REFRESH_LIST = "Refresh List"; private static final String REFRESH_LIST = "Refresh List";
private static final String RE_SUBMIT = "Re-submit"; private static final String RE_SUBMIT = "Re-submit";
@ -85,64 +85,64 @@ public class OccurrenceGridJob extends ContentPanel{
private Button buttonReSubmit; private Button buttonReSubmit;
private Button buttonRefreshList; private Button buttonRefreshList;
private Menu menu = new Menu(); private Menu menu = new Menu();
public OccurrenceGridJob(EventBus eventBus) { public OccurrenceGridJob(EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
ColumnConfig name = new ColumnConfig(JobOccurrencesModel.JOBNAME, JobOccurrencesModel.JOBNAME, 220); ColumnConfig name = new ColumnConfig(JobOccurrencesModel.JOBNAME, JobOccurrencesModel.JOBNAME, 220);
ColumnConfig dataSources = new ColumnConfig(JobOccurrencesModel.DATASOURCESASSTRING, JobOccurrencesModel.DATASOURCESASSTRING, 140); ColumnConfig dataSources = new ColumnConfig(JobOccurrencesModel.DATASOURCESASSTRING, JobOccurrencesModel.DATASOURCESASSTRING, 140);
ColumnConfig progress = new ColumnConfig(JobOccurrencesModel.PROGRESS, JobOccurrencesModel.PROGRESS, 150); ColumnConfig progress = new ColumnConfig(JobOccurrencesModel.PROGRESS, JobOccurrencesModel.PROGRESS, 150);
ColumnConfig startDate = new ColumnConfig(JobOccurrencesModel.STARTTIME, JobOccurrencesModel.STARTTIME, 140); ColumnConfig startDate = new ColumnConfig(JobOccurrencesModel.STARTTIME, JobOccurrencesModel.STARTTIME, 140);
ColumnConfig submitDate = new ColumnConfig(JobOccurrencesModel.SUBMITTIME, JobOccurrencesModel.SUBMITTIME, 140); ColumnConfig submitDate = new ColumnConfig(JobOccurrencesModel.SUBMITTIME, JobOccurrencesModel.SUBMITTIME, 140);
// creationDate.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT)); // creationDate.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig endTime = new ColumnConfig(JobOccurrencesModel.ENDTIME, JobOccurrencesModel.ENDTIME, 140); ColumnConfig endTime = new ColumnConfig(JobOccurrencesModel.ENDTIME, JobOccurrencesModel.ENDTIME, 140);
// endTime.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT)); // endTime.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig elapsedTime = new ColumnConfig(JobOccurrencesModel.ELAPSEDTIME, JobOccurrencesModel.ELAPSEDTIME + " Days, " + ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS, 100); ColumnConfig elapsedTime = new ColumnConfig(JobOccurrencesModel.ELAPSEDTIME, JobOccurrencesModel.ELAPSEDTIME + " Days, " + ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS, 100);
// elapsedTime.setHidden(true); // elapsedTime.setHidden(true);
ColumnConfig fileFormat = new ColumnConfig(JobOccurrencesModel.FILEFORMAT, JobOccurrencesModel.FILEFORMAT, 100); ColumnConfig fileFormat = new ColumnConfig(JobOccurrencesModel.FILEFORMAT, JobOccurrencesModel.FILEFORMAT, 100);
ColumnConfig csvType = new ColumnConfig(JobOccurrencesModel.CSVTYPE, JobOccurrencesModel.CSVTYPE, 100); ColumnConfig csvType = new ColumnConfig(JobOccurrencesModel.CSVTYPE, JobOccurrencesModel.CSVTYPE, 100);
ColumnConfig status = new ColumnConfig(JobOccurrencesModel.STATUS, JobOccurrencesModel.STATUS, 80); ColumnConfig status = new ColumnConfig(JobOccurrencesModel.STATUS, JobOccurrencesModel.STATUS, 80);
ColumnConfig itemsCount = new ColumnConfig(JobOccurrencesModel.ITEMSNUMBER, JobOccurrencesModel.ITEMSNUMBER, 95); ColumnConfig itemsCount = new ColumnConfig(JobOccurrencesModel.ITEMSNUMBER, JobOccurrencesModel.ITEMSNUMBER, 95);
final ColumnModel cm = new ColumnModel(Arrays.asList(name, dataSources, itemsCount, progress, submitDate, startDate, endTime, elapsedTime, fileFormat, csvType, status)); final ColumnModel cm = new ColumnModel(Arrays.asList(name, dataSources, itemsCount, progress, submitDate, startDate, endTime, elapsedTime, fileFormat, csvType, status));
setBodyBorder(false); setBodyBorder(false);
setHeaderVisible(false); setHeaderVisible(false);
setLayout(new FitLayout()); setLayout(new FitLayout());
GridFilters filters = new GridFilters(); GridFilters filters = new GridFilters();
filters.setLocal(true); filters.setLocal(true);
DateFilter dateFilterStartDate = new DateFilter(JobOccurrencesModel.STARTTIME); DateFilter dateFilterStartDate = new DateFilter(JobOccurrencesModel.STARTTIME);
DateFilter dateFilterSubmitDate = new DateFilter(JobOccurrencesModel.SUBMITTIME); DateFilter dateFilterSubmitDate = new DateFilter(JobOccurrencesModel.SUBMITTIME);
DateFilter dateFilterEnd = new DateFilter(JobOccurrencesModel.ENDTIME); DateFilter dateFilterEnd = new DateFilter(JobOccurrencesModel.ENDTIME);
filters.addFilter(dateFilterStartDate); filters.addFilter(dateFilterStartDate);
filters.addFilter(dateFilterSubmitDate); filters.addFilter(dateFilterSubmitDate);
filters.addFilter(dateFilterEnd); filters.addFilter(dateFilterEnd);
store = new ListStore<BaseModelData>(); store = new ListStore<BaseModelData>();
grid = new Grid<BaseModelData>(store, cm); grid = new Grid<BaseModelData>(store, cm);
grid.setLoadMask(true); grid.setLoadMask(true);
GridCellRenderer<BaseModelData> downloadStateRenderer = new GridCellRenderer<BaseModelData>() { GridCellRenderer<BaseModelData> downloadStateRenderer = new GridCellRenderer<BaseModelData>() {
@Override @Override
public String render(BaseModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) { public String render(BaseModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
String val = model.get(property).toString(); String val = model.get(property).toString();
String color="black"; String color="black";
// ONGOING, ONGOINGWITHFAILURES, FAILED, COMPLETED, COMPLETEDWITHFAILURES // ONGOING, ONGOINGWITHFAILURES, FAILED, COMPLETED, COMPLETEDWITHFAILURES
if(val!=null){ if(val!=null){
if(val.compareTo(DownloadState.SAVING.toString())==0){ if(val.compareTo(DownloadState.SAVING.toString())==0){
color = "#7093DB"; color = "#7093DB";
@ -152,301 +152,301 @@ public class OccurrenceGridJob extends ContentPanel{
} }
else else
val = ""; val = "";
return "<span qtitle='" + cm.getColumnById(property).getHeader() + "' qtip='" + val + "' style='color:" + color + "'>" + val + "</span>"; return "<span qtitle='" + cm.getColumnById(property).getHeader() + "' qtip='" + val + "' style='color:" + color + "'>" + val + "</span>";
} }
}; };
GridCellRenderer<BaseModelData> jobSpeciesRenderer = new GridCellRenderer<BaseModelData>() { GridCellRenderer<BaseModelData> jobSpeciesRenderer = new GridCellRenderer<BaseModelData>() {
public Object render(final BaseModelData model, String property, ColumnData config, final int rowIndex, public Object render(final BaseModelData model, String property, ColumnData config, final int rowIndex,
final int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) { final int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
grid.addListener(Events.ColumnResize, new Listener<GridEvent<BaseModelData>>() { grid.addListener(Events.ColumnResize, new Listener<GridEvent<BaseModelData>>() {
public void handleEvent(GridEvent<BaseModelData> be) { public void handleEvent(GridEvent<BaseModelData> be) {
for (int i = 0; i < be.getGrid().getStore().getCount(); i++) { for (int i = 0; i < be.getGrid().getStore().getCount(); i++) {
if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null
&& be.getGrid().getView().getWidget(i, be.getColIndex()) instanceof OccurrenceJobSpeciesProgressBar) { && be.getGrid().getView().getWidget(i, be.getColIndex()) instanceof OccurrenceJobSpeciesProgressBar) {
((OccurrenceJobSpeciesProgressBar) be.getGrid().getView().getWidget(i, be.getColIndex())).setWidth(be.getWidth() - 10); ((OccurrenceJobSpeciesProgressBar) be.getGrid().getView().getWidget(i, be.getColIndex())).setWidth(be.getWidth() - 10);
} }
} }
} }
}); });
return model.get(property); return model.get(property);
} }
}; };
progress.setRenderer(jobSpeciesRenderer); progress.setRenderer(jobSpeciesRenderer);
status.setRenderer(downloadStateRenderer); status.setRenderer(downloadStateRenderer);
// grid.getView().setAutoFill(true); // grid.getView().setAutoFill(true);
grid.getView().setEmptyText("Empty"); grid.getView().setEmptyText("Empty");
grid.getView().setShowDirtyCells(false); grid.getView().setShowDirtyCells(false);
grid.getView().setShowInvalidCells(false); grid.getView().setShowInvalidCells(false);
// setAlphanumericStoreSorter(grid); // setAlphanumericStoreSorter(grid);
// grid.setAutoExpandColumn(JobOccurrencesModel.JOBNAME); // grid.setAutoExpandColumn(JobOccurrencesModel.JOBNAME);
grid.setBorders(false); grid.setBorders(false);
// grid.setStripeRows(true); // grid.setStripeRows(true);
grid.setColumnLines(true); grid.setColumnLines(true);
grid.addPlugin(filters); grid.addPlugin(filters);
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<BaseModelData>() { grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<BaseModelData>() {
@Override @Override
public void selectionChanged(SelectionChangedEvent<BaseModelData> se) { public void selectionChanged(SelectionChangedEvent<BaseModelData> se) {
// System.out.println("selection grid change"); // System.out.println("selection grid change");
ModelData target = se.getSelectedItem(); ModelData target = se.getSelectedItem();
if(target!=null) if(target!=null)
enableButtonOnClick(true); enableButtonOnClick(true);
else else
enableButtonOnClick(false); enableButtonOnClick(false);
} }
}); });
add(grid); add(grid);
createGridToolBar(); createGridToolBar();
createMenuItemsOnGrid(); createMenuItemsOnGrid();
} }
public void addJobIntoGrid(JobOccurrencesModel jobModel, OccurrenceJobSpeciesProgressBar jobProgressBar) { public void addJobIntoGrid(JobOccurrencesModel jobModel, OccurrenceJobSpeciesProgressBar jobProgressBar) {
BaseModelData baseModelData = new BaseModelData(); BaseModelData baseModelData = new BaseModelData();
baseModelData.set(JobOccurrencesModel.JOBINDENTIFIER, jobModel.getJobIdentifier()); baseModelData.set(JobOccurrencesModel.JOBINDENTIFIER, jobModel.getJobIdentifier());
baseModelData.set(JobOccurrencesModel.JOBNAME, jobModel.getJobName()); baseModelData.set(JobOccurrencesModel.JOBNAME, jobModel.getJobName());
baseModelData.set(JobOccurrencesModel.PROGRESS, jobProgressBar); baseModelData.set(JobOccurrencesModel.PROGRESS, jobProgressBar);
baseModelData.set(JobOccurrencesModel.STATUS, jobModel.getDownloadState().toString()); baseModelData.set(JobOccurrencesModel.STATUS, jobModel.getDownloadState().toString());
baseModelData.set(JobOccurrencesModel.SUBMITTIME, jobModel.getSubmitTime()); baseModelData.set(JobOccurrencesModel.SUBMITTIME, jobModel.getSubmitTime());
baseModelData.set(JobOccurrencesModel.ENDTIME, jobModel.getEndTime()); baseModelData.set(JobOccurrencesModel.ENDTIME, jobModel.getEndTime());
baseModelData.set(JobOccurrencesModel.FILEFORMAT, jobModel.getFileFormat()); baseModelData.set(JobOccurrencesModel.FILEFORMAT, jobModel.getFileFormat());
baseModelData.set(JobOccurrencesModel.CSVTYPE, jobModel.getCsvType()); baseModelData.set(JobOccurrencesModel.CSVTYPE, jobModel.getCsvType());
baseModelData.set(JobOccurrencesModel.STARTTIME, jobModel.getStartTime()); baseModelData.set(JobOccurrencesModel.STARTTIME, jobModel.getStartTime());
baseModelData.set(JobOccurrencesModel.ELAPSEDTIME, jobModel.getElapsedTime()); baseModelData.set(JobOccurrencesModel.ELAPSEDTIME, jobModel.getElapsedTime());
baseModelData.set(JobOccurrencesModel.COMPLETEDENTRY, jobModel.getNodeCompleted()); baseModelData.set(JobOccurrencesModel.COMPLETEDENTRY, jobModel.getNodeCompleted());
baseModelData.set(JobOccurrencesModel.ITEMSNUMBER, jobModel.getTotalOccurrences()); baseModelData.set(JobOccurrencesModel.ITEMSNUMBER, jobModel.getTotalOccurrences());
String dataSources = ""; String dataSources = "";
for (DataSource dataSource : jobModel.getDataSources()) { for (DataSource dataSource : jobModel.getDataSources()) {
dataSources+= " "+dataSource.getName() + ","; dataSources+= " "+dataSource.getName() + ",";
} }
//Trim //Trim
dataSources = dataSources.trim(); dataSources = dataSources.trim();
//Remove last char , //Remove last char ,
dataSources = dataSources.substring(0, dataSources.lastIndexOf(",")); dataSources = dataSources.substring(0, dataSources.lastIndexOf(","));
baseModelData.set(JobOccurrencesModel.DATASOURCESASSTRING, dataSources); baseModelData.set(JobOccurrencesModel.DATASOURCESASSTRING, dataSources);
baseModelData.set(JobOccurrencesModel.SCIENTIFICNAME, jobModel.getScientificName()); baseModelData.set(JobOccurrencesModel.SCIENTIFICNAME, jobModel.getScientificName());
baseModelData.set(JobOccurrencesModel.DESCRIPTION, jobModel.getDescription()); baseModelData.set(JobOccurrencesModel.DESCRIPTION, jobModel.getDescription());
baseModelData.set(jobModel.getJobIdentifier(), jobModel); //store object JobOccurrencesModel baseModelData.set(jobModel.getJobIdentifier(), jobModel); //store object JobOccurrencesModel
store.add(baseModelData); store.add(baseModelData);
updateJobInfo(jobModel); updateJobInfo(jobModel);
} }
private void updateJobInfo(JobOccurrencesModel jobModel){ private void updateJobInfo(JobOccurrencesModel jobModel){
OccurrenceWindowInfoJobsSpecies win=listWindowInfo.get(jobModel.getJobIdentifier()); OccurrenceWindowInfoJobsSpecies win=listWindowInfo.get(jobModel.getJobIdentifier());
if(win==null){ if(win==null){
win = new OccurrenceWindowInfoJobsSpecies(); win = new OccurrenceWindowInfoJobsSpecies();
win.setWindowTitle("Job " + jobModel.getJobName() + " description:"); win.setWindowTitle("Job " + jobModel.getJobName() + " description:");
} }
win.updateDescription(jobModel); win.updateDescription(jobModel);
listWindowInfo.put(jobModel.getJobIdentifier(), win); listWindowInfo.put(jobModel.getJobIdentifier(), win);
} }
public void updateStatus(JobOccurrencesModel jobModel, OccurrenceJobSpeciesProgressBar jobProgressBar){ public void updateStatus(JobOccurrencesModel jobModel, OccurrenceJobSpeciesProgressBar jobProgressBar){
BaseModelData job = store.findModel(JobOccurrencesModel.JOBINDENTIFIER, jobModel.getJobIdentifier()); BaseModelData job = store.findModel(JobOccurrencesModel.JOBINDENTIFIER, jobModel.getJobIdentifier());
if(job!=null){ if(job!=null){
job.set(JobOccurrencesModel.PROGRESS, jobProgressBar); job.set(JobOccurrencesModel.PROGRESS, jobProgressBar);
job.set(JobOccurrencesModel.SUBMITTIME, jobModel.getSubmitTime()); job.set(JobOccurrencesModel.SUBMITTIME, jobModel.getSubmitTime());
job.set(JobOccurrencesModel.STATUS, jobModel.getDownloadState().toString()); job.set(JobOccurrencesModel.STATUS, jobModel.getDownloadState().toString());
job.set(JobOccurrencesModel.ENDTIME, jobModel.getEndTime()); job.set(JobOccurrencesModel.ENDTIME, jobModel.getEndTime());
job.set(JobOccurrencesModel.ELAPSEDTIME, jobModel.getElapsedTime()); job.set(JobOccurrencesModel.ELAPSEDTIME, jobModel.getElapsedTime());
job.set(JobOccurrencesModel.STARTTIME, jobModel.getStartTime()); job.set(JobOccurrencesModel.STARTTIME, jobModel.getStartTime());
updateJobInfo(jobModel); updateJobInfo(jobModel);
store.update(job); store.update(job);
} }
} }
public void removeSpeciesJobByIdentifier(String jobIdentifier) { public void removeSpeciesJobByIdentifier(String jobIdentifier) {
BaseModelData job = store.findModel(JobOccurrencesModel.JOBINDENTIFIER, jobIdentifier); BaseModelData job = store.findModel(JobOccurrencesModel.JOBINDENTIFIER, jobIdentifier);
if(job!=null){ if(job!=null){
store.remove(job); store.remove(job);
} }
} }
private void viewInfoJob() { private void viewInfoJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
OccurrenceWindowInfoJobsSpecies win = listWindowInfo.get(baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER)); OccurrenceWindowInfoJobsSpecies win = listWindowInfo.get(baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER));
win.show(); win.show();
} }
} }
private void cancelJob() { private void cancelJob() {
final BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); final BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String name = baseModelData.get(JobOccurrencesModel.JOBNAME); String name = baseModelData.get(JobOccurrencesModel.JOBNAME);
MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsSpeciesDiscovery.CONFIRM_DELETE, ConstantsSpeciesDiscovery.MESSAGE_CONFIRM_DELETE_JOB + " "+ name+"?"); MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsSpeciesDiscovery.CONFIRM_DELETE, ConstantsSpeciesDiscovery.MESSAGE_CONFIRM_DELETE_JOB + " "+ name+"?");
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() { mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) { public void handleEvent(MessageBoxEvent be) {
//IF CANCELLED //IF CANCELLED
String clickedButton = be.getButtonClicked().getItemId(); String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES)){ if(clickedButton.equals(Dialog.YES)){
final String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER); final String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER);
SpeciesDiscovery.taxonomySearchService.cancelOccurrenceJob(jobIdentifier, new AsyncCallback<Boolean>() { SpeciesDiscovery.taxonomySearchService.cancelOccurrenceJob(jobIdentifier, new AsyncCallback<Boolean>() {
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(Boolean result) {
if(result) if(result)
removeSpeciesJobByIdentifier(jobIdentifier); removeSpeciesJobByIdentifier(jobIdentifier);
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Info.display("Error", "An error occurred during the cancel"); Info.display("Error", "An error occurred during the cancel");
Log.error("Error during the cancel", caught.getMessage()); Log.error("Error during the cancel", caught.getMessage());
} }
}); });
} }
} }
}); });
} }
} }
private void saveJob() { private void saveJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String load = baseModelData.get(JobOccurrencesModel.STATUS).toString(); String load = baseModelData.get(JobOccurrencesModel.STATUS).toString();
if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){ if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){
String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER); String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER);
String scientificName = baseModelData.get(JobOccurrencesModel.SCIENTIFICNAME); String scientificName = baseModelData.get(JobOccurrencesModel.SCIENTIFICNAME);
JobOccurrencesModel jobModel = baseModelData.get(jobIdentifier); JobOccurrencesModel jobModel = baseModelData.get(jobIdentifier);
List<DataSource> dataSourceList = jobModel.getDataSources(); List<DataSource> dataSourceList = jobModel.getDataSources();
eventBus.fireEvent(new SaveJobEvent(jobIdentifier, scientificName, dataSourceList, SearchResultType.OCCURRENCE_POINT, jobModel)); eventBus.fireEvent(new SaveJobEvent(jobIdentifier, scientificName, dataSourceList, SearchResultType.OCCURRENCE_POINT, jobModel));
} }
else{ else{
String name = baseModelData.get(JobOccurrencesModel.JOBNAME); String name = baseModelData.get(JobOccurrencesModel.JOBNAME);
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The job "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null); MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The job "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
} }
} }
} }
private void saveErrorJob() { private void saveErrorJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String load = baseModelData.get(JobOccurrencesModel.STATUS).toString(); String load = baseModelData.get(JobOccurrencesModel.STATUS).toString();
if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 || load.compareTo(DownloadState.FAILED.toString())==0){ if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 || load.compareTo(DownloadState.FAILED.toString())==0){
String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER); String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER);
String scientificName = baseModelData.get(JobOccurrencesModel.SCIENTIFICNAME); String scientificName = baseModelData.get(JobOccurrencesModel.SCIENTIFICNAME);
JobOccurrencesModel jobModel = baseModelData.get(jobIdentifier); JobOccurrencesModel jobModel = baseModelData.get(jobIdentifier);
List<DataSource> dataSourceList = jobModel.getDataSources(); List<DataSource> dataSourceList = jobModel.getDataSources();
eventBus.fireEvent(new SaveJobErrorEvent(jobIdentifier, scientificName, dataSourceList, SearchResultType.OCCURRENCE_POINT, jobModel)); eventBus.fireEvent(new SaveJobErrorEvent(jobIdentifier, scientificName, dataSourceList, SearchResultType.OCCURRENCE_POINT, jobModel));
} }
else{ else{
String name = baseModelData.get(JobOccurrencesModel.JOBNAME); String name = baseModelData.get(JobOccurrencesModel.JOBNAME);
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The error file "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null); MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The error file "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
} }
} }
} }
private void resubmitJob() { private void resubmitJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String load = baseModelData.get(JobTaxonomyModel.STATUS).toString(); String load = baseModelData.get(JobTaxonomyModel.STATUS).toString();
if(load.compareTo(DownloadState.FAILED.toString())==0 || load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){ if(load.compareTo(DownloadState.FAILED.toString())==0 || load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){
String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER); String jobIdentifier = baseModelData.get(JobOccurrencesModel.JOBINDENTIFIER);
JobOccurrencesModel jobModel = (JobOccurrencesModel) baseModelData.get(jobIdentifier); //get object JobOccurrencesModel JobOccurrencesModel jobModel = (JobOccurrencesModel) baseModelData.get(jobIdentifier); //get object JobOccurrencesModel
eventBus.fireEvent(new ReSubmitJobEvent(SearchResultType.OCCURRENCE_POINT, jobModel, null)); eventBus.fireEvent(new ReSubmitJobEvent(SearchResultType.OCCURRENCE_POINT, jobModel, null, null));
} }
else{ else{
String name = baseModelData.get(JobTaxonomyModel.JOBNAME); String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
MessageBox.alert(INFO, "The job "+ name+ " " + ConstantsSpeciesDiscovery.CAN_NOT_BE_RE_SUBMITTED_UNTIL_IT_HAS_COMPLETED, null); MessageBox.alert(INFO, "The job "+ name+ " " + ConstantsSpeciesDiscovery.CAN_NOT_BE_RE_SUBMITTED_UNTIL_IT_HAS_COMPLETED, null);
} }
} }
} }
private void createGridToolBar(){ private void createGridToolBar(){
buttonInfo = new Button(INFO); buttonInfo = new Button(INFO);
@ -454,27 +454,27 @@ public class OccurrenceGridJob extends ContentPanel{
buttonInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon())); buttonInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon()));
buttonInfo.setStyleAttribute("margin-left", "5px"); buttonInfo.setStyleAttribute("margin-left", "5px");
buttonInfo.addSelectionListener(new SelectionListener<ButtonEvent>() { buttonInfo.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
viewInfoJob(); viewInfoJob();
} }
}); });
buttonCancel = new Button(CANCEL); buttonCancel = new Button(CANCEL);
buttonCancel.setScale(ButtonScale.MEDIUM); buttonCancel.setScale(ButtonScale.MEDIUM);
buttonCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete())); buttonCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete()));
buttonCancel.addListener(Events.OnClick, new Listener<BaseEvent>() { buttonCancel.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override @Override
public void handleEvent(BaseEvent be) { public void handleEvent(BaseEvent be) {
cancelJob(); cancelJob();
} }
}); });
buttonSave = new Button(SAVE); buttonSave = new Button(SAVE);
buttonSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); buttonSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
buttonSave.setScale(ButtonScale.MEDIUM); buttonSave.setScale(ButtonScale.MEDIUM);
@ -482,12 +482,12 @@ public class OccurrenceGridJob extends ContentPanel{
@Override @Override
public void handleEvent(BaseEvent be) { public void handleEvent(BaseEvent be) {
saveJob(); saveJob();
} }
}); });
buttonSaveError = new Button(SAVEERROR); buttonSaveError = new Button(SAVEERROR);
buttonSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); buttonSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
buttonSaveError.setScale(ButtonScale.MEDIUM); buttonSaveError.setScale(ButtonScale.MEDIUM);
@ -495,12 +495,12 @@ public class OccurrenceGridJob extends ContentPanel{
@Override @Override
public void handleEvent(BaseEvent be) { public void handleEvent(BaseEvent be) {
saveErrorJob(); saveErrorJob();
} }
}); });
buttonReSubmit = new Button(RE_SUBMIT); buttonReSubmit = new Button(RE_SUBMIT);
buttonReSubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit())); buttonReSubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit()));
buttonReSubmit.setScale(ButtonScale.MEDIUM); buttonReSubmit.setScale(ButtonScale.MEDIUM);
@ -508,61 +508,61 @@ public class OccurrenceGridJob extends ContentPanel{
@Override @Override
public void handleEvent(BaseEvent be) { public void handleEvent(BaseEvent be) {
resubmitJob(); resubmitJob();
} }
}); });
buttonRefreshList = new Button(REFRESH_LIST); buttonRefreshList = new Button(REFRESH_LIST);
buttonRefreshList.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getRefresh())); buttonRefreshList.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getRefresh()));
buttonRefreshList.setScale(ButtonScale.MEDIUM); buttonRefreshList.setScale(ButtonScale.MEDIUM);
buttonRefreshList.addListener(Events.OnClick, new Listener<BaseEvent>() { buttonRefreshList.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override @Override
public void handleEvent(BaseEvent be) { public void handleEvent(BaseEvent be) {
// resetStore(); // resetStore();
eventBus.fireEvent(new ReLoadListJobEvent(SearchResultType.OCCURRENCE_POINT)); eventBus.fireEvent(new ReLoadListJobEvent(SearchResultType.OCCURRENCE_POINT));
} }
}); });
toolBar.add(buttonInfo); toolBar.add(buttonInfo);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonSave); toolBar.add(buttonSave);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonSaveError); toolBar.add(buttonSaveError);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonCancel); toolBar.add(buttonCancel);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonReSubmit); toolBar.add(buttonReSubmit);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(new FillToolItem()); toolBar.add(new FillToolItem());
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonRefreshList); toolBar.add(buttonRefreshList);
setTopComponent(toolBar); setTopComponent(toolBar);
enableButtonOnClick(false); enableButtonOnClick(false);
} }
public void enableToolBar(boolean bool){ public void enableToolBar(boolean bool){
this.toolBar.setEnabled(bool); this.toolBar.setEnabled(bool);
} }
public void resetStore(){ public void resetStore(){
store.removeAll(); store.removeAll();
} }
public void enableButtonOnClick(boolean bool){ public void enableButtonOnClick(boolean bool){
this.buttonCancel.setEnabled(bool); this.buttonCancel.setEnabled(bool);
this.buttonInfo.setEnabled(bool); this.buttonInfo.setEnabled(bool);
@ -570,13 +570,13 @@ public class OccurrenceGridJob extends ContentPanel{
this.buttonReSubmit.setEnabled(bool); this.buttonReSubmit.setEnabled(bool);
this.buttonSaveError.setEnabled(bool); this.buttonSaveError.setEnabled(bool);
} }
public void createMenuItemsOnGrid(){ public void createMenuItemsOnGrid(){
MenuItem menuInfo = new MenuItem(); MenuItem menuInfo = new MenuItem();
menuInfo.setText(INFO); menuInfo.setText(INFO);
menuInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon())); menuInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon()));
menuInfo.addSelectionListener(new SelectionListener<MenuEvent>() { menuInfo.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
@ -587,44 +587,44 @@ public class OccurrenceGridJob extends ContentPanel{
}); });
menu.add(menuInfo); menu.add(menuInfo);
MenuItem menuSave= new MenuItem(); MenuItem menuSave= new MenuItem();
menuSave.setText(SAVE); menuSave.setText(SAVE);
menuSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); menuSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
menuSave.addSelectionListener(new SelectionListener<MenuEvent>() { menuSave.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
saveJob(); saveJob();
} }
}); });
menu.add(menuSave); menu.add(menuSave);
MenuItem menuSaveError = new MenuItem(); MenuItem menuSaveError = new MenuItem();
menuSaveError.setText(SAVEERROR); menuSaveError.setText(SAVEERROR);
menuSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); menuSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
menuSaveError.addSelectionListener(new SelectionListener<MenuEvent>() { menuSaveError.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
saveErrorJob(); saveErrorJob();
} }
}); });
menu.add(menuSaveError); menu.add(menuSaveError);
MenuItem menuCancel= new MenuItem(); MenuItem menuCancel= new MenuItem();
menuCancel.setText(CANCEL); menuCancel.setText(CANCEL);
menuCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete())); menuCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete()));
menuCancel.addSelectionListener(new SelectionListener<MenuEvent>() { menuCancel.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
@ -632,26 +632,26 @@ public class OccurrenceGridJob extends ContentPanel{
} }
}); });
menu.add(menuCancel); menu.add(menuCancel);
MenuItem menuResubmit= new MenuItem(); MenuItem menuResubmit= new MenuItem();
menuResubmit.setText(RE_SUBMIT); menuResubmit.setText(RE_SUBMIT);
menuResubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit())); menuResubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit()));
menuResubmit.addSelectionListener(new SelectionListener<MenuEvent>() { menuResubmit.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
resubmitJob(); resubmitJob();
} }
}); });
menu.add(menuResubmit); menu.add(menuResubmit);
grid.setContextMenu(menu); grid.setContextMenu(menu);
} }
} }

View File

@ -57,15 +57,15 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.user.client.ui.AbstractImagePrototype;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* *
*/ */
public class TaxonomyGridJob extends ContentPanel{ public class TaxonomyGridJob extends ContentPanel{
/** /**
* *
*/ */
private static final String SAVE_ERROR = "Save Errors"; private static final String SAVE_ERROR = "Save Errors";
private static final String REFRESH_LIST = "Refresh List"; private static final String REFRESH_LIST = "Refresh List";
@ -87,64 +87,64 @@ public class TaxonomyGridJob extends ContentPanel{
private Button buttonReSubmit; private Button buttonReSubmit;
private Button buttonRefreshList; private Button buttonRefreshList;
private Button buttonSaveError; private Button buttonSaveError;
private Menu menu = new Menu(); private Menu menu = new Menu();
public TaxonomyGridJob(EventBus eventBus) { public TaxonomyGridJob(EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
ColumnConfig name = new ColumnConfig(JobTaxonomyModel.JOBNAME, JobTaxonomyModel.JOBNAME, 220); ColumnConfig name = new ColumnConfig(JobTaxonomyModel.JOBNAME, JobTaxonomyModel.JOBNAME, 220);
ColumnConfig dataSources = new ColumnConfig(JobTaxonomyModel.DATASOURCE, JobTaxonomyModel.DATASOURCE, 90); ColumnConfig dataSources = new ColumnConfig(JobTaxonomyModel.DATASOURCE, JobTaxonomyModel.DATASOURCE, 90);
ColumnConfig progress = new ColumnConfig(JobTaxonomyModel.PROGRESS, JobTaxonomyModel.PROGRESS, 250); ColumnConfig progress = new ColumnConfig(JobTaxonomyModel.PROGRESS, JobTaxonomyModel.PROGRESS, 250);
ColumnConfig startDate = new ColumnConfig(JobTaxonomyModel.STARTTIME, JobTaxonomyModel.STARTTIME, 140); ColumnConfig startDate = new ColumnConfig(JobTaxonomyModel.STARTTIME, JobTaxonomyModel.STARTTIME, 140);
ColumnConfig submitDate = new ColumnConfig(JobTaxonomyModel.SUBMITTIME, JobTaxonomyModel.SUBMITTIME, 140); ColumnConfig submitDate = new ColumnConfig(JobTaxonomyModel.SUBMITTIME, JobTaxonomyModel.SUBMITTIME, 140);
// creationDate.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT)); // creationDate.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig endTime = new ColumnConfig(JobTaxonomyModel.ENDTIME, JobTaxonomyModel.ENDTIME, 140); ColumnConfig endTime = new ColumnConfig(JobTaxonomyModel.ENDTIME, JobTaxonomyModel.ENDTIME, 140);
// endTime.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT)); // endTime.setDateTimeFormat(DateTimeFormat.getFormat(DATE_TIME_FORMAT));
ColumnConfig elapsedTime = new ColumnConfig(JobTaxonomyModel.ELAPSEDTIME, JobTaxonomyModel.ELAPSEDTIME + " Days, " + ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS, 140); ColumnConfig elapsedTime = new ColumnConfig(JobTaxonomyModel.ELAPSEDTIME, JobTaxonomyModel.ELAPSEDTIME + " Days, " + ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS, 140);
ColumnConfig status = new ColumnConfig(JobTaxonomyModel.STATUS, JobTaxonomyModel.STATUS, 80); ColumnConfig status = new ColumnConfig(JobTaxonomyModel.STATUS, JobTaxonomyModel.STATUS, 80);
final ColumnModel cm = new ColumnModel(Arrays.asList(name, dataSources, progress, submitDate, startDate, endTime, elapsedTime, status)); final ColumnModel cm = new ColumnModel(Arrays.asList(name, dataSources, progress, submitDate, startDate, endTime, elapsedTime, status));
setBodyBorder(false); setBodyBorder(false);
setHeaderVisible(false); setHeaderVisible(false);
setLayout(new FitLayout()); setLayout(new FitLayout());
GridFilters filters = new GridFilters(); GridFilters filters = new GridFilters();
filters.setLocal(true); filters.setLocal(true);
DateFilter dateFilterStart = new DateFilter(JobTaxonomyModel.STARTTIME); DateFilter dateFilterStart = new DateFilter(JobTaxonomyModel.STARTTIME);
DateFilter dateFilterSubmit = new DateFilter(JobTaxonomyModel.SUBMITTIME); DateFilter dateFilterSubmit = new DateFilter(JobTaxonomyModel.SUBMITTIME);
DateFilter dateFilterEnd = new DateFilter(JobTaxonomyModel.ENDTIME); DateFilter dateFilterEnd = new DateFilter(JobTaxonomyModel.ENDTIME);
filters.addFilter(dateFilterStart); filters.addFilter(dateFilterStart);
filters.addFilter(dateFilterSubmit); filters.addFilter(dateFilterSubmit);
filters.addFilter(dateFilterEnd); filters.addFilter(dateFilterEnd);
store = new ListStore<BaseModelData>(); store = new ListStore<BaseModelData>();
grid = new Grid<BaseModelData>(store, cm); grid = new Grid<BaseModelData>(store, cm);
grid.setLoadMask(true); grid.setLoadMask(true);
GridCellRenderer<BaseModelData> downloadStateRenderer = new GridCellRenderer<BaseModelData>() { GridCellRenderer<BaseModelData> downloadStateRenderer = new GridCellRenderer<BaseModelData>() {
@Override @Override
public String render(BaseModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) { public String render(BaseModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
String val = model.get(property).toString(); String val = model.get(property).toString();
String color="black"; String color="black";
// ONGOING, ONGOINGWITHFAILURES, FAILED, COMPLETED, COMPLETEDWITHFAILURES // ONGOING, ONGOINGWITHFAILURES, FAILED, COMPLETED, COMPLETEDWITHFAILURES
if(val!=null){ if(val!=null){
// if(val.compareTo(DownloadState.COMPLETED.toString())==0){ // if(val.compareTo(DownloadState.COMPLETED.toString())==0){
// color ="#0000EE"; // color ="#0000EE";
// }else // }else
if(val.compareTo(DownloadState.SAVING.toString())==0){ if(val.compareTo(DownloadState.SAVING.toString())==0){
color = "#7093DB"; color = "#7093DB";
}else if(val.compareTo(DownloadState.FAILED.toString())==0){ }else if(val.compareTo(DownloadState.FAILED.toString())==0){
@ -153,81 +153,81 @@ public class TaxonomyGridJob extends ContentPanel{
} }
else else
val = ""; val = "";
return "<span qtitle='" + cm.getColumnById(property).getHeader() + "' qtip='" + val + "' style='color:" + color + "'>" + val + "</span>"; return "<span qtitle='" + cm.getColumnById(property).getHeader() + "' qtip='" + val + "' style='color:" + color + "'>" + val + "</span>";
} }
}; };
GridCellRenderer<BaseModelData> jobSpeciesRenderer = new GridCellRenderer<BaseModelData>() { GridCellRenderer<BaseModelData> jobSpeciesRenderer = new GridCellRenderer<BaseModelData>() {
public Object render(final BaseModelData model, String property, ColumnData config, final int rowIndex, public Object render(final BaseModelData model, String property, ColumnData config, final int rowIndex,
final int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) { final int colIndex, ListStore<BaseModelData> store, Grid<BaseModelData> grid) {
grid.addListener(Events.ColumnResize, new Listener<GridEvent<BaseModelData>>() { grid.addListener(Events.ColumnResize, new Listener<GridEvent<BaseModelData>>() {
public void handleEvent(GridEvent<BaseModelData> be) { public void handleEvent(GridEvent<BaseModelData> be) {
for (int i = 0; i < be.getGrid().getStore().getCount(); i++) { for (int i = 0; i < be.getGrid().getStore().getCount(); i++) {
if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null
&& be.getGrid().getView().getWidget(i, be.getColIndex()) instanceof TaxonomyJobSpeciesProgressBar) { && be.getGrid().getView().getWidget(i, be.getColIndex()) instanceof TaxonomyJobSpeciesProgressBar) {
((TaxonomyJobSpeciesProgressBar) be.getGrid().getView().getWidget(i, be.getColIndex())).setWidth(be.getWidth() - 10); ((TaxonomyJobSpeciesProgressBar) be.getGrid().getView().getWidget(i, be.getColIndex())).setWidth(be.getWidth() - 10);
} }
} }
} }
}); });
return model.get(property); return model.get(property);
} }
}; };
progress.setRenderer(jobSpeciesRenderer); progress.setRenderer(jobSpeciesRenderer);
status.setRenderer(downloadStateRenderer); status.setRenderer(downloadStateRenderer);
// grid.getView().setAutoFill(true); // grid.getView().setAutoFill(true);
grid.getView().setEmptyText("Empty"); grid.getView().setEmptyText("Empty");
grid.getView().setShowDirtyCells(false); grid.getView().setShowDirtyCells(false);
grid.getView().setShowInvalidCells(false); grid.getView().setShowInvalidCells(false);
// setAlphanumericStoreSorter(grid); // setAlphanumericStoreSorter(grid);
// grid.setAutoExpandColumn(JobTaxonomyModel.JOBNAME); // grid.setAutoExpandColumn(JobTaxonomyModel.JOBNAME);
grid.setBorders(false); grid.setBorders(false);
// grid.setStripeRows(true); // grid.setStripeRows(true);
grid.setColumnLines(true); grid.setColumnLines(true);
grid.addPlugin(filters); grid.addPlugin(filters);
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<BaseModelData>() { grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<BaseModelData>() {
@Override @Override
public void selectionChanged(SelectionChangedEvent<BaseModelData> se) { public void selectionChanged(SelectionChangedEvent<BaseModelData> se) {
// System.out.println("selection grid change"); // System.out.println("selection grid change");
ModelData target = se.getSelectedItem(); ModelData target = se.getSelectedItem();
if(target!=null) if(target!=null)
enableButtonOnClick(true); enableButtonOnClick(true);
else else
enableButtonOnClick(false); enableButtonOnClick(false);
} }
}); });
add(grid); add(grid);
createGridToolBar(); createGridToolBar();
createMenuItemsOnGrid(); createMenuItemsOnGrid();
} }
public void addJobIntoGrid(JobTaxonomyModel jobModel, TaxonomyJobSpeciesProgressBar jobProgressBar) { public void addJobIntoGrid(JobTaxonomyModel jobModel, TaxonomyJobSpeciesProgressBar jobProgressBar) {
BaseModelData baseModelData = new BaseModelData(); BaseModelData baseModelData = new BaseModelData();
baseModelData.set(JobTaxonomyModel.JOBINDENTIFIER, jobModel.getIdentifier()); baseModelData.set(JobTaxonomyModel.JOBINDENTIFIER, jobModel.getIdentifier());
baseModelData.set(JobTaxonomyModel.JOBNAME, jobModel.getName()); baseModelData.set(JobTaxonomyModel.JOBNAME, jobModel.getName());
baseModelData.set(JobTaxonomyModel.PROGRESS, jobProgressBar); baseModelData.set(JobTaxonomyModel.PROGRESS, jobProgressBar);
@ -235,81 +235,81 @@ public class TaxonomyGridJob extends ContentPanel{
baseModelData.set(JobTaxonomyModel.SUBMITTIME, jobModel.getSubmitTime()); baseModelData.set(JobTaxonomyModel.SUBMITTIME, jobModel.getSubmitTime());
baseModelData.set(JobTaxonomyModel.ENDTIME, jobModel.getEndTime()); baseModelData.set(JobTaxonomyModel.ENDTIME, jobModel.getEndTime());
baseModelData.set(JobTaxonomyModel.STARTTIME, jobModel.getStartTime()); baseModelData.set(JobTaxonomyModel.STARTTIME, jobModel.getStartTime());
baseModelData.set(JobTaxonomyModel.ELAPSEDTIME, jobModel.getElapsedTime()); baseModelData.set(JobTaxonomyModel.ELAPSEDTIME, jobModel.getElapsedTime());
baseModelData.set(JobTaxonomyModel.DATASOURCE, jobModel.getDataSource()); baseModelData.set(JobTaxonomyModel.DATASOURCE, jobModel.getDataSource());
baseModelData.set(JobTaxonomyModel.SCIENTIFICNAME, jobModel.getScientificName()); baseModelData.set(JobTaxonomyModel.SCIENTIFICNAME, jobModel.getScientificName());
baseModelData.set(JobTaxonomyModel.RANK, jobModel.getRank()); baseModelData.set(JobTaxonomyModel.RANK, jobModel.getRank());
baseModelData.set(jobModel.getIdentifier(), jobModel); baseModelData.set(jobModel.getIdentifier(), jobModel);
store.add(baseModelData); store.add(baseModelData);
updateJobInfo(jobModel); updateJobInfo(jobModel);
} }
/* /*
private void updateStringToDate(BaseModelData baseModel, String property, String dateValue){ private void updateStringToDate(BaseModelData baseModel, String property, String dateValue){
Date date = null; Date date = null;
try { try {
if(dateValue!=null && !dateValue.isEmpty()) if(dateValue!=null && !dateValue.isEmpty())
date = DateTimeFormat.getFormat(DATE_TIME_FORMAT).parse(dateValue); date = DateTimeFormat.getFormat(DATE_TIME_FORMAT).parse(dateValue);
} catch (Exception e) { } catch (Exception e) {
Log.trace("error in update date "+dateValue); Log.trace("error in update date "+dateValue);
Log.error(e.getMessage()); Log.error(e.getMessage());
} }
baseModel.set(property, date); baseModel.set(property, date);
} }
*/ */
private void updateJobInfo(JobTaxonomyModel jobModel){ private void updateJobInfo(JobTaxonomyModel jobModel){
TaxonomyWindowInfoJobsSpecies win=listWindowInfo.get(jobModel.getIdentifier()); TaxonomyWindowInfoJobsSpecies win=listWindowInfo.get(jobModel.getIdentifier());
if(win==null) if(win==null)
win = new TaxonomyWindowInfoJobsSpecies(); win = new TaxonomyWindowInfoJobsSpecies();
win.setWindowTitle("Job " + jobModel.getName() + " Status"); win.setWindowTitle("Job " + jobModel.getName() + " Status");
win.updateListStore(jobModel); win.updateListStore(jobModel);
listWindowInfo.put(jobModel.getIdentifier(), win); listWindowInfo.put(jobModel.getIdentifier(), win);
} }
public void updateStatus(JobTaxonomyModel jobModel, TaxonomyJobSpeciesProgressBar jobProgressBar){ public void updateStatus(JobTaxonomyModel jobModel, TaxonomyJobSpeciesProgressBar jobProgressBar){
BaseModelData job = store.findModel(JobTaxonomyModel.JOBINDENTIFIER, jobModel.getIdentifier()); BaseModelData job = store.findModel(JobTaxonomyModel.JOBINDENTIFIER, jobModel.getIdentifier());
if(job!=null){ if(job!=null){
job.set(JobTaxonomyModel.PROGRESS, jobProgressBar); job.set(JobTaxonomyModel.PROGRESS, jobProgressBar);
// updateStringToDate(job, JobSpeciesModel.STARTTIME, jobModel.getStartTime()); // updateStringToDate(job, JobSpeciesModel.STARTTIME, jobModel.getStartTime());
// updateStringToDate(job, JobSpeciesModel.ENDTIME, jobModel.getEndTime()); // updateStringToDate(job, JobSpeciesModel.ENDTIME, jobModel.getEndTime());
job.set(JobTaxonomyModel.SUBMITTIME, jobModel.getSubmitTime()); job.set(JobTaxonomyModel.SUBMITTIME, jobModel.getSubmitTime());
job.set(JobTaxonomyModel.STATUS, jobModel.getDownloadState().toString()); job.set(JobTaxonomyModel.STATUS, jobModel.getDownloadState().toString());
job.set(JobTaxonomyModel.ENDTIME, jobModel.getEndTime()); job.set(JobTaxonomyModel.ENDTIME, jobModel.getEndTime());
job.set(JobTaxonomyModel.ELAPSEDTIME, jobModel.getElapsedTime()); job.set(JobTaxonomyModel.ELAPSEDTIME, jobModel.getElapsedTime());
job.set(JobTaxonomyModel.STARTTIME, jobModel.getStartTime()); job.set(JobTaxonomyModel.STARTTIME, jobModel.getStartTime());
job.set(jobModel.getIdentifier(), jobModel); //Store jobModel job.set(jobModel.getIdentifier(), jobModel); //Store jobModel
updateJobInfo(jobModel); updateJobInfo(jobModel);
store.update(job); store.update(job);
// this.layout(); // this.layout();
} }
} }
public void removeSpeciesJobByIdentifier(String jobIdentifier) { public void removeSpeciesJobByIdentifier(String jobIdentifier) {
BaseModelData job = store.findModel(JobTaxonomyModel.JOBINDENTIFIER, jobIdentifier); BaseModelData job = store.findModel(JobTaxonomyModel.JOBINDENTIFIER, jobIdentifier);
if(job!=null){ if(job!=null){
@ -317,153 +317,153 @@ public class TaxonomyGridJob extends ContentPanel{
// this.layout(); // this.layout();
} }
} }
private void viewInfoJob() { private void viewInfoJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
TaxonomyWindowInfoJobsSpecies win = listWindowInfo.get(baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER)); TaxonomyWindowInfoJobsSpecies win = listWindowInfo.get(baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER));
win.show(); win.show();
} }
} }
private void cancelJob() { private void cancelJob() {
final BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); final BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String name = baseModelData.get(JobTaxonomyModel.JOBNAME); String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsSpeciesDiscovery.CONFIRM_DELETE, ConstantsSpeciesDiscovery.MESSAGE_CONFIRM_DELETE_JOB + " "+ name+"?"); MessageBoxConfirm mbc = new MessageBoxConfirm(ConstantsSpeciesDiscovery.CONFIRM_DELETE, ConstantsSpeciesDiscovery.MESSAGE_CONFIRM_DELETE_JOB + " "+ name+"?");
mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() { mbc.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) { public void handleEvent(MessageBoxEvent be) {
//IF CANCELLED //IF CANCELLED
String clickedButton = be.getButtonClicked().getItemId(); String clickedButton = be.getButtonClicked().getItemId();
if(clickedButton.equals(Dialog.YES)){ if(clickedButton.equals(Dialog.YES)){
final String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER); final String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER);
SpeciesDiscovery.taxonomySearchService.cancelTaxonomyJob(jobIdentifier, new AsyncCallback<Boolean>() { SpeciesDiscovery.taxonomySearchService.cancelTaxonomyJob(jobIdentifier, new AsyncCallback<Boolean>() {
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(Boolean result) {
if(result) if(result)
removeSpeciesJobByIdentifier(jobIdentifier); removeSpeciesJobByIdentifier(jobIdentifier);
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Info.display("Error", "An error occurred during the cancel"); Info.display("Error", "An error occurred during the cancel");
Log.error("Error during the cancel", caught.getMessage()); Log.error("Error during the cancel", caught.getMessage());
} }
}); });
} }
} }
}); });
} }
} }
private void saveJob() { private void saveJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String load = baseModelData.get(JobTaxonomyModel.STATUS).toString(); String load = baseModelData.get(JobTaxonomyModel.STATUS).toString();
if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){ if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 ){
String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER); String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER);
String scientificName = baseModelData.get(JobTaxonomyModel.SCIENTIFICNAME); String scientificName = baseModelData.get(JobTaxonomyModel.SCIENTIFICNAME);
String dataSource = baseModelData.get(JobTaxonomyModel.DATASOURCE); String dataSource = baseModelData.get(JobTaxonomyModel.DATASOURCE);
String rank = baseModelData.get(JobTaxonomyModel.RANK); String rank = baseModelData.get(JobTaxonomyModel.RANK);
JobTaxonomyModel jobModel = baseModelData.get(jobIdentifier); JobTaxonomyModel jobModel = baseModelData.get(jobIdentifier);
List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>(); List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>();
dataSourceList.add(new DataSource(dataSource,dataSource)); dataSourceList.add(new DataSource(dataSource,dataSource));
eventBus.fireEvent(new SaveJobEvent(jobIdentifier, scientificName, dataSourceList, rank, SearchResultType.TAXONOMY_ITEM, jobModel)); eventBus.fireEvent(new SaveJobEvent(jobIdentifier, scientificName, dataSourceList, rank, SearchResultType.TAXONOMY_ITEM, jobModel));
} }
else{ else{
String name = baseModelData.get(JobTaxonomyModel.JOBNAME); String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The job "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null); MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The job "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
} }
} }
} }
private void saveJobErrors() { private void saveJobErrors() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String load = baseModelData.get(JobTaxonomyModel.STATUS).toString(); String load = baseModelData.get(JobTaxonomyModel.STATUS).toString();
if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 || load.compareTo(DownloadState.FAILED.toString())==0){ if(load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0 || load.compareTo(DownloadState.FAILED.toString())==0){
String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER); String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER);
String scientificName = baseModelData.get(JobTaxonomyModel.SCIENTIFICNAME); String scientificName = baseModelData.get(JobTaxonomyModel.SCIENTIFICNAME);
String dataSource = baseModelData.get(JobTaxonomyModel.DATASOURCE); String dataSource = baseModelData.get(JobTaxonomyModel.DATASOURCE);
String rank = baseModelData.get(JobTaxonomyModel.RANK); String rank = baseModelData.get(JobTaxonomyModel.RANK);
JobTaxonomyModel jobModel = baseModelData.get(jobIdentifier); JobTaxonomyModel jobModel = baseModelData.get(jobIdentifier);
List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>(); List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>();
dataSourceList.add(new DataSource(dataSource,dataSource)); dataSourceList.add(new DataSource(dataSource,dataSource));
eventBus.fireEvent(new SaveJobErrorEvent(jobIdentifier, scientificName, dataSourceList, rank, SearchResultType.TAXONOMY_ITEM, jobModel)); eventBus.fireEvent(new SaveJobErrorEvent(jobIdentifier, scientificName, dataSourceList, rank, SearchResultType.TAXONOMY_ITEM, jobModel));
} }
else{ else{
String name = baseModelData.get(JobTaxonomyModel.JOBNAME); String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The error file "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null); MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The error file "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
} }
} }
} }
private void resubmitJob() { private void resubmitJob() {
BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem(); BaseModelData baseModelData = grid.getSelectionModel().getSelectedItem();
if(baseModelData!=null){ if(baseModelData!=null){
String load = baseModelData.get(JobTaxonomyModel.STATUS).toString(); String load = baseModelData.get(JobTaxonomyModel.STATUS).toString();
if(load.compareTo(DownloadState.FAILED.toString())==0 || load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0){ if(load.compareTo(DownloadState.FAILED.toString())==0 || load.compareTo(DownloadState.COMPLETED.toString())==0 || load.compareTo(DownloadState.SAVED.toString())==0){
String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER); String jobIdentifier = baseModelData.get(JobTaxonomyModel.JOBINDENTIFIER);
JobTaxonomyModel jobModel = (JobTaxonomyModel) baseModelData.get(jobIdentifier); //get object JobOccurrencesModel JobTaxonomyModel jobModel = (JobTaxonomyModel) baseModelData.get(jobIdentifier); //get object JobOccurrencesModel
eventBus.fireEvent(new ReSubmitJobEvent(SearchResultType.TAXONOMY_ITEM, null, jobModel)); eventBus.fireEvent(new ReSubmitJobEvent(SearchResultType.TAXONOMY_ITEM, null, jobModel, null));
} }
else{ else{
String name = baseModelData.get(JobTaxonomyModel.JOBNAME); String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
MessageBox.alert(INFO, "The job "+ name+" "+ConstantsSpeciesDiscovery.CAN_NOT_BE_RE_SUBMITTED_UNTIL_IT_HAS_COMPLETED, null); MessageBox.alert(INFO, "The job "+ name+" "+ConstantsSpeciesDiscovery.CAN_NOT_BE_RE_SUBMITTED_UNTIL_IT_HAS_COMPLETED, null);
} }
} }
} }
private void createGridToolBar(){ private void createGridToolBar(){
buttonInfo = new Button(INFO); buttonInfo = new Button(INFO);
buttonInfo.setScale(ButtonScale.MEDIUM); buttonInfo.setScale(ButtonScale.MEDIUM);
@ -472,19 +472,19 @@ public class TaxonomyGridJob extends ContentPanel{
buttonInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon())); buttonInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon()));
buttonInfo.setStyleAttribute("margin-left", "5px"); buttonInfo.setStyleAttribute("margin-left", "5px");
buttonInfo.addSelectionListener(new SelectionListener<ButtonEvent>() { buttonInfo.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
viewInfoJob(); viewInfoJob();
} }
}); });
buttonCancel = new Button(CANCEL); buttonCancel = new Button(CANCEL);
buttonCancel.setScale(ButtonScale.MEDIUM); buttonCancel.setScale(ButtonScale.MEDIUM);
// buttonCancel.setIconAlign(IconAlign.TOP); // buttonCancel.setIconAlign(IconAlign.TOP);
// buttonCancel.setArrowAlign(ButtonArrowAlign.BOTTOM); // buttonCancel.setArrowAlign(ButtonArrowAlign.BOTTOM);
buttonCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete())); buttonCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete()));
buttonCancel.addListener(Events.OnClick, new Listener<BaseEvent>() { buttonCancel.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override @Override
@ -492,13 +492,13 @@ public class TaxonomyGridJob extends ContentPanel{
cancelJob(); cancelJob();
} }
}); });
buttonSave = new Button(SAVE); buttonSave = new Button(SAVE);
buttonSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); buttonSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
buttonSave.setScale(ButtonScale.MEDIUM); buttonSave.setScale(ButtonScale.MEDIUM);
// buttonSave.setIconAlign(IconAlign.TOP); // buttonSave.setIconAlign(IconAlign.TOP);
// buttonSave.setArrowAlign(ButtonArrowAlign.BOTTOM); // buttonSave.setArrowAlign(ButtonArrowAlign.BOTTOM);
buttonSave.addListener(Events.OnClick, new Listener<BaseEvent>() { buttonSave.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override @Override
@ -506,13 +506,13 @@ public class TaxonomyGridJob extends ContentPanel{
saveJob(); saveJob();
} }
}); });
buttonSaveError = new Button(SAVE_ERROR); buttonSaveError = new Button(SAVE_ERROR);
buttonSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); buttonSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
buttonSaveError.setScale(ButtonScale.MEDIUM); buttonSaveError.setScale(ButtonScale.MEDIUM);
// buttonSave.setIconAlign(IconAlign.TOP); // buttonSave.setIconAlign(IconAlign.TOP);
// buttonSave.setArrowAlign(ButtonArrowAlign.BOTTOM); // buttonSave.setArrowAlign(ButtonArrowAlign.BOTTOM);
buttonSaveError.addListener(Events.OnClick, new Listener<BaseEvent>() { buttonSaveError.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override @Override
@ -520,7 +520,7 @@ public class TaxonomyGridJob extends ContentPanel{
saveJobErrors(); saveJobErrors();
} }
}); });
buttonReSubmit = new Button(RE_SUBMIT); buttonReSubmit = new Button(RE_SUBMIT);
buttonReSubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit())); buttonReSubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit()));
buttonReSubmit.setScale(ButtonScale.MEDIUM); buttonReSubmit.setScale(ButtonScale.MEDIUM);
@ -531,47 +531,47 @@ public class TaxonomyGridJob extends ContentPanel{
resubmitJob(); resubmitJob();
} }
}); });
buttonRefreshList = new Button(REFRESH_LIST); buttonRefreshList = new Button(REFRESH_LIST);
buttonRefreshList.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getRefresh())); buttonRefreshList.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getRefresh()));
buttonRefreshList.setScale(ButtonScale.MEDIUM); buttonRefreshList.setScale(ButtonScale.MEDIUM);
buttonRefreshList.addListener(Events.OnClick, new Listener<BaseEvent>() { buttonRefreshList.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override @Override
public void handleEvent(BaseEvent be) { public void handleEvent(BaseEvent be) {
// resetStore(); // resetStore();
eventBus.fireEvent(new ReLoadListJobEvent(SearchResultType.TAXONOMY_ITEM)); eventBus.fireEvent(new ReLoadListJobEvent(SearchResultType.TAXONOMY_ITEM));
} }
}); });
toolBar.add(buttonInfo); toolBar.add(buttonInfo);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonSave); toolBar.add(buttonSave);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonSaveError); toolBar.add(buttonSaveError);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonCancel); toolBar.add(buttonCancel);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonReSubmit); toolBar.add(buttonReSubmit);
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(new FillToolItem()); toolBar.add(new FillToolItem());
toolBar.add(new SeparatorToolItem()); toolBar.add(new SeparatorToolItem());
toolBar.add(buttonRefreshList); toolBar.add(buttonRefreshList);
setTopComponent(toolBar); setTopComponent(toolBar);
enableButtonOnClick(false); enableButtonOnClick(false);
} }
public void enableButtonOnClick(boolean bool){ public void enableButtonOnClick(boolean bool){
this.buttonCancel.setEnabled(bool); this.buttonCancel.setEnabled(bool);
this.buttonInfo.setEnabled(bool); this.buttonInfo.setEnabled(bool);
@ -583,11 +583,11 @@ public class TaxonomyGridJob extends ContentPanel{
public void resetStore(){ public void resetStore(){
store.removeAll(); store.removeAll();
} }
public void createMenuItemsOnGrid(){ public void createMenuItemsOnGrid(){
MenuItem menuInfo = new MenuItem(); MenuItem menuInfo = new MenuItem();
menuInfo.setText(INFO); menuInfo.setText(INFO);
menuInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon())); menuInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon()));
menuInfo.addSelectionListener(new SelectionListener<MenuEvent>() { menuInfo.addSelectionListener(new SelectionListener<MenuEvent>() {
@ -598,38 +598,38 @@ public class TaxonomyGridJob extends ContentPanel{
}); });
menu.add(menuInfo); menu.add(menuInfo);
MenuItem menuSave= new MenuItem(); MenuItem menuSave= new MenuItem();
menuSave.setText(SAVE); menuSave.setText(SAVE);
menuSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); menuSave.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
menuSave.addSelectionListener(new SelectionListener<MenuEvent>() { menuSave.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
saveJob(); saveJob();
} }
}); });
menu.add(menuSave); menu.add(menuSave);
MenuItem menuSaveError = new MenuItem(); MenuItem menuSaveError = new MenuItem();
menuSaveError.setText(SAVE_ERROR); menuSaveError.setText(SAVE_ERROR);
menuSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); menuSaveError.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
menuSaveError.addSelectionListener(new SelectionListener<MenuEvent>() { menuSaveError.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
saveJobErrors(); saveJobErrors();
} }
}); });
menu.add(menuSaveError); menu.add(menuSaveError);
MenuItem menuCancel= new MenuItem(); MenuItem menuCancel= new MenuItem();
menuCancel.setText(CANCEL); menuCancel.setText(CANCEL);
menuCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete())); menuCancel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getDelete()));
menuCancel.addSelectionListener(new SelectionListener<MenuEvent>() { menuCancel.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
@ -637,25 +637,25 @@ public class TaxonomyGridJob extends ContentPanel{
} }
}); });
menu.add(menuCancel); menu.add(menuCancel);
MenuItem menuResubmit= new MenuItem(); MenuItem menuResubmit= new MenuItem();
menuResubmit.setText(RE_SUBMIT); menuResubmit.setText(RE_SUBMIT);
menuResubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit())); menuResubmit.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getReSubmit()));
menuResubmit.addSelectionListener(new SelectionListener<MenuEvent>() { menuResubmit.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
resubmitJob(); resubmitJob();
} }
}); });
menu.add(menuResubmit); menu.add(menuResubmit);
grid.setContextMenu(menu); grid.setContextMenu(menu);
} }
} }

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.speciesdiscovery.client.resources; package org.gcube.portlets.user.speciesdiscovery.client.resources;
@ -13,166 +13,173 @@ import com.google.gwt.resources.client.TextResource;
* *
*/ */
public interface Resources extends ClientBundle { public interface Resources extends ClientBundle {
public Resources INSTANCE = GWT.create(Resources.class); public Resources INSTANCE = GWT.create(Resources.class);
@Source("loading-balls.gif") @Source("loading-balls.gif")
ImageResource loadingBalls(); ImageResource loadingBalls();
@Source("detailsview.png") @Source("detailsview.png")
ImageResource getDescriptiveSpeciesIcon(); ImageResource getDescriptiveSpeciesIcon();
@Source("gridview.png") @Source("gridview.png")
ImageResource getGridSpeciesIcon(); ImageResource getGridSpeciesIcon();
@Source("imagesGrid.png") @Source("imagesGrid.png")
ImageResource getGridImagesIcon(); ImageResource getGridImagesIcon();
@Source("collapse.png") @Source("collapse.png")
ImageResource getCollapse(); ImageResource getCollapse();
@Source("expand.png") @Source("expand.png")
ImageResource getExpand(); ImageResource getExpand();
@Source("Toggle.js") @Source("Toggle.js")
TextResource getToggleJavaScript(); TextResource getToggleJavaScript();
@Source("nopicavailable.png") @Source("nopicavailable.png")
ImageResource getNoPictureAvailable(); ImageResource getNoPictureAvailable();
@Source("show_products.png") @Source("show_products.png")
ImageResource getShowProducts(); ImageResource getShowProducts();
@Source("save_products.png") @Source("save_products.png")
ImageResource getSaveProducts(); ImageResource getSaveProducts();
@Source("save_products24.png") @Source("save_products24.png")
ImageResource getSaveProducts24(); ImageResource getSaveProducts24();
@Source("gis_products.png") @Source("gis_products.png")
ImageResource getGisProducts(); ImageResource getGisProducts();
// @Source("arrow-down.png") // @Source("arrow-down.png")
// ImageResource getArrowDown(); // ImageResource getArrowDown();
// //
// @Source("arrow-right.png") // @Source("arrow-right.png")
// ImageResource getArrowRight(); // ImageResource getArrowRight();
@Source("arrow-down.gif") @Source("arrow-down.gif")
ImageResource getArrowDown(); ImageResource getArrowDown();
@Source("arrow-right.gif") @Source("arrow-right.gif")
ImageResource getArrowRight(); ImageResource getArrowRight();
@Source("arrow-turn.png") @Source("arrow-turn.png")
ImageResource getArrowTurn(); ImageResource getArrowTurn();
@Source("gbif.gif") @Source("gbif.gif")
ImageResource getGbif(); ImageResource getGbif();
@Source("delete.png") @Source("delete.png")
ImageResource getDelete(); ImageResource getDelete();
// @Source("order_alphabetical_asc.gif") // @Source("order_alphabetical_asc.gif")
@Source("sortascending.gif") @Source("sortascending.gif")
ImageResource getSortIcon(); ImageResource getSortIcon();
@Source("info-icon.png") @Source("info-icon.png")
ImageResource getInfoIcon(); ImageResource getInfoIcon();
// @Source("help.jpeg") // @Source("help.jpeg")
// ImageResource getHelpIcon(); // ImageResource getHelpIcon();
@Source("question-mark.gif") @Source("question-mark.gif")
ImageResource getHelpIcon(); ImageResource getHelpIcon();
@Source("checkyes.png") @Source("checkyes.png")
ImageResource getCheckYes(); ImageResource getCheckYes();
@Source("checkno.png") @Source("checkno.png")
ImageResource getCheckNo(); ImageResource getCheckNo();
@Source("gear.png") @Source("gear.png")
ImageResource getReSubmit(); ImageResource getReSubmit();
@Source("credits.png") @Source("credits.png")
ImageResource getCredits(); ImageResource getCredits();
@Source("image-notfound.png") @Source("image-notfound.png")
ImageResource getImageNotFound(); ImageResource getImageNotFound();
@Source("getSynonyms.png") @Source("getSynonyms.png")
ImageResource getSynonyms(); ImageResource getSynonyms();
@Source("search-icon.png") @Source("search-icon.png")
ImageResource getSearch(); ImageResource getSearch();
@Source("occurrence/blueplace.png") @Source("occurrence/blueplace.png")
ImageResource getBluePlace(); ImageResource getBluePlace();
@Source("occurrence/blueplace16px.png") @Source("occurrence/blueplace16px.png")
ImageResource getBluePlace16px(); ImageResource getBluePlace16px();
@Source("occurrence/blueplace1.png") @Source("occurrence/blueplace1.png")
ImageResource getBluePlace1(); ImageResource getBluePlace1();
@Source("occurrence/blueplace2.png") @Source("occurrence/blueplace2.png")
ImageResource getBluePlace2(); ImageResource getBluePlace2();
@Source("occurrence/blueplace3.png") @Source("occurrence/blueplace3.png")
ImageResource getBluePlace3(); ImageResource getBluePlace3();
@Source("occurrence/blueplace4.png") @Source("occurrence/blueplace4.png")
ImageResource getBluePlace4(); ImageResource getBluePlace4();
@Source("occurrence/blueplace4+.png") @Source("occurrence/blueplace4+.png")
ImageResource getBluePlace4More(); ImageResource getBluePlace4More();
@Source("taxonomy/taxonomy.png") @Source("taxonomy/taxonomy.png")
ImageResource getTaxonomy(); ImageResource getTaxonomy();
@Source("taxonomy/taxonomy16px.png") @Source("taxonomy/taxonomy16px.png")
ImageResource getTaxonomy16px(); ImageResource getTaxonomy16px();
@Source("taxonomy/taxonomy1.png") @Source("taxonomy/taxonomy1.png")
ImageResource getTaxonomy1(); ImageResource getTaxonomy1();
@Source("taxonomy/taxonomy2.png") @Source("taxonomy/taxonomy2.png")
ImageResource getTaxonomy2(); ImageResource getTaxonomy2();
@Source("taxonomy/taxonomy3.png") @Source("taxonomy/taxonomy3.png")
ImageResource getTaxonomy3(); ImageResource getTaxonomy3();
@Source("taxonomy/taxonomy4.png") @Source("taxonomy/taxonomy4.png")
ImageResource getTaxonomy4(); ImageResource getTaxonomy4();
@Source("taxonomy/taxonomy4More.png") @Source("taxonomy/taxonomy4More.png")
ImageResource getTaxonomy4More(); ImageResource getTaxonomy4More();
@Source("refresh.gif") @Source("refresh.gif")
ImageResource getRefresh(); ImageResource getRefresh();
@Source("reload-icon.png") @Source("reload-icon.png")
ImageResource getReload(); ImageResource getReload();
@Source("checkbox-empty.png") @Source("checkbox-empty.png")
ImageResource getCheckBoxEmpty(); ImageResource getCheckBoxEmpty();
@Source("checkbox-full.png") @Source("checkbox-full.png")
ImageResource getCheckBoxFull(); ImageResource getCheckBoxFull();
@Source("select-icon.png") @Source("select-icon.png")
ImageResource getCheckSelected(); ImageResource getCheckSelected();
@Source("datailsWindow.png") @Source("datailsWindow.png")
ImageResource getDetailsWindow(); ImageResource getDetailsWindow();
@Source("attention.png") @Source("attention.png")
ImageResource getAttention(); ImageResource getAttention();
@Source("help.html") @Source("help.html")
TextResource help(); TextResource help();
/**
* @return
*/
@Source("gislayer/globe.png")
ImageResource getGlobe();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -67,7 +67,7 @@ public interface TaxonomySearchService extends RemoteService {
public void stopRetrievingOccurrences() throws SearchServiceException; public void stopRetrievingOccurrences() throws SearchServiceException;
JobGisLayerModel createGisLayerJobFromSelectedOccurrenceKeys( JobGisLayerModel createGisLayerJobFromSelectedOccurrenceKeys(
String layerTitle, String layerDescr) throws Exception; String layerTitle, String layerDescr, long totalPoints) throws Exception;
// Added by Francesco M. // Added by Francesco M.
public void saveSelectedOccurrencePoints(String destinationFolderId, public void saveSelectedOccurrencePoints(String destinationFolderId,
@ -206,4 +206,11 @@ public interface TaxonomySearchService extends RemoteService {
ClusterCommonNameDataSourceForTaxonomyRow loadClusterCommonNameForTaxonomyRowByScientificName( ClusterCommonNameDataSourceForTaxonomyRow loadClusterCommonNameForTaxonomyRowByScientificName(
String scientificName); String scientificName);
/**
* @return
* @throws Exception
*/
List<JobGisLayerModel> getListGisLayerJob()
throws Exception;
} }

View File

@ -59,7 +59,7 @@ public interface TaxonomySearchServiceAsync {
void createGisLayerJobFromSelectedOccurrenceKeys( void createGisLayerJobFromSelectedOccurrenceKeys(
String layerTitle, String layerDescr, String layerTitle, String layerDescr,
AsyncCallback<JobGisLayerModel> callback); long totalPoints, AsyncCallback<JobGisLayerModel> callback);
void saveSelectedOccurrencePoints(String destinationFolderId, String fileName, SaveFileFormat fileFormat, OccurrencesSaveEnum typeCSV, AsyncCallback<Void> callback); void saveSelectedOccurrencePoints(String destinationFolderId, String fileName, SaveFileFormat fileFormat, OccurrencesSaveEnum typeCSV, AsyncCallback<Void> callback);
@ -169,4 +169,6 @@ public interface TaxonomySearchServiceAsync {
String scientificName, String scientificName,
AsyncCallback<ClusterCommonNameDataSourceForTaxonomyRow> callback); AsyncCallback<ClusterCommonNameDataSourceForTaxonomyRow> callback);
void getListGisLayerJob(AsyncCallback<List<JobGisLayerModel>> callback);
} }

View File

@ -6,11 +6,11 @@ import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery; import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery;
import org.gcube.portlets.user.speciesdiscovery.client.SearchController; import org.gcube.portlets.user.speciesdiscovery.client.SearchController;
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery; import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateGisLayerJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateOccurrenceJobEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.CreateOccurrenceJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent.TaxonomyJobType; import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent.TaxonomyJobType;
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesMapEvent;
import org.gcube.portlets.user.speciesdiscovery.client.gridview.OccurrenceJobGridManager; import org.gcube.portlets.user.speciesdiscovery.client.gridview.OccurrenceJobGridManager;
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources; import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
import org.gcube.portlets.user.speciesdiscovery.client.util.GridField; import org.gcube.portlets.user.speciesdiscovery.client.util.GridField;
@ -69,7 +69,7 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
public class ViewDetailsWindow extends Window { public class ViewDetailsWindow extends Window {
protected final ViewDetailsWindow INSTANCE; protected final ViewDetailsWindow INSTANCE;
protected StreamPagingLoader loader; protected StreamPagingLoader loader;
protected int count = 0; protected int count = 0;
// private int numberOfSelectedRow = 0; // private int numberOfSelectedRow = 0;
@ -79,41 +79,41 @@ public class ViewDetailsWindow extends Window {
private TabItem tabItemDetails = new TabItem(ConstantsSpeciesDiscovery.DETAILS); private TabItem tabItemDetails = new TabItem(ConstantsSpeciesDiscovery.DETAILS);
private ContentPanel panelDetails = new ContentPanel(); private ContentPanel panelDetails = new ContentPanel();
private ContentPanel panelOccurrences = new ContentPanel(); private ContentPanel panelOccurrences = new ContentPanel();
private int width = 900; private int width = 900;
private int height = 600; private int height = 600;
private int widthPanelOccurrences = 1200; private int widthPanelOccurrences = 1200;
private int heightPanelOccurrences = height-70; private int heightPanelOccurrences = height-70;
public final static String FIVEPX = "5px"; public final static String FIVEPX = "5px";
// private SearchController searchController; // private SearchController searchController;
private ToolBar toolbarOccurrences; private ToolBar toolbarOccurrences;
private DataSourceManager dataSourceManager; private DataSourceManager dataSourceManager;
private ToolBar toolbarTaxonomy; private ToolBar toolbarTaxonomy;
private boolean isSearchByCommonName = false; private boolean isSearchByCommonName = false;
private Timer timerGetCountOfOccurrences; private Timer timerGetCountOfOccurrences;
// private List<String> lastlistDataSourceFound = null; // private List<String> lastlistDataSourceFound = null;
private DetailsFiller detailsFiller; private DetailsFiller detailsFiller;
private SearchEvent lastSearchEvent; private SearchEvent lastSearchEvent;
public ViewDetailsWindow(SearchEvent lastSearchEvent) { public ViewDetailsWindow(SearchEvent lastSearchEvent) {
INSTANCE = this; INSTANCE = this;
this.setCollapsible(false); this.setCollapsible(false);
this.setMaximizable(true); this.setMaximizable(true);
// this.setHideCollapseTool(true); // this.setHideCollapseTool(true);
this.dataSourceManager = DataSourceManager.getInstance(); this.dataSourceManager = DataSourceManager.getInstance();
this.lastSearchEvent = lastSearchEvent; this.lastSearchEvent = lastSearchEvent;
if(lastSearchEvent.getType().equals(SearchType.BY_COMMON_NAME)) if(lastSearchEvent.getType().equals(SearchType.BY_COMMON_NAME))
isSearchByCommonName = true; isSearchByCommonName = true;
container.setHeaderVisible(false); container.setHeaderVisible(false);
container.setBodyBorder(false); container.setBodyBorder(false);
container.setLayout(new FitLayout()); container.setLayout(new FitLayout());
@ -131,22 +131,22 @@ public class ViewDetailsWindow extends Window {
//loader is null if items are taxonomy //loader is null if items are taxonomy
if(loader!=null) if(loader!=null)
loader.reset(); loader.reset();
if(timerGetCountOfOccurrences!=null) if(timerGetCountOfOccurrences!=null)
stopTimerGetCountOfOccurrences(500); stopTimerGetCountOfOccurrences(500);
} }
}); });
addListener(Events.Resize, new Listener<BoxComponentEvent>() { addListener(Events.Resize, new Listener<BoxComponentEvent>() {
public void handleEvent(BoxComponentEvent event) { public void handleEvent(BoxComponentEvent event) {
windowResize(INSTANCE.getWidth(), INSTANCE.getHeight()); windowResize(INSTANCE.getWidth(), INSTANCE.getHeight());
} }
}); });
tabPanel = new TabPanel(); tabPanel = new TabPanel();
tabPanel.setBorders(false); tabPanel.setBorders(false);
if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){ if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
this.toolbarOccurrences = createToolbarOccurrences(); this.toolbarOccurrences = createToolbarOccurrences();
createTabItemDisplayResultItem(); createTabItemDisplayResultItem();
@ -158,30 +158,30 @@ public class ViewDetailsWindow extends Window {
container.add(tabPanel,new FitData(4)); container.add(tabPanel,new FitData(4));
add(container); add(container);
show(); show();
} }
protected void windowResize(int width,int height){ protected void windowResize(int width,int height){
if(width>widthPanelOccurrences) if(width>widthPanelOccurrences)
panelOccurrences.setWidth(width-20); panelOccurrences.setWidth(width-20);
else else
panelOccurrences.setWidth(widthPanelOccurrences); panelOccurrences.setWidth(widthPanelOccurrences);
if(height>heightPanelOccurrences) if(height>heightPanelOccurrences)
panelOccurrences.setHeight(height-70); panelOccurrences.setHeight(height-70);
else else
panelOccurrences.setHeight(heightPanelOccurrences); panelOccurrences.setHeight(heightPanelOccurrences);
} }
private void cretateTabItemDisplayTaxonomyItem() { private void cretateTabItemDisplayTaxonomyItem() {
tabItemDetails.setScrollMode(Scroll.AUTO); tabItemDetails.setScrollMode(Scroll.AUTO);
ContentPanel cpDetailsTaxonomy = new ContentPanel(); ContentPanel cpDetailsTaxonomy = new ContentPanel();
cpDetailsTaxonomy.setHeaderVisible(false); cpDetailsTaxonomy.setHeaderVisible(false);
cpDetailsTaxonomy.setBodyBorder(false); cpDetailsTaxonomy.setBodyBorder(false);
@ -192,42 +192,42 @@ public class ViewDetailsWindow extends Window {
panelDetails.setHeaderVisible(false); panelDetails.setHeaderVisible(false);
panelDetails.setBodyBorder(false); panelDetails.setBodyBorder(false);
// panelDetails.setStyleAttribute("padding", FIVEPX); // panelDetails.setStyleAttribute("padding", FIVEPX);
panelDetails.setStyleAttribute("padding-left", FIVEPX); panelDetails.setStyleAttribute("padding-left", FIVEPX);
panelDetails.setStyleAttribute("padding-right", FIVEPX); panelDetails.setStyleAttribute("padding-right", FIVEPX);
panelDetails.setStyleAttribute("padding-bottom", FIVEPX); panelDetails.setStyleAttribute("padding-bottom", FIVEPX);
panelDetails.setStyleAttribute("margin-left", FIVEPX); panelDetails.setStyleAttribute("margin-left", FIVEPX);
panelDetails.setStyleAttribute("margin-right", FIVEPX); panelDetails.setStyleAttribute("margin-right", FIVEPX);
panelDetails.setStyleAttribute("margin-bottom", FIVEPX); panelDetails.setStyleAttribute("margin-bottom", FIVEPX);
// panelDetails.setTopComponent(this.toolbarTaxonomy); // panelDetails.setTopComponent(this.toolbarTaxonomy);
tabItemDetails.add(panelDetails); tabItemDetails.add(panelDetails);
setFocusWidget(getButtonBar().getItem(0)); setFocusWidget(getButtonBar().getItem(0));
tabItemDetails.mask("Loading...", ConstantsSpeciesDiscovery.LOADINGSTYLE); tabItemDetails.mask("Loading...", ConstantsSpeciesDiscovery.LOADINGSTYLE);
enableToolbarTaxonomy(false); enableToolbarTaxonomy(false);
loadStructuresAndFillingPage(SpeciesCapability.TAXONOMYITEM); loadStructuresAndFillingPage(SpeciesCapability.TAXONOMYITEM);
tabPanel.add(tabItemDetails); tabPanel.add(tabItemDetails);
} }
private void createTabItemDisplayResultItem() { private void createTabItemDisplayResultItem() {
tabItemOccrs.setToolTip(new ToolTipConfig("Show Occurrences", "Shows occurences points from selected results.")); tabItemOccrs.setToolTip(new ToolTipConfig("Show Occurrences", "Shows occurences points from selected results."));
tabItemDetails.setScrollMode(Scroll.AUTO); tabItemDetails.setScrollMode(Scroll.AUTO);
panelDetails.setHeaderVisible(false); panelDetails.setHeaderVisible(false);
panelDetails.setBodyBorder(false); panelDetails.setBodyBorder(false);
panelDetails.setStyleAttribute("padding", FIVEPX); panelDetails.setStyleAttribute("padding", FIVEPX);
panelDetails.setStyleAttribute("margin", FIVEPX); panelDetails.setStyleAttribute("margin", FIVEPX);
// panelDetails.add(createButtonSaveAsHtml()); // panelDetails.add(createButtonSaveAsHtml());
panelOccurrences.setHeaderVisible(false); panelOccurrences.setHeaderVisible(false);
@ -244,68 +244,68 @@ public class ViewDetailsWindow extends Window {
setFocusWidget(getButtonBar().getItem(0)); setFocusWidget(getButtonBar().getItem(0));
createOccurrencesWindow(); createOccurrencesWindow();
tabItemDetails.mask("Loading...",ConstantsSpeciesDiscovery.LOADINGSTYLE); tabItemDetails.mask("Loading...",ConstantsSpeciesDiscovery.LOADINGSTYLE);
enableToolbarOccurrence(false); enableToolbarOccurrence(false);
// loadNumberOfSelectedRowAndDetailsFilling(SpeciesCapability.RESULTITEM); // loadNumberOfSelectedRowAndDetailsFilling(SpeciesCapability.RESULTITEM);
loadStructuresAndFillingPage(SpeciesCapability.RESULTITEM); loadStructuresAndFillingPage(SpeciesCapability.RESULTITEM);
tabPanel.add(tabItemDetails); tabPanel.add(tabItemDetails);
tabPanel.add(tabItemOccrs); tabPanel.add(tabItemOccrs);
} }
private void enableToolbarOccurrence(boolean bool){ private void enableToolbarOccurrence(boolean bool){
toolbarOccurrences.setEnabled(bool); toolbarOccurrences.setEnabled(bool);
} }
private void enableToolbarTaxonomy(boolean bool){ private void enableToolbarTaxonomy(boolean bool){
toolbarTaxonomy.setEnabled(bool); toolbarTaxonomy.setEnabled(bool);
} }
public void loadStructuresAndFillingPage(final SpeciesCapability capability){ public void loadStructuresAndFillingPage(final SpeciesCapability capability){
if(capability.getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){ if(capability.getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
ResultRowDetailsFiller resultRowFiller = new ResultRowDetailsFiller(tabItemDetails, toolbarOccurrences, panelDetails, lastSearchEvent); ResultRowDetailsFiller resultRowFiller = new ResultRowDetailsFiller(tabItemDetails, toolbarOccurrences, panelDetails, lastSearchEvent);
resultRowFiller.loadStructuresAndFillingPage(); resultRowFiller.loadStructuresAndFillingPage();
detailsFiller = resultRowFiller; detailsFiller = resultRowFiller;
}else if(capability.getName().compareTo(SpeciesCapability.TAXONOMYITEM.getName())==0){ }else if(capability.getName().compareTo(SpeciesCapability.TAXONOMYITEM.getName())==0){
TaxonomyRowDetailsFiller taxonomyFiller = new TaxonomyRowDetailsFiller(tabItemDetails, toolbarTaxonomy, tabPanel, panelDetails, lastSearchEvent); TaxonomyRowDetailsFiller taxonomyFiller = new TaxonomyRowDetailsFiller(tabItemDetails, toolbarTaxonomy, tabPanel, panelDetails, lastSearchEvent);
taxonomyFiller.loadStructuresAndFillingPage(); taxonomyFiller.loadStructuresAndFillingPage();
detailsFiller = taxonomyFiller; detailsFiller = taxonomyFiller;
} }
} }
public ToolBar createToolbarTaxonomy(){ public ToolBar createToolbarTaxonomy(){
ToolBar toolbar = new ToolBar(); ToolBar toolbar = new ToolBar();
Button btnTaxonomyMenu = new Button(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_ITEMS); Button btnTaxonomyMenu = new Button(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_ITEMS);
Menu formatSubMenu = new Menu(); Menu formatSubMenu = new Menu();
btnTaxonomyMenu.setMenu(formatSubMenu); btnTaxonomyMenu.setMenu(formatSubMenu);
btnTaxonomyMenu.setScale(ButtonScale.SMALL); btnTaxonomyMenu.setScale(ButtonScale.SMALL);
btnTaxonomyMenu.setIconAlign(IconAlign.TOP); btnTaxonomyMenu.setIconAlign(IconAlign.TOP);
btnTaxonomyMenu.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); btnTaxonomyMenu.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
btnTaxonomyMenu.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_ITEMS, "Save taxonomy items from selected results.")); btnTaxonomyMenu.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_ITEMS, "Save taxonomy items from selected results."));
// btnOccurrencesMenu.addSelectionListener(new SelectionListener<ButtonEvent>() { // btnOccurrencesMenu.addSelectionListener(new SelectionListener<ButtonEvent>() {
// //
// @Override // @Override
// public void componentSelected(ButtonEvent ce) { // public void componentSelected(ButtonEvent ce) {
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null));
// //
// } // }
// }); // });
MenuItem darwinCoreArchiveItem = new MenuItem(ConstantsSpeciesDiscovery.DARWIN_CORE_ARCHIVE); MenuItem darwinCoreArchiveItem = new MenuItem(ConstantsSpeciesDiscovery.DARWIN_CORE_ARCHIVE);
darwinCoreArchiveItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT)); darwinCoreArchiveItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT));
darwinCoreArchiveItem.addSelectionListener(new SelectionListener<MenuEvent>() { darwinCoreArchiveItem.addSelectionListener(new SelectionListener<MenuEvent>() {
@ -314,44 +314,44 @@ public class ViewDetailsWindow extends Window {
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
SearchController.eventBus.fireEvent(new CreateTaxonomyJobEvent(TaxonomyJobType.BYIDS)); SearchController.eventBus.fireEvent(new CreateTaxonomyJobEvent(TaxonomyJobType.BYIDS));
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null));
} }
}); });
formatSubMenu.add(darwinCoreArchiveItem); formatSubMenu.add(darwinCoreArchiveItem);
toolbar.add(btnTaxonomyMenu); toolbar.add(btnTaxonomyMenu);
return toolbar; return toolbar;
} }
public ToolBar createToolbarOccurrences(){ public ToolBar createToolbarOccurrences(){
ToolBar toolbar = new ToolBar(); ToolBar toolbar = new ToolBar();
Button btnShowInGisViewer = new Button(ConstantsSpeciesDiscovery.SHOW_IN_GIS_VIEWER); Button btnShowInGisViewer = new Button(ConstantsSpeciesDiscovery.CREATE_GIS_LAYER);
btnShowInGisViewer.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getGisProducts())); btnShowInGisViewer.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getGisProducts()));
btnShowInGisViewer.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SHOW_IN_GIS_VIEWER, "Show occurences points from selected results in a Gis Viewer Map.")); btnShowInGisViewer.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.CREATE_GIS_LAYER, "Create a Gis Layer from selected occurences points in a Gis Viewer Map"));
btnShowInGisViewer.setScale(ButtonScale.SMALL); btnShowInGisViewer.setScale(ButtonScale.SMALL);
btnShowInGisViewer.setIconAlign(IconAlign.TOP); btnShowInGisViewer.setIconAlign(IconAlign.TOP);
btnShowInGisViewer.setArrowAlign(ButtonArrowAlign.BOTTOM); btnShowInGisViewer.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnShowInGisViewer.addSelectionListener(new SelectionListener<ButtonEvent>() { btnShowInGisViewer.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
SearchController.eventBus.fireEvent(new ShowOccurrencesMapEvent(count)); SearchController.eventBus.fireEvent(new CreateGisLayerJobEvent(lastSearchEvent.getSearchTerm() +" Occurrences layer", "Gis Layer generated from SPD Portlet by gCube Framework", count));
} }
}); });
Button btnOccurrencesMenu = new Button(ConstantsSpeciesDiscovery.SAVE_OCCURRENCES); Button btnOccurrencesMenu = new Button(ConstantsSpeciesDiscovery.SAVE_OCCURRENCES);
Menu formatSubMenu = new Menu(); Menu formatSubMenu = new Menu();
btnOccurrencesMenu.setMenu(formatSubMenu); btnOccurrencesMenu.setMenu(formatSubMenu);
btnOccurrencesMenu.setScale(ButtonScale.SMALL); btnOccurrencesMenu.setScale(ButtonScale.SMALL);
btnOccurrencesMenu.setIconAlign(IconAlign.TOP); btnOccurrencesMenu.setIconAlign(IconAlign.TOP);
btnOccurrencesMenu.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); btnOccurrencesMenu.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
btnOccurrencesMenu.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVE_OCCURRENCES, ConstantsSpeciesDiscovery.SAVE_OCCURENCES_POINTS_FROM_SELECTED_RESULTS)); btnOccurrencesMenu.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVE_OCCURRENCES, ConstantsSpeciesDiscovery.SAVE_OCCURENCES_POINTS_FROM_SELECTED_RESULTS));
@ -361,143 +361,143 @@ public class ViewDetailsWindow extends Window {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm()); String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,false)); SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,false));
} }
}); });
formatSubMenu.add(csvFormatItem); formatSubMenu.add(csvFormatItem);
Menu csvTypeMenu = new Menu(); Menu csvTypeMenu = new Menu();
MenuItem csvStandard = new MenuItem(ConstantsSpeciesDiscovery.PLAIN_CSV); MenuItem csvStandard = new MenuItem(ConstantsSpeciesDiscovery.PLAIN_CSV);
csvStandard.addSelectionListener(new SelectionListener<MenuEvent>() { csvStandard.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm()); String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,false)); SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,false));
} }
}); });
MenuItem csvStandardByDataSource = new MenuItem(ConstantsSpeciesDiscovery.PLAIN_CSV_BY_DATA_SOURCE); MenuItem csvStandardByDataSource = new MenuItem(ConstantsSpeciesDiscovery.PLAIN_CSV_BY_DATA_SOURCE);
csvStandardByDataSource.addSelectionListener(new SelectionListener<MenuEvent>() { csvStandardByDataSource.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm()); String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,true)); SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,true));
} }
}); });
MenuItem csvOpenModeller = new MenuItem(ConstantsSpeciesDiscovery.OPEN_MODELLER); MenuItem csvOpenModeller = new MenuItem(ConstantsSpeciesDiscovery.OPEN_MODELLER);
csvOpenModeller.addSelectionListener(new SelectionListener<MenuEvent>() { csvOpenModeller.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm()); String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, detailsFiller.getLastlistDataSourceFound(), searchTerm,false)); SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, detailsFiller.getLastlistDataSourceFound(), searchTerm,false));
} }
}); });
MenuItem csvOpenModellerByDataSource = new MenuItem(ConstantsSpeciesDiscovery.OPEN_MODELLER_BY_DATA_SOURCE); MenuItem csvOpenModellerByDataSource = new MenuItem(ConstantsSpeciesDiscovery.OPEN_MODELLER_BY_DATA_SOURCE);
csvOpenModellerByDataSource.addSelectionListener(new SelectionListener<MenuEvent>() { csvOpenModellerByDataSource.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm()); String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, detailsFiller.getLastlistDataSourceFound(), searchTerm,true)); SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, detailsFiller.getLastlistDataSourceFound(), searchTerm,true));
} }
}); });
csvTypeMenu.add(csvStandard); csvTypeMenu.add(csvStandard);
csvTypeMenu.add(csvStandardByDataSource); csvTypeMenu.add(csvStandardByDataSource);
csvTypeMenu.add(csvOpenModeller); csvTypeMenu.add(csvOpenModeller);
csvTypeMenu.add(csvOpenModellerByDataSource); csvTypeMenu.add(csvOpenModellerByDataSource);
csvFormatItem.setSubMenu(csvTypeMenu); csvFormatItem.setSubMenu(csvTypeMenu);
MenuItem darwinCoreFormatItem = new MenuItem(ConstantsSpeciesDiscovery.DARWIN_CORE); MenuItem darwinCoreFormatItem = new MenuItem(ConstantsSpeciesDiscovery.DARWIN_CORE);
darwinCoreFormatItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_DARWIN_CORE_FILE_FORMAT)); darwinCoreFormatItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_DARWIN_CORE_FILE_FORMAT));
darwinCoreFormatItem.addSelectionListener(new SelectionListener<MenuEvent>() { darwinCoreFormatItem.addSelectionListener(new SelectionListener<MenuEvent>() {
@Override @Override
public void componentSelected(MenuEvent ce) { public void componentSelected(MenuEvent ce) {
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.DARWIN_CORE, count, null)); // searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.DARWIN_CORE, count, null));
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm()); String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.DARWIN_CORE, count, null, detailsFiller.getLastlistDataSourceFound(), searchTerm, false)); SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.DARWIN_CORE, count, null, detailsFiller.getLastlistDataSourceFound(), searchTerm, false));
} }
}); });
formatSubMenu.add(darwinCoreFormatItem); formatSubMenu.add(darwinCoreFormatItem);
toolbar.add(btnOccurrencesMenu); toolbar.add(btnOccurrencesMenu);
toolbar.add(new SeparatorToolItem()); toolbar.add(new SeparatorToolItem());
toolbar.add(btnShowInGisViewer); toolbar.add(btnShowInGisViewer);
return toolbar; return toolbar;
} }
protected void initLoader() protected void initLoader()
{ {
loader = new StreamPagingLoader(ConstantsSpeciesDiscovery.PAGE_SIZE); loader = new StreamPagingLoader(ConstantsSpeciesDiscovery.PAGE_SIZE);
// loader = new StreamPagingLoader(PAGE_SIZE); // loader = new StreamPagingLoader(PAGE_SIZE);
loader.setDataSource(dataSourceManager.getDataSourceByResultType(SpeciesCapability.OCCURRENCESPOINTS)); loader.setDataSource(dataSourceManager.getDataSourceByResultType(SpeciesCapability.OCCURRENCESPOINTS));
} }
public void createOccurrencesWindow() public void createOccurrencesWindow()
{ {
List<ColumnConfig> config = new ArrayList<ColumnConfig>(); List<ColumnConfig> config = new ArrayList<ColumnConfig>();
for (GridField field:OccurencesGridFields.values()) config.add(Util.createColumnConfig(field, 150)); for (GridField field:OccurencesGridFields.values()) config.add(Util.createColumnConfig(field, 150));
final ColumnModel cm = new ColumnModel(config); final ColumnModel cm = new ColumnModel(config);
initLoader(); initLoader();
Grid<ModelData> grid = new Grid<ModelData>(loader.getStore(), cm); Grid<ModelData> grid = new Grid<ModelData>(loader.getStore(), cm);
grid.setBorders(true); grid.setBorders(true);
grid.getView().setEmptyText(ConstantsSpeciesDiscovery.NORESULTS); grid.getView().setEmptyText(ConstantsSpeciesDiscovery.NORESULTS);
StreamPagingToolBar toolBar = new StreamPagingToolBar(); StreamPagingToolBar toolBar = new StreamPagingToolBar();
toolBar.bind(loader); toolBar.bind(loader);
panelOccurrences.setBottomComponent(toolBar); panelOccurrences.setBottomComponent(toolBar);
panelOccurrences.add(grid); panelOccurrences.add(grid);
} }
public void loadOccurences() public void loadOccurences()
@ -508,95 +508,95 @@ public class ViewDetailsWindow extends Window {
dataSourceManager.setExpectedOccurencePoints(count); dataSourceManager.setExpectedOccurencePoints(count);
SpeciesDiscovery.taxonomySearchService.retrieveOccurencesFromSelection(new AsyncCallback<Integer>() { SpeciesDiscovery.taxonomySearchService.retrieveOccurencesFromSelection(new AsyncCallback<Integer>() {
@Override @Override
public void onSuccess(Integer expectedPoints) { public void onSuccess(Integer expectedPoints) {
Log.trace("Expected points: "+expectedPoints); Log.trace("Expected points: "+expectedPoints);
dataSourceManager.setExpectedOccurencePoints(expectedPoints); dataSourceManager.setExpectedOccurencePoints(expectedPoints);
count = expectedPoints.intValue(); count = expectedPoints.intValue();
String items = count>0?"items":"item"; String items = count>0?"items":"item";
tabItemOccrs.setText(tabItemOccrs.getText() + " ("+count +" "+ items+")"); tabItemOccrs.setText(tabItemOccrs.getText() + " ("+count +" "+ items+")");
dataSourceManager.setExpectedOccurencePoints(count); dataSourceManager.setExpectedOccurencePoints(count);
// count = expectedPoints; // count = expectedPoints;
loader.startLoading(true); loader.startLoading(true);
pollingGetCountOfOcccurrences(count); pollingGetCountOfOcccurrences(count);
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Info.display("Error getting occurrences", "Error getting occurrences, retry"); Info.display("Error getting occurrences", "Error getting occurrences, retry");
Log.trace("Error getting occurrences", caught); Log.trace("Error getting occurrences", caught);
} }
}); });
} }
private void pollingGetCountOfOcccurrences(final int allItems){ private void pollingGetCountOfOcccurrences(final int allItems){
toolbarOccurrences.add(new SeparatorToolItem()); toolbarOccurrences.add(new SeparatorToolItem());
final Label labelLoading = new Label("loading 0 of "+allItems); final Label labelLoading = new Label("loading 0 of "+allItems);
labelLoading.setStyleAttribute("paddingLeft", "20px"); labelLoading.setStyleAttribute("paddingLeft", "20px");
labelLoading.setData("count", new Integer(0)); labelLoading.setData("count", new Integer(0));
toolbarOccurrences.add(labelLoading); toolbarOccurrences.add(labelLoading);
timerGetCountOfOccurrences = new Timer() { timerGetCountOfOccurrences = new Timer() {
@Override @Override
public void run() { public void run() {
SpeciesDiscovery.taxonomySearchService.getCountOfOccurrencesBatch(new AsyncCallback<OccurrencesStatus>() { SpeciesDiscovery.taxonomySearchService.getCountOfOccurrencesBatch(new AsyncCallback<OccurrencesStatus>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Log.error("Error on loading", "An error occurred on count of occurrence point, retry." +caught.getMessage()); Log.error("Error on loading", "An error occurred on count of occurrence point, retry." +caught.getMessage());
} }
@Override @Override
public void onSuccess(OccurrencesStatus result) { public void onSuccess(OccurrencesStatus result) {
int currentValue = ((Integer) labelLoading.getData("count")).intValue(); int currentValue = ((Integer) labelLoading.getData("count")).intValue();
if(result.getSize()>currentValue && result.getSize()<allItems) if(result.getSize()>currentValue && result.getSize()<allItems)
labelLoading.setText("loading "+result.getSize()+ " of " + allItems + " and counting..."); labelLoading.setText("loading "+result.getSize()+ " of " + allItems + " and counting...");
if(result.getSize()==allItems){ if(result.getSize()==allItems){
setLabelLoadedText(result.getSize(), allItems); setLabelLoadedText(result.getSize(), allItems);
stopTimerGetCountOfOccurrences(1000); stopTimerGetCountOfOccurrences(1000);
} }
//case stream completed //case stream completed
if(result.isResultEOF()){ if(result.isResultEOF()){
Log.trace("EOF of occurrences is true"); Log.trace("EOF of occurrences is true");
setLabelLoadedText(result.getSize(), allItems); setLabelLoadedText(result.getSize(), allItems);
stopTimerGetCountOfOccurrences(2000); stopTimerGetCountOfOccurrences(2000);
} }
labelLoading.setData("count", result.getSize()); labelLoading.setData("count", result.getSize());
Log.trace("loading " + result.getSize() + " occurrences" ); Log.trace("loading " + result.getSize() + " occurrences" );
toolbarOccurrences.layout(); toolbarOccurrences.layout();
} }
private void setLabelLoadedText(int size, int allItems) { private void setLabelLoadedText(int size, int allItems) {
String msg = "loaded "+size+ " of " + allItems; String msg = "loaded "+size+ " of " + allItems;
if(size<allItems){ if(size<allItems){
int difference = allItems - size; int difference = allItems - size;
msg+= " (" + difference + " duplicate or not available occurrence points were discarded)"; msg+= " (" + difference + " duplicate or not available occurrence points were discarded)";
} }
labelLoading.setText(msg); labelLoading.setText(msg);
} }
}); });
} }
@ -604,28 +604,28 @@ public class ViewDetailsWindow extends Window {
// Schedule the timer to run once in 1 seconds. // Schedule the timer to run once in 1 seconds.
timerGetCountOfOccurrences.scheduleRepeating(ConstantsSpeciesDiscovery.SCHEDULE_MILLIS_COUNT_OCCURRENCES); timerGetCountOfOccurrences.scheduleRepeating(ConstantsSpeciesDiscovery.SCHEDULE_MILLIS_COUNT_OCCURRENCES);
// timerGetCountOfOccurrences.run(); // timerGetCountOfOccurrences.run();
Log.trace("run timerGetCountOfOccurrences"); Log.trace("run timerGetCountOfOccurrences");
} }
private void stopTimerGetCountOfOccurrences(int delay) { private void stopTimerGetCountOfOccurrences(int delay) {
Log.trace("stop timerGetCountOfOccurrences"); Log.trace("stop timerGetCountOfOccurrences");
Timer timer = new Timer() { Timer timer = new Timer() {
@Override @Override
public void run() { public void run() {
// System.out.println("cancel cancel cancel"); // System.out.println("cancel cancel cancel");
timerGetCountOfOccurrences.cancel(); timerGetCountOfOccurrences.cancel();
} }
}; };
timer.schedule(delay); timer.schedule(delay);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -633,10 +633,10 @@ public class ViewDetailsWindow extends Window {
protected void onHide() { protected void onHide() {
super.onHide(); super.onHide();
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
public void execute() { public void execute() {
if(loader!=null){ if(loader!=null){
loader.reset(); loader.reset();
SpeciesDiscovery.taxonomySearchService.stopRetrievingOccurrences(new AsyncCallback<Void>() { SpeciesDiscovery.taxonomySearchService.stopRetrievingOccurrences(new AsyncCallback<Void>() {
@ -644,59 +644,59 @@ public class ViewDetailsWindow extends Window {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Log.error("An error occurred in stopRetrievingOccurrences: " + caught); Log.error("An error occurred in stopRetrievingOccurrences: " + caught);
} }
@Override @Override
public void onSuccess(Void result) { public void onSuccess(Void result) {
Log.trace("Stop retrieving Occurrences: OK"); Log.trace("Stop retrieving Occurrences: OK");
} }
}); });
} }
} }
}); });
} }
//TEST
public Button createButtonSaveAsHtml(){
ToolBar toolbar = new ToolBar();
Button btnExportAsHtml = new Button("Export As Html");
btnExportAsHtml.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
btnExportAsHtml.setToolTip(new ToolTipConfig("Show in Gis Viewer", "Show occurences points from selected results in a Gis Viewer Map."));
btnExportAsHtml.setScale(ButtonScale.SMALL);
btnExportAsHtml.setIconAlign(IconAlign.TOP);
btnExportAsHtml.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnExportAsHtml.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// searchController.getEventBus().fireEvent(new ShowOccurrencesMapEvent());
String html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html>" +
"<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
"<style type=\"text/css\">" +getCssStyles() +
"</style>" +
"<title>"+lastSearchEvent.getSearchTerm()+"</title>" +
"</head>" +
" <body>"+panelDetails.getElement().getInnerHTML()+"</body>" +
"</html> ";
// System.out.println(html);
}
});
return btnExportAsHtml;
} // //TEST
// public Button createButtonSaveAsHtml(){
//
// ToolBar toolbar = new ToolBar();
//
// Button btnExportAsHtml = new Button("Export As Html");
// btnExportAsHtml.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
// btnExportAsHtml.setToolTip(new ToolTipConfig("Show in Gis Viewer", "Show occurences points from selected results in a Gis Viewer Map."));
// btnExportAsHtml.setScale(ButtonScale.SMALL);
// btnExportAsHtml.setIconAlign(IconAlign.TOP);
// btnExportAsHtml.setArrowAlign(ButtonArrowAlign.BOTTOM);
// btnExportAsHtml.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
// @Override
// public void componentSelected(ButtonEvent ce) {
//// searchController.getEventBus().fireEvent(new ShowOccurrencesMapEvent());
//
// String html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html>" +
// "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
// "<style type=\"text/css\">" +getCssStyles() +
// "</style>" +
// "<title>"+lastSearchEvent.getSearchTerm()+"</title>" +
// "</head>" +
// " <body>"+panelDetails.getElement().getInnerHTML()+"</body>" +
// "</html> ";
//
//// System.out.println(html);
// }
// });
//
// return btnExportAsHtml;
//
// }
private String getCssStyles(){ private String getCssStyles(){
return ".button-hyperlink .x-btn-text {" + return ".button-hyperlink .x-btn-text {" +

View File

@ -37,7 +37,7 @@ import org.gcube.portlets.user.speciesdiscovery.client.model.ClassificationModel
import org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService; import org.gcube.portlets.user.speciesdiscovery.client.rpc.TaxonomySearchService;
import org.gcube.portlets.user.speciesdiscovery.client.util.GridField; import org.gcube.portlets.user.speciesdiscovery.client.util.GridField;
import org.gcube.portlets.user.speciesdiscovery.server.asl.SessionUtil; import org.gcube.portlets.user.speciesdiscovery.server.asl.SessionUtil;
import org.gcube.portlets.user.speciesdiscovery.server.job.GisLinkJobUtil; import org.gcube.portlets.user.speciesdiscovery.server.job.GisLayerJobUtil;
import org.gcube.portlets.user.speciesdiscovery.server.job.OccurrenceJobUtil; import org.gcube.portlets.user.speciesdiscovery.server.job.OccurrenceJobUtil;
import org.gcube.portlets.user.speciesdiscovery.server.job.OccurrenceKeys; import org.gcube.portlets.user.speciesdiscovery.server.job.OccurrenceKeys;
import org.gcube.portlets.user.speciesdiscovery.server.job.TaxonomyJobUtil; import org.gcube.portlets.user.speciesdiscovery.server.job.TaxonomyJobUtil;
@ -71,6 +71,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
import org.gcube.portlets.user.speciesdiscovery.shared.DatabaseServiceException; import org.gcube.portlets.user.speciesdiscovery.shared.DatabaseServiceException;
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState; import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement; import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement;
import org.gcube.portlets.user.speciesdiscovery.shared.GisLayerJob;
import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter; import org.gcube.portlets.user.speciesdiscovery.shared.ItemParameter;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel; import org.gcube.portlets.user.speciesdiscovery.shared.JobOccurrencesModel;
@ -849,7 +850,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public JobGisLayerModel createGisLayerJobFromSelectedOccurrenceKeys(String layerTitle, String layerDescr) throws Exception { public JobGisLayerModel createGisLayerJobFromSelectedOccurrenceKeys(String layerTitle, String layerDescr, long totalPoints) throws Exception {
try { try {
List<String> occurrenceKeys = getSelectedOccurrenceKeys(); List<String> occurrenceKeys = getSelectedOccurrenceKeys();
@ -857,11 +858,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
String author = getASLSession().getUsername(); String author = getASLSession().getUsername();
String credits = ""; String credits = "";
GisLayerJobPersistence gisLayerJob = DaoSession.getGisLayersJobDAO(getASLSession()); GisLayerJobPersistence gisLayerJob = DaoSession.getGisLayersJobDAO(getASLSession());
GisLinkJobUtil.createGisLayerJobByOccurrenceKeys(occurrenceKeys, taxonomyService, layerTitle, layerDescr, author, credits, gisLayerJob); return GisLayerJobUtil.createGisLayerJobByOccurrenceKeys(occurrenceKeys, taxonomyService, layerTitle, layerDescr, author, credits, totalPoints, gisLayerJob);
logger.trace("Generating Map form Occurrence Keys selected: "+occurrenceKeys.size());
String jobId = taxonomyService.generateMapFromOccurrenceKeys(occurrenceKeys,layerTitle,layerDescr,author,credits);
logger.info("generated gis layer jobID: "+jobId);
return new JobGisLayerModel(jobId, layerTitle, 0, Calendar.getInstance().getTimeInMillis(), 0, layerDescr, DownloadState.PENDING.toString());
} catch (Exception e) { } catch (Exception e) {
logger.error("An error occurred creating the map", e); logger.error("An error occurred creating the map", e);
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
@ -1706,6 +1703,55 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
} }
@Override
public List<JobGisLayerModel> getListGisLayerJob() throws Exception{
logger.info("getListGisLayerJob... ");
List<JobGisLayerModel> listJobs = new ArrayList<JobGisLayerModel>();
try {
GisLayerJobPersistence gisLayerJobDao = DaoSession.getGisLayersJobDAO(getASLSession());
Iterator<GisLayerJob> iterator = gisLayerJobDao.getList().iterator();
SpeciesService taxonomyService = getSpeciesService();
while (iterator!=null && iterator.hasNext()) {
GisLayerJob job = iterator.next();
CompleteJobStatus statusResponse = taxonomyService.getOccurrenceJobById(job.getId());
logger.info("get occurrence job "+job.getId()+ " from service");
try{
if(statusResponse!=null){
logger.info("statusResponse of gis layer job is not null..." + job.getId());
JobGisLayerModel convertJob = GisLayerJobUtil.convertJob(job, statusResponse, gisLayerJobDao);
if(convertJob!=null){
logger.info("added list jobOccurrenceId: "+convertJob.getJobIdentifier() + " status "+convertJob.getDownloadState());
listJobs.add(convertJob);
}
}
else{
logger.info("statusResponse of occurrence job is null..." + job.getId());
logger.info("deleting job ..." + job.getId());
GisLayerJobUtil.deleteGisLayerJobById(job.getId(),gisLayerJobDao);
}
}catch (Exception e) {
e.printStackTrace();
logger.error("Error on getListGisLayerJob ", e);
throw new Exception("Error on getListGisLayerJob", e);
}
}
} catch (Exception e) {
logger.error("Error on get iterator "+e, e);
}
return listJobs;
}
@Override @Override
public boolean saveOccurrenceJob(JobOccurrencesModel jobModel, String destinationFolderId, String fileName, String scientificName, String dataSourceName) throws Exception { public boolean saveOccurrenceJob(JobOccurrencesModel jobModel, String destinationFolderId, String fileName, String scientificName, String dataSourceName) throws Exception {
logger.info("saveOccurrenceJob jobId: "+jobModel.getJobIdentifier()+" destinationFolderId: "+destinationFolderId+" fileName: "+fileName + " file format: "+jobModel.getFileFormat()); logger.info("saveOccurrenceJob jobId: "+jobModel.getJobIdentifier()+" destinationFolderId: "+destinationFolderId+" fileName: "+fileName + " file format: "+jobModel.getFileFormat());

View File

@ -0,0 +1,212 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.server.job;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.data.spd.model.service.types.CompleteJobStatus;
import org.gcube.data.spd.model.service.types.JobStatus;
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.GisLayerJobPersistence;
import org.gcube.portlets.user.speciesdiscovery.server.service.SpeciesService;
import org.gcube.portlets.user.speciesdiscovery.server.util.DateUtil;
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
import org.gcube.portlets.user.speciesdiscovery.shared.GisLayerJob;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
/**
* The Class GisLinkJobUtil.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 9, 2017
*/
public class GisLayerJobUtil {
protected static Logger logger = Logger.getLogger(GisLayerJobUtil.class);
/**
* Creates the gis layer job by occurrence keys.
*
* @param occurrenceKeys the occurrence keys
* @param taxonomyService the taxonomy service
* @param layerTitle the layer title
* @param layerDescr the layer descr
* @param author the author
* @param credits the credits
* @param gisLayerJob the gis layer job
* @return the job gis layer model
* @throws Exception the exception
*/
public static JobGisLayerModel createGisLayerJobByOccurrenceKeys(List<String> occurrenceKeys, SpeciesService taxonomyService, String layerTitle, String layerDescr, String author, String credits, long totalPoints, GisLayerJobPersistence gisLayerJob) throws Exception {
try {
logger.trace("Generating Map form Occurrence Keys selected: "+occurrenceKeys.size());
String jobId = taxonomyService.generateGisLayerFromOccurrenceKeys(occurrenceKeys,layerTitle,layerDescr,author,credits);
logger.info("generated gis layer jobID: "+jobId);
Date submitTime = DateUtil.getDateFormat(Calendar.getInstance());
GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, submitTime.getTime(), 0, 0, layerDescr, DownloadState.PENDING.toString(), totalPoints);
gisLayerJob.insert(gisLJ);
return new JobGisLayerModel(jobId, layerTitle, DownloadState.PENDING,null, submitTime, null, null, layerDescr, 0, totalPoints);
} catch (Exception e) {
logger.error("An error occurred creating the map", e);
throw new Exception(e.getMessage());
}
}
/**
* Convert job.
*
* @param job the job
* @param statusResponse the status response
* @param gisLayerJobP the gis layer job p
* @return the job gis layer model
*/
public static JobGisLayerModel convertJob(GisLayerJob job, CompleteJobStatus statusResponse, GisLayerJobPersistence gisLayerJobP){
//TODO SET END TIME
JobGisLayerModel jobGisModel;
DownloadState downloadState = null;
long endTime = 0;
JobStatus status = statusResponse.getStatus();
downloadState = getDownloadState(status);
logger.trace("gis layer jobId: "+job.getId() +" download state: " + downloadState);
if(downloadState==null) //Case with exception
return null;
//SET SUBMIT TIME
long submitTime = job.getSubmitTime();
Date submit = DateUtil.millisecondsToDate(submitTime);
// int completedEntry = 0;
// if(statusResponse.getCompletedEntries()>0)
// completedEntry = statusResponse.getCompletedEntries();
boolean changeStatus = false;
//if status is completed and job was saved, update status as saved
if(downloadState.equals(DownloadState.COMPLETED)){
if(job.getState().compareTo(DownloadState.SAVED.toString())==0){
downloadState = DownloadState.SAVED;
changeStatus = true;
}
}
int completedEntry = 0;
if(statusResponse.getCompletedEntries()>0)
completedEntry = statusResponse.getCompletedEntries();
//TODO
jobGisModel = new JobGisLayerModel(job.getId(), job.getName(), downloadState, completedEntry, job.getTotalPoints());
jobGisModel.setSubmitTime(submit);
try{
boolean changeEndTime = false;
//UPDATE END TIME
if(downloadState.equals(DownloadState.FAILED) || downloadState.equals(DownloadState.COMPLETED)){
if(statusResponse.getEndDate()!=null && job.getEndTime()==0){ //UPDATE end time first time only
logger.trace("UPDATE end time first time only - " + downloadState);
endTime = statusResponse.getEndDate().getTimeInMillis();
job.setEndTime(endTime);
changeEndTime = true;
}
}
boolean changeStartTime = false;
//SET START TIME
long startTime = job.getStartTime();
if(statusResponse.getStartDate()!=null && startTime==0){ //UPDATE start time first time only
Date start = DateUtil.millisecondsToDate(statusResponse.getStartDate().getTimeInMillis());
jobGisModel.setStartTime(start);
changeStartTime = true;
}
//UPDATE DAO
if(changeStatus || changeEndTime || changeStartTime){
job.setState(downloadState.toString());
gisLayerJobP.update(job);
}
}catch (Exception e) {
logger.error("An error occurred on update the occurrencesJobDao ", e);
}
endTime = job.getEndTime();
long elapsedTime = 0;
//SET END TIME, BECAUSE IT IS CHANGED
if(endTime!=0){
Date end = DateUtil.millisecondsToDate(endTime);
jobGisModel.setEndTime(end);
elapsedTime = endTime;
}
else
elapsedTime = Calendar.getInstance().getTimeInMillis();
//SET ELAPSED TIME
jobGisModel.setElapsedTime(DateUtil.getDifference(submitTime, elapsedTime));
return jobGisModel;
}
/**
* Gets the download state.
*
* @param status the status
* @return the download state
*/
public static DownloadState getDownloadState(JobStatus status){
if(status!=null){
switch (status) {
case COMPLETED:
return DownloadState.COMPLETED;
case FAILED:
return DownloadState.FAILED;
case PENDING:
return DownloadState.PENDING;
case RUNNING:
return DownloadState.ONGOING;
default:
return null;
}
}
return null;
}
/**
* Delete gis layer job by id.
*
* @param jobIdentifier the job identifier
* @param gisLayerJobDao the gis layer job dao
* @return the int
*/
public static int deleteGisLayerJobById(String jobIdentifier, GisLayerJobPersistence gisLayerJobDao){
logger.trace("Delete gis layer job id: " + jobIdentifier);
try{
int removed = gisLayerJobDao.deleteItemByIdField(jobIdentifier);
return 1;
}catch (Exception e) {
logger.error("An error occured deleteGisLayerJobById jobId: " + jobIdentifier + " exception: "+e, e);
}
logger.trace("job not exists : " +jobIdentifier);
return 0;
}
}

View File

@ -1,57 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.server.job;
import java.util.Calendar;
import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.portlets.user.speciesdiscovery.server.persistence.dao.GisLayerJobPersistence;
import org.gcube.portlets.user.speciesdiscovery.server.service.SpeciesService;
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
import org.gcube.portlets.user.speciesdiscovery.shared.GisLayerJob;
import org.gcube.portlets.user.speciesdiscovery.shared.JobGisLayerModel;
/**
* The Class GisLinkJobUtil.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 9, 2017
*/
public class GisLinkJobUtil {
protected static Logger logger = Logger.getLogger(GisLinkJobUtil.class);
/**
* Creates the gis layer job by occurrence keys.
*
* @param occurrenceKeys the occurrence keys
* @param taxonomyService the taxonomy service
* @param layerTitle the layer title
* @param layerDescr the layer descr
* @param author the author
* @param credits the credits
* @param gisLayerJob the gis layer job
* @return the job gis layer model
* @throws Exception the exception
*/
public static JobGisLayerModel createGisLayerJobByOccurrenceKeys(List<String> occurrenceKeys, SpeciesService taxonomyService, String layerTitle, String layerDescr, String author, String credits, GisLayerJobPersistence gisLayerJob) throws Exception {
try {
logger.trace("Generating Map form Occurrence Keys selected: "+occurrenceKeys.size());
String jobId = taxonomyService.generateMapFromOccurrenceKeys(occurrenceKeys,layerTitle,layerDescr,author,credits);
logger.info("generated gis layer jobID: "+jobId);
GisLayerJob gisLJ = new GisLayerJob(jobId, layerTitle, 0, Calendar.getInstance().getTimeInMillis(), 0, layerDescr, DownloadState.PENDING.toString());
gisLayerJob.insert(gisLJ);
return new JobGisLayerModel(jobId, layerTitle, 0, Calendar.getInstance().getTimeInMillis(), 0, layerDescr, DownloadState.PENDING.toString());
} catch (Exception e) {
logger.error("An error occurred creating the map", e);
throw new Exception(e.getMessage());
}
}
}

View File

@ -469,9 +469,8 @@ public class SpeciesService {
} }
/** /**
* Generate map from occurrence keys. * Generate gis layer from occurrence keys.
* *
* @param occurrenceKeys the occurrence keys * @param occurrenceKeys the occurrence keys
* @param layerTitle the layer title * @param layerTitle the layer title
@ -481,7 +480,7 @@ public class SpeciesService {
* @return the string * @return the string
* @throws SearchServiceException the search service exception * @throws SearchServiceException the search service exception
*/ */
public String generateMapFromOccurrenceKeys(List<String> occurrenceKeys, String layerTitle, String layerDescr, String author, String credits) throws SearchServiceException { public String generateGisLayerFromOccurrenceKeys(List<String> occurrenceKeys, String layerTitle, String layerDescr, String author, String credits) throws SearchServiceException {
try { try {
ExecutorClient creator = AbstractPlugin.executor().build(); ExecutorClient creator = AbstractPlugin.executor().build();
@ -497,6 +496,69 @@ public class SpeciesService {
} }
} }
/**
* Gets the gis layer by job id.
*
* @param serverJobId the server job id
* @return the gis layer by job id
* @throws SearchServiceException the search service exception
*/
public CompleteJobStatus getGisLayerByJobId(String serverJobId) throws SearchServiceException {
try {
ExecutorClient creator = AbstractPlugin.executor().build();
return creator.getStatus(serverJobId);
}
catch (InvalidIdentifierException e) {
logger.error(
"Error calling the Species Service: " + e.getMessage(), e);
throw new SearchServiceException(
"Error calling the Species Service: " + e.getMessage());
}
}
/**
* Gets the gis layer result link by job id.
*
* @param serverJobId the server job id
* @return the gis layer result link by job id
* @throws SearchServiceException the search service exception
*/
public String getGisLayerResultLinkByJobId(String serverJobId) throws SearchServiceException {
try {
ExecutorClient creator = AbstractPlugin.executor().build();
return creator.getResultLink(serverJobId);
}
catch (InvalidIdentifierException e) {
logger.error(
"Error calling the Species Service: " + e.getMessage(), e);
throw new SearchServiceException(
"Error calling the Species Service: " + e.getMessage());
}
}
/**
* Removes the gis layer by job id.
*
* @param serverJobId the server job id
* @return the string
* @throws SearchServiceException the search service exception
*/
public void removeGisLayerByJobId(String serverJobId) {
try {
ExecutorClient creator = AbstractPlugin.executor().build();
creator.removeJob(serverJobId);
}
catch (Exception e) {
logger.error(
"Error calling the Species Service: " + e.getMessage(), e);
}
}
/** /**
* Gets the taxon children by parent id. * Gets the taxon children by parent id.
* *
@ -711,12 +773,8 @@ public class SpeciesService {
public CompleteJobStatus getOccurrenceJobById(String jobId) { public CompleteJobStatus getOccurrenceJobById(String jobId) {
try { try {
return this.executorCall.getStatus(jobId); // CHANGE INTO OCCURRENCE return this.executorCall.getStatus(jobId);
// JOB }catch (InvalidIdentifierException e) {
// **************************************************************************************
// //TODO
}
catch (InvalidIdentifierException e) {
logger.error("Error on service for get job by Id - InvalidIdentifierException"); logger.error("Error on service for get job by Id - InvalidIdentifierException");
return null; return null;
} }

View File

@ -12,77 +12,121 @@ import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Days; import org.joda.time.Days;
/**
* The Class DateUtil.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 10, 2017
*/
public class DateUtil { public class DateUtil {
/**
* The Enum TIMETYPE.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 10, 2017
*/
public static enum TIMETYPE{DAYS, HOURS, MINUTES, SECONDS}; public static enum TIMETYPE{DAYS, HOURS, MINUTES, SECONDS};
public static Logger logger = Logger.getLogger(DateUtil.class); public static Logger logger = Logger.getLogger(DateUtil.class);
public static final String DATE_TIME_FORMAT = "yyyy.MM.dd 'at' HH:mm:ss"; public static final String DATE_TIME_FORMAT = "yyyy.MM.dd 'at' HH:mm:ss";
public static final String DATE_TIME_FORMAT_2 = "dd-MM, yyyy HH:mm:ss z"; public static final String DATE_TIME_FORMAT_2 = "dd-MM, yyyy HH:mm:ss z";
/**
* To date.
*
* @param calendar the calendar
* @return the date
*/
public static Date toDate(Calendar calendar) public static Date toDate(Calendar calendar)
{ {
if (calendar == null) return new Date(0); if (calendar == null) return new Date(0);
return calendar.getTime(); return calendar.getTime();
} }
/**
* To date format to string.
*
* @param calendar the calendar
* @return the string
*/
public static String toDateFormatToString(Calendar calendar){ public static String toDateFormatToString(Calendar calendar){
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT);
Date resultdate = getDate(calendar); Date resultdate = getDate(calendar);
return dateFormat.format(resultdate); return dateFormat.format(resultdate);
} }
/**
* To date format.
*
* @param calendar the calendar
* @return the date
*/
public static Date toDateFormat(Calendar calendar){ public static Date toDateFormat(Calendar calendar){
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT);
Date resultdate = getDate(calendar); Date resultdate = getDate(calendar);
try { try {
resultdate = dateFormat.parse(dateFormat.format(resultdate)); resultdate = dateFormat.parse(dateFormat.format(resultdate));
} catch (ParseException e) { } catch (ParseException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resultdate = new Date(0); resultdate = new Date(0);
} }
return resultdate; return resultdate;
} }
/**
* Gets the date format.
*
* @param calendar the calendar
* @return the date format
*/
public static Date getDateFormat(Calendar calendar){ public static Date getDateFormat(Calendar calendar){
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT);
Date resultdate = null; Date resultdate = null;
if (calendar == null) if (calendar == null)
resultdate = new Date(0); resultdate = new Date(0);
else else
resultdate = getDate(calendar); resultdate = getDate(calendar);
try { try {
resultdate = dateFormat.parse(dateFormat.format(resultdate)); resultdate = dateFormat.parse(dateFormat.format(resultdate));
} catch (ParseException e) { } catch (ParseException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resultdate = new Date(0); resultdate = new Date(0);
} }
return resultdate; return resultdate;
} }
/**
* Gets the date.
*
* @param calendar the calendar
* @return the date
*/
public static Date getDate(Calendar calendar) { public static Date getDate(Calendar calendar) {
Date resultdate = null; Date resultdate = null;
@ -95,28 +139,40 @@ public class DateUtil {
return resultdate; return resultdate;
} }
/**
* String to date format.
*
* @param date the date
* @return the date
*/
public static Date stringToDateFormat(String date){ public static Date stringToDateFormat(String date){
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT);
Date resultdate = null; Date resultdate = null;
try { try {
resultdate = dateFormat.parse(date); resultdate = dateFormat.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resultdate = new Date(0); resultdate = new Date(0);
} }
return resultdate; return resultdate;
} }
/**
* Date to date format string.
*
* @param date the date
* @return the string
*/
public static String dateToDateFormatString(Date date){ public static String dateToDateFormatString(Date date){
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT);
String dateString = null; String dateString = null;
if(date!=null) if(date!=null)
dateString = dateFormat.format(date); dateString = dateFormat.format(date);
else else
@ -124,42 +180,57 @@ public class DateUtil {
return dateString; return dateString;
} }
/**
* Milliseconds to date.
*
* @param milliseconds the milliseconds
* @return the date
*/
public static Date millisecondsToDate(long milliseconds){ public static Date millisecondsToDate(long milliseconds){
Date date = null; Date date = null;
try { try {
date= new Date(milliseconds); date= new Date(milliseconds);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
date = new Date(0); date = new Date(0);
} }
return date; return date;
} }
/**
* Gets the difference.
*
* @param date1 the date1
* @param date2 the date2
* @param timeType the time type
* @return the difference
*/
public static long getDifference(long date1, long date2, TIMETYPE timeType){ public static long getDifference(long date1, long date2, TIMETYPE timeType){
// Calculates the difference in milliseconds. // Calculates the difference in milliseconds.
long millisDiff = date2 - date1; long millisDiff = date2 - date1;
switch (timeType) { switch (timeType) {
case DAYS: return (long) (millisDiff / 86400000); case DAYS: return millisDiff / 86400000;
case HOURS: return (long) (millisDiff / 3600000 % 24); case HOURS: return millisDiff / 3600000 % 24;
case MINUTES: return (long) (millisDiff / 60000 % 60); case MINUTES: return millisDiff / 60000 % 60;
case SECONDS: return (long) (millisDiff / 1000 % 60); case SECONDS: return millisDiff / 1000 % 60;
default: default:
return (long) (millisDiff / 1000 % 60); return millisDiff / 1000 % 60;
} }
} }
/** /**
* * Gets the difference.
* @param date1 *
* @param date2 * @param date1 the date1
* @param date2 the date2
* @return difference between two date in this format: N°day/days HH:mm:ss * @return difference between two date in this format: N°day/days HH:mm:ss
*/ */
public static String getDifference(long date1, long date2){ public static String getDifference(long date1, long date2){
@ -169,14 +240,14 @@ public class DateUtil {
DateFormat outFormat = new SimpleDateFormat(ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS); DateFormat outFormat = new SimpleDateFormat(ConstantsSpeciesDiscovery.TIMEFORMAT_HH_MM_SS);
outFormat.setTimeZone(TimeZone.getTimeZone(ConstantsSpeciesDiscovery.TIME_ZONE_UTC)); outFormat.setTimeZone(TimeZone.getTimeZone(ConstantsSpeciesDiscovery.TIME_ZONE_UTC));
int days = Days.daysBetween(new DateTime(date1), new DateTime(date2)).getDays(); int days = Days.daysBetween(new DateTime(date1), new DateTime(date2)).getDays();
if(days>0){ if(days>0){
String hours = outFormat.format(date); String hours = outFormat.format(date);
return days==1?days + " Day, "+hours:days + " Days, "+hours; return days==1?days + " Day, "+hours:days + " Days, "+hours;
} }
else else
return outFormat.format(date); return outFormat.format(date);
} }
} }

View File

@ -25,6 +25,7 @@ public class DefaultJob implements Serializable{
public final static String SUBMITTIME = "submitTime"; public final static String SUBMITTIME = "submitTime";
public final static String ENDTIME = "endTime"; public final static String ENDTIME = "endTime";
public static final String STATE = "state"; public static final String STATE = "state";
public static final String ELAPSEDTIME = "Elapsed Time";
protected String id; protected String id;
protected String name; protected String name;
@ -33,6 +34,8 @@ public class DefaultJob implements Serializable{
protected long endTime; protected long endTime;
protected String description; protected String description;
protected String state; protected String state;
protected long elapsedTime;
/** /**
* *
@ -42,21 +45,22 @@ public class DefaultJob implements Serializable{
} }
/** /**
* Instantiates a new default job. * @param id
* * @param name
* @param id the id * @param startTime
* @param name the name * @param submitTime
* @param startTime the start time * @param endTime
* @param submitTime the submit time * @param description
* @param endTime the end time * @param state
* @param description the description * @param elapsedTime
* @param state the state
*/ */
public DefaultJob( public DefaultJob(
String id, String name, long startTime, long submitTime, long endTime, String id, String name, long startTime, long submitTime, long endTime,
String description, String state) { String description, String state, long elapsedTime) {
super();
this.id = id; this.id = id;
this.name = name; this.name = name;
this.startTime = startTime; this.startTime = startTime;
@ -64,137 +68,187 @@ public class DefaultJob implements Serializable{
this.endTime = endTime; this.endTime = endTime;
this.description = description; this.description = description;
this.state = state; this.state = state;
this.elapsedTime = elapsedTime;
} }
/** /**
* @return the id * @return the id
*/ */
public String getId() { public String getId() {
return id; return id;
} }
/** /**
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* @return the startTime * @return the startTime
*/ */
public long getStartTime() { public long getStartTime() {
return startTime; return startTime;
} }
/** /**
* @return the submitTime * @return the submitTime
*/ */
public long getSubmitTime() { public long getSubmitTime() {
return submitTime; return submitTime;
} }
/** /**
* @return the endTime * @return the endTime
*/ */
public long getEndTime() { public long getEndTime() {
return endTime; return endTime;
} }
/** /**
* @return the description * @return the description
*/ */
public String getDescription() { public String getDescription() {
return description; return description;
} }
/** /**
* @return the state * @return the state
*/ */
public String getState() { public String getState() {
return state; return state;
} }
/**
* @return the elapsedTime
*/
public long getElapsedTime() {
return elapsedTime;
}
/** /**
* @param id the id to set * @param id the id to set
*/ */
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
/** /**
* @param name the name to set * @param name the name to set
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* @param startTime the startTime to set * @param startTime the startTime to set
*/ */
public void setStartTime(long startTime) { public void setStartTime(long startTime) {
this.startTime = startTime; this.startTime = startTime;
} }
/** /**
* @param submitTime the submitTime to set * @param submitTime the submitTime to set
*/ */
public void setSubmitTime(long submitTime) { public void setSubmitTime(long submitTime) {
this.submitTime = submitTime; this.submitTime = submitTime;
} }
/** /**
* @param endTime the endTime to set * @param endTime the endTime to set
*/ */
public void setEndTime(long endTime) { public void setEndTime(long endTime) {
this.endTime = endTime; this.endTime = endTime;
} }
/** /**
* @param description the description to set * @param description the description to set
*/ */
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
/** /**
* @param state the state to set * @param state the state to set
*/ */
public void setState(String state) { public void setState(String state) {
this.state = state; this.state = state;
} }
/**
* @param elapsedTime the elapsedTime to set
*/
public void setElapsedTime(long elapsedTime) {
this.elapsedTime = elapsedTime;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@ -216,8 +270,13 @@ public class DefaultJob implements Serializable{
builder.append(description); builder.append(description);
builder.append(", state="); builder.append(", state=");
builder.append(state); builder.append(state);
builder.append(", elapsedTime=");
builder.append(elapsedTime);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -19,6 +19,7 @@ public class GisLayerJob extends DefaultJob{
* *
*/ */
private static final long serialVersionUID = 2604265579184366453L; private static final long serialVersionUID = 2604265579184366453L;
private long totalPoints;
/** /**
@ -42,8 +43,31 @@ public class GisLayerJob extends DefaultJob{
*/ */
public GisLayerJob( public GisLayerJob(
String id, String name, long startTime, long submitTime, long endTime, String id, String name, long startTime, long submitTime, long endTime,
String description, String state) { long elapsedTime, String description, String state, long totalPoints) {
super(id, name, startTime, submitTime, endTime, description, state); super(id, name, startTime, submitTime, endTime, description, state, elapsedTime);
this.totalPoints = totalPoints;
}
/**
* @return the totalPoints
*/
public long getTotalPoints() {
return totalPoints;
}
/**
* @param totalPoints the totalPoints to set
*/
public void setTotalPoints(long totalPoints) {
this.totalPoints = totalPoints;
} }
@ -54,7 +78,29 @@ public class GisLayerJob extends DefaultJob{
@Override @Override
public String toString() { public String toString() {
return super.toString(); StringBuilder builder = new StringBuilder();
builder.append("GisLayerJob [totalPoints=");
builder.append(totalPoints);
builder.append(", id=");
builder.append(id);
builder.append(", name=");
builder.append(name);
builder.append(", startTime=");
builder.append(startTime);
builder.append(", submitTime=");
builder.append(submitTime);
builder.append(", endTime=");
builder.append(endTime);
builder.append(", description=");
builder.append(description);
builder.append(", state=");
builder.append(state);
builder.append(", elapsedTime=");
builder.append(elapsedTime);
builder.append("]");
return builder.toString();
} }
} }

View File

@ -3,6 +3,9 @@
*/ */
package org.gcube.portlets.user.speciesdiscovery.shared; package org.gcube.portlets.user.speciesdiscovery.shared;
import java.io.Serializable;
import java.util.Date;
@ -12,50 +15,348 @@ package org.gcube.portlets.user.speciesdiscovery.shared;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 9, 2017 * Feb 9, 2017
*/ */
public class JobGisLayerModel extends DefaultJob{ public class JobGisLayerModel implements Serializable{
/** /**
* *
*/ */
private static final long serialVersionUID = 8754068044391917378L; private static final long serialVersionUID = -8982510983374359781L;
public static final String JOBNAME = "Layer Title";
public static final String JOBINDENTIFIER = "jobIdentifier";
public static final String STARTTIME = "Start Time";
public static final String SUBMITTIME = "Submit Time";
public static final String PROGRESS = "Progress";
public static final String ENDTIME = "End Time";
public static final String ELAPSEDTIME = "Elapsed Time";
public static final String PERCENTAGE = "Percentage";
public static final String DESCRIPTION = "Description";
public static final String STATUS = "Status";
private String jobIdentifier;
private String jobName;
private DownloadState downloadState;
protected Date startTime;
protected Date submitTime;
protected Date endTime;
protected String elapsedTime;
private String layerDescription;
private float percentage;
private long totalPoints;
private long completedPoints;
/** /**
* Instantiates a new gis layer job. * Instantiates a new job gis layer model.
*/ */
public JobGisLayerModel() { public JobGisLayerModel() {
} }
/** /**
* Instantiates a new gis layer job. * Instantiates a new job gis layer model.
* *
* @param id the id * @param jobIdentifier the job identifier
* @param name the name * @param layerTitle the layer title
* @param startTime the start time * @param downloadState the download state
* @param submitTime the submit time * @param completedPoints the completed points
* @param endTime the end time * @param totalPoints the total points
* @param description the description
* @param state the state
*/ */
public JobGisLayerModel( public JobGisLayerModel(String jobIdentifier, String layerTitle, DownloadState downloadState, long completedPoints, long totalPoints) {
String id, String name, long startTime, long submitTime, long endTime, this.jobIdentifier = jobIdentifier;
String description, String state) { this.jobName = layerTitle;
super(id, name, startTime, submitTime, endTime, description, state); this.downloadState = downloadState;
this.completedPoints = completedPoints;
this.totalPoints = totalPoints;
} }
/**
* @param jobIdentifier
* @param jobName
* @param downloadState
* @param startTime
* @param submitTime
* @param endTime
* @param elapsedTime
* @param layerDescription
* @param percentage
* @param totalPoints
* @param completedPoints
*/
public JobGisLayerModel(
String jobIdentifier, String jobName, DownloadState downloadState,
Date startTime, Date submitTime, Date endTime, String elapsedTime,
String layerDescription, long completedPoints,
long totalPoints) {
super();
this.jobIdentifier = jobIdentifier;
this.jobName = jobName;
this.downloadState = downloadState;
this.startTime = startTime;
this.submitTime = submitTime;
this.endTime = endTime;
this.elapsedTime = elapsedTime;
this.layerDescription = layerDescription;
this.totalPoints = totalPoints;
this.completedPoints = completedPoints;
this.percentage = completedPoints!=0?completedPoints*100/totalPoints:0;
}
/**
* @return the jobIdentifier
*/
public String getJobIdentifier() {
return jobIdentifier;
}
/**
* @return the jobName
*/
public String getJobName() {
return jobName;
}
/**
* @return the downloadState
*/
public DownloadState getDownloadState() {
return downloadState;
}
/**
* @return the startTime
*/
public Date getStartTime() {
return startTime;
}
/**
* @return the submitTime
*/
public Date getSubmitTime() {
return submitTime;
}
/**
* @return the endTime
*/
public Date getEndTime() {
return endTime;
}
/**
* @return the elapsedTime
*/
public String getElapsedTime() {
return elapsedTime;
}
/**
* @return the layerDescription
*/
public String getLayerDescription() {
return layerDescription;
}
/**
* @return the percentage
*/
public float getPercentage() {
return percentage;
}
/**
* @return the totalPoints
*/
public long getTotalPoints() {
return totalPoints;
}
/**
* @return the completedPoints
*/
public long getCompletedPoints() {
return completedPoints;
}
/**
* @param jobIdentifier the jobIdentifier to set
*/
public void setJobIdentifier(String jobIdentifier) {
this.jobIdentifier = jobIdentifier;
}
/**
* @param jobName the jobName to set
*/
public void setJobName(String jobName) {
this.jobName = jobName;
}
/**
* @param downloadState the downloadState to set
*/
public void setDownloadState(DownloadState downloadState) {
this.downloadState = downloadState;
}
/**
* @param startTime the startTime to set
*/
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
/**
* @param submitTime the submitTime to set
*/
public void setSubmitTime(Date submitTime) {
this.submitTime = submitTime;
}
/**
* @param endTime the endTime to set
*/
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
/**
* @param elapsedTime the elapsedTime to set
*/
public void setElapsedTime(String elapsedTime) {
this.elapsedTime = elapsedTime;
}
/**
* @param layerDescription the layerDescription to set
*/
public void setLayerDescription(String layerDescription) {
this.layerDescription = layerDescription;
}
/**
* @param percentage the percentage to set
*/
public void setPercentage(float percentage) {
this.percentage = percentage;
}
/**
* @param totalPoints the totalPoints to set
*/
public void setTotalPoints(int totalPoints) {
this.totalPoints = totalPoints;
}
/**
* @param completedPoints the completedPoints to set
*/
public void setCompletedPoints(int completedPoints) {
this.completedPoints = completedPoints;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
return super.toString(); StringBuilder builder = new StringBuilder();
builder.append("JobGisLayerModel [jobIdentifier=");
builder.append(jobIdentifier);
builder.append(", jobName=");
builder.append(jobName);
builder.append(", downloadState=");
builder.append(downloadState);
builder.append(", startTime=");
builder.append(startTime);
builder.append(", submitTime=");
builder.append(submitTime);
builder.append(", endTime=");
builder.append(endTime);
builder.append(", elapsedTime=");
builder.append(elapsedTime);
builder.append(", layerDescription=");
builder.append(layerDescription);
builder.append(", percentage=");
builder.append(percentage);
builder.append(", totalPoints=");
builder.append(totalPoints);
builder.append(", completedPoints=");
builder.append(completedPoints);
builder.append("]");
return builder.toString();
} }
} }

View File

@ -1,34 +1,54 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.speciesdiscovery.shared; package org.gcube.portlets.user.speciesdiscovery.shared;
/** /**
* @author "Federico De Faveri defaveri@isti.cnr.it" * The Enum SearchResultType.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 10, 2017
*/ */
public enum SearchResultType { public enum SearchResultType {
SPECIES_PRODUCT("RESULTITEM", "Occurrences"), SPECIES_PRODUCT("RESULTITEM", "Occurrences"),
TAXONOMY_ITEM("TAXONOMYITEM", "Taxonomy"), TAXONOMY_ITEM("TAXONOMYITEM", "Taxonomy"),
OCCURRENCE_POINT("OCCURRENCESPOINTS", "OccurrencesPoints"); OCCURRENCE_POINT("OCCURRENCESPOINTS", "OccurrencesPoints"),
GIS_LAYER_POINT("GIS_LAYER_POINT", "GisLayerPoints");
private String id; private String id;
private String name; private String name;
/**
* Instantiates a new search result type.
*
* @param id the id
* @param name the name
*/
private SearchResultType(String id, String name) { private SearchResultType(String id, String name) {
this.id = id; this.id = id;
this.name = name; this.name = name;
} }
/**
* Gets the id.
*
* @return the id
*/
public String getId() { public String getId() {
return id; return id;
} }
/**
* Gets the name.
*
* @return the name
*/
public String getName() { public String getName() {
return name; return name;
} }