integration started for unfold filter

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@79290 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-07-17 14:31:22 +00:00
parent fd818dc6f2
commit bb0044ca79
21 changed files with 595 additions and 195 deletions

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
jarsExcludedFromWebInfLib= jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco-mangiacrapa/wseclipse/speciesdiscovery(trunk)/target/species-discovery-3.1.0-SNAPSHOT lastWarOutDir=/home/francesco-mangiacrapa/wseclipse/speciesdiscovery(trunk)/target/species-discovery-3.3.0-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -6,7 +6,6 @@ import org.gcube.portlets.user.speciesdiscovery.client.job.SpeciesJobPanel;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
import com.extjs.gxt.ui.client.Style.LayoutRegion; import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.util.Margins; import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel; import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; import com.extjs.gxt.ui.client.widget.layout.BorderLayout;

View File

@ -47,6 +47,8 @@ import org.gcube.portlets.user.speciesdiscovery.client.event.SaveJobEventHandler
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.SearchEventHandler; import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchStartedEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.SearchStartedEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchTypeSelectedEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchTypeSelectedEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.event.SetCommonNamesEvent; 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;
@ -259,6 +261,18 @@ public class SearchController {
} }
}); });
eventBus.addHandler(SearchTypeSelectedEvent.TYPE, new SearchTypeSelectedEventHandler() {
@Override
public void onSearchTypeSelected(SearchTypeSelectedEvent searchTypeSelectedEvent) {
if(searchTypeSelectedEvent.getType()!=null)
AdvancedSearchPanelManager.getInstance().disableFilterForSearchType(searchTypeSelectedEvent.getType());
}
});
eventBus.addHandler(SearchEvent.TYPE, new SearchEventHandler() { eventBus.addHandler(SearchEvent.TYPE, new SearchEventHandler() {
@ -274,7 +288,7 @@ public class SearchController {
// ResultFilterPanelManager.getInstance().setGroupByRank(event.getGroupByRank()); // ResultFilterPanelManager.getInstance().setGroupByRank(event.getGroupByRank());
if(event.getType().equals(SearchType.BY_COMMON_NAME) || event.getType().equals(SearchType.BY_SCIENTIFIC_NAME)){ if(event.getType().equals(SearchType.BY_COMMON_NAME) || event.getType().equals(SearchType.BY_SCIENTIFIC_NAME)){
search(event.getType(), event.getSearchTerm().trim(), event.getUpperBoundLongitude(), event.getUpperBoundLatitude(), event.getLowerBoundLongitude(), event.getLowerBoundLatitude(), event.getFromDate(), event.getToDate(), event.getLstDataSources(), event.getGroupByRank(), event.getResultType()); search(event.getType(), event.getSearchTerm().trim(), event.getUpperBoundLongitude(), event.getUpperBoundLatitude(), event.getLowerBoundLongitude(), event.getLowerBoundLatitude(), event.getFromDate(), event.getToDate(), event.getLstDataSources(), event.getGroupByRank(), event.getResultType(), event.getListDataSourcesForSynonyms(), event.getListDataSourcesForUnfold());
} }
else{ else{
searchByQuery(event.getQuery()); searchByQuery(event.getQuery());
@ -402,27 +416,7 @@ public class SearchController {
switch (createSpeciesJobEvent.getJobType()) { switch (createSpeciesJobEvent.getJobType()) {
case BYCHILDREN: case BYCHILDREN:
// createSpeciesJobEvent.getTaxonomy().setParent(null); //FIX FOR PARENTS SERIALIZATIONS
// SpeciesDiscovery.taxonomySearchService.createTaxonomyJobByChildren(createSpeciesJobEvent.getTaxonomy(), createSpeciesJobEvent.getDataSourceName(), new AsyncCallback<JobTaxonomyModel>() {
//
// @Override
// public void onFailure(Throwable caught) {
// Info.display("Error", "Sorry, An error occurred on create job. Please try again later");
// Log.error("Error on loading", "An error occurred on create job by children, retry." +caught.getMessage());
// }
//
// @Override
// public void onSuccess(JobTaxonomyModel result) {
//
// if(result!=null){
// Info.display("Species Taxonomy Job","A new taxonomy job was submitted");
// excecuteGetJobs(SearchResultType.TAXONOMY_ITEM, false);
// searchBorderLayoutPanel.getSpeciesSouthPanel().setIconTaxonomyByCounter(1);
// }
// }
// });
TaxonomyRow taxonomy = createSpeciesJobEvent.getTaxonomy(); TaxonomyRow taxonomy = createSpeciesJobEvent.getTaxonomy();
SpeciesDiscovery.taxonomySearchService.createTaxonomyJobByChildren(taxonomy.getServiceId(), taxonomy.getName(), taxonomy.getRank(), createSpeciesJobEvent.getDataSourceName(), new AsyncCallback<JobTaxonomyModel>() { SpeciesDiscovery.taxonomySearchService.createTaxonomyJobByChildren(taxonomy.getServiceId(), taxonomy.getName(), taxonomy.getRank(), createSpeciesJobEvent.getDataSourceName(), new AsyncCallback<JobTaxonomyModel>() {
@ -1445,6 +1439,12 @@ public class SearchController {
streamPagingLoader.setActiveFilterObject(null); streamPagingLoader.setActiveFilterObject(null);
// isActiveFilterOnResult = false; // isActiveFilterOnResult = false;
activeFilterOnResult(false); activeFilterOnResult(false);
//ADDED 17/07/2013
searchBorderLayoutPanel.getSpeciesCenterPanel().getResultRowPanel().getClassicGridView().unmask();
searchBorderLayoutPanel.getSpeciesWestPanel().unmask();
searchBorderLayoutPanel.getSpeciesWestPanel().resetFilters();
searchBorderLayoutPanel.getSpeciesNorthPanel().enableSearch();
} }
private void switchView(SpeciesCapability resultType) { private void switchView(SpeciesCapability resultType) {
@ -1467,7 +1467,7 @@ public class SearchController {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Info.display("Error", "An error occurred during the search"); 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();
streamPagingLoader.resetFilters(); streamPagingLoader.resetFilters();
@ -1521,7 +1521,7 @@ public class SearchController {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
doActiveMaskLoadingGridAndButtonSearch(false); doActiveMaskLoadingGridAndButtonSearch(false);
Info.display("Error", "An error occurred during the search"); 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();
streamPagingLoader.resetFilters(); streamPagingLoader.resetFilters();
@ -1546,7 +1546,7 @@ public class SearchController {
} }
protected void search(SearchType type, String searchTerm, Number upperBoundLongitude, Number upperBoundLatitude, Number lowerBoundLongitude, Number lowerBoundLatitude, Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String groupRank, SpeciesCapability resultType) protected void search(SearchType type, String searchTerm, Number upperBoundLongitude, Number upperBoundLatitude, Number lowerBoundLongitude, Number lowerBoundLatitude, Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String groupRank, SpeciesCapability resultType, List<DataSourceModel> listDataSourcesForSynonyms, List<DataSourceModel> listDataSourcesForUnfold)
{ {
Log.trace("IN SEARCH.............."); Log.trace("IN SEARCH..............");
@ -1556,7 +1556,7 @@ public class SearchController {
Coordinate upperCoordinate = (upperBoundLatitude!=null && upperBoundLongitude!=null)?new Coordinate(upperBoundLatitude.floatValue(), upperBoundLongitude.floatValue()):null; Coordinate upperCoordinate = (upperBoundLatitude!=null && upperBoundLongitude!=null)?new Coordinate(upperBoundLatitude.floatValue(), upperBoundLongitude.floatValue()):null;
Coordinate lowerCoordinate = (lowerBoundLatitude!=null && lowerBoundLongitude!=null)?new Coordinate(lowerBoundLatitude.floatValue(), lowerBoundLongitude.floatValue()):null; Coordinate lowerCoordinate = (lowerBoundLatitude!=null && lowerBoundLongitude!=null)?new Coordinate(lowerBoundLatitude.floatValue(), lowerBoundLongitude.floatValue()):null;
SearchFilters filters = new SearchFilters(upperCoordinate, lowerCoordinate, fromDate, toDate, listDataSources, groupRank, resultType); SearchFilters filters = new SearchFilters(upperCoordinate, lowerCoordinate, fromDate, toDate, listDataSources, groupRank, resultType, listDataSourcesForSynonyms, listDataSourcesForUnfold);
Log.trace("**********result type: " + filters.getResultType()); Log.trace("**********result type: " + filters.getResultType());

View File

@ -37,5 +37,9 @@ public class SpeciesResultFilterAccordionPanel extends ContentPanel {
add(panel); add(panel);
} }
} }
public void resetFilters(){
resultFilterManager.resetFilters();
}
} }

View File

@ -12,9 +12,9 @@ import org.gcube.portlets.user.speciesdiscovery.client.event.SearchCompleteEvent
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.SearchStartedEvent; import org.gcube.portlets.user.speciesdiscovery.client.event.SearchStartedEvent;
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchStartedEventHandler; import org.gcube.portlets.user.speciesdiscovery.client.event.SearchStartedEventHandler;
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchTypeSelectedEvent;
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.resources.Resources; import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
import org.gcube.portlets.user.speciesdiscovery.client.switchbutton.SwitchButton;
import org.gcube.portlets.user.speciesdiscovery.client.window.HelpQueryWindow; import org.gcube.portlets.user.speciesdiscovery.client.window.HelpQueryWindow;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel; import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType; import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
@ -125,6 +125,16 @@ public class SpeciesSearchFormPanel extends ContentPanel {
searchType.setEditable(false); searchType.setEditable(false);
searchType.setTriggerAction(TriggerAction.ALL); searchType.setTriggerAction(TriggerAction.ALL);
searchType.setSimpleValue(ConstantsSpeciesDiscovery.SCIENTIFIC_NAME); searchType.setSimpleValue(ConstantsSpeciesDiscovery.SCIENTIFIC_NAME);
searchType.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
eventBus.fireEvent(new SearchTypeSelectedEvent(getSearchType(se.getSelectedItem().getValue())));
}
});
} }
@ -161,10 +171,24 @@ public class SpeciesSearchFormPanel extends ContentPanel {
return SpeciesCapability.NAMESMAPPING; return SpeciesCapability.NAMESMAPPING;
else if(value.compareTo(SpeciesCapability.SYNONYMS.getName())==0) else if(value.compareTo(SpeciesCapability.SYNONYMS.getName())==0)
return SpeciesCapability.SYNONYMS; return SpeciesCapability.SYNONYMS;
else if(value.compareTo(SpeciesCapability.UNFOLD.getName())==0)
return SpeciesCapability.UNFOLD;
return SpeciesCapability.UNKNOWN; return SpeciesCapability.UNKNOWN;
} }
private SearchType getSearchType(String value){
if(value.compareTo(ConstantsSpeciesDiscovery.SCIENTIFIC_NAME)==0)
return SearchType.BY_SCIENTIFIC_NAME;
else if(value.compareTo(ConstantsSpeciesDiscovery.COMMON_NAME)==0)
return SearchType.BY_COMMON_NAME;
return SearchType.BY_SCIENTIFIC_NAME;
}
public void switchSearchType(SEARCHTYPE searchType){ public void switchSearchType(SEARCHTYPE searchType){
currentSearchType = searchType; currentSearchType = searchType;
@ -325,9 +349,6 @@ public class SpeciesSearchFormPanel extends ContentPanel {
checkValidateOccurrences.setStyleAttribute("margin-right", "10px"); checkValidateOccurrences.setStyleAttribute("margin-right", "10px");
// simpleSearchPanel.add(checkValidateOccurrences);
buttSimpleSearch = new Button("Search"); buttSimpleSearch = new Button("Search");
buttSimpleSearch.addClickHandler(new ClickHandler() { buttSimpleSearch.addClickHandler(new ClickHandler() {
@ -362,101 +383,10 @@ public class SpeciesSearchFormPanel extends ContentPanel {
textExpand.setStyleAttribute("margin-left", "5px"); textExpand.setStyleAttribute("margin-left", "5px");
textExpand.setStyleAttribute("margin-right", "5px"); textExpand.setStyleAttribute("margin-right", "5px");
// SwitchButton button = new SwitchButton(false);
// hpPanelExpand.add(textExpand);
// hpPanelExpand.add(new SimpleComboBox<String>());
// hpPanelExpand.add(button);
vtPanel.add(hpPanel); vtPanel.add(hpPanel);
// vtPanel.add(hpPanelExpand);
simpleSearchPanel.add(vtPanel); simpleSearchPanel.add(vtPanel);
/*
simpleSearchPanel.setSpacing(5);
simpleSearchPanel.setVerticalAlign(VerticalAlignment.MIDDLE);
Text textSearch = new Text("Search:");
textSearch.setStyleAttribute("margin-left", "5px");
textSearch.setStyleAttribute("margin-right", "5px");
simpleSearchPanel.add(textSearch);
simpleSearchPanel.add(searchTypeResults);
Text textBy = new Text("By:");
textBy.setStyleAttribute("margin-left", "5px");
textBy.setStyleAttribute("margin-right", "5px");
simpleSearchPanel.add(textBy);
simpleSearchPanel.add(searchType);
Text textTerm = new Text("Term:");
textTerm.setStyleAttribute("margin-left", "10px");
textTerm.setStyleAttribute("margin-right", "5px");
simpleSearchPanel.add(textTerm);
searchField = new TextField<String>();
searchField.setStyleAttribute("margin-left", "0px");
searchField.setStyleAttribute("margin-right", "10px");
searchField.setEmptyText(EXSEARCH);
searchField.setWidth(300);
searchField.addKeyListener(new KeyListener(){
@Override
public void componentKeyPress(ComponentEvent event) {
if (event.getKeyCode()==KeyCodes.KEY_ENTER) search();
}
});
simpleSearchPanel.add(searchField);
checkValidateOccurrences.setBoxLabel("validate occurrences");
checkValidateOccurrences.setValueAttribute("validate occurrences");
checkValidateOccurrences.setStyleAttribute("margin-right", "10px");
// simpleSearchPanel.add(checkValidateOccurrences);
buttSimpleSearch = new Button("Search");
buttSimpleSearch.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
search();
}
});
buttSimpleSearch.setStyleName("wizardButton");
simpleSearchPanel.add(buttSimpleSearch);
buttSimpleExample = new Button("Example", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
searchField.setValue("Carcharodon carcharias");
}
});
buttSimpleExample.setStyleName("wizardButton");
simpleSearchPanel.add(buttSimpleExample);
Text textExpand = new Text("Expand:");
textExpand.setStyleAttribute("margin-left", "10px");
textExpand.setStyleAttribute("margin-right", "5px");
SwitchButton button = new SwitchButton(false);
simpleSearchPanel.add(textExpand);
simpleSearchPanel.add(button);
*/
} }
public boolean getValueCheckValidateOcccurrences(){ public boolean getValueCheckValidateOcccurrences(){
@ -570,7 +500,9 @@ public class SpeciesSearchFormPanel extends ContentPanel {
advSearchPanelsManager.getToDate().getValue(), advSearchPanelsManager.getToDate().getValue(),
advSearchPanelsManager.getCheckedDataSources(), advSearchPanelsManager.getCheckedDataSources(),
ResultFilterPanelManager.getInstance().getGroupByRank(), ResultFilterPanelManager.getInstance().getGroupByRank(),
advSearchPanelsManager.getCurrentSelectedCapability()); advSearchPanelsManager.getCurrentSelectedCapability(),
advSearchPanelsManager.getCheckedDataSourceForSynonyms(),
advSearchPanelsManager.getCheckedDataSourceForUnfold());
// }else // }else
// search(searchTerm,null,null,null,null,null,null); // search(searchTerm,null,null,null,null,null,null);
} }
@ -578,7 +510,7 @@ 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) 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)
{ {
mask("Searching..."); mask("Searching...");
//searchButton.setEnabled(false); //searchButton.setEnabled(false);
@ -587,7 +519,7 @@ public class SpeciesSearchFormPanel extends ContentPanel {
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;
SearchEvent event = new SearchEvent(type, searchTerm, upperBoundLongitude, upperBoundLatitude, lowerBoundLongitude, lowerBoundLatitude, fromDate, toDate, listDataSources, groupRank, resultType); SearchEvent event = new SearchEvent(type, searchTerm, upperBoundLongitude, upperBoundLatitude, lowerBoundLongitude, lowerBoundLatitude, fromDate, toDate, listDataSources, groupRank, resultType, listDataSourceForSynonyms, listDataSourceForUnfold);
eventBus.fireEvent(event); eventBus.fireEvent(event);
} }

View File

@ -10,7 +10,8 @@ public enum AdvancedSearchPanelEnum {
DATE("Filter by Date"), DATE("Filter by Date"),
TYPE("Type"), TYPE("Type"),
REGION("Region"), REGION("Region"),
SYNONYMS("Synonyms From"), SYNONYMS("Synonyms From"),
UNFOLD("Unfold With"),
DATASOURCE("Filter by Source"), DATASOURCE("Filter by Source"),
CLASSIFICATION("Classification"); CLASSIFICATION("Classification");

View File

@ -6,12 +6,14 @@ import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceCapability; import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceCapability;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel; import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability; import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
import com.extjs.gxt.ui.client.widget.ContentPanel; 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
@ -30,6 +32,7 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
private HashMap<String,DataSourceModel> listDataSources; private HashMap<String,DataSourceModel> listDataSources;
private SpeciesCapability currentSelectedCapability; private SpeciesCapability currentSelectedCapability;
private SynonymsFilter synonymsFilter; private SynonymsFilter synonymsFilter;
private UnfoldFilter unfoldFilter;
public static synchronized AdvancedSearchPanelManager getInstance() { public static synchronized AdvancedSearchPanelManager getInstance() {
if (instance == null) if (instance == null)
@ -44,6 +47,7 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
regionFilter = new RegionFilter(); regionFilter = new RegionFilter();
dataSourceFilter = new DataSourceFilter(); dataSourceFilter = new DataSourceFilter();
synonymsFilter = new SynonymsFilter(); synonymsFilter = new SynonymsFilter();
unfoldFilter = new UnfoldFilter();
// classificationFilter = new ClassificationFilter(); // classificationFilter = new ClassificationFilter();
init(); init();
@ -52,6 +56,7 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
listAdvacedPanels.add(boundsFilter.getName()); listAdvacedPanels.add(boundsFilter.getName());
listAdvacedPanels.add(dateFilter.getName()); listAdvacedPanels.add(dateFilter.getName());
listAdvacedPanels.add(synonymsFilter.getName()); listAdvacedPanels.add(synonymsFilter.getName());
listAdvacedPanels.add(unfoldFilter.getName());
// listAdvacedPanels.add(regionFilter.getName()); // listAdvacedPanels.add(regionFilter.getName());
} }
@ -71,6 +76,7 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
add(dataSourceFilter.getPanel()); add(dataSourceFilter.getPanel());
add(regionFilter.getPanel()); add(regionFilter.getPanel());
add(synonymsFilter.getPanel()); add(synonymsFilter.getPanel());
add(unfoldFilter.getPanel());
cardLayout.setActiveItem(boundsFilter.getPanel()); cardLayout.setActiveItem(boundsFilter.getPanel());
} }
@ -91,6 +97,8 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
cardLayout.setActiveItem(regionFilter.getPanel()); cardLayout.setActiveItem(regionFilter.getPanel());
else if(name.equals(AdvancedSearchPanelEnum.SYNONYMS.getLabel())) else if(name.equals(AdvancedSearchPanelEnum.SYNONYMS.getLabel()))
cardLayout.setActiveItem(synonymsFilter.getPanel()); cardLayout.setActiveItem(synonymsFilter.getPanel());
else if(name.equals(AdvancedSearchPanelEnum.UNFOLD.getLabel()))
cardLayout.setActiveItem(unfoldFilter.getPanel());
// else if(name.equals(AdvancedSearchPanelEnum.CLASSIFICATION.getLabel())) // else if(name.equals(AdvancedSearchPanelEnum.CLASSIFICATION.getLabel()))
// cardLayout.setActiveItem(classificationFilter.getPanel()); // cardLayout.setActiveItem(classificationFilter.getPanel());
} }
@ -127,8 +135,8 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
public void loadDataSource(List<DataSourceModel> result) { public void loadDataSource(List<DataSourceModel> result) {
dataSourceFilter.loadDataSource(result); dataSourceFilter.loadDataSource(result);
synonymsFilter.loadDataSource(result); synonymsFilter.loadDataSource(result);
unfoldFilter.loadDataSource(result);
listDataSources = new HashMap<String, DataSourceModel>(); listDataSources = new HashMap<String, DataSourceModel>();
@ -160,9 +168,10 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
dateFilter.addAvailablePlugInfo(dsm, SpeciesCapability.TODATE); dateFilter.addAvailablePlugInfo(dsm, SpeciesCapability.TODATE);
else if(capabilityEnum.equals(SpeciesCapability.UPPERBOUND)) else if(capabilityEnum.equals(SpeciesCapability.UPPERBOUND))
boundsFilter.addAvailablePlugInfo(dsm, SpeciesCapability.UPPERBOUND); boundsFilter.addAvailablePlugInfo(dsm, SpeciesCapability.UPPERBOUND);
else if(capabilityEnum.equals(SpeciesCapability.SYNONYMS)) // else if(capabilityEnum.equals(SpeciesCapability.SYNONYMS))
boundsFilter.addAvailablePlugInfo(dsm, SpeciesCapability.SYNONYMS); // synonymsFilter.addAvailablePlugInfo(dsm, SpeciesCapability.SYNONYMS);
// else if(capabilityEnum.equals(SpeciesCapability.UNFOLD))
// unfoldFilter.addAvailablePlugInfo(dsm, SpeciesCapability.UNFOLD);
} }
} }
} }
@ -184,6 +193,8 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
dateFilter.getPanel().setVisible(bool); dateFilter.getPanel().setVisible(bool);
dataSourceFilter.getPanel().setVisible(bool); dataSourceFilter.getPanel().setVisible(bool);
regionFilter.getPanel().setVisible(bool); regionFilter.getPanel().setVisible(bool);
synonymsFilter.getPanel().setVisible(bool);
unfoldFilter.getPanel().setVisible(bool);
// classificationFilter.getPanel().setVisible(bool); // classificationFilter.getPanel().setVisible(bool);
} }
@ -200,6 +211,11 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
} }
public List<DataSourceModel> getCheckedDataSourceForSynonyms() {
return synonymsFilter.getCheckedGroupList();
}
public HashMap<String, DataSourceModel> findDataSourceByCapability(SpeciesCapability capability) { public HashMap<String, DataSourceModel> findDataSourceByCapability(SpeciesCapability capability) {
if(capability.getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){ if(capability.getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
@ -229,9 +245,24 @@ public class AdvancedSearchPanelManager extends ContentPanel implements Advanced
public SpeciesCapability getCurrentSelectedCapability() { public SpeciesCapability getCurrentSelectedCapability() {
return currentSelectedCapability; return currentSelectedCapability;
} }
public List<DataSourceModel> getCheckedDataSourceForUnfold() {
return unfoldFilter.getCheckedGroupList();
}
// public String getGroupByRank(){ public void disableFilterForSearchType(SearchType type){
// return classificationFilter.getSelectedRank();
// } switch (type) {
case BY_COMMON_NAME:
unfoldFilter.activeChecks(false);
break;
default:
unfoldFilter.activeChecks(true);
break;
}
}
} }

View File

@ -63,6 +63,7 @@ public class SynonymsFilter implements AdvancedSearchPanelInterface{
hp.add(text); hp.add(text);
hp.add(checkGroup); hp.add(checkGroup);
synonymsFilterPanel.add(hp);
} }
@ -107,13 +108,13 @@ public class SynonymsFilter implements AdvancedSearchPanelInterface{
for (DataSourceCapability dsc : dsm.getListCapabilities()) { for (DataSourceCapability dsc : dsm.getListCapabilities()) {
System.out.println("\tData Source capability name: " + dsc.getCapability().getName()); // System.out.println("\tData Source capability name: " + dsc.getCapability().getName());
if(dsc.getCapability().getName().compareTo(SpeciesCapability.SYNONYMS.getName())==0){ if(dsc.getCapability().getName().compareTo(SpeciesCapability.SYNONYMS.getName())==0){
check = createCheckBox(dsm, SpeciesCapability.RESULTITEM.getName()); check = createCheckBox(dsm, dsc.getCapability().getName());
System.out.println("\t\t added check " + dsm.getName() + " to checkGroupOccurences " + dsc.getCapability().getName()); System.out.println("added check " + dsm.getName() + " for SYNONYMS");
checkGroup.add(check); checkGroup.add(check);
@ -135,5 +136,32 @@ public class SynonymsFilter implements AdvancedSearchPanelInterface{
} }
/**
*
* @return
*/
public List<DataSourceModel> getCheckedGroupList() {
List<DataSourceModel> listDS = new ArrayList<DataSourceModel>();
List<CheckBox> values = new ArrayList<CheckBox>();
if(checkGroup.getValues().size()>0)
values = checkGroup.getValues();
for (CheckBox checkBox : values) {
if (checkBox.isEnabled())
listDS.add(new DataSourceModel(checkBox.getValueAttribute(), checkBox.getValueAttribute()));
}
if(listDS.size()==0)
return null;
// System.out.println("print synonyms ds : "+listDS);
return listDS;
}
} }

View File

@ -0,0 +1,173 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.client.advancedsearch;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceCapability;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Jul 16, 2013
*
*/
public class UnfoldFilter implements AdvancedSearchPanelInterface{
private Button btnResetAllFilters = new Button("Reset Filters");
private ContentPanel unfoldFilterPanel = new ContentPanel();
private CheckBoxGroup checkGroup = new CheckBoxGroup();
@Override
public ContentPanel getPanel() {
btnResetAllFilters.setStyleName("button-hyperlink");
return unfoldFilterPanel;
}
public UnfoldFilter(){
init();
}
/**
*
*/
private void init() {
unfoldFilterPanel.setHeaderVisible(false);
unfoldFilterPanel.setBodyBorder(false);
unfoldFilterPanel.setLayout(new FitLayout());
unfoldFilterPanel.setStyleAttribute("marginLeft", "10px");
unfoldFilterPanel.setStyleAttribute("marginRight", "10px");
unfoldFilterPanel.setStyleAttribute("padding", "5px");
Text text = new Text("Unfold with: ");
text.setStyleAttribute("margin-left", "5px");
text.setStyleAttribute("margin-right", "5px");
HorizontalPanel hp = new HorizontalPanel();
hp.setVerticalAlign(VerticalAlignment.MIDDLE);
hp.add(text);
hp.add(checkGroup);
unfoldFilterPanel.add(hp);
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.speciesdiscovery.client.advancedsearch.AdvancedSearchPanelInterface#getName()
*/
@Override
public String getName() {
return AdvancedSearchPanelEnum.UNFOLD.getLabel();
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.speciesdiscovery.client.advancedsearch.AdvancedSearchPanelInterface#resetAdvancedFields()
*/
@Override
public void resetAdvancedFields() {
}
@Override
public ArrayList<DataSourceModel> getAvailablePlugIn() {
return null;
}
private static Comparator<DataSourceModel> COMPARATOR = new Comparator<DataSourceModel>() {
// This is where the sorting happens.
public int compare(DataSourceModel o1, DataSourceModel o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
};
public void loadDataSource(List<DataSourceModel> result) {
Collections.sort(result, COMPARATOR);
if(result!=null){
for(DataSourceModel dsm: result){
System.out.println("Data Source name " + dsm.getName());
CheckBox check = null;
for (DataSourceCapability dsc : dsm.getListCapabilities()) {
System.out.println("\tData Source capability name: " + dsc.getCapability().getName());
if(dsc.getCapability().getName().compareTo(SpeciesCapability.UNFOLD.getName())==0){
check = createCheckBox(dsm, dsc.getCapability().getName());
System.out.println("added check " + dsm.getName() + " for UNFOLD");
checkGroup.add(check);
}
}
}
}
}
private CheckBox createCheckBox(DataSourceModel dsm, String property) {
CheckBox check = new CheckBox();
check.setBoxLabel(dsm.getName());
check.setValueAttribute(dsm.getName());
check.setData("capability", dsm);
check.setToolTip(new ToolTipConfig(dsm.getDescription()));
return check;
}
/**
*
* @return
*/
public List<DataSourceModel> getCheckedGroupList() {
List<DataSourceModel> listDS = new ArrayList<DataSourceModel>();
List<CheckBox> values = new ArrayList<CheckBox>();
if(checkGroup.getValues().size()>0)
values = checkGroup.getValues();
for (CheckBox checkBox : values) {
if (checkBox.isEnabled())
listDS.add(new DataSourceModel(checkBox.getValueAttribute(), checkBox.getValueAttribute()));
}
if(listDS.size()==0)
return null;
// System.out.println("print unfold ds : "+listDS);
return listDS;
}
public void activeChecks(boolean bool){
checkGroup.reset();
checkGroup.setEnabled(bool);
}
}

View File

@ -15,7 +15,9 @@ import org.gcube.portlets.user.speciesdiscovery.shared.filter.ResultFilter;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
/** /**
* @author "Federico De Faveri defaveri@isti.cnr.it" *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Jul 17, 2013
* *
*/ */
public class SearchEvent extends GwtEvent<SearchEventHandler> { public class SearchEvent extends GwtEvent<SearchEventHandler> {
@ -45,10 +47,27 @@ public class SearchEvent extends GwtEvent<SearchEventHandler> {
private SpeciesCapability resultType; private SpeciesCapability resultType;
private String query; private String query;
private ResultFilter activeFilterOnResult; private ResultFilter activeFilterOnResult;
private Map<SearchType, List<String>> mapTermsSearched; //USED FORM SEARCH BY QUERY - TEXT QUERY private Map<SearchType, List<String>> mapTermsSearched; //USED FOR SEARCH BY QUERY - TEXT QUERY
private List<DataSourceModel> listDataSourcesForSynonyms; //USED FOR EXTEND
private List<DataSourceModel> listDataSourcesForUnfold; //USED FOR UNFOLD
/**
*
* @param type
* @param searchTerm
* @param upperBoundLongitude
* @param upperBoundLatitude
* @param lowerBoundLongitude
* @param lowerBoundLatitude
* @param fromDate
* @param toDate
* @param listDataSources
* @param rank
* @param resultType
* @param listDataSourcesForSynonyms
*/
public SearchEvent(SearchType type, String searchTerm, Number upperBoundLongitude, Number upperBoundLatitude, Number lowerBoundLongitude, Number lowerBoundLatitude, public SearchEvent(SearchType type, String searchTerm, Number upperBoundLongitude, Number upperBoundLatitude, Number lowerBoundLongitude, Number lowerBoundLatitude,
Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String rank, SpeciesCapability resultType) { Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String rank, SpeciesCapability resultType,List<DataSourceModel> listDataSourcesForSynonyms, List<DataSourceModel> listDataSourcesForUnfold) {
this.type = type; this.type = type;
this.searchTerm = searchTerm; this.searchTerm = searchTerm;
this.upperBoundLongitude = upperBoundLongitude; this.upperBoundLongitude = upperBoundLongitude;
@ -60,6 +79,8 @@ public class SearchEvent extends GwtEvent<SearchEventHandler> {
this.lstDataSources = listDataSources; this.lstDataSources = listDataSources;
this.groupByRank = rank; this.groupByRank = rank;
this.resultType = resultType; this.resultType = resultType;
this.listDataSourcesForSynonyms = listDataSourcesForSynonyms;
this.listDataSourcesForUnfold = listDataSourcesForUnfold;
} }
public SearchEvent(SearchType byQuery, String query) { public SearchEvent(SearchType byQuery, String query) {
@ -124,32 +145,6 @@ public class SearchEvent extends GwtEvent<SearchEventHandler> {
return toDate; return toDate;
} }
/**
* {@inheritDoc}
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SearchEvent [searchTerm=");
builder.append(searchTerm);
builder.append(", type=");
builder.append(type);
builder.append(", upperBoundLongitude=");
builder.append(upperBoundLongitude);
builder.append(", upperBoundLatitude=");
builder.append(upperBoundLatitude);
builder.append(", lowerBoundLongitude=");
builder.append(lowerBoundLongitude);
builder.append(", lowerBoundLatitude=");
builder.append(lowerBoundLatitude);
builder.append(", fromDate=");
builder.append(fromDate);
builder.append(", toDate=");
builder.append(toDate);
builder.append("]");
return builder.toString();
}
public List<DataSourceModel> getLstDataSources() { public List<DataSourceModel> getLstDataSources() {
return lstDataSources; return lstDataSources;
} }
@ -227,4 +222,62 @@ public class SearchEvent extends GwtEvent<SearchEventHandler> {
public void setMapTermsSearched(Map<SearchType, List<String>> mapTermsSearched) { public void setMapTermsSearched(Map<SearchType, List<String>> mapTermsSearched) {
this.mapTermsSearched = mapTermsSearched; this.mapTermsSearched = mapTermsSearched;
} }
public List<DataSourceModel> getListDataSourcesForSynonyms() {
return listDataSourcesForSynonyms;
}
public void setListDataSourcesForSynonyms(
List<DataSourceModel> listDataSourcesForSynonyms) {
this.listDataSourcesForSynonyms = listDataSourcesForSynonyms;
}
public List<DataSourceModel> getListDataSourcesForUnfold() {
return listDataSourcesForUnfold;
}
public void setListDataSourcesForUnfold(
List<DataSourceModel> listDataSourcesForUnfold) {
this.listDataSourcesForUnfold = listDataSourcesForUnfold;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SearchEvent [searchTerm=");
builder.append(searchTerm);
builder.append(", type=");
builder.append(type);
builder.append(", upperBoundLongitude=");
builder.append(upperBoundLongitude);
builder.append(", upperBoundLatitude=");
builder.append(upperBoundLatitude);
builder.append(", lowerBoundLongitude=");
builder.append(lowerBoundLongitude);
builder.append(", lowerBoundLatitude=");
builder.append(lowerBoundLatitude);
builder.append(", fromDate=");
builder.append(fromDate);
builder.append(", toDate=");
builder.append(toDate);
builder.append(", lstDataSources=");
builder.append(lstDataSources);
builder.append(", groupByRank=");
builder.append(groupByRank);
builder.append(", resultType=");
builder.append(resultType);
builder.append(", query=");
builder.append(query);
builder.append(", activeFilterOnResult=");
builder.append(activeFilterOnResult);
builder.append(", mapTermsSearched=");
builder.append(mapTermsSearched);
builder.append(", listDataSourcesForSynonyms=");
builder.append(listDataSourcesForSynonyms);
builder.append(", listDataSourcesForUnfold=");
builder.append(listDataSourcesForUnfold);
builder.append("]");
return builder.toString();
}
} }

View File

@ -0,0 +1,42 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.client.event;
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
import com.google.gwt.event.shared.GwtEvent;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class SearchTypeSelectedEvent extends GwtEvent<SearchTypeSelectedEventHandler> {
public static final GwtEvent.Type<SearchTypeSelectedEventHandler> TYPE = new Type<SearchTypeSelectedEventHandler>();
private SearchType searchType;
public SearchTypeSelectedEvent(SearchType searchType) {
this.searchType = searchType;
}
@Override
public Type<SearchTypeSelectedEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(SearchTypeSelectedEventHandler handler) {
handler.onSearchTypeSelected(this);
}
/**
* @return
*/
public SearchType getType() {
return searchType;
}
}

View File

@ -0,0 +1,22 @@
/**
*
*/
package org.gcube.portlets.user.speciesdiscovery.client.event;
import com.google.gwt.event.shared.EventHandler;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Jul 17, 2013
*
*/
public interface SearchTypeSelectedEventHandler extends EventHandler {
/**
* @param searchTypeSelectedEvent
*/
public void onSearchTypeSelected(SearchTypeSelectedEvent searchTypeSelectedEvent);
}

View File

@ -263,7 +263,7 @@ public class ResultFilterPanelManager{
} }
private void resetFilters() { public void resetFilters() {
dataSourceFilter.reset(); dataSourceFilter.reset();
dataProviderFilter.reset(); dataProviderFilter.reset();
classificationFilter.reset(); classificationFilter.reset();

View File

@ -15,7 +15,6 @@ import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
import org.gcube.portlets.user.speciesdiscovery.client.window.MessageBoxConfirm; import org.gcube.portlets.user.speciesdiscovery.client.window.MessageBoxConfirm;
import org.gcube.portlets.user.speciesdiscovery.shared.DataSource; import org.gcube.portlets.user.speciesdiscovery.shared.DataSource;
import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState; import org.gcube.portlets.user.speciesdiscovery.shared.DownloadState;
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;

View File

@ -11,16 +11,11 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.css.CSS; import com.google.gwt.query.client.css.CSS;
import com.google.gwt.query.client.css.Length; import com.google.gwt.query.client.css.Length;
import com.google.gwt.query.client.css.RGBColor;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel; import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HasName; import com.google.gwt.user.client.ui.HasName;

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.dataaccess.spql.ParserException; import org.gcube.dataaccess.spql.ParserException;
import org.gcube.dataaccess.spql.SPQLQueryParser; import org.gcube.dataaccess.spql.SPQLQueryParser;
import org.gcube.portlets.user.speciesdiscovery.shared.Coordinate; import org.gcube.portlets.user.speciesdiscovery.shared.Coordinate;
@ -16,8 +17,10 @@ public class QueryBuilder {
protected static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy"); protected static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
protected static Logger logger = Logger.getLogger(QueryBuilder.class);
public static String buildQuery(String searchTerm, SearchType searchType, SearchFilters searchFilters){ public static String buildQuery(String searchTerm, SearchType searchType, SearchFilters searchFilters){
logger.trace("query building...");
StringBuilder query = new StringBuilder(); StringBuilder query = new StringBuilder();
@ -37,6 +40,21 @@ public class QueryBuilder {
if (searchType == SearchType.BY_COMMON_NAME) query.append("RESOLVE "); if (searchType == SearchType.BY_COMMON_NAME) query.append("RESOLVE ");
//ADDED BY FRANCESCO 17/07/2013
//ADD EXPAND sources;
if (searchFilters.getListDataSourcesForSynonyms()!=null && searchFilters.getListDataSourcesForSynonyms().size()>0) {
query.append("EXPAND WITH ");
Iterator<DataSourceModel> dsIterator = searchFilters.getListDataSourcesForSynonyms().iterator();
while(dsIterator.hasNext()) {
DataSourceModel ds = dsIterator.next();
query.append(ds.getId());
if (dsIterator.hasNext()) query.append(", ");
else query.append(" ");
}
}
//ADD data sources; //ADD data sources;
if (searchFilters.getListDataSources()!=null && searchFilters.getListDataSources().size()>0) { if (searchFilters.getListDataSources()!=null && searchFilters.getListDataSources().size()>0) {
query.append("IN "); query.append("IN ");
@ -49,7 +67,6 @@ public class QueryBuilder {
else query.append(" "); else query.append(" ");
} }
} }
List<String> conditions = createFilterProperties(searchFilters); List<String> conditions = createFilterProperties(searchFilters);
@ -80,7 +97,10 @@ public class QueryBuilder {
String builtQuery = query.toString(); String builtQuery = query.toString();
System.out.println("built query: "+builtQuery); // System.out.println("built query: "+builtQuery);
logger.trace("built query: "+builtQuery);
//FIXME TEST //FIXME TEST
try { try {
SPQLQueryParser.parse(builtQuery); SPQLQueryParser.parse(builtQuery);

View File

@ -27,6 +27,7 @@ import org.gcube.data.spd.client.proxies.Occurrence;
import org.gcube.data.spd.model.Conditions; import org.gcube.data.spd.model.Conditions;
import org.gcube.data.spd.model.PluginDescription; import org.gcube.data.spd.model.PluginDescription;
import org.gcube.data.spd.model.RepositoryInfo; import org.gcube.data.spd.model.RepositoryInfo;
import org.gcube.data.spd.model.exceptions.InvalidQueryException;
import org.gcube.data.spd.model.products.OccurrencePoint; import org.gcube.data.spd.model.products.OccurrencePoint;
import org.gcube.data.spd.model.products.ResultElement; import org.gcube.data.spd.model.products.ResultElement;
import org.gcube.data.spd.model.products.TaxonomyItem; import org.gcube.data.spd.model.products.TaxonomyItem;
@ -155,9 +156,14 @@ public class SpeciesService {
// 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 (InvalidQueryException e1) {
String error = "Error calling the Species Service: query syntax is not valid";
logger.error("Error calling the Species Service: " + e1.getMessage(), e1);
throw new SearchServiceException(error);
} catch (Exception e) { } catch (Exception e) {
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 calling the Species Service: "+e.getMessage()); throw new SearchServiceException(error);
} }
} }
@ -276,7 +282,8 @@ public class SpeciesService {
case Classification: return SpeciesCapability.TAXONOMYITEM; case Classification: return SpeciesCapability.TAXONOMYITEM;
case NamesMapping: return SpeciesCapability.NAMESMAPPING; case NamesMapping: return SpeciesCapability.NAMESMAPPING;
case Occurrence: return SpeciesCapability.RESULTITEM; case Occurrence: return SpeciesCapability.RESULTITEM;
case Synonims: return SpeciesCapability.SYNONYMS; case Expansion: return SpeciesCapability.SYNONYMS;
case Unfold: return SpeciesCapability.UNFOLD;
default: return SpeciesCapability.UNKNOWN; default: return SpeciesCapability.UNKNOWN;
} }
} }

View File

@ -25,19 +25,27 @@ public class SearchFilters implements Serializable {
private List<DataSourceModel> listDataSources; private List<DataSourceModel> listDataSources;
private String classificationGroupByRank; private String classificationGroupByRank;
private SpeciesCapability resultType; private SpeciesCapability resultType;
private List<DataSourceModel> listDataSourcesForSynonyms;
private List<DataSourceModel> listDataSourcesForUnfold;
public SearchFilters(){}; public SearchFilters(){};
/** /**
*
* @param upperBound * @param upperBound
* @param lowerBound * @param lowerBound
* @param fromDate * @param fromDate
* @param toDate * @param toDate
* @param listDataSources * @param listDataSources
* @param classificationGroupRank * @param classificationGroupRank
* @param resultType
* @param listDataSourcesForSynonyms
*/ */
public SearchFilters(Coordinate upperBound, Coordinate lowerBound, Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String classificationGroupRank, SpeciesCapability resultType) { public SearchFilters(Coordinate upperBound, Coordinate lowerBound, Date fromDate, Date toDate, List<DataSourceModel> listDataSources, String classificationGroupRank, SpeciesCapability resultType, List<DataSourceModel> listDataSourcesForSynonyms, List<DataSourceModel> listDataSourcesForUnfold) {
this.upperBound = upperBound; this.upperBound = upperBound;
this.lowerBound = lowerBound; this.lowerBound = lowerBound;
this.fromDate = fromDate; this.fromDate = fromDate;
@ -45,6 +53,8 @@ public class SearchFilters implements Serializable {
this.listDataSources = listDataSources; this.listDataSources = listDataSources;
this.classificationGroupByRank = classificationGroupRank; this.classificationGroupByRank = classificationGroupRank;
this.resultType = resultType; this.resultType = resultType;
this.listDataSourcesForSynonyms = listDataSourcesForSynonyms;
this.listDataSourcesForUnfold = listDataSourcesForUnfold;
} }
/** /**
@ -124,6 +134,27 @@ public class SearchFilters implements Serializable {
this.listDataSources = listDataSources; this.listDataSources = listDataSources;
} }
public List<DataSourceModel> getListDataSourcesForSynonyms() {
return listDataSourcesForSynonyms;
}
public void setListDataSourcesForSynonyms(
List<DataSourceModel> listDataSourcesForSynonyms) {
this.listDataSourcesForSynonyms = listDataSourcesForSynonyms;
}
public List<DataSourceModel> getListDataSourcesForUnfold() {
return listDataSourcesForUnfold;
}
public void setListDataSourcesForUnfold(
List<DataSourceModel> listDataSourcesForUnfold) {
this.listDataSourcesForUnfold = listDataSourcesForUnfold;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -141,7 +172,12 @@ public class SearchFilters implements Serializable {
builder.append(classificationGroupByRank); builder.append(classificationGroupByRank);
builder.append(", resultType="); builder.append(", resultType=");
builder.append(resultType); builder.append(resultType);
builder.append(", listDataSourcesForSynonyms=");
builder.append(listDataSourcesForSynonyms);
builder.append(", listDataSourcesForUnfold=");
builder.append(listDataSourcesForUnfold);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -16,6 +16,7 @@ public enum SpeciesCapability {
SYNONYMS("SYNONYMS", "Synonyms"), SYNONYMS("SYNONYMS", "Synonyms"),
UNFOLD("UNFOLD", "Unfold"),
NAMESMAPPING("NAMESMAPPING", "Names Mapping"), NAMESMAPPING("NAMESMAPPING", "Names Mapping"),
UNKNOWN("UNKNOWN", "unknown"); UNKNOWN("UNKNOWN", "unknown");

View File

@ -1,21 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module rename-to='speciesdiscovery'> <module rename-to='speciesdiscovery'>
<inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.user.User' />
<!-- Other module inherits --> <!-- Other module inherits -->
<inherits name="com.extjs.gxt.ui.GXT"/> <inherits name="com.extjs.gxt.ui.GXT" />
<inherits name="org.gcube.portlets.user.gcubegisviewer.GCubeGisViewer" /> <inherits name="org.gcube.portlets.user.gcubegisviewer.GCubeGisViewer" />
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<set-property name="log_DivLogger" value="DISABLED" /> <set-property name="log_DivLogger" value="DISABLED" />
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery'/>
<!-- Specify the paths for translatable code --> <inherits name='com.google.gwt.query.Query' />
<source path='client'/>
<source path='shared'/> <!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module> </module>

View File

@ -0,0 +1,54 @@
/* Switch Button */
.switch-button-label {
float: left;
font-size: 10pt;
cursor: pointer;
}}
.switch-button-label.off {
color: #adadad;
}
.switch-button-label.on {
color: #0088CC;
}
.switch-button-background {
float: left;
position: relative;
background: #ccc;
border: 1px solid #aaa;
margin: 1px 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
cursor: pointer;
width: 25px;
height: 11px;
outline-style: none; /* this avoid the tabindex property to sorround this element with a (maybe dotted) rectangle*/
}
.switch-button-button {
position: absolute;
width: 12px;
height: 11px;
left: 12px;
top : -1px;
background: #FAFAFA;
border: 1px solid #aaa;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}