Removed unused code

Added check to avoid Timeout and Null row fetched (max attempts 5)

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@117433 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-07-22 15:19:38 +00:00
parent 030b1eeb45
commit 7822e080af
9 changed files with 276 additions and 610 deletions

View File

@ -930,7 +930,7 @@ public class SearchController {
case DARWIN_CORE: fileName += ".xml"; break; case DARWIN_CORE: fileName += ".xml"; break;
} }
final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save "+fileFormat.toString()+" As... ", fileName, true); final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save "+fileFormat.toString()+" As... ", fileName, false);
WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){ WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){
@ -1001,7 +1001,7 @@ public class SearchController {
private void saveTaxonomyJobErrorFile() { private void saveTaxonomyJobErrorFile() {
final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save the file with job Error/s As...", fileName, true); final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save the file with job Error/s As...", fileName, false);
WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){ WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){
@ -1056,7 +1056,7 @@ public class SearchController {
String fileName = jobTaxonomyModel.getName() +" from "+dataSourceName+" - DWCA.zip"; String fileName = jobTaxonomyModel.getName() +" from "+dataSourceName+" - DWCA.zip";
final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save DWCA As...", fileName, true); final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save DWCA As...", fileName, false);
WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){ WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){
@ -1139,7 +1139,7 @@ public class SearchController {
private void saveOccurrenceJobError() { private void saveOccurrenceJobError() {
final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save the Error File As...", fileName, true); final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save the Error File As...", fileName, false);
WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){ WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){
@ -1217,7 +1217,7 @@ public class SearchController {
String fileName = jobOccurrencesModel.getJobName() +" from "+dataSourceName+" - "+suffix+"."+extension; String fileName = jobOccurrencesModel.getJobName() +" from "+dataSourceName+" - "+suffix+"."+extension;
final String dataSources = dataSourceName; final String dataSources = dataSourceName;
final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save "+jobOccurrencesModel.getFileFormat().toString() +" As...", fileName, true); final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save "+jobOccurrencesModel.getFileFormat().toString() +" As...", fileName, false);
WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){ WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){
@Override @Override
@ -1308,7 +1308,7 @@ public class SearchController {
case DARWIN_CORE_ARCHIVE: fileName += ".zip"; break; case DARWIN_CORE_ARCHIVE: fileName += ".zip"; break;
} }
final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save "+fileFormat.toString() +" As...", fileName, true); final WorkspaceExplorerSaveDialog navigator = new WorkspaceExplorerSaveDialog("Save "+fileFormat.toString() +" As...", fileName, false);
WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){ WorskpaceExplorerSaveNotificationListener listener = new WorskpaceExplorerSaveNotificationListener(){
@Override @Override

View File

@ -41,7 +41,6 @@ import com.extjs.gxt.ui.client.widget.form.SimpleComboValue;
import com.extjs.gxt.ui.client.widget.form.TextArea; import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField; import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout; import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyCodes;
@ -491,7 +490,6 @@ public class SpeciesSearchFormPanel extends ContentPanel {
String searchTerm = searchField.getValue(); String searchTerm = searchField.getValue();
if (buttSimpleSearch.isEnabled() && searchTerm!=null && searchTerm.length()!=0) { if (buttSimpleSearch.isEnabled() && searchTerm!=null && searchTerm.length()!=0) {
GWT.log("search...");
// if(isActiveAdvanced){ // if(isActiveAdvanced){
search(searchTerm, search(searchTerm,
advSearchPanelsManager.getUpperBoundLatitudeField().getValue(), advSearchPanelsManager.getUpperBoundLatitudeField().getValue(),
@ -514,26 +512,9 @@ public class SpeciesSearchFormPanel extends ContentPanel {
protected void search(String searchTerm, Number upperBoundLongitude, Number upperBoundLatitude, Number lowerBoundLongitude, Number lowerBoundLatitude, Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String groupRank, SpeciesCapability resultType, List<DataSourceModel> listDataSourceForSynonyms, List<DataSourceModel> listDataSourceForUnfold) protected void search(String searchTerm, Number upperBoundLongitude, Number upperBoundLatitude, Number lowerBoundLongitude, Number lowerBoundLatitude, Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String groupRank, SpeciesCapability resultType, List<DataSourceModel> listDataSourceForSynonyms, List<DataSourceModel> listDataSourceForUnfold)
{ {
GWT.log("Searching...");
mask("Searching..."); mask("Searching...");
//searchButton.setEnabled(false); //searchButton.setEnabled(false);
/*
GWT.log(searchTerm);
GWT.log(upperBoundLongitude!=null?upperBoundLongitude.toString():"upperBoundLongitude");
GWT.log(upperBoundLatitude!=null? upperBoundLatitude.toString():"upperBoundLatitude");
GWT.log(lowerBoundLongitude!=null? lowerBoundLongitude.toString():"lowerBoundLongitude");
GWT.log(lowerBoundLatitude!=null? lowerBoundLatitude.toString():"lowerBoundLatitude");
GWT.log(fromDate!=null? fromDate.toString():"fromDate");
GWT.log(toDate!=null? toDate.toString():"toDate");
for (DataSourceModel dataSourceModel : listDataSources) {
GWT.log(dataSourceModel.toString());
}
GWT.log(groupRank);
GWT.log(resultType.toString());
GWT.log(listDataSourceForSynonyms!=null?listDataSourceForSynonyms.toString():"");
GWT.log(listDataSourceForUnfold!=null?listDataSourceForUnfold.toString():"");
*/
SearchType type = null; SearchType type = null;
if (ConstantsSpeciesDiscovery.SCIENTIFIC_NAME.equals(searchType.getSimpleValue())) type = SearchType.BY_SCIENTIFIC_NAME; if (ConstantsSpeciesDiscovery.SCIENTIFIC_NAME.equals(searchType.getSimpleValue())) type = SearchType.BY_SCIENTIFIC_NAME;
if (ConstantsSpeciesDiscovery.COMMON_NAME.equals(searchType.getSimpleValue())) type = SearchType.BY_COMMON_NAME; if (ConstantsSpeciesDiscovery.COMMON_NAME.equals(searchType.getSimpleValue())) type = SearchType.BY_COMMON_NAME;

View File

@ -442,8 +442,6 @@ public class OccurrenceGridJob extends ContentPanel{
else{ else{
String name = baseModelData.get(JobTaxonomyModel.JOBNAME); String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
MessageBox.alert(INFO, "The job "+ name+ " " + ConstantsSpeciesDiscovery.CAN_NOT_BE_RE_SUBMITTED_UNTIL_IT_HAS_COMPLETED, null); MessageBox.alert(INFO, "The job "+ name+ " " + ConstantsSpeciesDiscovery.CAN_NOT_BE_RE_SUBMITTED_UNTIL_IT_HAS_COMPLETED, null);
} }
} }
@ -451,7 +449,6 @@ public class OccurrenceGridJob extends ContentPanel{
private void createGridToolBar(){ private void createGridToolBar(){
buttonInfo = new Button(INFO); buttonInfo = new Button(INFO);
buttonInfo.setScale(ButtonScale.MEDIUM); buttonInfo.setScale(ButtonScale.MEDIUM);
buttonInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon())); buttonInfo.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getInfoIcon()));

View File

@ -17,8 +17,9 @@ import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.user.client.ui.AbstractImagePrototype;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * The Class OccurrenceJobSpeciesPanel.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*/ */
public class OccurrenceJobSpeciesPanel extends ContentPanel { public class OccurrenceJobSpeciesPanel extends ContentPanel {
@ -48,12 +49,23 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
protected Window speciesJobWindow = new Window(); protected Window speciesJobWindow = new Window();
/**
* Gets the single instance of OccurrenceJobSpeciesPanel.
*
* @param eventBus the event bus
* @return single instance of OccurrenceJobSpeciesPanel
*/
public static synchronized OccurrenceJobSpeciesPanel getInstance(EventBus eventBus) { public static synchronized OccurrenceJobSpeciesPanel getInstance(EventBus eventBus) {
if (instance == null) if (instance == null)
instance = new OccurrenceJobSpeciesPanel(eventBus); instance = new OccurrenceJobSpeciesPanel(eventBus);
return instance; return instance;
} }
/**
* Instantiates a new occurrence job species panel.
*
* @param eventBus the event bus
*/
private OccurrenceJobSpeciesPanel(EventBus eventBus) { private OccurrenceJobSpeciesPanel(EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.gridJob = new OccurrenceGridJob(eventBus); this.gridJob = new OccurrenceGridJob(eventBus);
@ -64,6 +76,9 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
// createToolBar(); // createToolBar();
} }
/**
* Creates the species job window.
*/
private void createSpeciesJobWindow(){ private void createSpeciesJobWindow(){
lc = new LayoutContainer(); lc = new LayoutContainer();
@ -84,10 +99,9 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
lastOperation.setHtml(LASTOPERATION + OPERATIONONE); lastOperation.setHtml(LASTOPERATION + OPERATIONONE);
// cp.add(vp);
lc.add(lastOperation); lc.add(lastOperation);
lc.add(cp); lc.add(cp);
//
speciesJobWindow.setHeading(WINDOWTITLE); speciesJobWindow.setHeading(WINDOWTITLE);
speciesJobWindow.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace16px())); speciesJobWindow.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getBluePlace16px()));
speciesJobWindow.setSize(1020, 600); speciesJobWindow.setSize(1020, 600);
@ -96,50 +110,29 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
speciesJobWindow.add(lc); speciesJobWindow.add(lc);
} }
// private void createToolBar(){
// ToolBar toolbar = new ToolBar();
//
// Button btnJobs = new Button("Species Jobs");
// btnJobs.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getJob()));
//
// btnJobs.addSelectionListener(new SelectionListener<ButtonEvent>() {
//
// @Override
// public void componentSelected(ButtonEvent ce) {
//
// speciesJobWindow.show();
// }
//
// });
// toolbar.add(btnJobs);
// this.setTopComponent(toolbar);
// }
/** /**
* Adds the list job.
* *
* @param jobsModel * @param jobsModel the jobs model
* @return true if almost one progress bar is ongoing
*/ */
public boolean addListJob(List<JobOccurrencesModel> jobsModel){ public void addListJob(List<JobOccurrencesModel> jobsModel){
boolean isLoading = false;
for(final JobOccurrencesModel jobModel : jobsModel){
isLoading = addJob(jobModel);
}
return isLoading;
for(final JobOccurrencesModel jobModel : jobsModel)
addJob(jobModel);
} }
/**
* Adds the job.
*
* @param jobModel the job model
* @return true, if successful
*/
public boolean addJob(final JobOccurrencesModel jobModel){ public boolean addJob(final JobOccurrencesModel jobModel){
boolean isLoading = false; boolean isLoading = false;
// Log.trace("add job :" +jobModel);
OccurrenceJobSpeciesProgressBar jobsBar = hashProgressBars.get(jobModel.getJobIdentifier()); OccurrenceJobSpeciesProgressBar jobsBar = hashProgressBars.get(jobModel.getJobIdentifier());
if(jobsBar!=null){ //is update if(jobsBar!=null){ //is update
@ -159,22 +152,14 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
return true; return true;
} }
updateProgressBarView(jobsBar, jobModel); updateProgressBarView(jobsBar, jobModel);
gridJob.updateStatus(jobModel, jobsBar); gridJob.updateStatus(jobModel, jobsBar);
} }
else{ //create new grid item that contains new progress bar else{ //create new grid item that contains new progress bar
OccurrenceJobSpeciesProgressBar jobProgressBar = new OccurrenceJobSpeciesProgressBar(jobModel.getJobIdentifier(), jobModel.getDownloadState().toString()); OccurrenceJobSpeciesProgressBar jobProgressBar = new OccurrenceJobSpeciesProgressBar(jobModel.getJobIdentifier(), jobModel.getDownloadState().toString());
gridJob.addJobIntoGrid(jobModel, jobProgressBar); gridJob.addJobIntoGrid(jobModel, jobProgressBar);
updateProgressBarView(jobProgressBar, jobModel); updateProgressBarView(jobProgressBar, jobModel);
// hashTableContentPanels.put(jobModel.getIdentifier(), panelTable); //add contentPanel into hashTableContentPanels
hashProgressBars.put(jobModel.getJobIdentifier(), jobProgressBar); //add progressBar into hashProgressBars hashProgressBars.put(jobModel.getJobIdentifier(), jobProgressBar); //add progressBar into hashProgressBars
hashLoadCompletedNotify.put(jobModel.getJobIdentifier(), false); //add false (at load completed event) into hashLoadCompletedNotify hashLoadCompletedNotify.put(jobModel.getJobIdentifier(), false); //add false (at load completed event) into hashLoadCompletedNotify
} }
@ -186,6 +171,13 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
} }
/**
* Update progress bar view.
*
* @param jobsBar the jobs bar
* @param jobModel the job model
* @return true, if successful
*/
private boolean updateProgressBarView(OccurrenceJobSpeciesProgressBar jobsBar, JobOccurrencesModel jobModel){ private boolean updateProgressBarView(OccurrenceJobSpeciesProgressBar jobsBar, JobOccurrencesModel jobModel){
switch (jobModel.getDownloadState()) { switch (jobModel.getDownloadState()) {
@ -198,7 +190,6 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
case SAVING:{ case SAVING:{
lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " saving"); lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " saving");
jobsBar.getElement().getStyle().setBorderColor("#7093DB"); jobsBar.getElement().getStyle().setBorderColor("#7093DB");
// jobsBar.progressStart();
jobsBar.setProgressText(SAVING); jobsBar.setProgressText(SAVING);
break; break;
} }
@ -206,13 +197,10 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
case COMPLETED:{ case COMPLETED:{
lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " completed"); lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " completed");
jobsBar.getElement().getStyle().setBorderColor("#000000"); jobsBar.getElement().getStyle().setBorderColor("#000000");
// jobsBar.progressStop();
jobsBar.updateProgressWithoutPercentage(100); jobsBar.updateProgressWithoutPercentage(100);
jobsBar.setCompleted(true); jobsBar.setCompleted(true);
jobsBar.updateText(COMPLETED); jobsBar.updateText(COMPLETED);
break; break;
} }
@ -224,23 +212,16 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
jobsBar.setProgressText(SAVING); jobsBar.setProgressText(SAVING);
jobsBar.updateProgressWithPercentage(jobModel.getPercentage()); jobsBar.updateProgressWithPercentage(jobModel.getPercentage());
// jobsBar.progressStart();
return true; return true;
} }
case SAVED:{ case SAVED:{
lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " saved"); lastOperation.setHtml(LASTOPERATION + jobModel.getJobName() + " saved");
jobsBar.getElement().getStyle().setBorderColor("#000000"); jobsBar.getElement().getStyle().setBorderColor("#000000");
// jobsBar.progressStop();
jobsBar.updateProgressWithoutPercentage(100); jobsBar.updateProgressWithoutPercentage(100);
// jobsBar.updateProgressWithPercentage(jobModel.getPercentage(), jobModel.getDownloadState().toString());
jobsBar.setCompleted(true); jobsBar.setCompleted(true);
jobsBar.updateText(COMPLETED); jobsBar.updateText(COMPLETED);
break; break;
} }
@ -248,19 +229,16 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
jobsBar.getElement().getStyle().setBorderColor("#f00"); jobsBar.getElement().getStyle().setBorderColor("#f00");
jobsBar.updateText("loading " + jobModel.getJobName() + " with failures"); jobsBar.updateText("loading " + jobModel.getJobName() + " with failures");
break; break;
} }
case FAILED:{ case FAILED:{
jobsBar.getElement().getStyle().setBorderColor("#f00"); jobsBar.getElement().getStyle().setBorderColor("#f00");
// jobsBar.progressStop();
jobsBar.setProgressText(FAILED); jobsBar.setProgressText(FAILED);
jobsBar.updateProgressWithPercentage(jobModel.getPercentage()); jobsBar.updateProgressWithPercentage(jobModel.getPercentage());
jobsBar.setCompleted(true); jobsBar.setCompleted(true);
jobsBar.updateText(FAILED); jobsBar.updateText(FAILED);
break; break;
} }
@ -270,57 +248,50 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
jobsBar.updateText("loading " + jobModel.getJobName() + " with failures"); jobsBar.updateText("loading " + jobModel.getJobName() + " with failures");
jobsBar.updateProgressWithoutPercentage(100); jobsBar.updateProgressWithoutPercentage(100);
jobsBar.setCompleted(true); jobsBar.setCompleted(true);
break; break;
} }
} }
return false; return false;
} }
/**
* Removes the species job.
*
* @param hashHPKey the hash hp key
*/
public void removeSpeciesJob(String hashHPKey) { public void removeSpeciesJob(String hashHPKey) {
ContentPanel cp = hashTableContentPanels.get(hashHPKey); ContentPanel cp = hashTableContentPanels.get(hashHPKey);
vp.remove(cp); vp.remove(cp);
lastOperation.setHtml(LASTOPERATION + cp.getId() + " deleted"); lastOperation.setHtml(LASTOPERATION + cp.getId() + " deleted");
hashProgressBars.remove(hashHPKey); //remove progress bar from hash hashProgressBars.remove(hashHPKey); //remove progress bar from hash
hashTableContentPanels.remove(hashHPKey); //remove hp from hash hashTableContentPanels.remove(hashHPKey); //remove hp from hash
hashLoadCompletedNotify.remove(hashHPKey); //remove notify event hashLoadCompletedNotify.remove(hashHPKey); //remove notify event
vp.layout(); vp.layout();
} }
/**
* Delete progress completed.
*
* @param progressIdFound the progress id found
*/
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void deleteProgressCompleted(List<String> progressIdFound){ private void deleteProgressCompleted(List<String> progressIdFound){
List<String> progressIdNotFound = new ArrayList<String>(); List<String> progressIdNotFound = new ArrayList<String>();
for(String key : hashTableContentPanels.keySet()){ for(String key : hashTableContentPanels.keySet()){
// System.out.println("Key " + key );
if(!progressIdFound.contains(key)){ //if key isn't not found - progress is completed so is removed if(!progressIdFound.contains(key)){ //if key isn't not found - progress is completed so is removed
// System.out.println("Key is not present " + key );
OccurrenceJobSpeciesProgressBar bulkPB = hashProgressBars.get(key); OccurrenceJobSpeciesProgressBar bulkPB = hashProgressBars.get(key);
lastOperation.setHtml(LASTOPERATION + bulkPB.getProgressText() + " uploading completed"); lastOperation.setHtml(LASTOPERATION + bulkPB.getProgressText() + " uploading completed");
// bulkPB.updateProgress(100);
progressIdNotFound.add(key); progressIdNotFound.add(key);
} }
} }
for(String key : progressIdNotFound){ for(String key : progressIdNotFound){
OccurrenceJobSpeciesProgressBar bulkPB = hashProgressBars.get(key); OccurrenceJobSpeciesProgressBar bulkPB = hashProgressBars.get(key);
lastOperation.setHtml(LASTOPERATION + bulkPB.getProgressText() + " uploading completed"); lastOperation.setHtml(LASTOPERATION + bulkPB.getProgressText() + " uploading completed");
// vp.remove(hashHorizontalPanels.get(key)); //remove hp from view
hashProgressBars.remove(key); //remove progress bar from hash hashProgressBars.remove(key); //remove progress bar from hash
hashTableContentPanels.remove(key); //remove hp from hash hashTableContentPanels.remove(key); //remove hp from hash
} }
@ -329,10 +300,18 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
cp.layout(); cp.layout();
} }
/**
* Gets the species job window.
*
* @return the species job window
*/
public Window getSpeciesJobWindow() { public Window getSpeciesJobWindow() {
return speciesJobWindow; return speciesJobWindow;
} }
/**
* Reset structures.
*/
public void resetStructures(){ public void resetStructures(){
this.gridJob.resetStore(); this.gridJob.resetStore();
@ -343,10 +322,13 @@ public class OccurrenceJobSpeciesPanel extends ContentPanel {
hashLoadCompletedNotify.clear(); hashLoadCompletedNotify.clear();
} }
/**
* Gets the grid job.
*
* @return the grid job
*/
public OccurrenceGridJob getGridJob() { public OccurrenceGridJob getGridJob() {
return gridJob; return gridJob;
} }
} }

