enhancements on job saving.
enhancements on GUI, last query is displayed git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@79408 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b605cff75c
commit
b097c61612
|
@ -310,7 +310,7 @@ public class SearchController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!createOccurrenceJobEvent.isByDataSource()){ //ONE JOB FOR ALL DATASOURCE
|
if(!createOccurrenceJobEvent.isByDataSource()){ //ONE JOB FOR ALL DATASOURCE
|
||||||
|
/*
|
||||||
String jobName = createOccurrenceJobEvent.getSearchTerm() + " occurrences from";
|
String jobName = createOccurrenceJobEvent.getSearchTerm() + " occurrences from";
|
||||||
|
|
||||||
List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>();
|
List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>();
|
||||||
|
@ -319,6 +319,15 @@ public class SearchController {
|
||||||
dataSourceList.add(new org.gcube.portlets.user.speciesdiscovery.shared.DataSource(dataSource,dataSource));
|
dataSourceList.add(new org.gcube.portlets.user.speciesdiscovery.shared.DataSource(dataSource,dataSource));
|
||||||
jobName+=" "+dataSource;
|
jobName+=" "+dataSource;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
String jobName = createOccurrenceJobEvent.getSearchTerm() + " occurrences";
|
||||||
|
|
||||||
|
List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>();
|
||||||
|
|
||||||
|
for (String dataSource : createOccurrenceJobEvent.getListDataSourceFound()) {
|
||||||
|
dataSourceList.add(new org.gcube.portlets.user.speciesdiscovery.shared.DataSource(dataSource,dataSource));
|
||||||
|
}
|
||||||
|
|
||||||
listJobOccurrenceModel.add(new JobOccurrencesModel("", jobName,createOccurrenceJobEvent.getSearchTerm(), dataSourceList, createOccurrenceJobEvent.getFileFormat(), createOccurrenceJobEvent.getSaveEnum(), createOccurrenceJobEvent.isByDataSource(), createOccurrenceJobEvent.getExpectedOccurrences()));
|
listJobOccurrenceModel.add(new JobOccurrencesModel("", jobName,createOccurrenceJobEvent.getSearchTerm(), dataSourceList, createOccurrenceJobEvent.getFileFormat(), createOccurrenceJobEvent.getSaveEnum(), createOccurrenceJobEvent.isByDataSource(), createOccurrenceJobEvent.getExpectedOccurrences()));
|
||||||
|
|
||||||
|
@ -328,8 +337,10 @@ public class SearchController {
|
||||||
|
|
||||||
// System.out.println("########DATASOURCE FOUND: "+dataSource);
|
// System.out.println("########DATASOURCE FOUND: "+dataSource);
|
||||||
|
|
||||||
String jobName = createOccurrenceJobEvent.getSearchTerm() + " occurrences from " +dataSource;
|
// String jobName = createOccurrenceJobEvent.getSearchTerm() + " occurrences from " +dataSource;
|
||||||
|
|
||||||
|
String jobName = createOccurrenceJobEvent.getSearchTerm() + " occurrences";
|
||||||
|
|
||||||
List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>();
|
List<org.gcube.portlets.user.speciesdiscovery.shared.DataSource> dataSourceList = new ArrayList<org.gcube.portlets.user.speciesdiscovery.shared.DataSource>();
|
||||||
|
|
||||||
dataSourceList.add(new org.gcube.portlets.user.speciesdiscovery.shared.DataSource(dataSource,dataSource));
|
dataSourceList.add(new org.gcube.portlets.user.speciesdiscovery.shared.DataSource(dataSource,dataSource));
|
||||||
|
@ -662,6 +673,7 @@ public class SearchController {
|
||||||
public void onLoadDataSource(LoadDataSourceEvent loadDataSourceEvent) {
|
public void onLoadDataSource(LoadDataSourceEvent loadDataSourceEvent) {
|
||||||
|
|
||||||
searchBorderLayoutPanel.getSpeciesNorthPanel().mask("Loading data sources...", ConstantsSpeciesDiscovery.LOADINGSTYLE);
|
searchBorderLayoutPanel.getSpeciesNorthPanel().mask("Loading data sources...", ConstantsSpeciesDiscovery.LOADINGSTYLE);
|
||||||
|
|
||||||
loadDataSourceFromService();
|
loadDataSourceFromService();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -965,7 +977,9 @@ public class SearchController {
|
||||||
// IN THIS CASE THERE IS ONE DATASOURCE
|
// IN THIS CASE THERE IS ONE DATASOURCE
|
||||||
final String dataSourceName = listDataSources.get(0)!=null?listDataSources.get(0).getName():"no datasource";
|
final String dataSourceName = listDataSources.get(0)!=null?listDataSources.get(0).getName():"no datasource";
|
||||||
|
|
||||||
final String fileName = "Error on DWCA " +rank + " -"+scientificName +"- from "+dataSourceName+".zip";
|
// final String fileName = "Error on DWCA " +rank + " -"+scientificName +"- from "+dataSourceName+".zip";
|
||||||
|
|
||||||
|
final String fileName = "Error file: "+jobTaxonomyModel.getName()+" from "+dataSourceName+".txt";
|
||||||
|
|
||||||
SpeciesDiscovery.taxonomySearchService.isAvailableTaxonomyJobReportError(jobTaxonomyModel.getIdentifier(), new AsyncCallback<Boolean>() {
|
SpeciesDiscovery.taxonomySearchService.isAvailableTaxonomyJobReportError(jobTaxonomyModel.getIdentifier(), new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
|
@ -1041,7 +1055,9 @@ public class SearchController {
|
||||||
// IN THIS CASE THERE IS ONE DATASOURCE
|
// IN THIS CASE THERE IS ONE DATASOURCE
|
||||||
final String dataSourceName = listDataSources.get(0)!=null?listDataSources.get(0).getName():"no datasource";
|
final String dataSourceName = listDataSources.get(0)!=null?listDataSources.get(0).getName():"no datasource";
|
||||||
|
|
||||||
String fileName = "DWCA " +rank + " -"+scientificName +"- from "+dataSourceName+".zip";
|
|
||||||
|
String fileName = jobTaxonomyModel.getName() +" from "+dataSourceName+" - DWCA.zip";
|
||||||
|
// String fileName = "DWCA " +rank + " -"+scientificName +"- from "+dataSourceName+".zip";
|
||||||
|
|
||||||
WorkspaceLightTreeSavePopup popup = new WorkspaceLightTreeSavePopup("Select where to save the Job", true, fileName);
|
WorkspaceLightTreeSavePopup popup = new WorkspaceLightTreeSavePopup("Select where to save the Job", true, fileName);
|
||||||
popup.setModal(false);
|
popup.setModal(false);
|
||||||
|
@ -1096,26 +1112,17 @@ public class SearchController {
|
||||||
String dataSourceName = "";
|
String dataSourceName = "";
|
||||||
|
|
||||||
for (org.gcube.portlets.user.speciesdiscovery.shared.DataSource dataSource : dataSourceList) {
|
for (org.gcube.portlets.user.speciesdiscovery.shared.DataSource dataSource : dataSourceList) {
|
||||||
dataSourceName+= dataSource.getName() + "-";
|
dataSourceName+= dataSource.getName() + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove last - char
|
//remove last - char
|
||||||
dataSourceName = dataSourceName.substring(0, dataSourceName.lastIndexOf("-"));
|
if(dataSourceName.endsWith(","))
|
||||||
|
dataSourceName = dataSourceName.substring(0, dataSourceName.length()-1);
|
||||||
|
|
||||||
final String dataSources = dataSourceName;
|
final String dataSources = dataSourceName;
|
||||||
|
|
||||||
String extension = null;
|
final String fileName = "Error file: "+jobOccurrencesModel.getJobName()+" from "+dataSourceName+".txt";
|
||||||
|
|
||||||
switch (jobOccurrencesModel.getFileFormat()) {
|
|
||||||
case CSV: {
|
|
||||||
extension = "csv";
|
|
||||||
} break;
|
|
||||||
case DARWIN_CORE:{
|
|
||||||
extension = "xml";
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String fileName = "Error on Occurrences results of "+scientificName +"- from "+dataSourceName+"."+extension;
|
|
||||||
|
|
||||||
SpeciesDiscovery.taxonomySearchService.isAvailableOccurrenceJobReportError(jobOccurrencesModel.getJobIdentifier(), new AsyncCallback<Boolean>() {
|
SpeciesDiscovery.taxonomySearchService.isAvailableOccurrenceJobReportError(jobOccurrencesModel.getJobIdentifier(), new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
|
@ -1196,24 +1203,29 @@ public class SearchController {
|
||||||
String dataSourceName = "";
|
String dataSourceName = "";
|
||||||
|
|
||||||
for (org.gcube.portlets.user.speciesdiscovery.shared.DataSource dataSource : dataSourceList) {
|
for (org.gcube.portlets.user.speciesdiscovery.shared.DataSource dataSource : dataSourceList) {
|
||||||
dataSourceName+= dataSource.getName() + "-";
|
dataSourceName+= dataSource.getName() + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove last - char
|
//remove last - char
|
||||||
dataSourceName = dataSourceName.substring(0, dataSourceName.lastIndexOf("-"));
|
if(dataSourceName.endsWith(","))
|
||||||
|
dataSourceName = dataSourceName.substring(0, dataSourceName.lastIndexOf(","));
|
||||||
|
|
||||||
|
String extension = "";
|
||||||
|
String suffix = "";
|
||||||
|
|
||||||
String extension = null;
|
|
||||||
|
|
||||||
switch (jobOccurrencesModel.getFileFormat()) {
|
switch (jobOccurrencesModel.getFileFormat()) {
|
||||||
case CSV: {
|
case CSV: {
|
||||||
|
suffix = "CSV "+jobOccurrencesModel.getCsvType();
|
||||||
extension = "csv";
|
extension = "csv";
|
||||||
} break;
|
} break;
|
||||||
case DARWIN_CORE:{
|
case DARWIN_CORE:{
|
||||||
extension = "xml";
|
extension = "xml";
|
||||||
|
suffix = "DwC";
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileName = "Occurrences results of "+scientificName +"- from "+dataSourceName+"."+extension;
|
// String fileName = "Occurrences results of "+scientificName +"- from "+dataSourceName+" - "+suffix+"."+extension;
|
||||||
|
|
||||||
|
String fileName = jobOccurrencesModel.getJobName() +" from "+dataSourceName+" - "+suffix+"."+extension;
|
||||||
|
|
||||||
WorkspaceLightTreeSavePopup popup = new WorkspaceLightTreeSavePopup("Select where to save the Occurrence points", true, fileName);
|
WorkspaceLightTreeSavePopup popup = new WorkspaceLightTreeSavePopup("Select where to save the Occurrence points", true, fileName);
|
||||||
popup.setModal(false);
|
popup.setModal(false);
|
||||||
|
@ -1463,10 +1475,12 @@ public class SearchController {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void voi) {
|
public void onSuccess(Void voi) {
|
||||||
streamPagingLoader.startLoading(false);
|
streamPagingLoader.startLoading(false);
|
||||||
|
loadLastQuery(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
loadLastQuery(true);
|
||||||
Info.display("Error during the search", caught.getMessage());
|
Info.display("Error during the search", caught.getMessage());
|
||||||
Log.error("Error during the search", caught.getMessage());
|
Log.error("Error during the search", caught.getMessage());
|
||||||
reset();
|
reset();
|
||||||
|
@ -1515,6 +1529,8 @@ public class SearchController {
|
||||||
searchBorderLayoutPanel.getSpeciesCenterPanel().activeToolBarButtons(true);
|
searchBorderLayoutPanel.getSpeciesCenterPanel().activeToolBarButtons(true);
|
||||||
// eventBus.fireEvent(new SearchStartedEvent());
|
// eventBus.fireEvent(new SearchStartedEvent());
|
||||||
streamPagingLoader.startLoading(false);
|
streamPagingLoader.startLoading(false);
|
||||||
|
|
||||||
|
loadLastQuery(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1525,10 +1541,38 @@ public class SearchController {
|
||||||
Log.error("Error during the search", caught.getMessage());
|
Log.error("Error during the search", caught.getMessage());
|
||||||
reset();
|
reset();
|
||||||
streamPagingLoader.resetFilters();
|
streamPagingLoader.resetFilters();
|
||||||
|
loadLastQuery(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void loadLastQuery(boolean isError){
|
||||||
|
|
||||||
|
if(isError){
|
||||||
|
searchBorderLayoutPanel.getSpeciesSouthPanel().setLastQueryAsEmpty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SpeciesDiscovery.taxonomySearchService.getLastQuery(new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
|
searchBorderLayoutPanel.getSpeciesSouthPanel().setLastQueryAsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String query) {
|
||||||
|
GWT.log("load last Query: "+query);
|
||||||
|
|
||||||
|
if(query!=null && !query.isEmpty())
|
||||||
|
searchBorderLayoutPanel.getSpeciesSouthPanel().setLastQuery(query);
|
||||||
|
else
|
||||||
|
searchBorderLayoutPanel.getSpeciesSouthPanel().setLastQueryAsEmpty();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected void searchByQuery(String query) {
|
protected void searchByQuery(String query) {
|
||||||
|
|
||||||
Log.trace("IN SEARCH BY QUERY..." + query);
|
Log.trace("IN SEARCH BY QUERY..." + query);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
import com.extjs.gxt.ui.client.widget.form.DateField;
|
import com.extjs.gxt.ui.client.widget.form.DateField;
|
||||||
import com.extjs.gxt.ui.client.widget.form.NumberField;
|
import com.extjs.gxt.ui.client.widget.form.NumberField;
|
||||||
import com.extjs.gxt.ui.client.widget.layout.CardLayout;
|
import com.extjs.gxt.ui.client.widget.layout.CardLayout;
|
||||||
import com.netflix.astyanax.recipes.uniqueness.DedicatedMultiRowUniquenessConstraint;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
|
|
@ -3,19 +3,27 @@ package org.gcube.portlets.user.speciesdiscovery.client.job;
|
||||||
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;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.RenderTextFieldUtil;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
||||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Text;
|
||||||
import com.extjs.gxt.ui.client.widget.button.Button;
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||||
|
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||||
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||||
|
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.SeparatorToolItem;
|
||||||
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||||
import com.google.gwt.event.shared.EventBus;
|
import com.google.gwt.event.shared.EventBus;
|
||||||
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||||
|
|
||||||
public class SpeciesJobPanel extends ContentPanel{
|
public class SpeciesJobPanel extends ContentPanel{
|
||||||
|
|
||||||
|
protected static final String EMPTY = "Empty";
|
||||||
|
protected static final String LAST_QUERY = "Last query: ";
|
||||||
|
|
||||||
|
|
||||||
private ToolBar toolbar = new ToolBar();
|
private ToolBar toolbar = new ToolBar();
|
||||||
private TaxonomyJobSpeciesPanel taxonomyJobPanelInstance;
|
private TaxonomyJobSpeciesPanel taxonomyJobPanelInstance;
|
||||||
|
@ -25,6 +33,7 @@ public class SpeciesJobPanel extends ContentPanel{
|
||||||
private int jobOccurrenceCount = 0;
|
private int jobOccurrenceCount = 0;
|
||||||
private int jobTaxonomyCount = 0;
|
private int jobTaxonomyCount = 0;
|
||||||
|
|
||||||
|
private TextField<String> lastQuery;
|
||||||
|
|
||||||
public SpeciesJobPanel(EventBus eventBus) {
|
public SpeciesJobPanel(EventBus eventBus) {
|
||||||
this.setTopComponent(toolbar);
|
this.setTopComponent(toolbar);
|
||||||
|
@ -39,6 +48,23 @@ public class SpeciesJobPanel extends ContentPanel{
|
||||||
toolbar.add(new SeparatorToolItem());
|
toolbar.add(new SeparatorToolItem());
|
||||||
|
|
||||||
createTaxonomyToolBar();
|
createTaxonomyToolBar();
|
||||||
|
|
||||||
|
|
||||||
|
Text txtLastQuery = new Text(LAST_QUERY);
|
||||||
|
txtLastQuery.setStyleAttribute("padding-right", "2px");
|
||||||
|
txtLastQuery.setStyleAttribute("color", "gray");
|
||||||
|
|
||||||
|
lastQuery = new TextField<String>();
|
||||||
|
|
||||||
|
lastQuery.setReadOnly(true);
|
||||||
|
lastQuery.setWidth(350);
|
||||||
|
lastQuery.setValue(EMPTY);
|
||||||
|
toolbar.add(new FillToolItem());
|
||||||
|
toolbar.add(txtLastQuery);
|
||||||
|
toolbar.add(lastQuery);
|
||||||
|
|
||||||
|
RenderTextFieldUtil.setTextFieldAttr(lastQuery, "background", "none");
|
||||||
|
// RenderTextFieldUtil.setTextFieldAttr(lastQuery, "text-align", "right");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createOccurrencesToolBar(){
|
private void createOccurrencesToolBar(){
|
||||||
|
@ -85,6 +111,14 @@ public class SpeciesJobPanel extends ContentPanel{
|
||||||
toolbar.add(btnOccurrenceJobs);
|
toolbar.add(btnOccurrenceJobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLastQuery(String query){
|
||||||
|
this.lastQuery.setValue(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastQueryAsEmpty(){
|
||||||
|
this.lastQuery.setValue(EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
private void resetOccurrenceCounter(){
|
private void resetOccurrenceCounter(){
|
||||||
jobOccurrenceCount = 0;
|
jobOccurrenceCount = 0;
|
||||||
setIconOccurrenceByCounter(0);
|
setIconOccurrenceByCounter(0);
|
||||||
|
|
|
@ -415,7 +415,7 @@ public class OccurrenceGridJob extends ContentPanel{
|
||||||
|
|
||||||
else{
|
else{
|
||||||
String name = baseModelData.get(JobOccurrencesModel.JOBNAME);
|
String name = baseModelData.get(JobOccurrencesModel.JOBNAME);
|
||||||
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The job "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
|
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The error file "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ public class OccurrenceGridJob extends ContentPanel{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
saveJob();
|
saveErrorJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -433,7 +433,7 @@ public class TaxonomyGridJob extends ContentPanel{
|
||||||
|
|
||||||
else{
|
else{
|
||||||
String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
|
String name = baseModelData.get(JobTaxonomyModel.JOBNAME);
|
||||||
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The job "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
|
MessageBox.alert(ConstantsSpeciesDiscovery.ALERT, "The error file "+ name+ " " +ConstantsSpeciesDiscovery.IS_NOT_COMPLETED, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,5 +188,10 @@ public interface TaxonomySearchService extends RemoteService {
|
||||||
String dataSourceName) throws Exception;
|
String dataSourceName) throws Exception;
|
||||||
|
|
||||||
boolean isAvailableOccurrenceJobReportError(String jobIdentifier) throws Exception;
|
boolean isAvailableOccurrenceJobReportError(String jobIdentifier) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getLastQuery();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,5 +154,7 @@ public interface TaxonomySearchServiceAsync {
|
||||||
|
|
||||||
void isAvailableTaxonomyJobReportError(String jobIdentifier,
|
void isAvailableTaxonomyJobReportError(String jobIdentifier,
|
||||||
AsyncCallback<Boolean> callback);
|
AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
|
void getLastQuery(AsyncCallback<String> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.client.util;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.Events;
|
||||||
|
import com.extjs.gxt.ui.client.event.Listener;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Component;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Text;
|
||||||
|
import com.extjs.gxt.ui.client.widget.form.Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jul 18, 2013
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RenderTextFieldUtil {
|
||||||
|
|
||||||
|
public interface Function {
|
||||||
|
public void execute ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Safe function call on a component, which was rendered or not.
|
||||||
|
*
|
||||||
|
* @param c Component object that must be not null.
|
||||||
|
* @param f Function object with the function that must be called.
|
||||||
|
*/
|
||||||
|
public static void safeFunctionCallOn(final Component c, final Function f) {
|
||||||
|
c.enableEvents(true);
|
||||||
|
if (c.isRendered()) {
|
||||||
|
f.execute();
|
||||||
|
} else {
|
||||||
|
final Listener<ComponentEvent> lsnr = new Listener<ComponentEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleEvent(ComponentEvent be) {
|
||||||
|
f.execute();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
c.addListener(Events.Render, lsnr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Sets a style attribute for the text-field control */
|
||||||
|
public static void setTextFieldAttr(final Field<?> textField, final String cssAttrNm, final String attrVal) {
|
||||||
|
|
||||||
|
safeFunctionCallOn(textField, new Function() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
textField.el().firstChild().setStyleAttribute(cssAttrNm, attrVal);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets a style attribute for the text-field control */
|
||||||
|
public static void setTextAttr(final Text text, final String cssAttrNm, final String attrVal) {
|
||||||
|
|
||||||
|
safeFunctionCallOn(text, new Function() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
text.el().firstChild().setStyleAttribute(cssAttrNm, attrVal);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -155,6 +155,10 @@ public class StreamPagingLoader {
|
||||||
// streamSizePoller.cancel();
|
// streamSizePoller.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param isOccurrences
|
||||||
|
*/
|
||||||
public void startLoading(boolean isOccurrences)
|
public void startLoading(boolean isOccurrences)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForResultRow;
|
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForResultRow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForTaxonomyRow;
|
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForTaxonomyRow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
|
import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.util.NormalizeString;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
|
|
||||||
|
@ -197,16 +198,18 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
|
|
||||||
protected SearchResultType search(String searchTerm, SearchType searchType, SearchFilters searchFilters) throws SearchServiceException
|
protected SearchResultType search(String searchTerm, SearchType searchType, SearchFilters searchFilters) throws SearchServiceException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ASLSession aslSession = getASLSession();
|
||||||
try {
|
try {
|
||||||
deleteAllRowIntoDaoTable(); //RESET TABLE
|
deleteAllRowIntoDaoTable(); //RESET TABLE
|
||||||
|
|
||||||
ASLSession aslSession = getASLSession();
|
|
||||||
|
|
||||||
// logger.trace("In search session id: " + aslSession.getExternalSessionID() + " sessione username: " +aslSession.getUsername() + " session scope: "+aslSession.getScopeName());
|
// logger.trace("In search session id: " + aslSession.getExternalSessionID() + " sessione username: " +aslSession.getUsername() + " session scope: "+aslSession.getScopeName());
|
||||||
|
|
||||||
SpeciesService taxonomyService = getSpeciesService();
|
SpeciesService taxonomyService = getSpeciesService();
|
||||||
CloseableIterator<ResultElement> input = taxonomyService.searchByFilters(searchTerm, searchType, searchFilters);
|
CloseableIterator<ResultElement> input = taxonomyService.searchByFilters(searchTerm, searchType, searchFilters);
|
||||||
//DEBUG
|
//DEBUG
|
||||||
|
|
||||||
|
SessionUtil.setCurrentQuery(aslSession, taxonomyService.getLastQuery());
|
||||||
// System.out.println("returned input stream by service...");
|
// System.out.println("returned input stream by service...");
|
||||||
logger.trace("returned input stream by service...");
|
logger.trace("returned input stream by service...");
|
||||||
|
|
||||||
|
@ -217,6 +220,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error starting search "+searchType+" for term \""+searchTerm+"\" with filters "+searchFilters, e);
|
logger.error("Error starting search "+searchType+" for term \""+searchTerm+"\" with filters "+searchFilters, e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
SessionUtil.setCurrentQuery(aslSession, "invalid query");
|
||||||
throw new SearchServiceException(e.getMessage());
|
throw new SearchServiceException(e.getMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -228,16 +232,17 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
logger.trace("searchByQuery - query: "+query);
|
logger.trace("searchByQuery - query: "+query);
|
||||||
|
|
||||||
stopSearch();
|
stopSearch();
|
||||||
|
ASLSession aslSession = getASLSession();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deleteAllRowIntoDaoTable(); //RESET TABLE
|
deleteAllRowIntoDaoTable(); //RESET TABLE
|
||||||
|
|
||||||
ASLSession aslSession = getASLSession();
|
|
||||||
|
|
||||||
// logger.trace("In searchByQuery session id: " + aslSession.getExternalSessionID() + " sessione username: " +aslSession.getUsername() + " session scope: "+aslSession.getScopeName());
|
// logger.trace("In searchByQuery session id: " + aslSession.getExternalSessionID() + " sessione username: " +aslSession.getUsername() + " session scope: "+aslSession.getScopeName());
|
||||||
|
|
||||||
SpeciesService taxonomyService = getSpeciesService();
|
SpeciesService taxonomyService = getSpeciesService();
|
||||||
CloseableIterator<ResultElement> input = taxonomyService.searchByQuery(query);
|
CloseableIterator<ResultElement> input = taxonomyService.searchByQuery(query);
|
||||||
|
|
||||||
|
SessionUtil.setCurrentQuery(aslSession, query);
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
// System.out.println("service return iterator searched...");
|
// System.out.println("service return iterator searched...");
|
||||||
|
@ -251,6 +256,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error starting search by query", e);
|
logger.error("Error starting search by query", e);
|
||||||
|
SessionUtil.setCurrentQuery(aslSession, "invalid query");
|
||||||
throw new SearchServiceException(e.getMessage());
|
throw new SearchServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,37 +1156,72 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @SuppressWarnings("unchecked")
|
||||||
|
// protected List<String> getSelectedTaxonomyId() throws SearchServiceException
|
||||||
|
// {
|
||||||
|
// FetchingSession<TaxonomyRow> searchSession = (FetchingSession<TaxonomyRow>) getSearchSession();
|
||||||
|
//
|
||||||
|
// Collection<TaxonomyRow> selectedRows;
|
||||||
|
//
|
||||||
|
// List<String> listId = null;
|
||||||
|
// try {
|
||||||
|
// selectedRows = ((SelectableFetchingBuffer<TaxonomyRow>) searchSession.getBuffer()).getSelected();
|
||||||
|
//
|
||||||
|
// logger.trace("found "+selectedRows.size()+" selected rows");
|
||||||
|
//
|
||||||
|
// listId = new ArrayList<String>(selectedRows.size());
|
||||||
|
//
|
||||||
|
// for (TaxonomyRow row:selectedRows){
|
||||||
|
// listId.add(row.getServiceId());
|
||||||
|
// logger.trace("add this id: "+row.getServiceId()+" to list");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// logger.trace("found "+listId.size()+" id");
|
||||||
|
//
|
||||||
|
// //TODO remove
|
||||||
|
// if (logger.isTraceEnabled()) logger.trace("selected ids: "+listId);
|
||||||
|
//
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// logger.error("An error occured in getSelectedOccurrenceKeys" + e.getMessage());
|
||||||
|
// throw new SearchServiceException(e.getMessage());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return listId;
|
||||||
|
// }
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected List<String> getSelectedTaxonomyId() throws SearchServiceException
|
protected Map<String, String> getSelectedTaxonomyIdAndDataSource() throws SearchServiceException
|
||||||
{
|
{
|
||||||
FetchingSession<TaxonomyRow> searchSession = (FetchingSession<TaxonomyRow>) getSearchSession();
|
FetchingSession<TaxonomyRow> searchSession = (FetchingSession<TaxonomyRow>) getSearchSession();
|
||||||
|
|
||||||
|
HashMap<String, String> hashIdTaxonDataSource = null;
|
||||||
|
|
||||||
Collection<TaxonomyRow> selectedRows;
|
Collection<TaxonomyRow> selectedRows;
|
||||||
|
|
||||||
List<String> listId = null;
|
// List<String> listId = null;
|
||||||
try {
|
try {
|
||||||
selectedRows = ((SelectableFetchingBuffer<TaxonomyRow>) searchSession.getBuffer()).getSelected();
|
selectedRows = ((SelectableFetchingBuffer<TaxonomyRow>) searchSession.getBuffer()).getSelected();
|
||||||
|
|
||||||
logger.trace("found "+selectedRows.size()+" selected rows");
|
logger.trace("found "+selectedRows.size()+" selected rows");
|
||||||
|
|
||||||
listId = new ArrayList<String>(selectedRows.size());
|
hashIdTaxonDataSource = new HashMap<String, String>(selectedRows.size());
|
||||||
|
|
||||||
for (TaxonomyRow row:selectedRows){
|
for (TaxonomyRow row:selectedRows){
|
||||||
listId.add(row.getServiceId());
|
hashIdTaxonDataSource.put(row.getServiceId(), row.getDataProviderName());
|
||||||
logger.trace("add this id: "+row.getServiceId()+" to list");
|
logger.trace("add this id: "+row.getServiceId()+" to list");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("found "+listId.size()+" id");
|
logger.trace("found "+hashIdTaxonDataSource.size()+" id");
|
||||||
|
|
||||||
//TODO remove
|
//TODO remove
|
||||||
if (logger.isTraceEnabled()) logger.trace("selected ids: "+listId);
|
if (logger.isTraceEnabled()) logger.trace("selected ids: "+hashIdTaxonDataSource);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An error occured in getSelectedOccurrenceKeys" + e.getMessage());
|
logger.error("An error occured in getSelectedOccurrenceKeys" + e.getMessage());
|
||||||
throw new SearchServiceException(e.getMessage());
|
throw new SearchServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return listId;
|
return hashIdTaxonDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File generateCSVFile(List<String> ids, OccurrencesSaveEnum csvType) throws Exception
|
protected File generateCSVFile(List<String> ids, OccurrencesSaveEnum csvType) throws Exception
|
||||||
|
@ -1417,8 +1458,10 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
|
|
||||||
long submitTime = Calendar.getInstance().getTimeInMillis();
|
long submitTime = Calendar.getInstance().getTimeInMillis();
|
||||||
|
|
||||||
|
String name = NormalizeString.lowerCaseUpFirstChar(taxonomyName) + " group";
|
||||||
|
|
||||||
//STORE INTO DAO
|
//STORE INTO DAO
|
||||||
TaxonomyJob speciesJob = new TaxonomyJob(speciesJobId, DownloadState.PENDING.toString(), SAVE_CHILDREN_OF+taxonomyName, taxonomyName, dataSourceName, taxonomyRank, 0, submitTime, 0, taxonomyServiceId);
|
TaxonomyJob speciesJob = new TaxonomyJob(speciesJobId, DownloadState.PENDING.toString(), name, taxonomyName, dataSourceName, taxonomyRank, 0, submitTime, 0, taxonomyServiceId);
|
||||||
taxonomyJobDao.insert(speciesJob);
|
taxonomyJobDao.insert(speciesJob);
|
||||||
|
|
||||||
jobSpeciesModel = new JobTaxonomyModel(speciesJob.getId(), speciesJob.getDescriptiveName(), DownloadState.PENDING, null, taxonomyName, dataSourceName, taxonomyRank);
|
jobSpeciesModel = new JobTaxonomyModel(speciesJob.getId(), speciesJob.getDescriptiveName(), DownloadState.PENDING, null, taxonomyName, dataSourceName, taxonomyRank);
|
||||||
|
@ -1431,43 +1474,15 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
return jobSpeciesModel;
|
return jobSpeciesModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public JobTaxonomyModel createTaxonomyJobByChildren(TaxonomyRow taxonomy, String dataSourceName) throws Exception {
|
|
||||||
//
|
|
||||||
// logger.trace("Create job for taxonomy id: " + taxonomy.getServiceId());
|
|
||||||
//// System.out.println("Create job for taxonomy id: " + taxonomy.getServiceId());
|
|
||||||
//
|
|
||||||
// JobTaxonomyModel jobSpeciesModel = null;
|
|
||||||
//
|
|
||||||
// TaxonomyJobPersistence taxonomyJobDao = DaoSession.getTaxonomyJobDAO(getASLSession());
|
|
||||||
//
|
|
||||||
// SpeciesService taxonomyService = getSpeciesService();
|
|
||||||
//
|
|
||||||
// String speciesJobId = taxonomyService.createTaxonomyJobForDWCAByChildren(taxonomy.getServiceId());
|
|
||||||
//
|
|
||||||
// long startTime = Calendar.getInstance().getTimeInMillis();
|
|
||||||
//
|
|
||||||
// //STORE INTO DAO
|
|
||||||
// TaxonomyJob speciesJob = new TaxonomyJob(speciesJobId, DownloadState.PENDING.toString(), SAVE_CHILDREN_OF+taxonomy.getName(), taxonomy.getName(), dataSourceName, taxonomy.getRank(), startTime, 0, taxonomy.getServiceId());
|
|
||||||
// taxonomyJobDao.insert(speciesJob);
|
|
||||||
//
|
|
||||||
// jobSpeciesModel = new JobTaxonomyModel(speciesJob.getId(), speciesJob.getDescriptiveName(), DownloadState.PENDING, null, taxonomy.getName(), dataSourceName, taxonomy.getRank());
|
|
||||||
//
|
|
||||||
// Date start = DateUtil.millisecondsToDate(speciesJob.getStartTime());
|
|
||||||
//// jobSpeciesModel.setStartTime(DateUtil.dateToDateFormatString(start));
|
|
||||||
// jobSpeciesModel.setStartTime(start);
|
|
||||||
// jobSpeciesModel.setEndTime(null);
|
|
||||||
//
|
|
||||||
// return jobSpeciesModel;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JobTaxonomyModel createTaxonomyJobByIds(String search, List<DataSourceModel> dataSources) throws Exception {
|
public JobTaxonomyModel createTaxonomyJobByIds(String search, List<DataSourceModel> dataSources) throws Exception {
|
||||||
|
|
||||||
logger.trace("Create job ForDWCAByIds for: " + search);
|
logger.trace("Create job ForDWCAByIds for: " + search);
|
||||||
|
|
||||||
List<String> listId = getSelectedTaxonomyId();
|
// List<String> listId = getSelectedTaxonomyId();
|
||||||
|
|
||||||
|
Map<String, String> hashIdDs = getSelectedTaxonomyIdAndDataSource();
|
||||||
// printId(listId);
|
// printId(listId);
|
||||||
|
|
||||||
// System.out.println("Create job for taxonomy id: " + taxonomy.getServiceId());
|
// System.out.println("Create job for taxonomy id: " + taxonomy.getServiceId());
|
||||||
|
@ -1478,11 +1493,35 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
|
|
||||||
SpeciesService taxonomyService = getSpeciesService();
|
SpeciesService taxonomyService = getSpeciesService();
|
||||||
|
|
||||||
|
List<String> listId = new ArrayList<String>(hashIdDs.keySet());
|
||||||
|
|
||||||
String speciesJobId = taxonomyService.createTaxonomyJobForDWCAByIds(listId);
|
String speciesJobId = taxonomyService.createTaxonomyJobForDWCAByIds(listId);
|
||||||
|
|
||||||
long submitTime = Calendar.getInstance().getTimeInMillis();
|
long submitTime = Calendar.getInstance().getTimeInMillis();
|
||||||
|
|
||||||
String name = "Save DWCA with "+listId.size()+ " ";
|
|
||||||
|
String name = NormalizeString.lowerCaseUpFirstChar(search) + " - ";
|
||||||
|
name += listId.size() + " ";
|
||||||
|
name += listId.size()>1?"taxa":"taxon";
|
||||||
|
|
||||||
|
String dataSourceName = "";
|
||||||
|
|
||||||
|
for (String taxonId : listId) {
|
||||||
|
if(!dataSourceName.contains(hashIdDs.get(taxonId))) //remove duplicate
|
||||||
|
dataSourceName+=hashIdDs.get(taxonId) + ", ";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// String dataSourceName = "";
|
||||||
|
//
|
||||||
|
// for (DataSourceModel dataSource : dataSources) {
|
||||||
|
// dataSourceName+=dataSource.getName() + ", ";
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(dataSourceName.endsWith(", "))
|
||||||
|
dataSourceName = dataSourceName.substring(0, dataSourceName.length()-2);
|
||||||
|
|
||||||
|
/*String name = "Save DWCA with "+listId.size()+ " ";
|
||||||
|
|
||||||
name += listId.size()>1?"items":"item";
|
name += listId.size()>1?"items":"item";
|
||||||
name += " "+search;
|
name += " "+search;
|
||||||
|
@ -1491,7 +1530,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
|
|
||||||
for (DataSourceModel dataSource : dataSources) {
|
for (DataSourceModel dataSource : dataSources) {
|
||||||
dataSourceName+=dataSource.getName() + ", ";
|
dataSourceName+=dataSource.getName() + ", ";
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//STORE INTO DAO
|
//STORE INTO DAO
|
||||||
TaxonomyJob speciesJob = new TaxonomyJob(speciesJobId, DownloadState.PENDING.toString(), name, name, dataSourceName, "", 0, submitTime, 0, speciesJobId);
|
TaxonomyJob speciesJob = new TaxonomyJob(speciesJobId, DownloadState.PENDING.toString(), name, name, dataSourceName, "", 0, submitTime, 0, speciesJobId);
|
||||||
|
@ -1542,8 +1581,10 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
|
|
||||||
long submitTime = Calendar.getInstance().getTimeInMillis();
|
long submitTime = Calendar.getInstance().getTimeInMillis();
|
||||||
|
|
||||||
|
String name = RESUBMIT + ": " +NormalizeString.lowerCaseUpFirstChar(taxonomy.getDescriptiveName());
|
||||||
|
|
||||||
//STORE INTO DAO
|
//STORE INTO DAO
|
||||||
TaxonomyJob speciesJob = new TaxonomyJob(speciesJobId, DownloadState.PENDING.toString(), RESUBMIT + " " + SAVE_CHILDREN_OF+taxonomy.getDescriptiveName(), taxonomy.getDescriptiveName(), taxonomy.getDataSourceName(), taxonomy.getRank(), 0, submitTime, 0, taxonomy.getTaxonomyId());
|
TaxonomyJob speciesJob = new TaxonomyJob(speciesJobId, DownloadState.PENDING.toString(), name, taxonomy.getDescriptiveName(), taxonomy.getDataSourceName(), taxonomy.getRank(), 0, submitTime, 0, taxonomy.getTaxonomyId());
|
||||||
taxonomyJobDao.insert(speciesJob);
|
taxonomyJobDao.insert(speciesJob);
|
||||||
|
|
||||||
jobSpeciesModel = new JobTaxonomyModel(speciesJob.getId(), speciesJob.getDescriptiveName(), DownloadState.PENDING, null, taxonomy.getDescriptiveName(), taxonomy.getDataSourceName(), taxonomy.getRank());
|
jobSpeciesModel = new JobTaxonomyModel(speciesJob.getId(), speciesJob.getDescriptiveName(), DownloadState.PENDING, null, taxonomy.getDescriptiveName(), taxonomy.getDataSourceName(), taxonomy.getRank());
|
||||||
|
@ -1852,7 +1893,9 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
//recover csv type
|
//recover csv type
|
||||||
OccurrencesSaveEnum csvType = OccurrenceJobUtil.convertCsvType(job.getCsvType());
|
OccurrencesSaveEnum csvType = OccurrenceJobUtil.convertCsvType(job.getCsvType());
|
||||||
|
|
||||||
JobOccurrencesModel jobModel = new JobOccurrencesModel("",job.getName(), job.getScientificName(), job.getDataSources(), fileFormat, csvType, job.isByDataSource());
|
String name = RESUBMIT + ": "+job.getName();
|
||||||
|
|
||||||
|
JobOccurrencesModel jobModel = new JobOccurrencesModel("",name, job.getScientificName(), job.getDataSources(), fileFormat, csvType, job.isByDataSource());
|
||||||
jobModel.setTotalOccurrences(job.getExpectedOccurrence());
|
jobModel.setTotalOccurrences(job.getExpectedOccurrence());
|
||||||
|
|
||||||
listResultJobModel.add(OccurrenceJobUtil.createOccurrenceJobOnServiceByKeys(jobModel, taxonomyService, occurrencesJobDao, keys, job.getDataSources(), fileFormat, csvType, jobModel.getTotalOccurrences()));
|
listResultJobModel.add(OccurrenceJobUtil.createOccurrenceJobOnServiceByKeys(jobModel, taxonomyService, occurrencesJobDao, keys, job.getDataSources(), fileFormat, csvType, jobModel.getTotalOccurrences()));
|
||||||
|
@ -2212,4 +2255,11 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLastQuery(){
|
||||||
|
logger.trace("getLastQuery...");
|
||||||
|
ASLSession session = getASLSession();
|
||||||
|
return SessionUtil.getCurrentQuery(session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class SessionUtil {
|
||||||
public static final String EJB_TAXONOMY = "EJB_TAXONOMY";
|
public static final String EJB_TAXONOMY = "EJB_TAXONOMY";
|
||||||
public static final String EJB_OCCURRENCES_JOB = "EJB_OCCURRENCES_JOB";
|
public static final String EJB_OCCURRENCES_JOB = "EJB_OCCURRENCES_JOB";
|
||||||
public static final String EJB_TAXONOMY_JOB = "EJB_TAXONOMY_JOB";
|
public static final String EJB_TAXONOMY_JOB = "EJB_TAXONOMY_JOB";
|
||||||
|
public static final String CURRENT_SPD_QUERY = "CURRENT_SPD_QUERY";
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(SessionUtil.class);
|
protected static Logger logger = Logger.getLogger(SessionUtil.class);
|
||||||
|
|
||||||
|
@ -177,4 +178,24 @@ public class SessionUtil {
|
||||||
public static void setCurrentDAOTaxonomyJob(ASLSession session, TaxonomyJobPersistence taxonomyJobPeristence) {
|
public static void setCurrentDAOTaxonomyJob(ASLSession session, TaxonomyJobPersistence taxonomyJobPeristence) {
|
||||||
session.setAttribute(EJB_TAXONOMY_JOB, taxonomyJobPeristence);
|
session.setAttribute(EJB_TAXONOMY_JOB, taxonomyJobPeristence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param aslSession
|
||||||
|
* @param lastQuery
|
||||||
|
*/
|
||||||
|
public static void setCurrentQuery(ASLSession aslSession, String lastQuery) {
|
||||||
|
logger.trace("Last query in session: "+lastQuery);
|
||||||
|
aslSession.setAttribute(CURRENT_SPD_QUERY, lastQuery);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param aslSession
|
||||||
|
*/
|
||||||
|
public static String getCurrentQuery(ASLSession aslSession) {
|
||||||
|
return (String) aslSession.getAttribute(CURRENT_SPD_QUERY);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,22 @@ public class QueryBuilder {
|
||||||
query.append(searchTerm);
|
query.append(searchTerm);
|
||||||
query.append("' ");
|
query.append("' ");
|
||||||
|
|
||||||
|
//ADDED BY FRANCESCO 18/07/2013
|
||||||
|
//ADD UNFOLD
|
||||||
|
if (searchType == SearchType.BY_SCIENTIFIC_NAME && searchFilters.getListDataSourcesForUnfold()!=null && searchFilters.getListDataSourcesForUnfold().size()>0){
|
||||||
|
|
||||||
|
query.append("UNFOLD WITH ");
|
||||||
|
|
||||||
|
Iterator<DataSourceModel> dsIterator = searchFilters.getListDataSourcesForUnfold().iterator();
|
||||||
|
while(dsIterator.hasNext()) {
|
||||||
|
DataSourceModel ds = dsIterator.next();
|
||||||
|
query.append(ds.getId());
|
||||||
|
if (dsIterator.hasNext()) query.append(", ");
|
||||||
|
else query.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (searchType == SearchType.BY_COMMON_NAME) query.append("RESOLVE ");
|
if (searchType == SearchType.BY_COMMON_NAME) query.append("RESOLVE ");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.gcube.data.spd.model.products.ResultElement;
|
||||||
import org.gcube.data.spd.model.products.TaxonomyItem;
|
import org.gcube.data.spd.model.products.TaxonomyItem;
|
||||||
import org.gcube.data.spd.model.util.Capabilities;
|
import org.gcube.data.spd.model.util.Capabilities;
|
||||||
import org.gcube.data.spd.stubs.exceptions.InvalidIdentifierException;
|
import org.gcube.data.spd.stubs.exceptions.InvalidIdentifierException;
|
||||||
|
import org.gcube.data.spd.stubs.exceptions.UnsupportedPluginException;
|
||||||
import org.gcube.data.spd.stubs.types.Status;
|
import org.gcube.data.spd.stubs.types.Status;
|
||||||
import org.gcube.data.streams.Stream;
|
import org.gcube.data.streams.Stream;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.server.stream.CloseableIterator;
|
import org.gcube.portlets.user.speciesdiscovery.server.stream.CloseableIterator;
|
||||||
|
@ -64,6 +65,8 @@ public class SpeciesService {
|
||||||
protected Occurrence occurrencesCall;
|
protected Occurrence occurrencesCall;
|
||||||
protected Classification classificationCall;
|
protected Classification classificationCall;
|
||||||
protected Executor executorCall;
|
protected Executor executorCall;
|
||||||
|
|
||||||
|
protected String lastQuery = "";
|
||||||
|
|
||||||
|
|
||||||
public SpeciesService(GCUBEScope scope, ASLSession session) throws Exception
|
public SpeciesService(GCUBEScope scope, ASLSession session) throws Exception
|
||||||
|
@ -108,7 +111,7 @@ public class SpeciesService {
|
||||||
String query = QueryBuilder.buildQuery(searchTerm, searchType, searchFilters);
|
String query = QueryBuilder.buildQuery(searchTerm, searchType, searchFilters);
|
||||||
// System.out.println("query build - OK " + query);
|
// System.out.println("query build - OK " + query);
|
||||||
logger.trace("query build - OK " + query);
|
logger.trace("query build - OK " + query);
|
||||||
System.out.println("query: "+query);
|
// System.out.println("query: "+query);
|
||||||
return searchByQuery(query);
|
return searchByQuery(query);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error calling the Species Service: " + e.getMessage(), e);
|
logger.error("Error calling the Species Service: " + e.getMessage(), e);
|
||||||
|
@ -151,16 +154,25 @@ public class SpeciesService {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScopeProvider.instance.set(scope.toString());
|
ScopeProvider.instance.set(scope.toString());
|
||||||
|
lastQuery = query;
|
||||||
// System.err.println("ScopeProvider SCOPE "+ScopeProvider.instance.get());
|
// System.err.println("ScopeProvider SCOPE "+ScopeProvider.instance.get());
|
||||||
logger.trace("call species service search...");
|
logger.trace("call species service search...");
|
||||||
// System.out.println("call species service search...");
|
// System.out.println("call species service search...");
|
||||||
Stream<ResultElement> stream = call.search(query);
|
Stream<ResultElement> stream = call.search(query);
|
||||||
return new StreamIterator<ResultElement>(stream);
|
return new StreamIterator<ResultElement>(stream);
|
||||||
|
|
||||||
|
}catch (UnsupportedPluginException e2) {
|
||||||
|
lastQuery = "Invalid query";
|
||||||
|
String error = "Error calling the Species Service: plugin usupported";
|
||||||
|
logger.error("Error calling the Species Service: " + e2.getMessage(), e2);
|
||||||
|
throw new SearchServiceException(error);
|
||||||
}catch (InvalidQueryException e1) {
|
}catch (InvalidQueryException e1) {
|
||||||
|
lastQuery = "Invalid query";
|
||||||
String error = "Error calling the Species Service: query syntax is not valid";
|
String error = "Error calling the Species Service: query syntax is not valid";
|
||||||
logger.error("Error calling the Species Service: " + e1.getMessage(), e1);
|
logger.error("Error calling the Species Service: " + e1.getMessage(), e1);
|
||||||
throw new SearchServiceException(error);
|
throw new SearchServiceException(error);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
lastQuery = "Invalid query";
|
||||||
String error = "Error calling the Species Service: an error occurred contacting the service";
|
String error = "Error calling the Species Service: an error occurred contacting the service";
|
||||||
logger.error("Error calling the Species Service: " + e.getMessage(), e);
|
logger.error("Error calling the Species Service: " + e.getMessage(), e);
|
||||||
throw new SearchServiceException(error);
|
throw new SearchServiceException(error);
|
||||||
|
@ -662,4 +674,9 @@ public class SpeciesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getLastQuery() {
|
||||||
|
return lastQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public enum SpeciesCapability {
|
||||||
UPPERBOUND("UPPERBOUND", "Upper Bound"),
|
UPPERBOUND("UPPERBOUND", "Upper Bound"),
|
||||||
|
|
||||||
//Capabilities
|
//Capabilities
|
||||||
RESULTITEM("RESULTITEM", "Occurrences"),
|
RESULTITEM("RESULTITEM", "Occurrence"),
|
||||||
TAXONOMYITEM("TAXONOMYITEM", "Taxon"),
|
TAXONOMYITEM("TAXONOMYITEM", "Taxon"),
|
||||||
OCCURRENCESPOINTS("OCCURRENCESPOINTS", "OccurrencesPoints"),
|
OCCURRENCESPOINTS("OCCURRENCESPOINTS", "OccurrencesPoints"),
|
||||||
|
|
||||||
|
|
|
@ -352,6 +352,3 @@ ul {
|
||||||
padding-left:10px !important;
|
padding-left:10px !important;
|
||||||
margin-left: 10px !important;
|
margin-left: 10px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jul 18, 2013
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String a = "123 45";
|
||||||
|
|
||||||
|
if(a.endsWith("45"))
|
||||||
|
System.out.println(a.substring(0, a.length()-2));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue