Added GcubeProfilesPerUCDIdCache and Updated SearchFacilityUI
This commit is contained in:
parent
7647628716
commit
8e51d51460
|
@ -4,12 +4,12 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
|
@ -134,7 +134,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
RootPanel.get(APP_DIV).add(loaderApp);
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().listOfFieldsForSearching(new AsyncCallback<List<ItemFieldDV>>() {
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().listOfFieldsForSearching(new AsyncCallback<Map<String, List<ItemFieldDV>>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -143,32 +143,32 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<ItemFieldDV> result) {
|
||||
GWT.log("Loaded item fields: "+result);
|
||||
public void onSuccess(Map<String, List<ItemFieldDV>> mapOfSearchingFilterForUCD) {
|
||||
GWT.log("listOfFieldsForSearching: "+mapOfSearchingFilterForUCD);
|
||||
|
||||
for (ItemFieldDV itemField : result) {
|
||||
if(itemField.isDisplayAsResult()) {
|
||||
displayFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSearchable()) {
|
||||
searchByFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSortable()) {
|
||||
sortByFields.add(itemField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GWT.log("List display fields: "+result);
|
||||
SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
initialSortFilter.setOrder(ORDER.ASC);
|
||||
// for (ItemFieldDV itemField : result) {
|
||||
// if(itemField.isDisplayAsResult()) {
|
||||
// displayFields.add(itemField);
|
||||
// }
|
||||
//
|
||||
// if(itemField.isSearchable()) {
|
||||
// searchByFields.add(itemField);
|
||||
// }
|
||||
//
|
||||
// if(itemField.isSortable()) {
|
||||
// sortByFields.add(itemField);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// GWT.log("List display fields: "+result);
|
||||
// SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
// initialSortFilter.setOrder(ORDER.ASC);
|
||||
|
||||
//TODO MUST BE REVISITED
|
||||
//initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
|
||||
|
||||
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),sortByFields,searchByFields,initialSortFilter);
|
||||
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),mapOfSearchingFilterForUCD);
|
||||
RootPanel.get(APP_DIV).add(mainPanel);
|
||||
|
||||
initApplication();
|
||||
|
@ -571,16 +571,14 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
if(searchPerformedEvent!=null) {
|
||||
|
||||
|
||||
|
||||
LinkedHashMap<String, Image> wmsMap = olMapMng.getOLMap().getWmsLayerMap();
|
||||
String firstWMSKey = wmsMap.keySet().iterator().next();
|
||||
List<ConcessioneDV> result = searchPerformedEvent.getData();
|
||||
List<? extends DocumentDV> result = searchPerformedEvent.getData();
|
||||
|
||||
if(result!=null && result.size()>0) {
|
||||
String cqlFilter = "product_id IN(";
|
||||
for (ConcessioneDV concessioneDV : result) {
|
||||
cqlFilter+="'"+concessioneDV.getItemId()+"',";
|
||||
for (DocumentDV documentDV : result) {
|
||||
cqlFilter+="'"+documentDV.getProjectID()+"',";
|
||||
}
|
||||
cqlFilter = cqlFilter.substring(0,cqlFilter.length()-1)+")";
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
|
@ -137,20 +138,20 @@ public interface GeoportalDataViewerService extends RemoteService {
|
|||
* @return the list
|
||||
* @throws Exception
|
||||
*/
|
||||
List<ItemFieldDV> listOfFieldsForSearching() throws Exception;
|
||||
Map<String, List<ItemFieldDV>> listOfFieldsForSearching() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the list concessioni.
|
||||
*
|
||||
* @param start the start
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @param reloadFromService the reload from service
|
||||
* @return the list concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception;
|
||||
// /**
|
||||
// * Gets the list concessioni.
|
||||
// *
|
||||
// * @param start the start
|
||||
// * @param limit the limit
|
||||
// * @param filter the filter
|
||||
// * @param reloadFromService the reload from service
|
||||
// * @return the list concessioni
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
// boolean reloadFromService) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the project view for id.
|
||||
|
@ -162,4 +163,18 @@ public interface GeoportalDataViewerService extends RemoteService {
|
|||
*/
|
||||
ProjectView getProjectViewForId(String profileID, String projectID) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the list projects.
|
||||
*
|
||||
* @param theProfileID the the profile ID
|
||||
* @param start the start
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @param reloadFromService the reload from service
|
||||
* @return the list projects
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ResultSetPaginatedData getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
|
@ -64,11 +65,14 @@ public interface GeoportalDataViewerServiceAsync {
|
|||
|
||||
void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback);
|
||||
|
||||
void listOfFieldsForSearching(AsyncCallback<List<ItemFieldDV>> callback);
|
||||
void listOfFieldsForSearching(AsyncCallback<Map<String, List<ItemFieldDV>>> callback);
|
||||
|
||||
void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService,
|
||||
AsyncCallback<ResultSetPaginatedData> callback);
|
||||
// void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService,
|
||||
// AsyncCallback<ResultSetPaginatedData> callback);
|
||||
|
||||
void getProjectViewForId(String profileID, String projectID, AsyncCallback<ProjectView> callback);
|
||||
|
||||
void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService, AsyncCallback<ResultSetPaginatedData> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import com.google.gwt.event.shared.GwtEvent;
|
|||
*/
|
||||
public class SearchPerformedEvent extends GwtEvent<SearchPerformedEventHandler> {
|
||||
public static Type<SearchPerformedEventHandler> TYPE = new Type<SearchPerformedEventHandler>();
|
||||
private List<ConcessioneDV> data;
|
||||
private List<? extends DocumentDV> data;
|
||||
private boolean searchReset;
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ public class SearchPerformedEvent extends GwtEvent<SearchPerformedEventHandler>
|
|||
* @param data the data
|
||||
* @param searchReset the search reset
|
||||
*/
|
||||
public SearchPerformedEvent(List<ConcessioneDV> data, boolean searchReset) {
|
||||
public SearchPerformedEvent(List<? extends DocumentDV> data, boolean searchReset) {
|
||||
this.data = data;
|
||||
this.searchReset = searchReset;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class SearchPerformedEvent extends GwtEvent<SearchPerformedEventHandler>
|
|||
*
|
||||
* @return the data
|
||||
*/
|
||||
public List<ConcessioneDV> getData() {
|
||||
public List<? extends DocumentDV> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
||||
|
@ -12,6 +15,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEven
|
|||
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.search.SearchFacilityUI;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
|
@ -19,6 +23,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
|||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.NavList;
|
||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -93,6 +98,9 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
|
||||
@UiField
|
||||
DropdownButton searchFacilityButton;
|
||||
|
||||
@UiField
|
||||
NavList navListSearch;
|
||||
|
||||
@UiField
|
||||
ScrollPanel overlayLayersPanel;
|
||||
|
@ -118,19 +126,80 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
|
||||
private HandlerManager applicationBus;
|
||||
|
||||
private SearchFacilityUI searchFacility;
|
||||
// /**
|
||||
// * Instantiates a new geona data view main panel.
|
||||
// *
|
||||
// * @param applicationBus the application bus
|
||||
// * @param mapHeight the map height
|
||||
// * @param sortByFields the sort by fields
|
||||
// * @param searchForFields the search for fields
|
||||
// * @param initialSortFilter the initial sort filter
|
||||
// */
|
||||
// public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List<ItemFieldDV> sortByFields,
|
||||
// List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
|
||||
// initWidget(uiBinder.createAndBindUi(this));
|
||||
// this.applicationBus = applicationBus;
|
||||
// mapPanel = new MapPanel(mapHeight + "px");
|
||||
// detailsPanel.setHeight(mapHeight + "px");
|
||||
// detailsPanel.setApplicationBus(applicationBus);
|
||||
// mainContainerPanel.add(mapPanel);
|
||||
// bindHandlers();
|
||||
// dataPointSelection.setIcon(IconType.SCREENSHOT);
|
||||
// dataBoxSelection.setIcon(IconType.BOOKMARK);
|
||||
// removeQuery.setIcon(IconType.REMOVE);
|
||||
//
|
||||
// Image italyImg = new Image(GNAImages.ICONS.italyIcon());
|
||||
// italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
||||
// extentToItaly.getElement().appendChild(italyImg.getElement());
|
||||
// extentToItaly.setWidth("140px");
|
||||
//
|
||||
// Image worldImg = new Image(GNAImages.ICONS.worldIcon());
|
||||
// worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
||||
// extentToEarth.getElement().appendChild(worldImg.getElement());
|
||||
// extentToEarth.setWidth("140px");
|
||||
//
|
||||
// linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
|
||||
// linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
|
||||
// linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
|
||||
//
|
||||
// SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
// initialSortFilter.setOrder(ORDER.ASC);
|
||||
//
|
||||
// for (ItemFieldDV itemField : result) {
|
||||
// if (itemField.isDisplayAsResult()) {
|
||||
// displayFields.add(itemField);
|
||||
// }
|
||||
//
|
||||
// if (itemField.isSearchable()) {
|
||||
// searchByFields.add(itemField);
|
||||
// }
|
||||
//
|
||||
// if (itemField.isSortable()) {
|
||||
// sortByFields.add(itemField);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter);
|
||||
// searchFacility.setSearchButton(searchFacilityButton);
|
||||
// searchFacilityButton.setIcon(IconType.SEARCH);
|
||||
// searchFacilityPanel.add(searchFacility);
|
||||
// Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
//
|
||||
// @Override
|
||||
// public void execute() {
|
||||
// searchFacilityPanel.getElement().getParentElement().getStyle().setOpacity(0.9);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// // layersDDB.setToggle(true);
|
||||
// bindEvents();
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Instantiates a new geona data view main panel.
|
||||
*
|
||||
* @param applicationBus the application bus
|
||||
* @param mapHeight the map height
|
||||
* @param sortByFields the sort by fields
|
||||
* @param searchForFields the search for fields
|
||||
* @param initialSortFilter the initial sort filter
|
||||
*/
|
||||
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List<ItemFieldDV> sortByFields,
|
||||
List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
|
||||
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight,
|
||||
Map<String, List<ItemFieldDV>> mapOfSearchingFilterForUCD) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.applicationBus = applicationBus;
|
||||
mapPanel = new MapPanel(mapHeight + "px");
|
||||
|
@ -156,10 +225,55 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
|
||||
linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
|
||||
|
||||
searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter);
|
||||
searchFacility.setSearchButton(searchFacilityButton);
|
||||
SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
initialSortFilter.setOrder(ORDER.ASC);
|
||||
|
||||
for (final String profileID : mapOfSearchingFilterForUCD.keySet()) {
|
||||
|
||||
List<ItemFieldDV> result = mapOfSearchingFilterForUCD.get(profileID);
|
||||
List<ItemFieldDV> displayFields = new ArrayList<ItemFieldDV>();
|
||||
List<ItemFieldDV> searchByFields = new ArrayList<ItemFieldDV>();
|
||||
List<ItemFieldDV> sortByFields = new ArrayList<ItemFieldDV>();
|
||||
for (ItemFieldDV itemField : result) {
|
||||
if (itemField.isDisplayAsResult()) {
|
||||
displayFields.add(itemField);
|
||||
}
|
||||
|
||||
if (itemField.isSearchable()) {
|
||||
searchByFields.add(itemField);
|
||||
}
|
||||
|
||||
if (itemField.isSortable()) {
|
||||
sortByFields.add(itemField);
|
||||
}
|
||||
}
|
||||
|
||||
NavLink navLink = new NavLink(profileID);
|
||||
navLink.setText(profileID);
|
||||
navLink.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
searchFacilityPanel.clear();
|
||||
SearchFacilityUI searchFacility = new SearchFacilityUI(profileID, applicationBus, sortByFields, searchByFields,
|
||||
initialSortFilter);
|
||||
searchFacilityPanel.add(searchFacility);
|
||||
searchFacility.setSearchButton(searchFacilityButton);
|
||||
}
|
||||
});
|
||||
|
||||
GWT.log("Added navLink for: " + profileID);
|
||||
navListSearch.add(navLink);
|
||||
|
||||
}
|
||||
|
||||
searchFacilityButton.setIcon(IconType.SEARCH);
|
||||
searchFacilityPanel.add(searchFacility);
|
||||
|
||||
if (mapOfSearchingFilterForUCD.size() == 0) {
|
||||
searchFacilityPanel.setVisible(false);
|
||||
searchFacilityButton.setVisible(false);
|
||||
}
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
|
@ -334,7 +448,6 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the displayed record.
|
||||
*
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
</b:DropdownButton>
|
||||
<b:DropdownButton type="LINK" text="Search"
|
||||
ui:field="searchFacilityButton">
|
||||
<b:NavList ui:field="navListSearch"></b:NavList>
|
||||
<g:ScrollPanel ui:field="searchFacilityPanel"
|
||||
addStyleNames="search-facility"></g:ScrollPanel>
|
||||
</b:DropdownButton>
|
||||
|
|
|
@ -1,475 +1,475 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
||||
/**
|
||||
* The Class SearchFacilityUI.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
public class SearchFacilityUI extends Composite {
|
||||
|
||||
private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
|
||||
|
||||
protected static final int MIN_LENGHT_SERCHING_STRING = 3;
|
||||
|
||||
@UiField
|
||||
ListBox listBoxSortBy;
|
||||
|
||||
@UiField
|
||||
ListBox listBoxSearchFor;
|
||||
|
||||
@UiField
|
||||
TextBox searchField;
|
||||
|
||||
@UiField
|
||||
NavLink sortByToogle;
|
||||
|
||||
@UiField
|
||||
Button resetSearch;
|
||||
|
||||
@UiField
|
||||
HTMLPanel panelResults;
|
||||
|
||||
@UiField
|
||||
HorizontalPanel toogleSortBy;
|
||||
|
||||
private List<ItemFieldDV> searchForFields;
|
||||
|
||||
private List<ItemFieldDV> sortByFields;
|
||||
|
||||
private SearchingFilter currentSortFilter;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
private static final String LABEL_FILTER_SEPARATOR = " - ";
|
||||
|
||||
private ResultSetPaginatedData latestResult;
|
||||
|
||||
private DropdownButton searchFacilityButton;
|
||||
|
||||
/**
|
||||
* The Interface SearchFacilityPanelUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
interface SearchFacilityPanelUiBinder extends UiBinder<Widget, SearchFacilityUI> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new search facility UI.
|
||||
*
|
||||
* @param appManagerBus the app manager bus
|
||||
* @param sortByFields the sort by fields
|
||||
* @param searchForFields the search for fields
|
||||
* @param initialSortFilter the initial sort filter
|
||||
*/
|
||||
public SearchFacilityUI(HandlerManager appManagerBus, List<ItemFieldDV> sortByFields, List<ItemFieldDV> searchForFields,
|
||||
SearchingFilter initialSortFilter) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.searchForFields = searchForFields;
|
||||
this.currentSortFilter = initialSortFilter;
|
||||
this.sortByFields = sortByFields;
|
||||
this.appManagerBus = appManagerBus;
|
||||
|
||||
resetSearch.setType(ButtonType.LINK);
|
||||
|
||||
listBoxSortBy.setWidth("180px");
|
||||
listBoxSearchFor.setWidth("140px");
|
||||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* To label filter.
|
||||
*
|
||||
* @param itemField the item field
|
||||
* @param direction the direction
|
||||
* @return the string
|
||||
*/
|
||||
private String toLabelFilter(ItemFieldDV itemField, ORDER direction) {
|
||||
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
|
||||
return labelFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
for (ItemFieldDV record_FIELD : sortByFields) {
|
||||
if(record_FIELD.isSortable()) {
|
||||
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
||||
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
||||
listBoxSortBy.addItem(labelASC);
|
||||
listBoxSortBy.addItem(labelDESC);
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSortBy.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if(latestResult!=null && latestResult.getData().size()>0) {
|
||||
doSearchEvent();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (ItemFieldDV record_FIELD : searchForFields) {
|
||||
GWT.log("search for: "+record_FIELD);
|
||||
if(record_FIELD.isSearchable()) {
|
||||
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSearchFor.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
sortByToogle.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (toogleSortBy.isVisible())
|
||||
toogleSortBy.setVisible(false);
|
||||
else
|
||||
toogleSortBy.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
searchField.addKeyPressHandler(new KeyPressHandler() {
|
||||
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) {
|
||||
GWT.log(searchField.getText());
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
resetSearch.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
searchField.setText("");
|
||||
resetSearch.setVisible(false);
|
||||
panelResults.clear();
|
||||
latestResult = null;
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(null,true));
|
||||
setSearchEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setSearchEnabled(boolean bool) {
|
||||
if(bool) {
|
||||
searchFacilityButton.getElement().addClassName("highlight-button");
|
||||
}
|
||||
else {
|
||||
searchFacilityButton.getElement().removeClassName("highlight-button");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search concessioni.
|
||||
*/
|
||||
private void searchConcessioni() {
|
||||
|
||||
SearchingFilter filter = getCurrentSortFilter();
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
panelResults.add(new LoaderIcon("Searching..."));
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false,
|
||||
new AsyncCallback<ResultSetPaginatedData>() {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// showLoading(false);
|
||||
// Window.alert(caught.getMessage());
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
Alert alert = new Alert("Error on searching. Please, refresh or change the search");
|
||||
alert.setType(AlertType.ERROR);
|
||||
alert.setClose(false);
|
||||
panelResults.add(alert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResultSetPaginatedData result) {
|
||||
|
||||
Window.alert("searchConcessioni must be revisited");
|
||||
/*
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
|
||||
|
||||
|
||||
setSearchEnabled(true);
|
||||
latestResult = result;
|
||||
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
|
||||
if (result.getData().size() == 0) {
|
||||
panelResults.add(new HTML("No result found"));
|
||||
return;
|
||||
}
|
||||
|
||||
FlexTable ft = new FlexTable();
|
||||
ft.getElement().setClassName("table-results");
|
||||
int i = 1;
|
||||
ft.setWidget(0, i, new HTML("Nome Progetto"));
|
||||
|
||||
String selValue = listBoxSearchFor.getSelectedValue().toLowerCase();
|
||||
|
||||
boolean addIntroduction = false;
|
||||
if(selValue.startsWith("proj") || selValue.startsWith("any")) {
|
||||
ft.setWidget(0, ++i, new HTML("Introduzione"));
|
||||
addIntroduction = true;
|
||||
}
|
||||
|
||||
boolean addStaff = false;
|
||||
if(selValue.startsWith("director")) {
|
||||
ft.setWidget(0, ++i, new HTML("Autori"));
|
||||
ft.setWidget(0, ++i, new HTML("Responsabile"));
|
||||
ft.setWidget(0, ++i, new HTML("Editore"));
|
||||
ft.setWidget(0, ++i, new HTML("Titolari"));
|
||||
ft.setWidget(0, ++i, new HTML("Contributore"));
|
||||
addStaff = true;
|
||||
}
|
||||
boolean addParole = false;
|
||||
if(selValue.startsWith("keyword")) {
|
||||
ft.setWidget(0, ++i, new HTML("Parole Libere"));
|
||||
ft.setWidget(0, ++i, new HTML("Parole Cronologia"));
|
||||
addParole = true;
|
||||
}
|
||||
|
||||
i = 1;
|
||||
for (DocumentDV concessione : result.getData()) {
|
||||
int j = -1;
|
||||
|
||||
NavLink locateOnMap = new NavLink("Show");
|
||||
locateOnMap.setTitle("Locate on the Map and show details");
|
||||
locateOnMap.setIcon(IconType.MAP_MARKER);
|
||||
|
||||
locateOnMap.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
GeoNaItemRef gir = new GeoNaItemRef(concessione.getItemId(), GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString());
|
||||
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
|
||||
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ft.setWidget(i, ++j, locateOnMap);
|
||||
|
||||
|
||||
ft.setWidget(i, ++j, new HTML(concessione.getNome()));
|
||||
if(addIntroduction)
|
||||
ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 200)));
|
||||
|
||||
if(addStaff) {
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getResponsabile()))));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getEditore()))));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getContributore()))));
|
||||
}
|
||||
|
||||
if(addParole) {
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveLibere())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD())));
|
||||
}
|
||||
|
||||
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
panelResults.add(ft);
|
||||
*/
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* To display authors.
|
||||
*
|
||||
* @param listValues the list values
|
||||
* @return the string
|
||||
*/
|
||||
private String toDisplayList(List<String> listValues) {
|
||||
String toDisplay = "";
|
||||
if (listValues == null)
|
||||
return toDisplay;
|
||||
|
||||
for (String author : listValues) {
|
||||
toDisplay += author + "; ";
|
||||
}
|
||||
return toDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do search event.
|
||||
*/
|
||||
private void doSearchEvent() {
|
||||
String searchText = searchField.getText();
|
||||
if (searchText.length() < MIN_LENGHT_SERCHING_STRING) {
|
||||
Window.alert("Please enter at least " + MIN_LENGHT_SERCHING_STRING + " characters");
|
||||
return;
|
||||
}
|
||||
|
||||
resetSearch.setVisible(true);
|
||||
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
// getCurrentSortFilter()));
|
||||
|
||||
searchConcessioni();
|
||||
}
|
||||
|
||||
/**
|
||||
* To sort filter.
|
||||
*
|
||||
* @param labelFilter the label filter
|
||||
* @return the searching filter
|
||||
*/
|
||||
public SearchingFilter toSortFilter(String labelFilter) {
|
||||
GWT.log("toSortFilter for label " + labelFilter);
|
||||
String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
|
||||
SearchingFilter sortFilter = null;
|
||||
try {
|
||||
ItemFieldDV recordField = null;
|
||||
for (ItemFieldDV value : sortByFields) {
|
||||
if (array[0].equalsIgnoreCase(value.getDisplayName())) {
|
||||
recordField = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ORDER orderField = ORDER.valueOf(array[1]);
|
||||
sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
GWT.log("toSortFilter Got " + sortFilter);
|
||||
return sortFilter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Built searching filter.
|
||||
*
|
||||
* @return the searching filter
|
||||
*/
|
||||
private SearchingFilter builtSearchingFilter() {
|
||||
SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue());
|
||||
String searchText = searchField.getText();
|
||||
if (searchText != null && !searchText.isEmpty()) {
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
|
||||
List<String> listOfSeachingFields = new ArrayList<String>();
|
||||
|
||||
for (ItemFieldDV recordField : searchForFields) {
|
||||
if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
|
||||
listOfSeachingFields = recordField.getJsonFields();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(listOfSeachingFields.size()==0) {
|
||||
listOfSeachingFields.add("nome");
|
||||
}
|
||||
for (String fieldname : listOfSeachingFields) {
|
||||
searchInto.put(fieldname, searchText);
|
||||
}
|
||||
|
||||
WhereClause where = new WhereClause();
|
||||
where.setSearchInto(searchInto);
|
||||
where.setOperator(LOGICAL_OP.OR);
|
||||
|
||||
//THIS CLAUSE IS ADDED IN ORDER TO SEARCH ONLY PUBLISHED PRODUCT (WITH SUCCESS)
|
||||
Map<String, Object> searchInto2 = new HashMap<String, Object>();
|
||||
searchInto2.put("report.status", "PASSED");
|
||||
WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
|
||||
|
||||
searchingFilter.setConditions(Arrays.asList(where, where2));
|
||||
}
|
||||
return searchingFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current sort filter.
|
||||
*
|
||||
* @return the current sort filter
|
||||
*/
|
||||
public SearchingFilter getCurrentSortFilter() {
|
||||
currentSortFilter = builtSearchingFilter();
|
||||
GWT.log("currentSortFilter: " + currentSortFilter);
|
||||
return currentSortFilter;
|
||||
}
|
||||
|
||||
public void setSearchButton(DropdownButton searchFacilityButton) {
|
||||
this.searchFacilityButton = searchFacilityButton;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
//import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
//import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
//import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
//import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
//import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
//import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
//import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
|
||||
//import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
//
|
||||
//import com.github.gwtbootstrap.client.ui.Alert;
|
||||
//import com.github.gwtbootstrap.client.ui.Button;
|
||||
//import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||
//import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
//import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
//import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
//import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
//import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
//import com.google.gwt.core.client.GWT;
|
||||
//import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
//import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
//import com.google.gwt.event.dom.client.ClickEvent;
|
||||
//import com.google.gwt.event.dom.client.ClickHandler;
|
||||
//import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
//import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
//import com.google.gwt.event.shared.HandlerManager;
|
||||
//import com.google.gwt.uibinder.client.UiBinder;
|
||||
//import com.google.gwt.uibinder.client.UiField;
|
||||
//import com.google.gwt.user.client.Window;
|
||||
//import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
//import com.google.gwt.user.client.ui.Composite;
|
||||
//import com.google.gwt.user.client.ui.HTML;
|
||||
//import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
//import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
//import com.google.gwt.user.client.ui.Widget;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * The Class SearchFacilityUI.
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
// *
|
||||
// * Dec 14, 2021
|
||||
// */
|
||||
//public class SearchFacilityUI extends Composite {
|
||||
//
|
||||
// private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
|
||||
//
|
||||
// protected static final int MIN_LENGHT_SERCHING_STRING = 3;
|
||||
//
|
||||
// @UiField
|
||||
// ListBox listBoxSortBy;
|
||||
//
|
||||
// @UiField
|
||||
// ListBox listBoxSearchFor;
|
||||
//
|
||||
// @UiField
|
||||
// TextBox searchField;
|
||||
//
|
||||
// @UiField
|
||||
// NavLink sortByToogle;
|
||||
//
|
||||
// @UiField
|
||||
// Button resetSearch;
|
||||
//
|
||||
// @UiField
|
||||
// HTMLPanel panelResults;
|
||||
//
|
||||
// @UiField
|
||||
// HorizontalPanel toogleSortBy;
|
||||
//
|
||||
// private List<ItemFieldDV> searchForFields;
|
||||
//
|
||||
// private List<ItemFieldDV> sortByFields;
|
||||
//
|
||||
// private SearchingFilter currentSortFilter;
|
||||
//
|
||||
// private HandlerManager appManagerBus;
|
||||
//
|
||||
// private static final String LABEL_FILTER_SEPARATOR = " - ";
|
||||
//
|
||||
// private ResultSetPaginatedData latestResult;
|
||||
//
|
||||
// private DropdownButton searchFacilityButton;
|
||||
//
|
||||
// /**
|
||||
// * The Interface SearchFacilityPanelUiBinder.
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
// *
|
||||
// * Dec 14, 2021
|
||||
// */
|
||||
// interface SearchFacilityPanelUiBinder extends UiBinder<Widget, SearchFacilityUI> {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Instantiates a new search facility UI.
|
||||
// *
|
||||
// * @param appManagerBus the app manager bus
|
||||
// * @param sortByFields the sort by fields
|
||||
// * @param searchForFields the search for fields
|
||||
// * @param initialSortFilter the initial sort filter
|
||||
// */
|
||||
// public SearchFacilityUI(HandlerManager appManagerBus, List<ItemFieldDV> sortByFields, List<ItemFieldDV> searchForFields,
|
||||
// SearchingFilter initialSortFilter) {
|
||||
// initWidget(uiBinder.createAndBindUi(this));
|
||||
// this.searchForFields = searchForFields;
|
||||
// this.currentSortFilter = initialSortFilter;
|
||||
// this.sortByFields = sortByFields;
|
||||
// this.appManagerBus = appManagerBus;
|
||||
//
|
||||
// resetSearch.setType(ButtonType.LINK);
|
||||
//
|
||||
// listBoxSortBy.setWidth("180px");
|
||||
// listBoxSearchFor.setWidth("140px");
|
||||
//
|
||||
// bindEvents();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * To label filter.
|
||||
// *
|
||||
// * @param itemField the item field
|
||||
// * @param direction the direction
|
||||
// * @return the string
|
||||
// */
|
||||
// private String toLabelFilter(ItemFieldDV itemField, ORDER direction) {
|
||||
// String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
|
||||
// return labelFilter;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Bind events.
|
||||
// */
|
||||
// private void bindEvents() {
|
||||
//
|
||||
// for (ItemFieldDV record_FIELD : sortByFields) {
|
||||
// if(record_FIELD.isSortable()) {
|
||||
// String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
||||
// String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
||||
// listBoxSortBy.addItem(labelASC);
|
||||
// listBoxSortBy.addItem(labelDESC);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// listBoxSortBy.addChangeHandler(new ChangeHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onChange(ChangeEvent event) {
|
||||
// if(latestResult!=null && latestResult.getData().size()>0) {
|
||||
// doSearchEvent();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// for (ItemFieldDV record_FIELD : searchForFields) {
|
||||
// GWT.log("search for: "+record_FIELD);
|
||||
// if(record_FIELD.isSearchable()) {
|
||||
// listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// listBoxSearchFor.addChangeHandler(new ChangeHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onChange(ChangeEvent event) {
|
||||
// if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
||||
// doSearchEvent();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// sortByToogle.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// if (toogleSortBy.isVisible())
|
||||
// toogleSortBy.setVisible(false);
|
||||
// else
|
||||
// toogleSortBy.setVisible(true);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// searchField.addKeyPressHandler(new KeyPressHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onKeyPress(KeyPressEvent event) {
|
||||
// if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) {
|
||||
// GWT.log(searchField.getText());
|
||||
// doSearchEvent();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// resetSearch.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// searchField.setText("");
|
||||
// resetSearch.setVisible(false);
|
||||
// panelResults.clear();
|
||||
// latestResult = null;
|
||||
// appManagerBus.fireEvent(new SearchPerformedEvent(null,true));
|
||||
// setSearchEnabled(false);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void setSearchEnabled(boolean bool) {
|
||||
// if(bool) {
|
||||
// searchFacilityButton.getElement().addClassName("highlight-button");
|
||||
// }
|
||||
// else {
|
||||
// searchFacilityButton.getElement().removeClassName("highlight-button");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Search concessioni.
|
||||
// */
|
||||
// private void searchConcessioni() {
|
||||
//
|
||||
// SearchingFilter filter = getCurrentSortFilter();
|
||||
// panelResults.clear();
|
||||
// panelResults.add(new HTML("<hr>"));
|
||||
// panelResults.add(new LoaderIcon("Searching..."));
|
||||
// GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false,
|
||||
// new AsyncCallback<ResultSetPaginatedData>() {
|
||||
//
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
//// showLoading(false);
|
||||
//// Window.alert(caught.getMessage());
|
||||
// panelResults.clear();
|
||||
// panelResults.add(new HTML("<hr>"));
|
||||
// Alert alert = new Alert("Error on searching. Please, refresh or change the search");
|
||||
// alert.setType(AlertType.ERROR);
|
||||
// alert.setClose(false);
|
||||
// panelResults.add(alert);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(ResultSetPaginatedData result) {
|
||||
//
|
||||
// Window.alert("searchConcessioni must be revisited");
|
||||
// /*
|
||||
// appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
|
||||
//
|
||||
//
|
||||
// setSearchEnabled(true);
|
||||
// latestResult = result;
|
||||
//
|
||||
// panelResults.clear();
|
||||
// panelResults.add(new HTML("<hr>"));
|
||||
//
|
||||
// if (result.getData().size() == 0) {
|
||||
// panelResults.add(new HTML("No result found"));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// FlexTable ft = new FlexTable();
|
||||
// ft.getElement().setClassName("table-results");
|
||||
// int i = 1;
|
||||
// ft.setWidget(0, i, new HTML("Nome Progetto"));
|
||||
//
|
||||
// String selValue = listBoxSearchFor.getSelectedValue().toLowerCase();
|
||||
//
|
||||
// boolean addIntroduction = false;
|
||||
// if(selValue.startsWith("proj") || selValue.startsWith("any")) {
|
||||
// ft.setWidget(0, ++i, new HTML("Introduzione"));
|
||||
// addIntroduction = true;
|
||||
// }
|
||||
//
|
||||
// boolean addStaff = false;
|
||||
// if(selValue.startsWith("director")) {
|
||||
// ft.setWidget(0, ++i, new HTML("Autori"));
|
||||
// ft.setWidget(0, ++i, new HTML("Responsabile"));
|
||||
// ft.setWidget(0, ++i, new HTML("Editore"));
|
||||
// ft.setWidget(0, ++i, new HTML("Titolari"));
|
||||
// ft.setWidget(0, ++i, new HTML("Contributore"));
|
||||
// addStaff = true;
|
||||
// }
|
||||
// boolean addParole = false;
|
||||
// if(selValue.startsWith("keyword")) {
|
||||
// ft.setWidget(0, ++i, new HTML("Parole Libere"));
|
||||
// ft.setWidget(0, ++i, new HTML("Parole Cronologia"));
|
||||
// addParole = true;
|
||||
// }
|
||||
//
|
||||
// i = 1;
|
||||
// for (DocumentDV concessione : result.getData()) {
|
||||
// int j = -1;
|
||||
//
|
||||
// NavLink locateOnMap = new NavLink("Show");
|
||||
// locateOnMap.setTitle("Locate on the Map and show details");
|
||||
// locateOnMap.setIcon(IconType.MAP_MARKER);
|
||||
//
|
||||
// locateOnMap.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// GeoNaItemRef gir = new GeoNaItemRef(concessione.getItemId(), GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString());
|
||||
// appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
|
||||
// appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione));
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ft.setWidget(i, ++j, locateOnMap);
|
||||
//
|
||||
//
|
||||
// ft.setWidget(i, ++j, new HTML(concessione.getNome()));
|
||||
// if(addIntroduction)
|
||||
// ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 200)));
|
||||
//
|
||||
// if(addStaff) {
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors())));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getResponsabile()))));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getEditore()))));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari())));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getContributore()))));
|
||||
// }
|
||||
//
|
||||
// if(addParole) {
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveLibere())));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD())));
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// i++;
|
||||
// }
|
||||
//
|
||||
// panelResults.add(ft);
|
||||
// */
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * To display authors.
|
||||
// *
|
||||
// * @param listValues the list values
|
||||
// * @return the string
|
||||
// */
|
||||
// private String toDisplayList(List<String> listValues) {
|
||||
// String toDisplay = "";
|
||||
// if (listValues == null)
|
||||
// return toDisplay;
|
||||
//
|
||||
// for (String author : listValues) {
|
||||
// toDisplay += author + "; ";
|
||||
// }
|
||||
// return toDisplay;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Do search event.
|
||||
// */
|
||||
// private void doSearchEvent() {
|
||||
// String searchText = searchField.getText();
|
||||
// if (searchText.length() < MIN_LENGHT_SERCHING_STRING) {
|
||||
// Window.alert("Please enter at least " + MIN_LENGHT_SERCHING_STRING + " characters");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// resetSearch.setVisible(true);
|
||||
// // appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
// // getCurrentSortFilter()));
|
||||
//
|
||||
// searchConcessioni();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * To sort filter.
|
||||
// *
|
||||
// * @param labelFilter the label filter
|
||||
// * @return the searching filter
|
||||
// */
|
||||
// public SearchingFilter toSortFilter(String labelFilter) {
|
||||
// GWT.log("toSortFilter for label " + labelFilter);
|
||||
// String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
//
|
||||
// SearchingFilter sortFilter = null;
|
||||
// try {
|
||||
// ItemFieldDV recordField = null;
|
||||
// for (ItemFieldDV value : sortByFields) {
|
||||
// if (array[0].equalsIgnoreCase(value.getDisplayName())) {
|
||||
// recordField = value;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// ORDER orderField = ORDER.valueOf(array[1]);
|
||||
// sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField);
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
// GWT.log("toSortFilter Got " + sortFilter);
|
||||
// return sortFilter;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Built searching filter.
|
||||
// *
|
||||
// * @return the searching filter
|
||||
// */
|
||||
// private SearchingFilter builtSearchingFilter() {
|
||||
// SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue());
|
||||
// String searchText = searchField.getText();
|
||||
// if (searchText != null && !searchText.isEmpty()) {
|
||||
// Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
//
|
||||
// List<String> listOfSeachingFields = new ArrayList<String>();
|
||||
//
|
||||
// for (ItemFieldDV recordField : searchForFields) {
|
||||
// if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
|
||||
// listOfSeachingFields = recordField.getJsonFields();
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(listOfSeachingFields.size()==0) {
|
||||
// listOfSeachingFields.add("nome");
|
||||
// }
|
||||
// for (String fieldname : listOfSeachingFields) {
|
||||
// searchInto.put(fieldname, searchText);
|
||||
// }
|
||||
//
|
||||
// WhereClause where = new WhereClause();
|
||||
// where.setSearchInto(searchInto);
|
||||
// where.setOperator(LOGICAL_OP.OR);
|
||||
//
|
||||
// //THIS CLAUSE IS ADDED IN ORDER TO SEARCH ONLY PUBLISHED PRODUCT (WITH SUCCESS)
|
||||
// Map<String, Object> searchInto2 = new HashMap<String, Object>();
|
||||
// searchInto2.put("report.status", "PASSED");
|
||||
// WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
|
||||
//
|
||||
// searchingFilter.setConditions(Arrays.asList(where, where2));
|
||||
// }
|
||||
// return searchingFilter;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the current sort filter.
|
||||
// *
|
||||
// * @return the current sort filter
|
||||
// */
|
||||
// public SearchingFilter getCurrentSortFilter() {
|
||||
// currentSortFilter = builtSearchingFilter();
|
||||
// GWT.log("currentSortFilter: " + currentSortFilter);
|
||||
// return currentSortFilter;
|
||||
// }
|
||||
//
|
||||
// public void setSearchButton(DropdownButton searchFacilityButton) {
|
||||
// this.searchFacilityButton = searchFacilityButton;
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<!-- <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||
|
@ -57,4 +57,4 @@
|
|||
</g:HTMLPanel>
|
||||
</g:FlowPanel>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
||||
</ui:UiBinder> -->
|
|
@ -0,0 +1,473 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* The Class SearchFacilityUI.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
public class SearchFacilityUI extends Composite {
|
||||
|
||||
private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
|
||||
|
||||
protected static final int MIN_LENGHT_SERCHING_STRING = 3;
|
||||
|
||||
@UiField
|
||||
ListBox listBoxSortBy;
|
||||
|
||||
@UiField
|
||||
ListBox listBoxSearchFor;
|
||||
|
||||
@UiField
|
||||
TextBox searchField;
|
||||
|
||||
@UiField
|
||||
NavLink sortByToogle;
|
||||
|
||||
@UiField
|
||||
Button resetSearch;
|
||||
|
||||
@UiField
|
||||
HTMLPanel panelResults;
|
||||
|
||||
@UiField
|
||||
HorizontalPanel toogleSortBy;
|
||||
|
||||
private List<ItemFieldDV> searchForFields;
|
||||
|
||||
private List<ItemFieldDV> sortByFields;
|
||||
|
||||
private SearchingFilter currentSortFilter;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
private static final String LABEL_FILTER_SEPARATOR = " - ";
|
||||
|
||||
private ResultSetPaginatedData latestResult;
|
||||
|
||||
private DropdownButton searchFacilityButton;
|
||||
|
||||
private String profileID;
|
||||
|
||||
/**
|
||||
* The Interface SearchFacilityPanelUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
interface SearchFacilityPanelUiBinder extends UiBinder<Widget, SearchFacilityUI> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new search facility UI.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param appManagerBus the app manager bus
|
||||
* @param sortByFields the sort by fields
|
||||
* @param searchForFields the search for fields
|
||||
* @param initialSortFilter the initial sort filter
|
||||
*/
|
||||
public SearchFacilityUI(String profileID, HandlerManager appManagerBus, List<ItemFieldDV> sortByFields,
|
||||
List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.profileID = profileID;
|
||||
this.searchForFields = searchForFields;
|
||||
this.currentSortFilter = initialSortFilter;
|
||||
this.sortByFields = sortByFields;
|
||||
this.appManagerBus = appManagerBus;
|
||||
|
||||
resetSearch.setType(ButtonType.LINK);
|
||||
|
||||
listBoxSortBy.setWidth("180px");
|
||||
listBoxSearchFor.setWidth("140px");
|
||||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* To label filter.
|
||||
*
|
||||
* @param itemField the item field
|
||||
* @param direction the direction
|
||||
* @return the string
|
||||
*/
|
||||
private String toLabelFilter(ItemFieldDV itemField, ORDER direction) {
|
||||
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
|
||||
return labelFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
for (ItemFieldDV record_FIELD : sortByFields) {
|
||||
if (record_FIELD.isSortable()) {
|
||||
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
||||
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
||||
listBoxSortBy.addItem(labelASC);
|
||||
listBoxSortBy.addItem(labelDESC);
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSortBy.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if (latestResult != null && latestResult.getData().size() > 0) {
|
||||
doSearchEvent();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (ItemFieldDV record_FIELD : searchForFields) {
|
||||
GWT.log("search for: " + record_FIELD);
|
||||
if (record_FIELD.isSearchable()) {
|
||||
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSearchFor.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
sortByToogle.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (toogleSortBy.isVisible())
|
||||
toogleSortBy.setVisible(false);
|
||||
else
|
||||
toogleSortBy.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
searchField.addKeyPressHandler(new KeyPressHandler() {
|
||||
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) {
|
||||
GWT.log(searchField.getText());
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
resetSearch.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
searchField.setText("");
|
||||
resetSearch.setVisible(false);
|
||||
panelResults.clear();
|
||||
latestResult = null;
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(null, true));
|
||||
setSearchEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search enabled.
|
||||
*
|
||||
* @param bool the new search enabled
|
||||
*/
|
||||
private void setSearchEnabled(boolean bool) {
|
||||
if (bool) {
|
||||
searchFacilityButton.getElement().addClassName("highlight-button");
|
||||
} else {
|
||||
searchFacilityButton.getElement().removeClassName("highlight-button");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search concessioni.
|
||||
*/
|
||||
private void searchProjects() {
|
||||
|
||||
SearchingFilter filter = getCurrentSortFilter();
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
panelResults.add(new LoaderIcon("Searching..."));
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, 30, filter, false,
|
||||
new AsyncCallback<ResultSetPaginatedData>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// showLoading(false);
|
||||
// Window.alert(caught.getMessage());
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
Alert alert = new Alert("Error on searching. Please, refresh or change the search");
|
||||
alert.setType(AlertType.ERROR);
|
||||
alert.setClose(false);
|
||||
panelResults.add(alert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResultSetPaginatedData result) {
|
||||
|
||||
Window.alert("searchConcessioni must be revisited");
|
||||
/*
|
||||
* appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
|
||||
*
|
||||
*
|
||||
* setSearchEnabled(true); latestResult = result;
|
||||
*
|
||||
* panelResults.clear(); panelResults.add(new HTML("<hr>"));
|
||||
*
|
||||
* if (result.getData().size() == 0) { panelResults.add(new
|
||||
* HTML("No result found")); return; }
|
||||
*
|
||||
* FlexTable ft = new FlexTable();
|
||||
* ft.getElement().setClassName("table-results");
|
||||
*
|
||||
* for (ItemFieldDV itemField : searchForFields) {
|
||||
*
|
||||
* }
|
||||
*
|
||||
*
|
||||
* int i = 1; ft.setWidget(0, i, new HTML("Nome Progetto"));
|
||||
*
|
||||
* String selValue = listBoxSearchFor.getSelectedValue().toLowerCase();
|
||||
*
|
||||
* boolean addIntroduction = false; if(selValue.startsWith("proj") ||
|
||||
* selValue.startsWith("any")) { ft.setWidget(0, ++i, new HTML("Introduzione"));
|
||||
* addIntroduction = true; }
|
||||
*
|
||||
* boolean addStaff = false; if(selValue.startsWith("director")) {
|
||||
* ft.setWidget(0, ++i, new HTML("Autori")); ft.setWidget(0, ++i, new
|
||||
* HTML("Responsabile")); ft.setWidget(0, ++i, new HTML("Editore"));
|
||||
* ft.setWidget(0, ++i, new HTML("Titolari")); ft.setWidget(0, ++i, new
|
||||
* HTML("Contributore")); addStaff = true; } boolean addParole = false;
|
||||
* if(selValue.startsWith("keyword")) { ft.setWidget(0, ++i, new
|
||||
* HTML("Parole Libere")); ft.setWidget(0, ++i, new HTML("Parole Cronologia"));
|
||||
* addParole = true; }
|
||||
*
|
||||
* i = 1; for (DocumentDV concessione : result.getData()) { int j = -1;
|
||||
*
|
||||
* NavLink locateOnMap = new NavLink("Show");
|
||||
* locateOnMap.setTitle("Locate on the Map and show details");
|
||||
* locateOnMap.setIcon(IconType.MAP_MARKER);
|
||||
*
|
||||
* locateOnMap.addClickHandler(new ClickHandler() {
|
||||
*
|
||||
* @Override public void onClick(ClickEvent event) { GeoNaItemRef gir = new
|
||||
* GeoNaItemRef(concessione.getItemId(),
|
||||
* GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString());
|
||||
* appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
|
||||
* appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione));
|
||||
*
|
||||
* } });
|
||||
*
|
||||
* ft.setWidget(i, ++j, locateOnMap);
|
||||
*
|
||||
*
|
||||
* ft.setWidget(i, ++j, new HTML(concessione.getNome())); if(addIntroduction)
|
||||
* ft.setWidget(i, ++j, new
|
||||
* HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 200)));
|
||||
*
|
||||
* if(addStaff) { ft.setWidget(i, ++j, new
|
||||
* HTML(toDisplayList(concessione.getAuthors()))); ft.setWidget(i, ++j, new
|
||||
* HTML(toDisplayList(Arrays.asList(concessione.getResponsabile()))));
|
||||
* ft.setWidget(i, ++j, new
|
||||
* HTML(toDisplayList(Arrays.asList(concessione.getEditore()))));
|
||||
* ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari())));
|
||||
* ft.setWidget(i, ++j, new
|
||||
* HTML(toDisplayList(Arrays.asList(concessione.getContributore())))); }
|
||||
*
|
||||
* if(addParole) { ft.setWidget(i, ++j, new
|
||||
* HTML(toDisplayList(concessione.getParoleChiaveLibere()))); ft.setWidget(i,
|
||||
* ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD()))); }
|
||||
*
|
||||
*
|
||||
*
|
||||
* i++; }
|
||||
*
|
||||
* panelResults.add(ft);
|
||||
*
|
||||
*/
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* To display authors.
|
||||
*
|
||||
* @param listValues the list values
|
||||
* @return the string
|
||||
*/
|
||||
private String toDisplayList(List<String> listValues) {
|
||||
String toDisplay = "";
|
||||
if (listValues == null)
|
||||
return toDisplay;
|
||||
|
||||
for (String author : listValues) {
|
||||
toDisplay += author + "; ";
|
||||
}
|
||||
return toDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do search event.
|
||||
*/
|
||||
private void doSearchEvent() {
|
||||
String searchText = searchField.getText();
|
||||
if (searchText.length() < MIN_LENGHT_SERCHING_STRING) {
|
||||
Window.alert("Please enter at least " + MIN_LENGHT_SERCHING_STRING + " characters");
|
||||
return;
|
||||
}
|
||||
|
||||
resetSearch.setVisible(true);
|
||||
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
// getCurrentSortFilter()));
|
||||
|
||||
searchProjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* To sort filter.
|
||||
*
|
||||
* @param labelFilter the label filter
|
||||
* @return the searching filter
|
||||
*/
|
||||
public SearchingFilter toSortFilter(String labelFilter) {
|
||||
GWT.log("toSortFilter for label " + labelFilter);
|
||||
String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
|
||||
SearchingFilter sortFilter = null;
|
||||
try {
|
||||
ItemFieldDV recordField = null;
|
||||
for (ItemFieldDV value : sortByFields) {
|
||||
if (array[0].equalsIgnoreCase(value.getDisplayName())) {
|
||||
recordField = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ORDER orderField = ORDER.valueOf(array[1]);
|
||||
sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
GWT.log("toSortFilter Got " + sortFilter);
|
||||
return sortFilter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Built searching filter.
|
||||
*
|
||||
* @return the searching filter
|
||||
*/
|
||||
private SearchingFilter builtSearchingFilter() {
|
||||
SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue());
|
||||
String searchText = searchField.getText();
|
||||
if (searchText != null && !searchText.isEmpty()) {
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
|
||||
List<String> listOfSeachingFields = new ArrayList<String>();
|
||||
|
||||
for (ItemFieldDV recordField : searchForFields) {
|
||||
if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
|
||||
listOfSeachingFields = recordField.getJsonFields();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (String fieldname : listOfSeachingFields) {
|
||||
searchInto.put(fieldname, searchText);
|
||||
}
|
||||
|
||||
WhereClause where = new WhereClause();
|
||||
where.setSearchInto(searchInto);
|
||||
where.setOperator(LOGICAL_OP.OR);
|
||||
|
||||
// THIS CLAUSE IS ADDED IN ORDER TO SEARCH ONLY PUBLISHED PRODUCT (WITH SUCCESS)
|
||||
Map<String, Object> searchInto2 = new HashMap<String, Object>();
|
||||
// searchInto2.put("report.status", "PASSED");
|
||||
WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
|
||||
|
||||
// searchingFilter.setConditions(Arrays.asList(where, where2));
|
||||
|
||||
searchingFilter.setConditions(Arrays.asList(where));
|
||||
}
|
||||
return searchingFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current sort filter.
|
||||
*
|
||||
* @return the current sort filter
|
||||
*/
|
||||
public SearchingFilter getCurrentSortFilter() {
|
||||
currentSortFilter = builtSearchingFilter();
|
||||
GWT.log("currentSortFilter: " + currentSortFilter);
|
||||
return currentSortFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search button.
|
||||
*
|
||||
* @param searchFacilityButton the new search button
|
||||
*/
|
||||
public void setSearchButton(DropdownButton searchFacilityButton) {
|
||||
this.searchFacilityButton = searchFacilityButton;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||
xmlns:c="urn:import:org.gcube.portlets.user.geoportaldataviewer.client.ui">
|
||||
<ui:style>
|
||||
.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.container-panel {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.add-margin-right {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.add-margin-right-23 {
|
||||
margin-right: 23px;
|
||||
}
|
||||
|
||||
.margin-top-5 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.font-size-12 {
|
||||
font-size: 12px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel addStyleNames="{style.container-panel}">
|
||||
<g:FlowPanel>
|
||||
<g:FlowPanel>
|
||||
<g:FlowPanel>
|
||||
<g:HorizontalPanel>
|
||||
<g:Label addStyleNames="{style.add-margin-right}">Search for: </g:Label>
|
||||
<b:ListBox title="Search for"
|
||||
ui:field="listBoxSearchFor"
|
||||
addStyleNames="{style.add-margin-right}">
|
||||
</b:ListBox>
|
||||
<b:TextBox ui:field="searchField"
|
||||
addStyleNames="search-textbox" placeholder="type a text..."></b:TextBox>
|
||||
<b:Button icon="REMOVE_CIRCLE" ui:field="resetSearch"
|
||||
title="Reset the search" visible="false">Reset</b:Button>
|
||||
</g:HorizontalPanel>
|
||||
</g:FlowPanel>
|
||||
<g:FlowPanel>
|
||||
<b:NavLink ui:field="sortByToogle" addStyleNames="{style.font-size-12}">Sort Results</b:NavLink>
|
||||
<g:HorizontalPanel ui:field="toogleSortBy"
|
||||
addStyleNames="{style.margin-top-5}" visible="false">
|
||||
<g:Label addStyleNames="{style.add-margin-right-23}">Sort by: </g:Label>
|
||||
<b:ListBox ui:field="listBoxSortBy">
|
||||
</b:ListBox>
|
||||
</g:HorizontalPanel>
|
||||
</g:FlowPanel>
|
||||
</g:FlowPanel>
|
||||
<g:HTMLPanel ui:field="panelResults">
|
||||
</g:HTMLPanel>
|
||||
</g:FlowPanel>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -7,7 +7,6 @@ package org.gcube.portlets.user.geoportaldataviewer.server;
|
|||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
|
|
|
@ -3,10 +3,10 @@ package org.gcube.portlets.user.geoportaldataviewer.server;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -15,8 +15,13 @@ import javax.servlet.http.HttpSession;
|
|||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||||
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
||||
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
|
@ -24,11 +29,17 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|||
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||||
|
@ -63,7 +74,6 @@ import org.json.JSONArray;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
|
@ -660,23 +670,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
|
||||
}
|
||||
|
||||
// TODO THIS PART REQUIRES THE JSON MAPPING based on keys read from gCube Meta
|
||||
|
||||
/**
|
||||
* List of fields for searching.
|
||||
*
|
||||
* @return the list
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<ItemFieldDV> listOfFieldsForSearching() throws Exception {
|
||||
LOG.info("listOfFieldsForSearching called");
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile();
|
||||
return profile.getListItemFields();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -707,145 +700,221 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
LOG.info("init called");
|
||||
//Init one GcubeProfilesPerUCDIdCache for the application
|
||||
new GcubeProfilesPerUCDIdCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBeforeRequestDeserialized(String serializedRequest) {
|
||||
LOG.info("onBeforeRequestDeserialized called");
|
||||
String scope = "";
|
||||
try {
|
||||
|
||||
@Override
|
||||
public Map<String, List<ItemFieldDV>> listOfFieldsForSearching() throws Exception {
|
||||
LOG.info("listOfFieldsForSearching called");
|
||||
|
||||
try {
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
// GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile();
|
||||
// return profile.getListItemFields();
|
||||
|
||||
Map<String, List<ItemFieldDV>> map = new HashMap<String, List<ItemFieldDV>>();
|
||||
|
||||
List<String> handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_list.getId());
|
||||
List<UseCaseDescriptor> listUseCaseDescriptor;
|
||||
try {
|
||||
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
|
||||
listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on reading handlerIds: " + handlersIds + ", in the UCDs", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (listUseCaseDescriptor == null) {
|
||||
listUseCaseDescriptor = new ArrayList<UseCaseDescriptor>();
|
||||
}
|
||||
|
||||
List<UseCaseDescriptorDV> listUCDDV = new ArrayList<UseCaseDescriptorDV>(listUseCaseDescriptor.size());
|
||||
for (UseCaseDescriptor ucd : listUseCaseDescriptor) {
|
||||
UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null);
|
||||
listUCDDV.add(ucdDV);
|
||||
HandlerDeclarationDV dataListHandler = getHandlerDeclarationFor(ucdDV,
|
||||
GEOPORTAL_DATA_HANDLER.geoportal_data_list);
|
||||
|
||||
if (dataListHandler != null) {
|
||||
ConfigurationDV<?> config = dataListHandler.getConfiguration();
|
||||
switch (config.getConfigurationType()) {
|
||||
case item_fields:
|
||||
List<ItemFieldDV> listItemFields = (List<ItemFieldDV>) config.getConfiguration();
|
||||
map.put(ucdDV.getProfileID(), listItemFields);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
LOG.info("listOfFieldsForSearching returning: " + map);
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading list of fields for searching: ", e);
|
||||
throw new Exception("Error occurred on loading list of fields for searching. Error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static HandlerDeclarationDV getHandlerDeclarationFor(UseCaseDescriptorDV useCaseDescriptor,
|
||||
GEOPORTAL_DATA_HANDLER dataHandler) {
|
||||
|
||||
if (useCaseDescriptor == null)
|
||||
return null;
|
||||
|
||||
for (HandlerDeclarationDV handler : useCaseDescriptor.getHandlers()) {
|
||||
GEOPORTAL_DATA_HANDLER dataHandlerType = handler.getDataHandlerType();
|
||||
|
||||
if (dataHandlerType != null && dataHandlerType.equals(dataHandler)) {
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
LOG.info("init called");
|
||||
// Init one GcubeProfilesPerUCDIdCache for the application
|
||||
new GcubeProfilesPerUCDIdCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBeforeRequestDeserialized(String serializedRequest) {
|
||||
LOG.info("onBeforeRequestDeserialized called");
|
||||
String scope = "";
|
||||
try {
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
//Loading GcubeProfilesPerUCDIdCache per scope
|
||||
scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
// Loading GcubeProfilesPerUCDIdCache per scope
|
||||
GcubeProfilesPerUCDIdCache.get(scope);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading the " + GcubeProfilesPerUCDIdCache.class.getSimpleName() + " for scope: "+scope, e);
|
||||
LOG.error("Error on loading the " + GcubeProfilesPerUCDIdCache.class.getSimpleName() + " for scope: "
|
||||
+ scope, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
super.onBeforeRequestDeserialized(serializedRequest);
|
||||
}
|
||||
super.onBeforeRequestDeserialized(serializedRequest);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the list concessioni.
|
||||
// *
|
||||
// * @param start the start
|
||||
// * @param limit the limit
|
||||
// * @param filter the filter
|
||||
// * @param reloadFromService the reload from service
|
||||
// * @return the list concessioni
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// @Override
|
||||
// public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
// boolean reloadFromService) throws Exception {
|
||||
// LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// throw new Exception("getListConcessioni must be revisited!!!!");
|
||||
// /*
|
||||
// *
|
||||
// * // setting identity as D4S User or KC client new
|
||||
// * GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
// * SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
// * MongoServiceCommon serviceCommon = new MongoServiceCommon(); // TODO MUST BE
|
||||
// * REPLACED BY COUNT List<Concessione> listOfConcessioni =
|
||||
// * SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService);
|
||||
// * int listConcessioniSize = listOfConcessioni.size();
|
||||
// *
|
||||
// * ResultSetPaginatedData searchedData =
|
||||
// * serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
|
||||
// * "concessione"); return searchedData;
|
||||
// */
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
|
||||
// throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the list concessioni.
|
||||
* Gets the list projects.
|
||||
*
|
||||
* @param theProfileID the the profile ID
|
||||
* @param start the start
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @param reloadFromService the reload from service
|
||||
* @return the list concessioni
|
||||
* @return the list projects
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception {
|
||||
LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
|
||||
public ResultSetPaginatedData getListProjects(String theProfileID, Integer start, Integer limit,
|
||||
SearchingFilter filter, boolean reloadFromService) throws Exception {
|
||||
LOG.info("getListProjects called with profileID: " + theProfileID + ", start: " + start + ", limit: " + limit
|
||||
+ ", filter: " + filter);
|
||||
|
||||
try {
|
||||
|
||||
throw new Exception("getListConcessioni must be revisited!!!!");
|
||||
/*
|
||||
*
|
||||
* // setting identity as D4S User or KC client new
|
||||
* GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
* SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
* MongoServiceCommon serviceCommon = new MongoServiceCommon(); // TODO MUST BE
|
||||
* REPLACED BY COUNT List<Concessione> listOfConcessioni =
|
||||
* SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService);
|
||||
* int listConcessioniSize = listOfConcessioni.size();
|
||||
*
|
||||
* ResultSetPaginatedData searchedData =
|
||||
* serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
|
||||
* "concessione"); return searchedData;
|
||||
*/
|
||||
ProjectsCaller client = GeoportalClientCaller.projects();
|
||||
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
|
||||
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
|
||||
theProfileID);
|
||||
|
||||
if (totalProjectForProfile == null) {
|
||||
totalProjectForProfile = client.getTotalDocument(theProfileID);
|
||||
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), theProfileID, totalProjectForProfile);
|
||||
}
|
||||
|
||||
LOG.info("Total Docs read from config: " + totalProjectForProfile);
|
||||
|
||||
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalProjectForProfile, start, limit,
|
||||
filter);
|
||||
|
||||
ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, false);
|
||||
searchedData.setTotalItems(totalProjectForProfile);
|
||||
|
||||
List<ResultDocumentDV> toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||
|
||||
searchedData.setData(toReturnList);
|
||||
|
||||
// TODO BUGGY WORKAROUND. BLOCKED BY #22487 IT MUST BE REMOVE AFTER THE QUERY
|
||||
// COUNT
|
||||
// AND LIST.SIZE BY QUERY WILL BE AVAILABLE IN THE SERVICE
|
||||
if (filter.getConditions() != null) {
|
||||
searchedData.setTotalItems(toReturnList.size());
|
||||
int totalItems = toReturnList.size();
|
||||
searchedData.setTotalItems(totalItems);
|
||||
}
|
||||
|
||||
if (totalProjectForProfile == limit || totalProjectForProfile == 0) {
|
||||
LOG.debug("Page completed returning " + totalProjectForProfile + " projects");
|
||||
int newOffset = start + limit;
|
||||
searchedData.setServerSearchFinished(newOffset > totalProjectForProfile || totalProjectForProfile == 0);
|
||||
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
||||
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("returning {}", searchedData.getData());
|
||||
}
|
||||
|
||||
List<? extends DocumentDV> data = searchedData.getData();
|
||||
if (data != null) {
|
||||
LOG.info("returning {} project/s", data.size());
|
||||
}
|
||||
|
||||
return searchedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
|
||||
LOG.error("Error on loading paginated and filtered list of projects for id: ", e);
|
||||
throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Preloadg cube profiles for UC ds.
|
||||
// */
|
||||
// public void preloadgCubeProfilesForUCDs() {
|
||||
// LOG.info("preloadgCubeProfilesForUCDs called");
|
||||
// try {
|
||||
//
|
||||
// String currentContext = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
// LOG.info("preloadgCubeProfilesForUCDs context: " + currentContext);
|
||||
// UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
||||
// SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
// List<UseCaseDescriptor> listUCDs = clientUCD.getList();
|
||||
// LOG.debug("listUCDs: " + listUCDs);
|
||||
//
|
||||
// for (UseCaseDescriptor ucd : listUCDs) {
|
||||
//
|
||||
// LOG.info("Loaded UCD for ID: " + ucd.getId());
|
||||
// String profileID = ucd.getId();
|
||||
// GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
|
||||
// List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
|
||||
//
|
||||
// if (handlers.size() == 0) {
|
||||
// LOG.warn("No handler " + theHandler + "found into UCD " + ucd.getId() + ", continue...");
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // Loading Handler gcube_profiles
|
||||
// HandlerDeclaration dataEntryHandler = handlers.get(0);
|
||||
// HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
|
||||
// .toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
|
||||
//
|
||||
// LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + ucd.getId());
|
||||
// LOG.debug("" + handlerGcubeProfiles);
|
||||
//
|
||||
// ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
|
||||
// // List of gCube Profiles defined in the UCD
|
||||
// List<GcubeProfileDV> listGcubeProfiles = (List<GcubeProfileDV>) config.getConfiguration();
|
||||
// LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
|
||||
//
|
||||
// List<GcubeProfilesMetadataForUCD> listProfilesBean = new ArrayList<GcubeProfilesMetadataForUCD>();
|
||||
// // Loading Metadata Profile from IS
|
||||
// MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
|
||||
//
|
||||
// LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>();
|
||||
// for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
|
||||
// String context = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
// GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
|
||||
// List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(context,
|
||||
// gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
|
||||
//
|
||||
// String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
|
||||
// LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
|
||||
// gCubeProfileMetadataForUCD.setGcubeProfile(gcubeProfileDV);
|
||||
// gCubeProfileMetadataForUCD.setListMetadataProfileBean(listProfiles);
|
||||
// listProfilesBean.add(gCubeProfileMetadataForUCD);
|
||||
//
|
||||
// }
|
||||
// linkedMap_UCDId_gCubeProfiles.put(ucd.getId(), listProfilesBean);
|
||||
//
|
||||
// for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
|
||||
// LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
|
||||
// }
|
||||
//
|
||||
// SessionUtil.setMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID,
|
||||
// linkedMap_UCDId_gCubeProfiles);
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
|
||||
// LOG.error(erroMsg, e);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the layers for id.
|
||||
*
|
||||
|
@ -960,7 +1029,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
ProjectView projectView = new ProjectView();
|
||||
projectView.setTheProjectDV(theProjectDV);
|
||||
|
||||
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache.get(scope);
|
||||
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
|
||||
.get(scope);
|
||||
|
||||
// NO UCD defined, applyong default
|
||||
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
|
||||
|
|
|
@ -45,6 +45,8 @@ public class SessionUtil {
|
|||
private static final String LIST_BASE_MAPS_LAYERS = "LIST_BASE_MAPS_LAYERS";
|
||||
private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI_DATA_VIEWER";
|
||||
private static final String GNA_DATAVIEWER_CONFIG_PROFILE = "GNA_DATAVIEWER_CONFIG_PROFILE";
|
||||
|
||||
private static final String COUNT_DOCS_FOR_PROFILE_ID = "GNA_DATAVIEWER_COUNT_DOCS_FOR_PROFILE_ID";
|
||||
|
||||
/**
|
||||
* Checks if is into portal.
|
||||
|
@ -272,4 +274,32 @@ public class SessionUtil {
|
|||
HttpSession session = httpServletRequest.getSession();
|
||||
session.setAttribute(GNA_DATAVIEWER_CONFIG_PROFILE, gNADVConfigProfile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the total document for profile ID.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param theProfileID the the profile ID
|
||||
* @return the total document for profile ID
|
||||
*/
|
||||
public static Integer getTotalDocumentForProfileID(HttpServletRequest httpServletRequest, String theProfileID) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
return (Integer) session.getAttribute(COUNT_DOCS_FOR_PROFILE_ID + theProfileID);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total document for profile ID.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param theProfileID the the profile ID
|
||||
* @param countForProfileId the count for profile id
|
||||
*/
|
||||
public static void setTotalDocumentForProfileID(HttpServletRequest httpServletRequest, String theProfileID,
|
||||
Integer countForProfileId) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
session.setAttribute(COUNT_DOCS_FOR_PROFILE_ID + theProfileID, countForProfileId);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue