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

@ -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";

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

@ -3,6 +3,7 @@
*/ */
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;
@ -24,15 +25,18 @@ public class ReSubmitJobEvent extends GwtEvent<ReSubmitJobEventHandler> {
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() {

View File

@ -6,6 +6,7 @@ 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,9 +14,9 @@ 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> {
@ -27,12 +28,20 @@ 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);
@ -40,13 +49,14 @@ public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> {
/** /**
* Instantiates a new save job error event.
* *
* @param jobIdentifier * @param jobIdentifier the job identifier
* @param scientificName * @param scientificName the scientific name
* @param listDataSource * @param dataSourceList the data source list
* @param rank * @param rank the rank
* @param type * @param type the type
* @param jobTaxonomyModel * @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;
@ -58,13 +68,30 @@ public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> {
} }
/** /**
* Instantiates a new save job error event.
* *
* @param jobIdentifier * @param jobIdentifier the job identifier
* @param scientificName * @param layerTitle the layer title
* @param dataSourceList * @param jobGisLayer the job gis layer
* @param type * @param type the type
* @param jobOccurrenceModel */
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;
@ -75,46 +102,101 @@ public class SaveJobErrorEvent extends GwtEvent<SaveJobErrorEventHandler> {
} }
/**
* 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

@ -6,6 +6,7 @@ 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;
@ -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() {
@ -75,6 +78,25 @@ public class SaveJobEvent extends GwtEvent<SaveJobEventHandler> {
} }
/**
*
* @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;
} }

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;
@ -28,10 +29,13 @@ public class SpeciesJobPanel extends ContentPanel{
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;
@ -42,27 +46,25 @@ public class SpeciesJobPanel extends ContentPanel{
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");
} }
@ -111,6 +113,26 @@ public class SpeciesJobPanel extends ContentPanel{
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);
} }
@ -130,31 +152,50 @@ public class SpeciesJobPanel extends ContentPanel{
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();
}
public void setIconGisLayerByCounter(int count){
this.jobGisLayerCount += count;
switch (jobGisLayerCount) {
case 0:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getGlobe()));
break;
case 1:
btnGisLayerJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace1()));
break;
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(); 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

@ -436,7 +436,7 @@ public class OccurrenceGridJob extends ContentPanel{
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{

View File

@ -453,7 +453,7 @@ public class TaxonomyGridJob extends ContentPanel{
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{

View File

@ -171,8 +171,15 @@ public interface Resources extends ClientBundle {
@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;
@ -332,9 +332,9 @@ public class ViewDetailsWindow extends Window {
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);
@ -342,7 +342,7 @@ public class ViewDetailsWindow extends Window {
@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));
} }
}); });
@ -662,39 +662,39 @@ public class ViewDetailsWindow extends Window {
//TEST // //TEST
public Button createButtonSaveAsHtml(){ // public Button createButtonSaveAsHtml(){
//
ToolBar toolbar = new ToolBar(); // ToolBar toolbar = new ToolBar();
//
Button btnExportAsHtml = new Button("Export As Html"); // Button btnExportAsHtml = new Button("Export As Html");
btnExportAsHtml.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts())); // 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.setToolTip(new ToolTipConfig("Show in Gis Viewer", "Show occurences points from selected results in a Gis Viewer Map."));
btnExportAsHtml.setScale(ButtonScale.SMALL); // btnExportAsHtml.setScale(ButtonScale.SMALL);
btnExportAsHtml.setIconAlign(IconAlign.TOP); // btnExportAsHtml.setIconAlign(IconAlign.TOP);
btnExportAsHtml.setArrowAlign(ButtonArrowAlign.BOTTOM); // btnExportAsHtml.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnExportAsHtml.addSelectionListener(new SelectionListener<ButtonEvent>() { // btnExportAsHtml.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
@Override // @Override
public void componentSelected(ButtonEvent ce) { // public void componentSelected(ButtonEvent ce) {
// searchController.getEventBus().fireEvent(new ShowOccurrencesMapEvent()); //// searchController.getEventBus().fireEvent(new ShowOccurrencesMapEvent());
//
String html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html>" + // 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\">" + // "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
"<style type=\"text/css\">" +getCssStyles() + // "<style type=\"text/css\">" +getCssStyles() +
"</style>" + // "</style>" +
"<title>"+lastSearchEvent.getSearchTerm()+"</title>" + // "<title>"+lastSearchEvent.getSearchTerm()+"</title>" +
"</head>" + // "</head>" +
" <body>"+panelDetails.getElement().getInnerHTML()+"</body>" + // " <body>"+panelDetails.getElement().getInnerHTML()+"</body>" +
"</html> "; // "</html> ";
//
// System.out.println(html); //// System.out.println(html);
} // }
}); // });
//
return btnExportAsHtml; // return btnExportAsHtml;
//
} // }
private String getCssStyles(){ private String getCssStyles(){

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,8 +12,22 @@ 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);
@ -24,6 +38,12 @@ public class DateUtil {
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);
@ -31,6 +51,12 @@ public class DateUtil {
} }
/**
* 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);
@ -41,6 +67,12 @@ public class DateUtil {
} }
/**
* 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);
@ -60,6 +92,12 @@ public class DateUtil {
} }
/**
* 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);
@ -83,6 +121,12 @@ public class DateUtil {
} }
/**
* 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;
@ -96,6 +140,12 @@ public class DateUtil {
} }
/**
* 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);
@ -112,6 +162,12 @@ public class DateUtil {
} }
/**
* 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);
@ -125,6 +181,12 @@ 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;
@ -139,27 +201,36 @@ public class DateUtil {
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 date1 the date1
* @param date2 * @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){

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,6 +68,7 @@ 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;
} }
@ -78,6 +83,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @return the name * @return the name
*/ */
@ -87,6 +94,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @return the startTime * @return the startTime
*/ */
@ -96,6 +105,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @return the submitTime * @return the submitTime
*/ */
@ -105,6 +116,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @return the endTime * @return the endTime
*/ */
@ -114,6 +127,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @return the description * @return the description
*/ */
@ -123,6 +138,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @return the state * @return the state
*/ */
@ -132,6 +149,19 @@ public class DefaultJob implements Serializable{
} }
/**
* @return the elapsedTime
*/
public long getElapsedTime() {
return elapsedTime;
}
/** /**
* @param id the id to set * @param id the id to set
*/ */
@ -141,6 +171,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @param name the name to set * @param name the name to set
*/ */
@ -150,6 +182,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @param startTime the startTime to set * @param startTime the startTime to set
*/ */
@ -159,6 +193,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @param submitTime the submitTime to set * @param submitTime the submitTime to set
*/ */
@ -168,6 +204,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @param endTime the endTime to set * @param endTime the endTime to set
*/ */
@ -177,6 +215,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @param description the description to set * @param description the description to set
*/ */
@ -186,6 +226,8 @@ public class DefaultJob implements Serializable{
} }
/** /**
* @param state the state to set * @param state the state to set
*/ */
@ -195,6 +237,18 @@ public class DefaultJob implements Serializable{
} }
/**
* @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

@ -3,32 +3,52 @@
*/ */
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;
} }