View File

@ -6,41 +6,14 @@ public class OccurrenceJobSpeciesProgressBar extends ProgressBar {
private String progressText; private String progressText;
private float progress; private float progress;
// private final Timer timer;
private boolean isCompleted = false; private boolean isCompleted = false;
public OccurrenceJobSpeciesProgressBar(String idJob, final String text) { public OccurrenceJobSpeciesProgressBar(String idJob, final String text) {
this.progressText = text; this.progressText = text;
setSize(140, 20); setSize(140, 20);
updateProgress(progress, text); updateProgress(progress, text);
// timer = new Timer() {
// float i;
//
// @Override
// public void run() {
// updateProgress(i / 100, progressText);
// i += 5;
// if (i > 105) {
// if(!isCompleted)
// i = 0;
// }
// }
// };
} }
/*
public void progressStart(){
timer.scheduleRepeating(500);
}
public void progressStop(){
timer.cancel();
}
*/
public void updateProgressWithoutPercentage(float counter) { public void updateProgressWithoutPercentage(float counter) {
progress = counter / 100; progress = counter / 100;
updateProgress(progress, progressText); updateProgress(progress, progressText);

View File

@ -14,8 +14,6 @@ public class TaxonomyJobSpeciesProgressBar extends ProgressBar {
this.progressText = text; this.progressText = text;
setSize(240, 20); setSize(240, 20);
// setBounds(10, 10, 200, Style.DEFAULT);
updateProgress(progress, text); updateProgress(progress, text);
timer = new Timer() { timer = new Timer() {

View File

@ -11,17 +11,27 @@ import org.gcube.portlets.user.speciesdiscovery.server.stream.CloseableIterator;
import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement; import org.gcube.portlets.user.speciesdiscovery.shared.FetchingElement;
/** /**
* The Class Fetcher.
*
* @author "Federico De Faveri defaveri@isti.cnr.it" * @author "Federico De Faveri defaveri@isti.cnr.it"
* *
* updated by Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @param <T> the generic type
*/ */
public class Fetcher<T extends FetchingElement> implements Runnable, Closeable { public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
protected Logger logger = Logger.getLogger(Fetcher.class); protected Logger logger = Logger.getLogger(Fetcher.class);
protected final int MAX_CONSECUTIVE_ATTEMPTS_ON_NULL = 5;
protected FetchingBuffer<T> buffer; protected FetchingBuffer<T> buffer;
protected CloseableIterator<T> source; protected CloseableIterator<T> source;
protected boolean complete = false; protected boolean complete = false;
/**
* Instantiates a new fetcher.
*
* @param source the source
* @param buffer the buffer
*/
public Fetcher(CloseableIterator<T> source, FetchingBuffer<T> buffer) { public Fetcher(CloseableIterator<T> source, FetchingBuffer<T> buffer) {
this.source = source; this.source = source;
this.complete = false; this.complete = false;
@ -29,6 +39,8 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
} }
/** /**
* Gets the source.
*
* @return the source * @return the source
*/ */
public CloseableIterator<T> getSource() { public CloseableIterator<T> getSource() {
@ -36,6 +48,8 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
} }
/** /**
* Sets the source.
*
* @param source the source to set * @param source the source to set
*/ */
public void setSource(CloseableIterator<T> source) { public void setSource(CloseableIterator<T> source) {
@ -50,6 +64,7 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
T next = null; T next = null;
int count = 0; int count = 0;
int countNullItems = 0;
try { try {
while(source!=null && source.hasNext() && !complete) { while(source!=null && source.hasNext() && !complete) {
@ -58,26 +73,26 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
next = source.next(); next = source.next();
if(next!=null){ if(next!=null){
logger.trace("item "+count++ +" fetch new row: "+next.getId()); logger.info("item "+count++ +" fetch new row: "+next.getId());
buffer.add(next); buffer.add(next);
} }
else{ else{
logger.trace("fetch new row: null"); countNullItems++;
logger.warn("fetch new row is null!! It is the number: "+countNullItems);
if(MAX_CONSECUTIVE_ATTEMPTS_ON_NULL==countNullItems){
logger.warn("Fetched "+MAX_CONSECUTIVE_ATTEMPTS_ON_NULL+ " null rows, MAX ATTEMPTS reached, complete fetch true and closing stream!!");
silentClose();
}
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("Error in source.next() " + e.getMessage(), e); logger.error("Error in source.next() " + e.getMessage(), e);
e.printStackTrace();
silentClose(); silentClose();
} }
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("Error in add row " + e.getMessage()); logger.error("Error in add row " + e.getMessage());
// System.out.println("Error in add row " + e.getMessage());
// e.printStackTrace();
silentClose(); silentClose();
} }
@ -86,10 +101,11 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
logger.trace("exit fetch run - complete true"); logger.trace("exit fetch run - complete true");
complete = true; complete = true;
// System.out.println("#################################TOTAL " + count);
} }
/**
* Silent close.
*/
protected void silentClose() protected void silentClose()
{ {
try { try {
@ -99,12 +115,20 @@ public class Fetcher<T extends FetchingElement> implements Runnable, Closeable {
} }
} }
/* (non-Javadoc)
* @see java.io.Closeable#close()
*/
public void close() throws IOException public void close() throws IOException
{ {
complete = true; complete = true;
source.close(); source.close();
} }
/**
* Checks if is complete.
*
* @return true, if is complete
*/
public boolean isComplete() public boolean isComplete()
{ {
return complete; return complete;

View File

@ -55,41 +55,33 @@ public class FetchingSession<T extends FetchingElement> implements Closeable {
public void startFetching() public void startFetching()
{ {
fetcherThread = new Thread(fetcher); fetcherThread = new Thread(fetcher);
logger.trace("###fetcherThread start"); logger.info("fetcherThread: "+fetcherThread.getId()+" start...");
// System.out.println("#######fetcherThread start"); // System.out.println("#######fetcherThread start");
fetcherThread.start(); fetcherThread.start();
} }
public void close() throws IOException public void close() throws IOException
{ {
new Thread(){ new Thread(){
@Override @Override
public void run() { public void run() {
try { try {
Long startTime = System.currentTimeMillis(); Long startTime = System.currentTimeMillis();
logger.trace("##new thread run for closing old fetcher... time: "+startTime); logger.trace("##new thread run for closing old fetcher... time: "+startTime);
fetcher.close(); fetcher.close();
//logger.trace("###fetcherThread close - OK");
Long endTime = System.currentTimeMillis() - startTime; Long endTime = System.currentTimeMillis() - startTime;
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
logger.trace("##old fetcher has been closed.. in " + time); logger.trace("##old fetcher has been closed.. in " + time);
logger.info("fetcherThread: "+fetcherThread.getId()+" closed!");
} catch (IOException e) { } catch (IOException e) {
logger.error("An error occurred in fetcher Thread close ",e); logger.error("An error occurred in fetcher Thread close ",e);
e.printStackTrace();
} }
}; };
}.start(); }.start();
} }
public boolean isComplete() public boolean isComplete(){
{
return fetcher.isComplete(); return fetcher.isComplete();
} }