viewdetailswindows class was split in different class
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/speciesdiscovery@71452 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1424d76254
commit
181bc4a5f2
|
@ -3,12 +3,6 @@
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
<dependent-module archiveName="gis-viewer-3.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gis-viewer(branch)/gis-viewer(branch)">
|
|
||||||
<dependency-type>uses</dependency-type>
|
|
||||||
</dependent-module>
|
|
||||||
<dependent-module archiveName="gcube-gis-viewer-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-gis-viewer(branch)/gcube-gis-viewer(branch)">
|
|
||||||
<dependency-type>uses</dependency-type>
|
|
||||||
</dependent-module>
|
|
||||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||||
<property name="context-root" value="species-discovery"/>
|
<property name="context-root" value="species-discovery"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
7
pom.xml
7
pom.xml
|
@ -52,6 +52,13 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-fw-clients</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data.spd</groupId>
|
<groupId>org.gcube.data.spd</groupId>
|
||||||
<artifactId>spql-parser</artifactId>
|
<artifactId>spql-parser</artifactId>
|
||||||
|
|
|
@ -71,7 +71,7 @@ import org.gcube.portlets.user.speciesdiscovery.client.util.stream.DataSourceMan
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingLoader;
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingLoader;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.window.MessageBoxAlert;
|
import org.gcube.portlets.user.speciesdiscovery.client.window.MessageBoxAlert;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.window.MessageDialog;
|
import org.gcube.portlets.user.speciesdiscovery.client.window.MessageDialog;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.window.ViewDetailsWindow;
|
import org.gcube.portlets.user.speciesdiscovery.client.windowdetail.ViewDetailsWindow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
|
import org.gcube.portlets.user.speciesdiscovery.shared.CommonName;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.Coordinate;
|
import org.gcube.portlets.user.speciesdiscovery.shared.Coordinate;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
|
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
|
||||||
|
@ -82,6 +82,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchByQueryParameter;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
|
||||||
|
@ -268,10 +269,12 @@ 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());
|
||||||
else
|
}
|
||||||
|
else{
|
||||||
searchByQuery(event.getQuery());
|
searchByQuery(event.getQuery());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -633,7 +636,9 @@ public class SearchController {
|
||||||
@Override
|
@Override
|
||||||
public void onViewDetails(ViewDetailsOfSelectedEvent viewDetailsOfSelectedEvent) {
|
public void onViewDetails(ViewDetailsOfSelectedEvent viewDetailsOfSelectedEvent) {
|
||||||
|
|
||||||
final ViewDetailsWindow view = new ViewDetailsWindow(instance, lastSearchEvent.getResultType(), lastSearchEvent.getType());
|
// final ViewDetailsWindow view = new ViewDetailsWindow(instance, lastSearchEvent.getResultType(), lastSearchEvent.getType());
|
||||||
|
|
||||||
|
final ViewDetailsWindow view = new ViewDetailsWindow(lastSearchEvent);
|
||||||
|
|
||||||
//IF SELECTED CAPABILITY IS OCCURENCES - IS CALL LOAD OCCURENCES METHOD
|
//IF SELECTED CAPABILITY IS OCCURENCES - IS CALL LOAD OCCURENCES METHOD
|
||||||
if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
|
if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
|
||||||
|
@ -1231,7 +1236,7 @@ public class SearchController {
|
||||||
searchBorderLayoutPanel.getSpeciesCenterPanel().updateCurrentGridView(resultType);
|
searchBorderLayoutPanel.getSpeciesCenterPanel().updateCurrentGridView(resultType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsyncCallback<Void> initSearch(){
|
private AsyncCallback<Void> initSearchCallback(){
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
searchBorderLayoutPanel.getSpeciesCenterPanel().setFilterActive(false, "");
|
searchBorderLayoutPanel.getSpeciesCenterPanel().setFilterActive(false, "");
|
||||||
|
@ -1254,16 +1259,26 @@ public class SearchController {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsyncCallback<SearchResultType> initSearchByQuery(){
|
private AsyncCallback<SearchByQueryParameter> initSearchByQueryCallback(){
|
||||||
|
|
||||||
return new AsyncCallback<SearchResultType>() {
|
reset();
|
||||||
|
searchBorderLayoutPanel.getSpeciesCenterPanel().setFilterActive(false, "");
|
||||||
|
setOnlySelected(false);
|
||||||
|
|
||||||
|
return new AsyncCallback<SearchByQueryParameter>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(SearchResultType resultType) {
|
public void onSuccess(SearchByQueryParameter queryParameters) {
|
||||||
|
|
||||||
|
SpeciesCapability capability = Util.getCapabilityFromResultType(queryParameters.getSearchResultType());
|
||||||
|
|
||||||
|
//UPDATING LAST SEARCH EVENT FOR UPDATE THE GUI
|
||||||
|
lastSearchEvent.setResultType(capability);
|
||||||
|
lastSearchEvent.setMapTermsSearched(queryParameters.getTerms());
|
||||||
|
|
||||||
SpeciesCapability capability = Util.getCapabilityFromResultType(resultType);
|
|
||||||
setDataSourceType(capability);
|
setDataSourceType(capability);
|
||||||
switchView(capability);
|
switchView(capability);
|
||||||
|
|
||||||
searchBorderLayoutPanel.getSpeciesCenterPanel().activeToolBarButtons(true);
|
searchBorderLayoutPanel.getSpeciesCenterPanel().activeToolBarButtons(true);
|
||||||
// eventBus.fireEvent(new SearchStartedEvent());
|
// eventBus.fireEvent(new SearchStartedEvent());
|
||||||
streamPagingLoader.startLoading(false);
|
streamPagingLoader.startLoading(false);
|
||||||
|
@ -1283,12 +1298,7 @@ public class SearchController {
|
||||||
|
|
||||||
Log.trace("IN SEARCH BY QUERY..." + query);
|
Log.trace("IN SEARCH BY QUERY..." + query);
|
||||||
|
|
||||||
AsyncCallback<SearchResultType> callback = initSearchByQuery();
|
AsyncCallback<SearchByQueryParameter> callback = initSearchByQueryCallback();
|
||||||
|
|
||||||
reset();
|
|
||||||
searchBorderLayoutPanel.getSpeciesCenterPanel().setFilterActive(false, "");
|
|
||||||
setOnlySelected(false);
|
|
||||||
|
|
||||||
|
|
||||||
SpeciesDiscovery.taxonomySearchService.searchByQuery(query, callback);
|
SpeciesDiscovery.taxonomySearchService.searchByQuery(query, callback);
|
||||||
|
|
||||||
|
@ -1302,7 +1312,7 @@ public class SearchController {
|
||||||
|
|
||||||
Log.trace("IN SEARCH..............");
|
Log.trace("IN SEARCH..............");
|
||||||
|
|
||||||
AsyncCallback<Void> callback = initSearch();
|
AsyncCallback<Void> callback = initSearchCallback();
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.user.speciesdiscovery.client.event;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -31,7 +32,7 @@ public class SearchEvent extends GwtEvent<SearchEventHandler> {
|
||||||
handler.onSearch(this);
|
handler.onSearch(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String searchTerm;
|
protected String searchTerm; //USED FROM SEARCH BY GUI - SIMPLE QUERY
|
||||||
protected SearchType type;
|
protected SearchType type;
|
||||||
protected Number upperBoundLongitude;
|
protected Number upperBoundLongitude;
|
||||||
protected Number upperBoundLatitude;
|
protected Number upperBoundLatitude;
|
||||||
|
@ -44,6 +45,7 @@ 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
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -162,4 +164,64 @@ public class SearchEvent extends GwtEvent<SearchEventHandler> {
|
||||||
public String getQuery() {
|
public String getQuery() {
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSearchTerm(String searchTerm) {
|
||||||
|
this.searchTerm = searchTerm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(SearchType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpperBoundLongitude(Number upperBoundLongitude) {
|
||||||
|
this.upperBoundLongitude = upperBoundLongitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpperBoundLatitude(Number upperBoundLatitude) {
|
||||||
|
this.upperBoundLatitude = upperBoundLatitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLowerBoundLongitude(Number lowerBoundLongitude) {
|
||||||
|
this.lowerBoundLongitude = lowerBoundLongitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLowerBoundLatitude(Number lowerBoundLatitude) {
|
||||||
|
this.lowerBoundLatitude = lowerBoundLatitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromDate(Date fromDate) {
|
||||||
|
this.fromDate = fromDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToDate(Date toDate) {
|
||||||
|
this.toDate = toDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLstDataSources(List<DataSourceModel> lstDataSources) {
|
||||||
|
this.lstDataSources = lstDataSources;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupByRank(String groupByRank) {
|
||||||
|
this.groupByRank = groupByRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultType(SpeciesCapability resultType) {
|
||||||
|
this.resultType = resultType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuery(String query) {
|
||||||
|
this.query = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveFilterOnResult(ResultFilter activeFilterOnResult) {
|
||||||
|
this.activeFilterOnResult = activeFilterOnResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<SearchType, List<String>> getMapTermsSearched() {
|
||||||
|
return mapTermsSearched;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMapTermsSearched(Map<SearchType, List<String>> mapTermsSearched) {
|
||||||
|
this.mapTermsSearched = mapTermsSearched;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchByQueryParameter;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchStatus;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
|
import org.gcube.portlets.user.speciesdiscovery.shared.Taxon;
|
||||||
|
@ -43,8 +43,7 @@ public interface TaxonomySearchService extends RemoteService {
|
||||||
public void searchByCommonName(String searchTerm,
|
public void searchByCommonName(String searchTerm,
|
||||||
SearchFilters searchFilters) throws SearchServiceException;
|
SearchFilters searchFilters) throws SearchServiceException;
|
||||||
|
|
||||||
public SearchResultType searchByQuery(String query)
|
public SearchByQueryParameter searchByQuery(String query) throws SearchServiceException;
|
||||||
throws SearchServiceException;
|
|
||||||
|
|
||||||
public SearchStatus getSearchStatus(boolean onlySelected,
|
public SearchStatus getSearchStatus(boolean onlySelected,
|
||||||
boolean isActiveFilterOnResult) throws SearchServiceException;
|
boolean isActiveFilterOnResult) throws SearchServiceException;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchByQueryParameter;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
||||||
|
@ -74,7 +75,7 @@ public interface TaxonomySearchServiceAsync {
|
||||||
|
|
||||||
void countOfSelectedRow(AsyncCallback<Integer> callback);
|
void countOfSelectedRow(AsyncCallback<Integer> callback);
|
||||||
|
|
||||||
void searchByQuery(String query, AsyncCallback<SearchResultType> callback);
|
void searchByQuery(String query, AsyncCallback<SearchByQueryParameter> callback);
|
||||||
|
|
||||||
void getSearchResultRows(int start, int limit,
|
void getSearchResultRows(int start, int limit,
|
||||||
ResultFilter activeFiltersObject,
|
ResultFilter activeFiltersObject,
|
||||||
|
|
|
@ -0,0 +1,279 @@
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.client.windowdetail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.advancedsearch.AdvancedSearchPanelManager;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.externalsystem.OtherInformationSystemsEnum;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.externalsystem.OtherMappingSystemsEnum;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.window.WindowCredits;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.window.WindowOpenUrl;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.widget.Html;
|
||||||
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||||
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
|
|
||||||
|
public class CommonDetailComponents {
|
||||||
|
|
||||||
|
public final static String FIVEPX = "5px";
|
||||||
|
private SearchEvent lastSearchEvent;
|
||||||
|
private AbstractImagePrototype imageYes = AbstractImagePrototype.create(Resources.INSTANCE.getCheckYes());
|
||||||
|
private AbstractImagePrototype imageNo = AbstractImagePrototype.create(Resources.INSTANCE.getCheckNo());
|
||||||
|
|
||||||
|
CommonDetailComponents(SearchEvent lastSearchEvent){
|
||||||
|
this.lastSearchEvent = lastSearchEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSearchType(){
|
||||||
|
|
||||||
|
String searchType = "";
|
||||||
|
switch (lastSearchEvent.getType()) {
|
||||||
|
case BY_COMMON_NAME:
|
||||||
|
|
||||||
|
searchType = ConstantsSpeciesDiscovery.BYCOMMONNAME;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BY_SCIENTIFIC_NAME:
|
||||||
|
|
||||||
|
searchType = ConstantsSpeciesDiscovery.BYSCIENTIFICNAME;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return searchType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSearchTitle(){
|
||||||
|
|
||||||
|
|
||||||
|
return "<br/><br/><p style=\"font-size:18px;\"><b>" + lastSearchEvent.getSearchTerm() + "</b></p>" +
|
||||||
|
"<p style=\"font-family:\"Times New Roman\", Times, serif; font-size:12px; font-style:italic; \">search "+getSearchType()+"</p><br/><hr><br/>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createTableWithCheckCommonNameDataSource(HashMap<String, ArrayList<String>> hashCommonNameDataSources, ArrayList<String> listDataSourceFound){
|
||||||
|
|
||||||
|
|
||||||
|
List<String> listCommonNames = new ArrayList<String>(hashCommonNameDataSources.keySet());
|
||||||
|
Collections.sort(listCommonNames, String.CASE_INSENSITIVE_ORDER);
|
||||||
|
String table;
|
||||||
|
/*
|
||||||
|
To sort an ArrayList object, use Collection.sort method. This is a
|
||||||
|
static method. It sorts an ArrayList object's elements into ascending order.
|
||||||
|
*/
|
||||||
|
Collections.sort(listDataSourceFound);
|
||||||
|
|
||||||
|
|
||||||
|
//USE FOR DEBUG
|
||||||
|
// System.out.println("############# Common Name size " + listCommonNames.size());
|
||||||
|
// System.out.println("############# Data Source size " + listDataSourceFound.size());
|
||||||
|
//
|
||||||
|
// for (String dataSource : listDataSourceFound) {
|
||||||
|
// System.out.println("############# Data Source " + dataSource);
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(listCommonNames.size()>0){
|
||||||
|
|
||||||
|
int[][] checkCommonNameDataSources = new int[listCommonNames.size()][listDataSourceFound.size()];
|
||||||
|
|
||||||
|
//Create a matrix common names / data sources with 1 in coincidence values
|
||||||
|
for (int i=0; i< listCommonNames.size(); i++) {
|
||||||
|
|
||||||
|
String commonName = listCommonNames.get(i);
|
||||||
|
|
||||||
|
ArrayList<String> cmDataSources = hashCommonNameDataSources.get(commonName);
|
||||||
|
|
||||||
|
for (String dataSource : cmDataSources) {
|
||||||
|
// System.out.println("dataSource " + dataSource);
|
||||||
|
int index = listDataSourceFound.indexOf(dataSource);
|
||||||
|
// System.out.println("i: " + i + " index " + index);
|
||||||
|
checkCommonNameDataSources[i][index] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//USE FOR DEBUG
|
||||||
|
// for (int i=0; i<listCommonNames.size(); i++){
|
||||||
|
// for (int j=0; j<listDataSourceFound.size(); j++) {
|
||||||
|
// System.out.println(" ############ common name " + listCommonNames.get(i) + " i, j " + checkCommonNameDataSources[i][j]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
table = "<table class=\"simpletable\"\"><tr><th>Common names / Data Sources</th>";
|
||||||
|
|
||||||
|
for (String dataSource: listDataSourceFound) {
|
||||||
|
|
||||||
|
table+="<th>"+dataSource+"</th>";
|
||||||
|
}
|
||||||
|
|
||||||
|
table+="</tr>";
|
||||||
|
for (int i=0; i<listCommonNames.size(); i++){
|
||||||
|
|
||||||
|
table+= "<tr><td class=\"commonname\">"+listCommonNames.get(i)+"</td>";
|
||||||
|
|
||||||
|
for (int j=0; j<listDataSourceFound.size(); j++) {
|
||||||
|
|
||||||
|
if(checkCommonNameDataSources[i][j]==1)
|
||||||
|
table+="<td>"+imageYes.getHTML()+"</td>";
|
||||||
|
else
|
||||||
|
table+="<td>"+imageNo.getHTML()+"</td>";
|
||||||
|
}
|
||||||
|
table+="</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
table+="</table>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
table = "Not found";
|
||||||
|
|
||||||
|
|
||||||
|
return table;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public VerticalPanel createIndexOfContents(List<String> listScientificName){
|
||||||
|
|
||||||
|
VerticalPanel verticalPanel = new VerticalPanel();
|
||||||
|
verticalPanel.setStyleAttribute("margin", FIVEPX);
|
||||||
|
verticalPanel.setStyleAttribute("padding", FIVEPX);
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
|
||||||
|
for (final String scientificName : listScientificName) {
|
||||||
|
|
||||||
|
Anchor anchor = new Anchor(++i +". "+scientificName);
|
||||||
|
|
||||||
|
anchor.addClickHandler(new ClickHandler() {
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
com.google.gwt.user.client.Window.Location.assign("#"+scientificName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
verticalPanel.add(anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return verticalPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VerticalPanel createPanelAbout(SpeciesCapability capability, List<String> listDataSourcesFound) {
|
||||||
|
|
||||||
|
VerticalPanel verticalPanel = new VerticalPanel();
|
||||||
|
verticalPanel.setStyleAttribute("margin", FIVEPX);
|
||||||
|
verticalPanel.setStyleAttribute("padding", FIVEPX);
|
||||||
|
|
||||||
|
verticalPanel.add(new Html("<p style=\"font-size:12px;\"><b> About Data Sources</b></p><br/>"));
|
||||||
|
|
||||||
|
for (String dataSoruceName : listDataSourcesFound) {
|
||||||
|
DataSourceModel dataSource = AdvancedSearchPanelManager.getInstance().findDataSourceByCapabilityAndName(capability, dataSoruceName);
|
||||||
|
Anchor createAbout = createAbout(dataSource,false);
|
||||||
|
if(createAbout!=null)
|
||||||
|
verticalPanel.add(createAbout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return verticalPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Anchor createAbout(final DataSourceModel ds, boolean insertAboutCitation)
|
||||||
|
{
|
||||||
|
Anchor anchor = null;
|
||||||
|
|
||||||
|
if(ds!=null){
|
||||||
|
String anchorValue = "";
|
||||||
|
|
||||||
|
if(insertAboutCitation)
|
||||||
|
anchorValue = "<nobr>About "+ds.getName()+"</nobr>";
|
||||||
|
else
|
||||||
|
anchorValue = "<nobr>"+ds.getName()+"</nobr>";
|
||||||
|
|
||||||
|
anchor = new Anchor(anchorValue, true);
|
||||||
|
|
||||||
|
anchor.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
ArrayList<DataSourceModel> list = new ArrayList<DataSourceModel>();
|
||||||
|
list.add(ds);
|
||||||
|
new WindowCredits("About "+ds.getName(), list);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return anchor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param searchValue
|
||||||
|
* @return a vetical panel with external links on input
|
||||||
|
*/
|
||||||
|
public VerticalPanel createExternalLinks(final String searchValue){
|
||||||
|
|
||||||
|
VerticalPanel vpExternalLink = new VerticalPanel();
|
||||||
|
|
||||||
|
// Create Links to Other Information Systems
|
||||||
|
Html htmlLinkOIS = new Html("<p style=\"font-size:12px;\"><b>Links to Other Information Systems</b></p>");
|
||||||
|
VerticalPanel vpOIS = new VerticalPanel();
|
||||||
|
vpOIS.setStyleAttribute("margin", FIVEPX);
|
||||||
|
vpOIS.setStyleAttribute("padding", FIVEPX);
|
||||||
|
|
||||||
|
|
||||||
|
for (final OtherInformationSystemsEnum infSystem : OtherInformationSystemsEnum.values()) {
|
||||||
|
|
||||||
|
Anchor anchor = new Anchor(infSystem.getName());
|
||||||
|
anchor.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
String url = infSystem.getBaseUrl() + searchValue + infSystem.getSuffixUrl();
|
||||||
|
new WindowOpenUrl(url, "_blank", null);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vpOIS.add(anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create Links to Other Mapping Systems
|
||||||
|
Html htmlLinkOMS = new Html("<p style=\"font-size:12px;\"><b>Links to Other Mapping Systems</b></p>");
|
||||||
|
VerticalPanel vpOMS = new VerticalPanel();
|
||||||
|
vpOMS.setStyleAttribute("margin", FIVEPX);
|
||||||
|
vpOMS.setStyleAttribute("padding", FIVEPX);
|
||||||
|
|
||||||
|
|
||||||
|
for (final OtherMappingSystemsEnum infSystem : OtherMappingSystemsEnum.values()) {
|
||||||
|
|
||||||
|
Anchor anchor = new Anchor(infSystem.getName());
|
||||||
|
anchor.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
String url = infSystem.getBaseUrl() + searchValue + infSystem.getSuffixUrl();
|
||||||
|
new WindowOpenUrl(url, "_blank", null);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vpOMS.add(anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
vpExternalLink.add(htmlLinkOIS);
|
||||||
|
vpExternalLink.add(vpOIS);
|
||||||
|
|
||||||
|
vpExternalLink.add(htmlLinkOMS);
|
||||||
|
vpExternalLink.add(vpOMS);
|
||||||
|
|
||||||
|
return vpExternalLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.gcube.portlets.user.speciesdiscovery.client.window;
|
package org.gcube.portlets.user.speciesdiscovery.client.windowdetail;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -14,6 +14,7 @@ import org.gcube.portlets.user.speciesdiscovery.client.cluster.TablesForTaxonomy
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateOccurrenceJobEvent;
|
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateOccurrenceJobEvent;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent;
|
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent.TaxonomyJobType;
|
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent.TaxonomyJobType;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesMapEvent;
|
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesMapEvent;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.externalsystem.OtherInformationSystemsEnum;
|
import org.gcube.portlets.user.speciesdiscovery.client.externalsystem.OtherInformationSystemsEnum;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.externalsystem.OtherMappingSystemsEnum;
|
import org.gcube.portlets.user.speciesdiscovery.client.externalsystem.OtherMappingSystemsEnum;
|
||||||
|
@ -26,6 +27,8 @@ import org.gcube.portlets.user.speciesdiscovery.client.util.stream.DataSourceMan
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.ResultRowDataSource;
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.ResultRowDataSource;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingLoader;
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingLoader;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingToolBar;
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingToolBar;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.window.WindowCredits;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.window.WindowOpenUrl;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
|
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
||||||
|
@ -93,9 +96,9 @@ import com.google.gwt.user.client.ui.Anchor;
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ViewDetailsWindow extends Window {
|
public class CopyOfViewDetailsWindow extends Window {
|
||||||
|
|
||||||
protected final ViewDetailsWindow INSTANCE;
|
protected final CopyOfViewDetailsWindow INSTANCE;
|
||||||
|
|
||||||
protected StreamPagingLoader loader;
|
protected StreamPagingLoader loader;
|
||||||
protected int count = 0;
|
protected int count = 0;
|
||||||
|
@ -114,7 +117,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
public final static String FIVEPX = "5px";
|
public final static String FIVEPX = "5px";
|
||||||
|
|
||||||
|
|
||||||
private SearchController searchController;
|
// private SearchController searchController;
|
||||||
private ToolBar toolbarOccurrences;
|
private ToolBar toolbarOccurrences;
|
||||||
private DataSourceManager dataSourceManager;
|
private DataSourceManager dataSourceManager;
|
||||||
private AbstractImagePrototype imageYes = AbstractImagePrototype.create(Resources.INSTANCE.getCheckYes());
|
private AbstractImagePrototype imageYes = AbstractImagePrototype.create(Resources.INSTANCE.getCheckYes());
|
||||||
|
@ -123,24 +126,24 @@ public class ViewDetailsWindow extends Window {
|
||||||
private AbstractImagePrototype imgAttention = AbstractImagePrototype.create(Resources.INSTANCE.getAttention());
|
private AbstractImagePrototype imgAttention = AbstractImagePrototype.create(Resources.INSTANCE.getAttention());
|
||||||
|
|
||||||
private ToolBar toolbarTaxonomy;
|
private ToolBar toolbarTaxonomy;
|
||||||
private SearchType searchType;
|
|
||||||
private boolean isSearchByCommonName = false;
|
private boolean isSearchByCommonName = false;
|
||||||
private Timer timerGetCountOfOccurrences;
|
private Timer timerGetCountOfOccurrences;
|
||||||
|
|
||||||
private List<String> lastlistDataSourceFound = null;
|
private List<String> lastlistDataSourceFound = null;
|
||||||
private String lastScientificName = null;
|
private String lastScientificName = null;
|
||||||
|
|
||||||
public ViewDetailsWindow(SearchController searchController, SpeciesCapability capability, SearchType searchType) {
|
private SearchEvent lastSearchEvent;
|
||||||
|
|
||||||
|
public CopyOfViewDetailsWindow(SearchEvent lastSearchEvent) {
|
||||||
|
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
this.setCollapsible(false);
|
this.setCollapsible(false);
|
||||||
this.setMaximizable(true);
|
this.setMaximizable(true);
|
||||||
// this.setHideCollapseTool(true);
|
// this.setHideCollapseTool(true);
|
||||||
this.searchController = searchController;
|
|
||||||
this.dataSourceManager = DataSourceManager.getInstance();
|
this.dataSourceManager = DataSourceManager.getInstance();
|
||||||
this.searchType = searchType;
|
this.lastSearchEvent = lastSearchEvent;
|
||||||
|
|
||||||
if(searchType.equals(SearchType.BY_COMMON_NAME))
|
if(lastSearchEvent.getType().equals(SearchType.BY_COMMON_NAME))
|
||||||
isSearchByCommonName = true;
|
isSearchByCommonName = true;
|
||||||
|
|
||||||
container.setHeaderVisible(false);
|
container.setHeaderVisible(false);
|
||||||
|
@ -176,11 +179,11 @@ public class ViewDetailsWindow extends Window {
|
||||||
tabPanel = new TabPanel();
|
tabPanel = new TabPanel();
|
||||||
tabPanel.setBorders(false);
|
tabPanel.setBorders(false);
|
||||||
|
|
||||||
if(capability.getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
|
if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
|
||||||
this.toolbarOccurrences = createToolbarOccurrences();
|
this.toolbarOccurrences = createToolbarOccurrences();
|
||||||
createTabItemDisplayResultItem();
|
createTabItemDisplayResultItem();
|
||||||
}
|
}
|
||||||
else if(capability.getName().compareTo(SpeciesCapability.TAXONOMYITEM.getName())==0){
|
else if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.TAXONOMYITEM.getName())==0){
|
||||||
this.toolbarTaxonomy = createToolbarTaxonomy();
|
this.toolbarTaxonomy = createToolbarTaxonomy();
|
||||||
cretateTabItemDisplayTaxonomyItem();
|
cretateTabItemDisplayTaxonomyItem();
|
||||||
}
|
}
|
||||||
|
@ -192,6 +195,68 @@ public class ViewDetailsWindow extends Window {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public ViewDetailsWindow(SearchController searchController, SpeciesCapability capability, SearchType searchType) {
|
||||||
|
//
|
||||||
|
// INSTANCE = this;
|
||||||
|
// this.setCollapsible(false);
|
||||||
|
// this.setMaximizable(true);
|
||||||
|
//// this.setHideCollapseTool(true);
|
||||||
|
// this.dataSourceManager = DataSourceManager.getInstance();
|
||||||
|
// this.searchType = searchType;
|
||||||
|
//
|
||||||
|
// if(searchType.equals(SearchType.BY_COMMON_NAME))
|
||||||
|
// isSearchByCommonName = true;
|
||||||
|
//
|
||||||
|
// container.setHeaderVisible(false);
|
||||||
|
// container.setBodyBorder(false);
|
||||||
|
// container.setLayout(new FitLayout());
|
||||||
|
//
|
||||||
|
// setSize(width, height);
|
||||||
|
// setPlain(true);
|
||||||
|
// setModal(false);
|
||||||
|
// setBlinkModal(false);
|
||||||
|
// setHeading("View Details");
|
||||||
|
// setLayout(new FitLayout());
|
||||||
|
// addWindowListener(new WindowListener() {
|
||||||
|
// @Override
|
||||||
|
// public void windowHide(WindowEvent we) {
|
||||||
|
//
|
||||||
|
// //loader is null if items are taxonomy
|
||||||
|
// if(loader!=null)
|
||||||
|
// loader.reset();
|
||||||
|
//
|
||||||
|
// if(timerGetCountOfOccurrences!=null)
|
||||||
|
// stopTimerGetCountOfOccurrences(500);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// addListener(Events.Resize, new Listener<BoxComponentEvent>() {
|
||||||
|
// public void handleEvent(BoxComponentEvent event) {
|
||||||
|
// windowResize(INSTANCE.getWidth(), INSTANCE.getHeight());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// tabPanel = new TabPanel();
|
||||||
|
// tabPanel.setBorders(false);
|
||||||
|
//
|
||||||
|
// if(capability.getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
|
||||||
|
// this.toolbarOccurrences = createToolbarOccurrences();
|
||||||
|
// createTabItemDisplayResultItem();
|
||||||
|
// }
|
||||||
|
// else if(capability.getName().compareTo(SpeciesCapability.TAXONOMYITEM.getName())==0){
|
||||||
|
// this.toolbarTaxonomy = createToolbarTaxonomy();
|
||||||
|
// cretateTabItemDisplayTaxonomyItem();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// container.add(tabPanel,new FitData(4));
|
||||||
|
// add(container);
|
||||||
|
//
|
||||||
|
// show();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
protected void windowResize(int width,int height){
|
protected void windowResize(int width,int height){
|
||||||
|
|
||||||
if(width>widthPanelOccurrences)
|
if(width>widthPanelOccurrences)
|
||||||
|
@ -334,7 +399,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
msg+= tabItemDetails.getText() + " ("+size +" "+ items+")";
|
msg+= tabItemDetails.getText() + " ("+size +" "+ items+")";
|
||||||
tabItemDetails.setText(msg);
|
tabItemDetails.setText(msg);
|
||||||
|
|
||||||
createCommonNameDetailsPageForResultRow(searchController.getLastSearchEvent().getSearchTerm(), result);
|
createCommonNameDetailsPageForResultRow(lastSearchEvent.getSearchTerm(), result);
|
||||||
|
|
||||||
enableToolbarOccurrence(true);
|
enableToolbarOccurrence(true);
|
||||||
tabItemDetails.unmask();
|
tabItemDetails.unmask();
|
||||||
|
@ -387,7 +452,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
tabItemDetails.setText(msg);
|
tabItemDetails.setText(msg);
|
||||||
|
|
||||||
|
|
||||||
createCommonNameDetailsPageForTaxonomyRow(result, searchController.getLastSearchEvent().getSearchTerm());
|
createCommonNameDetailsPageForTaxonomyRow(result, lastSearchEvent.getSearchTerm());
|
||||||
enableToolbarTaxonomy(true);
|
enableToolbarTaxonomy(true);
|
||||||
tabItemDetails.unmask();
|
tabItemDetails.unmask();
|
||||||
|
|
||||||
|
@ -495,7 +560,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
TaxonomyRow taxonomy = result.getTaxonomyRowByKey(arrayTaxonomyID.get(i));
|
TaxonomyRow taxonomy = result.getTaxonomyRowByKey(arrayTaxonomyID.get(i));
|
||||||
String dataSource = taxonomy.getDataProviderName();
|
String dataSource = taxonomy.getDataProviderName();
|
||||||
|
|
||||||
TablesForTaxonomyRow tables = new TablesForTaxonomyRow(tabPanel, searchController.getEventBus());
|
TablesForTaxonomyRow tables = new TablesForTaxonomyRow(tabPanel, SearchController.eventBus);
|
||||||
|
|
||||||
HorizontalPanel horizontalPanel = new HorizontalPanel();
|
HorizontalPanel horizontalPanel = new HorizontalPanel();
|
||||||
horizontalPanel.add(new Html("<br/><p style=\"font-size:12px;\"><b> Scientific Classification of "+ scientificName + " on " +dataSource+ " Data Source</b> </p> "));
|
horizontalPanel.add(new Html("<br/><p style=\"font-size:12px;\"><b> Scientific Classification of "+ scientificName + " on " +dataSource+ " Data Source</b> </p> "));
|
||||||
|
@ -644,7 +709,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
searchController.getEventBus().fireEvent(new CreateTaxonomyJobEvent(TaxonomyJobType.BYIDS));
|
SearchController.eventBus.fireEvent(new CreateTaxonomyJobEvent(TaxonomyJobType.BYIDS));
|
||||||
|
|
||||||
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null));
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null));
|
||||||
}
|
}
|
||||||
|
@ -673,7 +738,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(ButtonEvent ce) {
|
public void componentSelected(ButtonEvent ce) {
|
||||||
searchController.getEventBus().fireEvent(new ShowOccurrencesMapEvent(count));
|
SearchController.eventBus.fireEvent(new ShowOccurrencesMapEvent(count));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -694,9 +759,9 @@ public class ViewDetailsWindow extends Window {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
||||||
|
|
||||||
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, searchController.getLastSearchEvent().getSearchTerm());
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
searchController.getEventBus().fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, lastlistDataSourceFound, searchTerm,false));
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, lastlistDataSourceFound, searchTerm,false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -713,9 +778,9 @@ public class ViewDetailsWindow extends Window {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
||||||
|
|
||||||
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, searchController.getLastSearchEvent().getSearchTerm());
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
searchController.getEventBus().fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, lastlistDataSourceFound, searchTerm,false));
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, lastlistDataSourceFound, searchTerm,false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -728,9 +793,9 @@ public class ViewDetailsWindow extends Window {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
||||||
|
|
||||||
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, searchController.getLastSearchEvent().getSearchTerm());
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
searchController.getEventBus().fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, lastlistDataSourceFound, searchTerm,true));
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, lastlistDataSourceFound, searchTerm,true));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -744,9 +809,9 @@ public class ViewDetailsWindow extends Window {
|
||||||
|
|
||||||
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
|
||||||
|
|
||||||
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, searchController.getLastSearchEvent().getSearchTerm());
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
searchController.getEventBus().fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, lastlistDataSourceFound, searchTerm,false));
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, lastlistDataSourceFound, searchTerm,false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -760,9 +825,9 @@ public class ViewDetailsWindow extends Window {
|
||||||
|
|
||||||
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
|
||||||
|
|
||||||
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, searchController.getLastSearchEvent().getSearchTerm());
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
searchController.getEventBus().fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, lastlistDataSourceFound, searchTerm,true));
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, lastlistDataSourceFound, searchTerm,true));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -784,9 +849,9 @@ public class ViewDetailsWindow extends Window {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.DARWIN_CORE, count, null));
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.DARWIN_CORE, count, null));
|
||||||
|
|
||||||
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, searchController.getLastSearchEvent().getSearchTerm());
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
searchController.getEventBus().fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.DARWIN_CORE, count, null, lastlistDataSourceFound, searchTerm, false));
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.DARWIN_CORE, count, null, lastlistDataSourceFound, searchTerm, false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
formatSubMenu.add(darwinCoreFormatItem);
|
formatSubMenu.add(darwinCoreFormatItem);
|
||||||
|
@ -801,7 +866,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
private String getSearchType(){
|
private String getSearchType(){
|
||||||
|
|
||||||
String searchType = "";
|
String searchType = "";
|
||||||
switch (searchController.getLastSearchEvent().getType()) {
|
switch (lastSearchEvent.getType()) {
|
||||||
case BY_COMMON_NAME:
|
case BY_COMMON_NAME:
|
||||||
|
|
||||||
searchType = ConstantsSpeciesDiscovery.BYCOMMONNAME;
|
searchType = ConstantsSpeciesDiscovery.BYCOMMONNAME;
|
||||||
|
@ -820,7 +885,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
private String getSearchTitle(){
|
private String getSearchTitle(){
|
||||||
|
|
||||||
|
|
||||||
return "<br/><br/><p style=\"font-size:18px;\"><b>" + searchController.getLastSearchEvent().getSearchTerm() + "</b></p>" +
|
return "<br/><br/><p style=\"font-size:18px;\"><b>" + lastSearchEvent.getSearchTerm() + "</b></p>" +
|
||||||
"<p style=\"font-family:\"Times New Roman\", Times, serif; font-size:12px; font-style:italic; \">search "+getSearchType()+"</p><br/><hr><br/>";
|
"<p style=\"font-family:\"Times New Roman\", Times, serif; font-size:12px; font-style:italic; \">search "+getSearchType()+"</p><br/><hr><br/>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1257,7 +1322,7 @@ public class ViewDetailsWindow extends Window {
|
||||||
"<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
|
"<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
|
||||||
"<style type=\"text/css\">" +getCssStyles() +
|
"<style type=\"text/css\">" +getCssStyles() +
|
||||||
"</style>" +
|
"</style>" +
|
||||||
"<title>"+searchController.getLastSearchEvent().getSearchTerm()+"</title>" +
|
"<title>"+lastSearchEvent.getSearchTerm()+"</title>" +
|
||||||
"</head>" +
|
"</head>" +
|
||||||
" <body>"+panelDetails.getElement().getInnerHTML()+"</body>" +
|
" <body>"+panelDetails.getElement().getInnerHTML()+"</body>" +
|
||||||
"</html> ";
|
"</html> ";
|
||||||
|
@ -1337,8 +1402,4 @@ public class ViewDetailsWindow extends Window {
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchController getSearchController() {
|
|
||||||
return searchController;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.client.windowdetail;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DetailsFiller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getLastScientificName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<String> getLastlistDataSourceFound();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.client.windowdetail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.cluster.TablesForResultRow;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.ResultRowDataSource;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSource;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForResultRow;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Html;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Info;
|
||||||
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.TabItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.TableData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||||
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
|
|
||||||
|
public class ResultRowDetailsFiller implements DetailsFiller {
|
||||||
|
|
||||||
|
|
||||||
|
private TabItem tabItemDetails;
|
||||||
|
private ToolBar toolbarOccurrences;
|
||||||
|
private AbstractImagePrototype imgAttention = AbstractImagePrototype.create(Resources.INSTANCE.getAttention());
|
||||||
|
private ContentPanel panelDetails;
|
||||||
|
private int width = 900;
|
||||||
|
private List<String> lastlistDataSourceFound;
|
||||||
|
private CommonDetailComponents common;
|
||||||
|
private String lastScientificName;
|
||||||
|
|
||||||
|
public ResultRowDetailsFiller(TabItem tabItemDetails, ToolBar toolbarOccurrences, ContentPanel panelDetails, SearchEvent lastSearchEvent){
|
||||||
|
this.tabItemDetails = tabItemDetails;
|
||||||
|
this.toolbarOccurrences = toolbarOccurrences;
|
||||||
|
this.panelDetails = panelDetails;
|
||||||
|
this.common = new CommonDetailComponents(lastSearchEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableToolbarOccurrence(boolean bool){
|
||||||
|
toolbarOccurrences.setEnabled(bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void loadStructuresAndFillingPage(){
|
||||||
|
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
SpeciesDiscovery.taxonomySearchService.loadStructuresForResultRowClustering(new AsyncCallback<ClusterStructuresForResultRow>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Info.display("Sorry", "Error retriving selected results");
|
||||||
|
tabItemDetails.unmask();
|
||||||
|
enableToolbarOccurrence(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ClusterStructuresForResultRow result) {
|
||||||
|
|
||||||
|
int size = result.getResult().size();
|
||||||
|
|
||||||
|
long returnedTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
long loadTime = returnedTime-startTime;
|
||||||
|
|
||||||
|
Log.trace("fillPageDetailsForOccurences: " +size +" cluster result row was loaded in "+ loadTime +" msc");
|
||||||
|
|
||||||
|
String items = size>0?"items":"item";
|
||||||
|
|
||||||
|
String msg = "";
|
||||||
|
|
||||||
|
if(result.getTotalRow()>size){
|
||||||
|
msg = ConstantsSpeciesDiscovery.ROW_LIMIT_REACHED + " - ";
|
||||||
|
tabItemDetails.setIcon(imgAttention);
|
||||||
|
tabItemDetails.setToolTip(ConstantsSpeciesDiscovery.THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS+ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg+= tabItemDetails.getText() + " ("+size +" "+ items+")";
|
||||||
|
tabItemDetails.setText(msg);
|
||||||
|
|
||||||
|
createCommonNameDetailsPageForResultRow(result);
|
||||||
|
|
||||||
|
enableToolbarOccurrence(true);
|
||||||
|
tabItemDetails.unmask();
|
||||||
|
|
||||||
|
long avilableTime = System.currentTimeMillis()-returnedTime;
|
||||||
|
|
||||||
|
Log.trace("fillPageDetailsForOccurences: " +size +" view details result row are available in "+ avilableTime +" msc");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCommonNameDetailsPageForResultRow(ClusterStructuresForResultRow result) {
|
||||||
|
|
||||||
|
HashMap<String, ArrayList<String>> hashResultRowIdTables = result.getHashClusterScientificNameResultRowID();
|
||||||
|
HashMap<String, ClusterCommonNameDataSource<ResultRow>> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
|
||||||
|
|
||||||
|
String title = common.getSearchTitle();
|
||||||
|
|
||||||
|
panelDetails.add(new Html(title));
|
||||||
|
|
||||||
|
List<String> listKey = new ArrayList<String>(hashResultRowIdTables.keySet());
|
||||||
|
Collections.sort(listKey);
|
||||||
|
|
||||||
|
final Anchor anchorIndex = new Anchor();
|
||||||
|
anchorIndex.setName("indexOfContents");
|
||||||
|
|
||||||
|
panelDetails.add(new Html("<p style=\"font-size:12px;\"><b> Index of Contents"+anchorIndex+"</b></p><br/>"));
|
||||||
|
panelDetails.add(common.createIndexOfContents(listKey));
|
||||||
|
|
||||||
|
panelDetails.add(new Html("<hr><br/>"));
|
||||||
|
|
||||||
|
//update last list data source found
|
||||||
|
lastlistDataSourceFound = result.getListFoundDataSources();
|
||||||
|
|
||||||
|
VerticalPanel verticaPanelAbouts = common.createPanelAbout(SpeciesCapability.RESULTITEM, result.getListFoundDataSources());
|
||||||
|
panelDetails.add(verticaPanelAbouts);
|
||||||
|
panelDetails.add(new Html("<br/>"));
|
||||||
|
|
||||||
|
for (final String scientificName : listKey) {
|
||||||
|
|
||||||
|
Anchor anchor = new Anchor("[top index]");
|
||||||
|
anchor.setName(scientificName);
|
||||||
|
|
||||||
|
anchor.addClickHandler(new ClickHandler() {
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
com.google.gwt.user.client.Window.Location.assign("#indexOfContents");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LayoutContainer titleContainer = new LayoutContainer();
|
||||||
|
titleContainer.setLayout(new ColumnLayout());
|
||||||
|
titleContainer.setWidth(width-80);
|
||||||
|
|
||||||
|
LayoutContainer left = new LayoutContainer();
|
||||||
|
FormLayout layout = new FormLayout();
|
||||||
|
left.setLayout(layout);
|
||||||
|
|
||||||
|
LayoutContainer right = new LayoutContainer();
|
||||||
|
layout = new FormLayout();
|
||||||
|
right.setLayout(layout);
|
||||||
|
|
||||||
|
|
||||||
|
HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
hp.setTableWidth("100%");
|
||||||
|
TableData td = new TableData();
|
||||||
|
td.setHorizontalAlign(HorizontalAlignment.RIGHT);
|
||||||
|
hp.add(anchor, td);
|
||||||
|
|
||||||
|
|
||||||
|
titleContainer.add(left, new ColumnData(.8));
|
||||||
|
titleContainer.add(right, new ColumnData(.2));
|
||||||
|
|
||||||
|
this.lastScientificName = scientificName;
|
||||||
|
|
||||||
|
|
||||||
|
left.add(new Html("<p style=\"margin-right:5px; font-size:14px;\"><b>" + ConstantsSpeciesDiscovery.SCIENTIFICNAME + ": " + scientificName + "</b></p>"));
|
||||||
|
right.add(hp);
|
||||||
|
|
||||||
|
panelDetails.add(titleContainer);
|
||||||
|
|
||||||
|
panelDetails.add(new Html("<br/><br/>"));
|
||||||
|
|
||||||
|
panelDetails.add(common.createExternalLinks(scientificName));
|
||||||
|
|
||||||
|
String commonNamesTitle = "<p style=\"font-size:12px;\"><b>Common Names (Data Source/s)</b></p>";
|
||||||
|
panelDetails.add(new Html(commonNamesTitle));
|
||||||
|
|
||||||
|
ClusterCommonNameDataSource<ResultRow> cluster = hashClusterCommonNamesDataSources.get(scientificName);
|
||||||
|
|
||||||
|
String tableCommonName = common.createTableWithCheckCommonNameDataSource(cluster.getHashMapCommonNameDataSources(), cluster.getListDataSourcesFound());
|
||||||
|
panelDetails.add(new Html("<br/>"+tableCommonName+"<br/><br/>"));
|
||||||
|
|
||||||
|
ArrayList<String> arrayRowID = hashResultRowIdTables.get(scientificName);
|
||||||
|
|
||||||
|
for(int i=0; i<arrayRowID.size(); i++ ){
|
||||||
|
ResultRow row = result.getResultRowByRowID(arrayRowID.get(i));
|
||||||
|
Html table = TablesForResultRow.getTableForResultRow(row, ResultRowDataSource.getClassification(row.getParents()));
|
||||||
|
panelDetails.add(table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
panelDetails.layout(true);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<String> getLastlistDataSourceFound() {
|
||||||
|
return lastlistDataSourceFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLastScientificName() {
|
||||||
|
return lastScientificName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,253 @@
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.client.windowdetail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.SearchController;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.advancedsearch.AdvancedSearchPanelManager;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.cluster.TablesForTaxonomyRow;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.DataSourceModel;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.TaxonomyRow;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterCommonNameDataSource;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.cluster.ClusterStructuresForTaxonomyRow;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
|
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.Html;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Info;
|
||||||
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.TabItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.TabPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.TableData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||||
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||||
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
|
|
||||||
|
public class TaxonomyRowDetailsFiller implements DetailsFiller {
|
||||||
|
|
||||||
|
private TabItem tabItemDetails;
|
||||||
|
private ToolBar toolbarTaxonomy;
|
||||||
|
private AbstractImagePrototype imgAttention = AbstractImagePrototype.create(Resources.INSTANCE.getAttention());
|
||||||
|
private ContentPanel panelDetails;
|
||||||
|
private int width = 900;
|
||||||
|
private List<String> lastlistDataSourceFound;
|
||||||
|
private CommonDetailComponents common;
|
||||||
|
private String lastScientificName;
|
||||||
|
private TabPanel tabPanel;
|
||||||
|
|
||||||
|
public TaxonomyRowDetailsFiller(TabItem tabItemDetails, ToolBar toolbarTaxonomy, TabPanel tabPanel, ContentPanel panelDetails, SearchEvent lastSearchEvent){
|
||||||
|
this.tabItemDetails = tabItemDetails;
|
||||||
|
this.toolbarTaxonomy = toolbarTaxonomy;
|
||||||
|
this.panelDetails = panelDetails;
|
||||||
|
this.tabPanel = tabPanel;
|
||||||
|
this.common = new CommonDetailComponents(lastSearchEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void enableToolbarTaxonomy(boolean bool){
|
||||||
|
toolbarTaxonomy.setEnabled(bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadStructuresAndFillingPage(){
|
||||||
|
|
||||||
|
final long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
SpeciesDiscovery.taxonomySearchService.loadStructuresForTaxonomyClustering(new AsyncCallback<ClusterStructuresForTaxonomyRow>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Info.display("Sorry", "Error retriving selected results");
|
||||||
|
tabItemDetails.unmask();
|
||||||
|
enableToolbarTaxonomy(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ClusterStructuresForTaxonomyRow result) {
|
||||||
|
|
||||||
|
int size = result.getResult().size();
|
||||||
|
|
||||||
|
long returnedTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
long loadTime = returnedTime-startTime;
|
||||||
|
|
||||||
|
Log.trace("fillPageDetailsForTaxonomy: " +size +" cluster taxonomy row was loaded in "+ loadTime +" msc");
|
||||||
|
|
||||||
|
// TablesForTaxonomyRow tableClassification = new TablesForTaxonomyRow(result, DEFAULTLANGUAGE, tabPanel, isSearchByCommonName, searchController.getEventBus());
|
||||||
|
|
||||||
|
String items = size>0?"items":"item";
|
||||||
|
|
||||||
|
String msg = "";
|
||||||
|
|
||||||
|
if(result.getTotalRow()>size){
|
||||||
|
msg = ConstantsSpeciesDiscovery.ROW_LIMIT_REACHED + " - ";
|
||||||
|
tabItemDetails.setIcon(imgAttention);
|
||||||
|
tabItemDetails.setToolTip(ConstantsSpeciesDiscovery.THE_MAX_NUMBER_OF_ITEMS_DISPLAYABLE_IS+ConstantsSpeciesDiscovery.LIMIT_ITEM_DETAILS);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg+= tabItemDetails.getText() + " ("+size +" "+ items+")";
|
||||||
|
tabItemDetails.setText(msg);
|
||||||
|
|
||||||
|
|
||||||
|
createCommonNameDetailsPageForTaxonomyRow(result);
|
||||||
|
enableToolbarTaxonomy(true);
|
||||||
|
tabItemDetails.unmask();
|
||||||
|
|
||||||
|
long avilableTime = returnedTime-loadTime;
|
||||||
|
|
||||||
|
Log.trace("fillPageDetailsForTaxonomy: " +size +" view details taxonomy row are available in "+ avilableTime +" msc");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCommonNameDetailsPageForTaxonomyRow(ClusterStructuresForTaxonomyRow result) {
|
||||||
|
HashMap<String, ArrayList<String>> hashTaxonomyRowID = result.getHashClusterScientificNameTaxonomyRowID();
|
||||||
|
// ArrayList<String> listDataSourceFound = tableClassification.getListFoundDataSources();
|
||||||
|
HashMap<String,ClusterCommonNameDataSource<TaxonomyRow>> hashClusterCommonNamesDataSources = result.getHashClusterCommonNamesDataSources();
|
||||||
|
|
||||||
|
// HashMap<String, ArrayList<GxtClassificationModel>> hashHTMLTables = result.getHashClassificationTables();
|
||||||
|
|
||||||
|
String title = common.getSearchTitle();
|
||||||
|
panelDetails.add(new Html(title));
|
||||||
|
|
||||||
|
// for (String dataSource : listDataSourceFound) {
|
||||||
|
// System.out.println("############# Data Source found " + dataSource);
|
||||||
|
// }
|
||||||
|
|
||||||
|
List<String> listKey = new ArrayList<String>(hashTaxonomyRowID.keySet());
|
||||||
|
Collections.sort(listKey);
|
||||||
|
|
||||||
|
|
||||||
|
final Anchor anchorIndex = new Anchor();
|
||||||
|
anchorIndex.setName("indexOfContents");
|
||||||
|
|
||||||
|
panelDetails.add(new Html("<p style=\"font-size:12px;\"><b> Index of Contents"+anchorIndex+"</b></p><br/>"));
|
||||||
|
panelDetails.add(common.createIndexOfContents(listKey));
|
||||||
|
|
||||||
|
//update last list data source found
|
||||||
|
lastlistDataSourceFound = result.getListFoundDataSources();
|
||||||
|
|
||||||
|
//Create panels about
|
||||||
|
panelDetails.add(new Html("<hr><br/>"));
|
||||||
|
VerticalPanel verticaPanelAbouts = common.createPanelAbout(SpeciesCapability.TAXONOMYITEM, result.getListFoundDataSources());
|
||||||
|
panelDetails.add(verticaPanelAbouts);
|
||||||
|
panelDetails.add(new Html("<br/>"));
|
||||||
|
|
||||||
|
for (final String scientificName : listKey) {
|
||||||
|
|
||||||
|
Anchor anchor = new Anchor("[top index]");
|
||||||
|
anchor.setName(scientificName);
|
||||||
|
|
||||||
|
anchor.addClickHandler(new ClickHandler() {
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
com.google.gwt.user.client.Window.Location.assign("#indexOfContents");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LayoutContainer titleContainer = new LayoutContainer();
|
||||||
|
titleContainer.setLayout(new ColumnLayout());
|
||||||
|
titleContainer.setWidth(width-80);
|
||||||
|
|
||||||
|
LayoutContainer left = new LayoutContainer();
|
||||||
|
FormLayout layout = new FormLayout();
|
||||||
|
left.setLayout(layout);
|
||||||
|
|
||||||
|
LayoutContainer right = new LayoutContainer();
|
||||||
|
layout = new FormLayout();
|
||||||
|
right.setLayout(layout);
|
||||||
|
|
||||||
|
|
||||||
|
HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
hp.setTableWidth("100%");
|
||||||
|
TableData td = new TableData();
|
||||||
|
td.setHorizontalAlign(HorizontalAlignment.RIGHT);
|
||||||
|
hp.add(anchor, td);
|
||||||
|
|
||||||
|
|
||||||
|
titleContainer.add(left, new ColumnData(.8));
|
||||||
|
titleContainer.add(right, new ColumnData(.2));
|
||||||
|
|
||||||
|
// HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
// hp.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||||
|
// hp.setStyleAttribute("margin", FIVEPX);
|
||||||
|
|
||||||
|
this.lastScientificName = scientificName;
|
||||||
|
|
||||||
|
left.add(new Html("<p style=\"margin-right:5px; font-size:14px;\"><b>" + ConstantsSpeciesDiscovery.SCIENTIFICNAME + ": " + scientificName + "</b></p>"));
|
||||||
|
right.add(hp);
|
||||||
|
|
||||||
|
panelDetails.add(titleContainer);
|
||||||
|
panelDetails.add(new Html("<br/><br/>"));
|
||||||
|
panelDetails.add(common.createExternalLinks(scientificName));
|
||||||
|
|
||||||
|
String commonNamesTitle = "<p style=\"font-size:12px;\"><b>Common Names (Data Source/s)</b></p>";
|
||||||
|
panelDetails.add(new Html(commonNamesTitle));
|
||||||
|
|
||||||
|
ClusterCommonNameDataSource<TaxonomyRow> cluster = hashClusterCommonNamesDataSources.get(scientificName);
|
||||||
|
|
||||||
|
String tableCommonName = common.createTableWithCheckCommonNameDataSource(cluster.getHashMapCommonNameDataSources(), cluster.getListDataSourcesFound());
|
||||||
|
panelDetails.add(new Html("<br/>"+tableCommonName+"<br/>"));
|
||||||
|
|
||||||
|
ArrayList<String> arrayTaxonomyID = hashTaxonomyRowID.get(scientificName);
|
||||||
|
|
||||||
|
for(int i=0; i<arrayTaxonomyID.size(); i++ ){
|
||||||
|
TaxonomyRow taxonomy = result.getTaxonomyRowByKey(arrayTaxonomyID.get(i));
|
||||||
|
String dataSource = taxonomy.getDataProviderName();
|
||||||
|
|
||||||
|
TablesForTaxonomyRow tables = new TablesForTaxonomyRow(tabPanel, SearchController.eventBus);
|
||||||
|
|
||||||
|
HorizontalPanel horizontalPanel = new HorizontalPanel();
|
||||||
|
horizontalPanel.add(new Html("<br/><p style=\"font-size:12px;\"><b> Scientific Classification of "+ scientificName + " on " +dataSource+ " Data Source</b> </p> "));
|
||||||
|
horizontalPanel.setVerticalAlign(VerticalAlignment.BOTTOM);
|
||||||
|
|
||||||
|
DataSourceModel ds = AdvancedSearchPanelManager.getInstance().findDataSourceByCapabilityAndName(SpeciesCapability.TAXONOMYITEM, dataSource);
|
||||||
|
|
||||||
|
Anchor createAbout = common.createAbout(ds,true);
|
||||||
|
if(createAbout!=null){
|
||||||
|
createAbout.getElement().getStyle().setMarginLeft(25, Unit.PX);
|
||||||
|
horizontalPanel.add(createAbout);
|
||||||
|
}
|
||||||
|
|
||||||
|
panelDetails.add(horizontalPanel);
|
||||||
|
panelDetails.add(tables.getPanelClassificationForTaxonomy(taxonomy, dataSource, false));
|
||||||
|
|
||||||
|
tables.setParents(taxonomy.getParents());
|
||||||
|
panelDetails.add(tables.getHTMLTableForTaxonomyWithRef(taxonomy, false, dataSource));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
panelDetails.layout(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLastScientificName() {
|
||||||
|
return lastScientificName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getLastlistDataSourceFound() {
|
||||||
|
return lastlistDataSourceFound;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,766 @@
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.client.windowdetail;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.ConstantsSpeciesDiscovery;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.SearchController;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.SpeciesDiscovery;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateOccurrenceJobEvent;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.CreateTaxonomyJobEvent.TaxonomyJobType;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.SearchEvent;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.event.ShowOccurrencesMapEvent;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.gridview.OccurrenceJobGridManager;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.GridField;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.OccurencesGridFields;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.Util;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.DataSourceManager;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingLoader;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.client.util.stream.StreamPagingToolBar;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.extjs.gxt.ui.client.Style.ButtonArrowAlign;
|
||||||
|
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
||||||
|
import com.extjs.gxt.ui.client.Style.IconAlign;
|
||||||
|
import com.extjs.gxt.ui.client.Style.Scroll;
|
||||||
|
import com.extjs.gxt.ui.client.data.ModelData;
|
||||||
|
import com.extjs.gxt.ui.client.event.BoxComponentEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.Events;
|
||||||
|
import com.extjs.gxt.ui.client.event.Listener;
|
||||||
|
import com.extjs.gxt.ui.client.event.MenuEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
|
import com.extjs.gxt.ui.client.event.WindowEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.WindowListener;
|
||||||
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Info;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Label;
|
||||||
|
import com.extjs.gxt.ui.client.widget.TabItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.TabPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Window;
|
||||||
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FitData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.menu.Menu;
|
||||||
|
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||||
|
import com.google.gwt.core.client.Scheduler;
|
||||||
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ViewDetailsWindow extends Window {
|
||||||
|
|
||||||
|
protected final ViewDetailsWindow INSTANCE;
|
||||||
|
|
||||||
|
protected StreamPagingLoader loader;
|
||||||
|
protected int count = 0;
|
||||||
|
// private int numberOfSelectedRow = 0;
|
||||||
|
private ContentPanel container = new ContentPanel();
|
||||||
|
private TabPanel tabPanel = new TabPanel();
|
||||||
|
private TabItem tabItemOccrs = new TabItem(ConstantsSpeciesDiscovery.OCCURRENCEPOINTS);
|
||||||
|
private TabItem tabItemDetails = new TabItem(ConstantsSpeciesDiscovery.DETAILS);
|
||||||
|
private ContentPanel panelDetails = new ContentPanel();
|
||||||
|
private ContentPanel panelOccurrences = new ContentPanel();
|
||||||
|
|
||||||
|
private int width = 900;
|
||||||
|
private int height = 600;
|
||||||
|
private int widthPanelOccurrences = 1200;
|
||||||
|
private int heightPanelOccurrences = height-70;
|
||||||
|
public final static String FIVEPX = "5px";
|
||||||
|
|
||||||
|
|
||||||
|
// private SearchController searchController;
|
||||||
|
private ToolBar toolbarOccurrences;
|
||||||
|
private DataSourceManager dataSourceManager;
|
||||||
|
|
||||||
|
|
||||||
|
private ToolBar toolbarTaxonomy;
|
||||||
|
private boolean isSearchByCommonName = false;
|
||||||
|
private Timer timerGetCountOfOccurrences;
|
||||||
|
|
||||||
|
// private List<String> lastlistDataSourceFound = null;
|
||||||
|
|
||||||
|
private DetailsFiller detailsFiller;
|
||||||
|
|
||||||
|
private SearchEvent lastSearchEvent;
|
||||||
|
|
||||||
|
public ViewDetailsWindow(SearchEvent lastSearchEvent) {
|
||||||
|
|
||||||
|
INSTANCE = this;
|
||||||
|
this.setCollapsible(false);
|
||||||
|
this.setMaximizable(true);
|
||||||
|
// this.setHideCollapseTool(true);
|
||||||
|
this.dataSourceManager = DataSourceManager.getInstance();
|
||||||
|
this.lastSearchEvent = lastSearchEvent;
|
||||||
|
|
||||||
|
if(lastSearchEvent.getType().equals(SearchType.BY_COMMON_NAME))
|
||||||
|
isSearchByCommonName = true;
|
||||||
|
|
||||||
|
container.setHeaderVisible(false);
|
||||||
|
container.setBodyBorder(false);
|
||||||
|
container.setLayout(new FitLayout());
|
||||||
|
|
||||||
|
setSize(width, height);
|
||||||
|
setPlain(true);
|
||||||
|
setModal(false);
|
||||||
|
setBlinkModal(false);
|
||||||
|
setHeading("View Details");
|
||||||
|
setLayout(new FitLayout());
|
||||||
|
addWindowListener(new WindowListener() {
|
||||||
|
@Override
|
||||||
|
public void windowHide(WindowEvent we) {
|
||||||
|
|
||||||
|
//loader is null if items are taxonomy
|
||||||
|
if(loader!=null)
|
||||||
|
loader.reset();
|
||||||
|
|
||||||
|
if(timerGetCountOfOccurrences!=null)
|
||||||
|
stopTimerGetCountOfOccurrences(500);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addListener(Events.Resize, new Listener<BoxComponentEvent>() {
|
||||||
|
public void handleEvent(BoxComponentEvent event) {
|
||||||
|
windowResize(INSTANCE.getWidth(), INSTANCE.getHeight());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tabPanel = new TabPanel();
|
||||||
|
tabPanel.setBorders(false);
|
||||||
|
|
||||||
|
if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
|
||||||
|
this.toolbarOccurrences = createToolbarOccurrences();
|
||||||
|
createTabItemDisplayResultItem();
|
||||||
|
}
|
||||||
|
else if(lastSearchEvent.getResultType().getName().compareTo(SpeciesCapability.TAXONOMYITEM.getName())==0){
|
||||||
|
this.toolbarTaxonomy = createToolbarTaxonomy();
|
||||||
|
cretateTabItemDisplayTaxonomyItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
container.add(tabPanel,new FitData(4));
|
||||||
|
add(container);
|
||||||
|
|
||||||
|
show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void windowResize(int width,int height){
|
||||||
|
|
||||||
|
if(width>widthPanelOccurrences)
|
||||||
|
panelOccurrences.setWidth(width-20);
|
||||||
|
else
|
||||||
|
panelOccurrences.setWidth(widthPanelOccurrences);
|
||||||
|
|
||||||
|
if(height>heightPanelOccurrences)
|
||||||
|
panelOccurrences.setHeight(height-70);
|
||||||
|
else
|
||||||
|
panelOccurrences.setHeight(heightPanelOccurrences);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void cretateTabItemDisplayTaxonomyItem() {
|
||||||
|
|
||||||
|
tabItemDetails.setScrollMode(Scroll.AUTO);
|
||||||
|
|
||||||
|
ContentPanel cpDetailsTaxonomy = new ContentPanel();
|
||||||
|
cpDetailsTaxonomy.setHeaderVisible(false);
|
||||||
|
cpDetailsTaxonomy.setBodyBorder(false);
|
||||||
|
cpDetailsTaxonomy.add(panelDetails);
|
||||||
|
cpDetailsTaxonomy.setTopComponent(this.toolbarTaxonomy);
|
||||||
|
tabItemDetails.add(cpDetailsTaxonomy);
|
||||||
|
|
||||||
|
panelDetails.setHeaderVisible(false);
|
||||||
|
panelDetails.setBodyBorder(false);
|
||||||
|
// panelDetails.setStyleAttribute("padding", FIVEPX);
|
||||||
|
|
||||||
|
panelDetails.setStyleAttribute("padding-left", FIVEPX);
|
||||||
|
panelDetails.setStyleAttribute("padding-right", FIVEPX);
|
||||||
|
panelDetails.setStyleAttribute("padding-bottom", FIVEPX);
|
||||||
|
|
||||||
|
panelDetails.setStyleAttribute("margin-left", FIVEPX);
|
||||||
|
panelDetails.setStyleAttribute("margin-right", FIVEPX);
|
||||||
|
panelDetails.setStyleAttribute("margin-bottom", FIVEPX);
|
||||||
|
|
||||||
|
// panelDetails.setTopComponent(this.toolbarTaxonomy);
|
||||||
|
|
||||||
|
tabItemDetails.add(panelDetails);
|
||||||
|
|
||||||
|
setFocusWidget(getButtonBar().getItem(0));
|
||||||
|
|
||||||
|
tabItemDetails.mask("Loading...", ConstantsSpeciesDiscovery.LOADINGSTYLE);
|
||||||
|
enableToolbarTaxonomy(false);
|
||||||
|
|
||||||
|
loadStructuresAndFillingPage(SpeciesCapability.TAXONOMYITEM);
|
||||||
|
|
||||||
|
tabPanel.add(tabItemDetails);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTabItemDisplayResultItem() {
|
||||||
|
|
||||||
|
tabItemOccrs.setToolTip(new ToolTipConfig("Show Occurrences", "Shows occurences points from selected results."));
|
||||||
|
|
||||||
|
tabItemDetails.setScrollMode(Scroll.AUTO);
|
||||||
|
|
||||||
|
panelDetails.setHeaderVisible(false);
|
||||||
|
panelDetails.setBodyBorder(false);
|
||||||
|
panelDetails.setStyleAttribute("padding", FIVEPX);
|
||||||
|
panelDetails.setStyleAttribute("margin", FIVEPX);
|
||||||
|
|
||||||
|
// panelDetails.add(createButtonSaveAsHtml());
|
||||||
|
|
||||||
|
panelOccurrences.setHeaderVisible(false);
|
||||||
|
panelOccurrences.setBodyBorder(false);
|
||||||
|
// panelOccurences.setStyleAttribute("padding", FIVEPX);
|
||||||
|
panelOccurrences.setScrollMode(Scroll.AUTO);
|
||||||
|
panelOccurrences.setSize(widthPanelOccurrences, heightPanelOccurrences);
|
||||||
|
panelOccurrences.setLayout(new FitLayout());
|
||||||
|
panelOccurrences.setTopComponent(this.toolbarOccurrences);
|
||||||
|
|
||||||
|
tabItemDetails.add(panelDetails);
|
||||||
|
tabItemOccrs.add(panelOccurrences);
|
||||||
|
|
||||||
|
setFocusWidget(getButtonBar().getItem(0));
|
||||||
|
|
||||||
|
createOccurrencesWindow();
|
||||||
|
|
||||||
|
tabItemDetails.mask("Loading...",ConstantsSpeciesDiscovery.LOADINGSTYLE);
|
||||||
|
enableToolbarOccurrence(false);
|
||||||
|
|
||||||
|
// loadNumberOfSelectedRowAndDetailsFilling(SpeciesCapability.RESULTITEM);
|
||||||
|
|
||||||
|
loadStructuresAndFillingPage(SpeciesCapability.RESULTITEM);
|
||||||
|
|
||||||
|
tabPanel.add(tabItemDetails);
|
||||||
|
tabPanel.add(tabItemOccrs);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableToolbarOccurrence(boolean bool){
|
||||||
|
toolbarOccurrences.setEnabled(bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableToolbarTaxonomy(boolean bool){
|
||||||
|
toolbarTaxonomy.setEnabled(bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void loadStructuresAndFillingPage(final SpeciesCapability capability){
|
||||||
|
|
||||||
|
if(capability.getName().compareTo(SpeciesCapability.RESULTITEM.getName())==0){
|
||||||
|
|
||||||
|
ResultRowDetailsFiller resultRowFiller = new ResultRowDetailsFiller(tabItemDetails, toolbarOccurrences, panelDetails, lastSearchEvent);
|
||||||
|
resultRowFiller.loadStructuresAndFillingPage();
|
||||||
|
|
||||||
|
detailsFiller = resultRowFiller;
|
||||||
|
|
||||||
|
}else if(capability.getName().compareTo(SpeciesCapability.TAXONOMYITEM.getName())==0){
|
||||||
|
|
||||||
|
TaxonomyRowDetailsFiller taxonomyFiller = new TaxonomyRowDetailsFiller(tabItemDetails, toolbarTaxonomy, tabPanel, panelDetails, lastSearchEvent);
|
||||||
|
taxonomyFiller.loadStructuresAndFillingPage();
|
||||||
|
|
||||||
|
detailsFiller = taxonomyFiller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ToolBar createToolbarTaxonomy(){
|
||||||
|
|
||||||
|
ToolBar toolbar = new ToolBar();
|
||||||
|
|
||||||
|
Button btnTaxonomyMenu = new Button(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_ITEMS);
|
||||||
|
Menu formatSubMenu = new Menu();
|
||||||
|
btnTaxonomyMenu.setMenu(formatSubMenu);
|
||||||
|
btnTaxonomyMenu.setScale(ButtonScale.SMALL);
|
||||||
|
btnTaxonomyMenu.setIconAlign(IconAlign.TOP);
|
||||||
|
btnTaxonomyMenu.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
|
||||||
|
btnTaxonomyMenu.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVE_TAXONOMY_ITEMS, "Save taxonomy items from selected results."));
|
||||||
|
|
||||||
|
// btnOccurrencesMenu.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void componentSelected(ButtonEvent ce) {
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null));
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
MenuItem darwinCoreArchiveItem = new MenuItem(ConstantsSpeciesDiscovery.DARWIN_CORE_ARCHIVE);
|
||||||
|
darwinCoreArchiveItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_DARWIN_CORE_ARCHIVE_FORMAT));
|
||||||
|
darwinCoreArchiveItem.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
SearchController.eventBus.fireEvent(new CreateTaxonomyJobEvent(TaxonomyJobType.BYIDS));
|
||||||
|
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.TAXONOMY_ITEM, SaveFileFormat.DARWIN_CORE_ARCHIVE, count, null));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
formatSubMenu.add(darwinCoreArchiveItem);
|
||||||
|
|
||||||
|
toolbar.add(btnTaxonomyMenu);
|
||||||
|
|
||||||
|
return toolbar;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolBar createToolbarOccurrences(){
|
||||||
|
|
||||||
|
ToolBar toolbar = new ToolBar();
|
||||||
|
|
||||||
|
Button btnShowInGisViewer = new Button(ConstantsSpeciesDiscovery.SHOW_IN_GIS_VIEWER);
|
||||||
|
btnShowInGisViewer.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getGisProducts()));
|
||||||
|
btnShowInGisViewer.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SHOW_IN_GIS_VIEWER, "Show occurences points from selected results in a Gis Viewer Map."));
|
||||||
|
btnShowInGisViewer.setScale(ButtonScale.SMALL);
|
||||||
|
btnShowInGisViewer.setIconAlign(IconAlign.TOP);
|
||||||
|
btnShowInGisViewer.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
btnShowInGisViewer.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
SearchController.eventBus.fireEvent(new ShowOccurrencesMapEvent(count));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Button btnOccurrencesMenu = new Button(ConstantsSpeciesDiscovery.SAVE_OCCURRENCES);
|
||||||
|
Menu formatSubMenu = new Menu();
|
||||||
|
btnOccurrencesMenu.setMenu(formatSubMenu);
|
||||||
|
btnOccurrencesMenu.setScale(ButtonScale.SMALL);
|
||||||
|
btnOccurrencesMenu.setIconAlign(IconAlign.TOP);
|
||||||
|
btnOccurrencesMenu.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
|
||||||
|
btnOccurrencesMenu.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVE_OCCURRENCES, ConstantsSpeciesDiscovery.SAVE_OCCURENCES_POINTS_FROM_SELECTED_RESULTS));
|
||||||
|
|
||||||
|
MenuItem csvFormatItem = new MenuItem(ConstantsSpeciesDiscovery.CSV);
|
||||||
|
csvFormatItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_CSV_FILE_FORMAT));
|
||||||
|
csvFormatItem.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
||||||
|
|
||||||
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
formatSubMenu.add(csvFormatItem);
|
||||||
|
|
||||||
|
Menu csvTypeMenu = new Menu();
|
||||||
|
|
||||||
|
MenuItem csvStandard = new MenuItem(ConstantsSpeciesDiscovery.PLAIN_CSV);
|
||||||
|
|
||||||
|
csvStandard.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
||||||
|
|
||||||
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
MenuItem csvStandardByDataSource = new MenuItem(ConstantsSpeciesDiscovery.PLAIN_CSV_BY_DATA_SOURCE);
|
||||||
|
|
||||||
|
csvStandardByDataSource.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD));
|
||||||
|
|
||||||
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.STANDARD, detailsFiller.getLastlistDataSourceFound(), searchTerm,true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
MenuItem csvOpenModeller = new MenuItem(ConstantsSpeciesDiscovery.OPEN_MODELLER);
|
||||||
|
|
||||||
|
csvOpenModeller.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
|
||||||
|
|
||||||
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, detailsFiller.getLastlistDataSourceFound(), searchTerm,false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
MenuItem csvOpenModellerByDataSource = new MenuItem(ConstantsSpeciesDiscovery.OPEN_MODELLER_BY_DATA_SOURCE);
|
||||||
|
|
||||||
|
csvOpenModellerByDataSource.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER));
|
||||||
|
|
||||||
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.CSV, count, OccurrencesSaveEnum.OPENMODELLER, detailsFiller.getLastlistDataSourceFound(), searchTerm,true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
csvTypeMenu.add(csvStandard);
|
||||||
|
|
||||||
|
csvTypeMenu.add(csvStandardByDataSource);
|
||||||
|
|
||||||
|
csvTypeMenu.add(csvOpenModeller);
|
||||||
|
|
||||||
|
csvTypeMenu.add(csvOpenModellerByDataSource);
|
||||||
|
|
||||||
|
csvFormatItem.setSubMenu(csvTypeMenu);
|
||||||
|
|
||||||
|
MenuItem darwinCoreFormatItem = new MenuItem(ConstantsSpeciesDiscovery.DARWIN_CORE);
|
||||||
|
darwinCoreFormatItem.setToolTip(new ToolTipConfig(ConstantsSpeciesDiscovery.SAVES_IN_DARWIN_CORE_FILE_FORMAT));
|
||||||
|
darwinCoreFormatItem.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
// searchController.getEventBus().fireEvent(new SaveItemsEvent(SearchResultType.OCCURRENCE_POINT, SaveFileFormat.DARWIN_CORE, count, null));
|
||||||
|
|
||||||
|
String searchTerm = OccurrenceJobGridManager.getSearchTermBySearchType(isSearchByCommonName, lastSearchEvent.getSearchTerm());
|
||||||
|
|
||||||
|
SearchController.eventBus.fireEvent(new CreateOccurrenceJobEvent(SaveFileFormat.DARWIN_CORE, count, null, detailsFiller.getLastlistDataSourceFound(), searchTerm, false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
formatSubMenu.add(darwinCoreFormatItem);
|
||||||
|
|
||||||
|
toolbar.add(btnOccurrencesMenu);
|
||||||
|
toolbar.add(new SeparatorToolItem());
|
||||||
|
toolbar.add(btnShowInGisViewer);
|
||||||
|
return toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void initLoader()
|
||||||
|
{
|
||||||
|
loader = new StreamPagingLoader(ConstantsSpeciesDiscovery.PAGE_SIZE);
|
||||||
|
|
||||||
|
// loader = new StreamPagingLoader(PAGE_SIZE);
|
||||||
|
loader.setDataSource(dataSourceManager.getDataSourceByResultType(SpeciesCapability.OCCURRENCESPOINTS));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void createOccurrencesWindow()
|
||||||
|
{
|
||||||
|
|
||||||
|
List<ColumnConfig> config = new ArrayList<ColumnConfig>();
|
||||||
|
|
||||||
|
for (GridField field:OccurencesGridFields.values()) config.add(Util.createColumnConfig(field, 150));
|
||||||
|
|
||||||
|
final ColumnModel cm = new ColumnModel(config);
|
||||||
|
|
||||||
|
initLoader();
|
||||||
|
|
||||||
|
Grid<ModelData> grid = new Grid<ModelData>(loader.getStore(), cm);
|
||||||
|
grid.setBorders(true);
|
||||||
|
grid.getView().setEmptyText(ConstantsSpeciesDiscovery.NORESULTS);
|
||||||
|
|
||||||
|
StreamPagingToolBar toolBar = new StreamPagingToolBar();
|
||||||
|
toolBar.bind(loader);
|
||||||
|
|
||||||
|
panelOccurrences.setBottomComponent(toolBar);
|
||||||
|
|
||||||
|
panelOccurrences.add(grid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadOccurences()
|
||||||
|
{
|
||||||
|
Log.trace("Loading occurrences");
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
dataSourceManager.setExpectedOccurencePoints(count);
|
||||||
|
|
||||||
|
SpeciesDiscovery.taxonomySearchService.retrieveOccurencesFromSelection(new AsyncCallback<Integer>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Integer expectedPoints) {
|
||||||
|
Log.trace("Expected points: "+expectedPoints);
|
||||||
|
dataSourceManager.setExpectedOccurencePoints(expectedPoints);
|
||||||
|
|
||||||
|
count = expectedPoints.intValue();
|
||||||
|
String items = count>0?"items":"item";
|
||||||
|
tabItemOccrs.setText(tabItemOccrs.getText() + " ("+count +" "+ items+")");
|
||||||
|
|
||||||
|
dataSourceManager.setExpectedOccurencePoints(count);
|
||||||
|
// count = expectedPoints;
|
||||||
|
loader.startLoading(true);
|
||||||
|
|
||||||
|
pollingGetCountOfOcccurrences(count);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Info.display("Error getting occurrences", "Error getting occurrences, retry");
|
||||||
|
Log.trace("Error getting occurrences", caught);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void pollingGetCountOfOcccurrences(final int allItems){
|
||||||
|
|
||||||
|
toolbarOccurrences.add(new SeparatorToolItem());
|
||||||
|
final Label labelLoading = new Label("loading 0 of "+allItems);
|
||||||
|
labelLoading.setStyleAttribute("paddingLeft", "20px");
|
||||||
|
labelLoading.setData("count", new Integer(0));
|
||||||
|
toolbarOccurrences.add(labelLoading);
|
||||||
|
|
||||||
|
timerGetCountOfOccurrences = new Timer() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
SpeciesDiscovery.taxonomySearchService.getCountOfOccurrencesBatch(new AsyncCallback<OccurrencesStatus>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Log.error("Error on loading", "An error occurred on count of occurrence point, retry." +caught.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(OccurrencesStatus result) {
|
||||||
|
|
||||||
|
int currentValue = ((Integer) labelLoading.getData("count")).intValue();
|
||||||
|
|
||||||
|
|
||||||
|
if(result.getSize()>currentValue && result.getSize()<allItems)
|
||||||
|
labelLoading.setText("loading "+result.getSize()+ " of " + allItems + " and counting...");
|
||||||
|
|
||||||
|
|
||||||
|
if(result.getSize()==allItems){
|
||||||
|
setLabelLoadedText(result.getSize(), allItems);
|
||||||
|
stopTimerGetCountOfOccurrences(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//case stream completed
|
||||||
|
if(result.isResultEOF()){
|
||||||
|
Log.trace("EOF of occurrences is true");
|
||||||
|
setLabelLoadedText(result.getSize(), allItems);
|
||||||
|
stopTimerGetCountOfOccurrences(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
labelLoading.setData("count", result.getSize());
|
||||||
|
|
||||||
|
Log.trace("loading " + result.getSize() + " occurrences" );
|
||||||
|
|
||||||
|
toolbarOccurrences.layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLabelLoadedText(int size, int allItems) {
|
||||||
|
|
||||||
|
String msg = "loaded "+size+ " of " + allItems;
|
||||||
|
|
||||||
|
if(size<allItems){
|
||||||
|
int difference = allItems - size;
|
||||||
|
msg+= " (" + difference + " duplicate or not available occurrence points were discarded)";
|
||||||
|
}
|
||||||
|
|
||||||
|
labelLoading.setText(msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Schedule the timer to run once in 1 seconds.
|
||||||
|
timerGetCountOfOccurrences.scheduleRepeating(ConstantsSpeciesDiscovery.SCHEDULE_MILLIS_COUNT_OCCURRENCES);
|
||||||
|
|
||||||
|
// timerGetCountOfOccurrences.run();
|
||||||
|
Log.trace("run timerGetCountOfOccurrences");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopTimerGetCountOfOccurrences(int delay) {
|
||||||
|
|
||||||
|
Log.trace("stop timerGetCountOfOccurrences");
|
||||||
|
Timer timer = new Timer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// System.out.println("cancel cancel cancel");
|
||||||
|
timerGetCountOfOccurrences.cancel();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
timer.schedule(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onHide() {
|
||||||
|
super.onHide();
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
|
||||||
|
if(loader!=null){
|
||||||
|
loader.reset();
|
||||||
|
SpeciesDiscovery.taxonomySearchService.stopRetrievingOccurrences(new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Log.error("An error occurred in stopRetrievingOccurrences: " + caught);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void result) {
|
||||||
|
Log.trace("Stop retrieving Occurrences: OK");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//TEST
|
||||||
|
public Button createButtonSaveAsHtml(){
|
||||||
|
|
||||||
|
ToolBar toolbar = new ToolBar();
|
||||||
|
|
||||||
|
Button btnExportAsHtml = new Button("Export As Html");
|
||||||
|
btnExportAsHtml.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.getSaveProducts()));
|
||||||
|
btnExportAsHtml.setToolTip(new ToolTipConfig("Show in Gis Viewer", "Show occurences points from selected results in a Gis Viewer Map."));
|
||||||
|
btnExportAsHtml.setScale(ButtonScale.SMALL);
|
||||||
|
btnExportAsHtml.setIconAlign(IconAlign.TOP);
|
||||||
|
btnExportAsHtml.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||||
|
btnExportAsHtml.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
// searchController.getEventBus().fireEvent(new ShowOccurrencesMapEvent());
|
||||||
|
|
||||||
|
String html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html>" +
|
||||||
|
"<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" +
|
||||||
|
"<style type=\"text/css\">" +getCssStyles() +
|
||||||
|
"</style>" +
|
||||||
|
"<title>"+lastSearchEvent.getSearchTerm()+"</title>" +
|
||||||
|
"</head>" +
|
||||||
|
" <body>"+panelDetails.getElement().getInnerHTML()+"</body>" +
|
||||||
|
"</html> ";
|
||||||
|
|
||||||
|
// System.out.println(html);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return btnExportAsHtml;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getCssStyles(){
|
||||||
|
|
||||||
|
return ".button-hyperlink .x-btn-text {" +
|
||||||
|
"cursor: pointer !important;" +
|
||||||
|
"cursor: hand !important;" +
|
||||||
|
"border: none !important;" +
|
||||||
|
"/* Disable the button-style */" +
|
||||||
|
"background-color: transparent !important;" +
|
||||||
|
"background: none !important;" +
|
||||||
|
"background-image: none !important;" +
|
||||||
|
"padding: 0px !important;" +
|
||||||
|
"color: #4784C3 !important;" +
|
||||||
|
"font-size: 10px;" +
|
||||||
|
"font-family: Serif, \"Times New Roman\", Georgia,;" +
|
||||||
|
"text-decoration: underline !important;" +
|
||||||
|
"}" +
|
||||||
|
".button-hyperlink .x-btn-tl,.button-hyperlink.x-btn-tr,.button-hyperlink " +
|
||||||
|
".x-btn-tc,.button-hyperlink .x-btn-ml,.button-hyperlink .x-btn-mr,.button-hyperlink " +
|
||||||
|
".x-btn-mc,.button-hyperlink .x-btn-bl,.button-hyperlink .x-btn-br,.button-hyperlink .x-btn-bc" +
|
||||||
|
"{" +
|
||||||
|
"background-image: none !important;" +
|
||||||
|
"background: none !important;" +
|
||||||
|
"}" +
|
||||||
|
".button-hyperlink .x-btn-small .x-btn-mr, .button-hyperlink .x-btn-small .x-btn-ml,.button-hyperlink .x-btn-small .x-btn-mc," +
|
||||||
|
".button-hyperlink .x-btn-small .x-btn-br,.button-hyperlink .x-btn-small .x-btn-bl,.button-hyperlink .x-btn-small .x-btn-bc," +
|
||||||
|
".button-hyperlink .x-btn-small .x-btn-tc,.button-hyperlink .x-btn-small .x-btn-tr,.button-hyperlink .x-btn-small .x-btn-tl" +
|
||||||
|
"{" +
|
||||||
|
"background-image: none !important;" +
|
||||||
|
"background: none !important;" +
|
||||||
|
"}" +
|
||||||
|
".button-hyperlink .x-btn-tl i,.button-hyperlink .x-btn-tr i,.button-hyperlink .x-btn-tc i,.button-hyperlink .x-btn-ml i,.button-hyperlink .x-btn-mr i,.button-hyperlink .x-btn-mc i,.button-hyperlink .x-btn-bl i,.button-hyperlink .x-btn-br i,.button-hyperlink .x-btn-bc i" +
|
||||||
|
"{" +
|
||||||
|
"font-size: 0px;" +
|
||||||
|
"}" +
|
||||||
|
"table.imagetable {" +
|
||||||
|
"font-family: verdana,arial,sans-serif;" +
|
||||||
|
"font-size:10px;" +
|
||||||
|
"border: 1px solid #e3e3e3;" +
|
||||||
|
"background-color: #f2f2f2;" +
|
||||||
|
"width: 100%;" +
|
||||||
|
"border-radius: 6px;" +
|
||||||
|
"-webkit-border-radius: 6px;" +
|
||||||
|
"-moz-border-radius: 6px;" +
|
||||||
|
"}" +
|
||||||
|
"table.imagetable .title {" +
|
||||||
|
"background:#b5cfd2;" +
|
||||||
|
"border-width: 1px;" +
|
||||||
|
"width: 30%;" +
|
||||||
|
"padding: 8px;" +
|
||||||
|
"border-style: solid;" +
|
||||||
|
"border-color: #999999;" +
|
||||||
|
"}" +
|
||||||
|
"table.imagetable td {" +
|
||||||
|
"background:#dcddc0;" +
|
||||||
|
"border-width: 1px;" +
|
||||||
|
"padding: 8px;" +
|
||||||
|
"border-style: solid;" +
|
||||||
|
"border-color: #999999;" +
|
||||||
|
"}" +
|
||||||
|
"table.imagetable th {" +
|
||||||
|
"height: 35px;" +
|
||||||
|
"font-weight: bold;" +
|
||||||
|
"font-size: 12px;" +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -82,6 +82,7 @@ import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesSaveEnum;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
import org.gcube.portlets.user.speciesdiscovery.shared.OccurrencesStatus;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
import org.gcube.portlets.user.speciesdiscovery.shared.ResultRow;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SaveFileFormat;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchByQueryParameter;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResult;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
||||||
|
@ -222,7 +223,7 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchResultType searchByQuery(String query) throws SearchServiceException {
|
public SearchByQueryParameter searchByQuery(String query) throws SearchServiceException {
|
||||||
logger.trace("searchByQuery - query: "+query);
|
logger.trace("searchByQuery - query: "+query);
|
||||||
|
|
||||||
stopSearch();
|
stopSearch();
|
||||||
|
@ -241,11 +242,11 @@ public class TaxonomySearchServiceImpl extends RemoteServiceServlet implements T
|
||||||
// System.out.println("service return iterator searched...");
|
// System.out.println("service return iterator searched...");
|
||||||
logger.trace("service return iterator searched...");
|
logger.trace("service return iterator searched...");
|
||||||
|
|
||||||
SearchResultType resultType = QueryUtil.getQueryResultType(query);
|
SearchByQueryParameter queryParameters = QueryUtil.getQueryResultType(query);
|
||||||
CloseableIterator<FetchingElement> output = IteratorChainBuilder.buildChain(input, resultType, aslSession);
|
CloseableIterator<FetchingElement> output = IteratorChainBuilder.buildChain(input, queryParameters.getSearchResultType(), aslSession);
|
||||||
FetchingSessionUtil.createFetchingSession(output, resultType, aslSession);
|
FetchingSessionUtil.createFetchingSession(output, queryParameters.getSearchResultType(), aslSession);
|
||||||
logger.trace("creating fetching session completed!");
|
logger.trace("creating fetching session completed!");
|
||||||
return resultType;
|
return queryParameters;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error starting search by query", e);
|
logger.error("Error starting search by query", e);
|
||||||
|
|
|
@ -99,18 +99,21 @@ public class SessionUtil {
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
||||||
logger.error("TaxonomySearchServiceImpl STARTING IN TEST MODE - NO USER FOUND");
|
|
||||||
|
|
||||||
//for test only
|
//for test only
|
||||||
user = "test.user";
|
user = "test.user";
|
||||||
// user = "francesco.mangiacrapa";
|
// user = "francesco.mangiacrapa";
|
||||||
// user = "pasquale.pagano";
|
// user = "pasquale.pagano";
|
||||||
// user = "lucio.lelii";
|
// user = "lucio.lelii";
|
||||||
|
|
||||||
|
String scope = "/gcube/devsec"; //Development
|
||||||
|
// scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment"; //Production
|
||||||
|
|
||||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
||||||
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
|
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||||
session.setScope("/gcube/devsec");
|
session.setScope(scope);
|
||||||
|
|
||||||
// session.setScope("/d4science.research-infrastructures.eu/gCubeApps/BiodiversityResearchEnvironment");
|
logger.warn("TaxonomySearchServiceImpl STARTING IN TEST MODE - NO USER FOUND");
|
||||||
|
logger.warn("Created fake Asl session for user "+user + " with scope "+scope);
|
||||||
// session.setScope("/gcube/devsec");
|
// session.setScope("/gcube/devsec");
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package org.gcube.portlets.user.speciesdiscovery.server.util;
|
package org.gcube.portlets.user.speciesdiscovery.server.util;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.antlr.runtime.ANTLRStringStream;
|
import org.antlr.runtime.ANTLRStringStream;
|
||||||
import org.antlr.runtime.CommonTokenStream;
|
import org.antlr.runtime.CommonTokenStream;
|
||||||
import org.antlr.runtime.RecognitionException;
|
import org.antlr.runtime.RecognitionException;
|
||||||
|
@ -8,20 +12,24 @@ import org.gcube.dataaccess.spql.SPQLLexer;
|
||||||
import org.gcube.dataaccess.spql.SPQLParser;
|
import org.gcube.dataaccess.spql.SPQLParser;
|
||||||
import org.gcube.dataaccess.spql.model.ParsingResult;
|
import org.gcube.dataaccess.spql.model.ParsingResult;
|
||||||
import org.gcube.dataaccess.spql.model.ReturnType;
|
import org.gcube.dataaccess.spql.model.ReturnType;
|
||||||
|
import org.gcube.dataaccess.spql.model.TermType;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchByQueryParameter;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchFilters;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchResultType;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchServiceException;
|
||||||
|
import org.gcube.portlets.user.speciesdiscovery.shared.SearchType;
|
||||||
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
import org.gcube.portlets.user.speciesdiscovery.shared.SpeciesCapability;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author "Federico De Faveri defaveri@isti.cnr.it"
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QueryUtil {
|
public class QueryUtil {
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(QueryUtil.class);
|
protected static Logger logger = Logger.getLogger(QueryUtil.class);
|
||||||
|
|
||||||
public static SearchResultType getQueryResultType(String query) throws SearchServiceException
|
public static SearchByQueryParameter getQueryResultType(String query) throws SearchServiceException
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
SPQLLexer lexer = new SPQLLexer(new ANTLRStringStream(query));
|
SPQLLexer lexer = new SPQLLexer(new ANTLRStringStream(query));
|
||||||
|
@ -29,22 +37,51 @@ public class QueryUtil {
|
||||||
SPQLParser parser = new SPQLParser(tokens);
|
SPQLParser parser = new SPQLParser(tokens);
|
||||||
ParsingResult result = parser.query();
|
ParsingResult result = parser.query();
|
||||||
|
|
||||||
ReturnType type = result.getReturnExpression().getType();
|
|
||||||
if (type == null) return SearchResultType.SPECIES_PRODUCT;
|
|
||||||
switch (type) {
|
Map<SearchType, List<String>> terms = new HashMap<SearchType, List<String>>();
|
||||||
case ALL: return SearchResultType.SPECIES_PRODUCT;
|
|
||||||
case OCCURRENCE: return SearchResultType.OCCURRENCE_POINT;
|
for (TermType key : result.getTerms().keySet()) {
|
||||||
case TAXON: return SearchResultType.TAXONOMY_ITEM;
|
|
||||||
default: logger.error("Unknow return type: "+type);
|
if(key.equals(TermType.COMMON_NAME)){
|
||||||
|
terms.put(SearchType.BY_COMMON_NAME, terms.get(key));
|
||||||
|
}else if(key.equals(TermType.SCIENTIFIC_NAME)){
|
||||||
|
terms.put(SearchType.BY_COMMON_NAME, terms.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnType type = result.getReturnExpression().getType();
|
||||||
|
|
||||||
|
SearchResultType searchResultType = null;
|
||||||
|
|
||||||
|
if (type == null) searchResultType = SearchResultType.SPECIES_PRODUCT;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case ALL:{
|
||||||
|
searchResultType = SearchResultType.SPECIES_PRODUCT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case OCCURRENCE:{
|
||||||
|
searchResultType = SearchResultType.OCCURRENCE_POINT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TAXON: {
|
||||||
|
searchResultType = SearchResultType.TAXONOMY_ITEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
logger.error("Unknow return type: "+type + " setting default "+SearchResultType.SPECIES_PRODUCT);
|
||||||
|
searchResultType = SearchResultType.SPECIES_PRODUCT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SearchByQueryParameter(terms, searchResultType);
|
||||||
|
|
||||||
} catch (RecognitionException e) {
|
} catch (RecognitionException e) {
|
||||||
logger.warn("Error parsing the user query", e);
|
logger.warn("Error parsing the user query", e);
|
||||||
throw new SearchServiceException("Wrong query: "+e.getMessage());
|
throw new SearchServiceException("Wrong query: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchResultType getResultType(SearchFilters searchFilters)
|
public static SearchResultType getResultType(SearchFilters searchFilters)
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.speciesdiscovery.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SearchByQueryParameter implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private SearchResultType searchResultType;
|
||||||
|
private Map<SearchType, List<String>> terms;
|
||||||
|
|
||||||
|
public SearchByQueryParameter(){}
|
||||||
|
|
||||||
|
public SearchByQueryParameter(Map<SearchType, List<String>> terms, SearchResultType searchResultType){
|
||||||
|
this.terms = terms;
|
||||||
|
this.searchResultType = searchResultType;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchResultType getSearchResultType() {
|
||||||
|
return searchResultType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<SearchType, List<String>> getTerms() {
|
||||||
|
return terms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchResultType(SearchResultType searchResultType) {
|
||||||
|
this.searchResultType = searchResultType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTerms(Map<SearchType, List<String>> terms) {
|
||||||
|
this.terms = terms;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Reference in New Issue