Applied CQL_Filter for cross filtering
This commit is contained in:
parent
9d48e78fac
commit
33d6dbc89f
|
@ -60,6 +60,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -143,6 +144,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -226,6 +228,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -309,6 +312,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -392,6 +396,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -475,6 +480,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -561,6 +567,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -644,6 +651,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -727,6 +735,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -810,6 +819,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
|||
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
||||
|
@ -24,6 +25,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.AddLayerToMapEv
|
|||
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ApplyCQLToLayerMapEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ApplyCQLToLayerMapEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
|
||||
|
@ -863,9 +866,6 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
cqlFilter = cqlFilter.substring(0, cqlFilter.length() - 1) + ")";
|
||||
setCqlFilter = cqlFilter;
|
||||
|
||||
setCqlFilter = "INTERSECTS(geom,querySingle('limiti_amministrativi:regioni','the_geom','DEN_REG=''Calabria'''));INCLUDE";
|
||||
GWT.log("HARD-CODED CQL FILTER: " + setCqlFilter);
|
||||
|
||||
olMapMng.getOLMap().setCQLFilterToWMSLayer(layerName, setCqlFilter);
|
||||
|
||||
} else {
|
||||
|
@ -886,6 +886,48 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
}
|
||||
});
|
||||
|
||||
applicationBus.addHandler(ApplyCQLToLayerMapEvent.TYPE, new ApplyCQLToLayerMapEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onApplyCQL(ApplyCQLToLayerMapEvent applyCQLToLayerMapEvent) {
|
||||
GWT.log("Fired: " + applyCQLToLayerMapEvent);
|
||||
|
||||
if (applyCQLToLayerMapEvent != null) {
|
||||
|
||||
String layerName = null;
|
||||
|
||||
GCubeSDILayer layer = applyCQLToLayerMapEvent.getTheIndeLayer().getLayer();
|
||||
|
||||
try {
|
||||
String wmsLink = layer.getOgcLinks().get("wms");
|
||||
layerName = URLUtil.extractValueOfParameterFromURL("layers", wmsLink);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
String setCqlFilter = null;
|
||||
|
||||
if (layerName != null) {
|
||||
|
||||
GWT.log("ApplyCQLToLayerMapEvent: " + layerName + ", filter : "
|
||||
+ applyCQLToLayerMapEvent.getCqlFilterValue());
|
||||
|
||||
|
||||
if (applyCQLToLayerMapEvent.getCqlFilterValue() == null) {
|
||||
olMapMng.getOLMap().setCQLFilterToWMSLayer(layerName, null);
|
||||
setCqlFilter = null; // is already null
|
||||
} else {
|
||||
setCqlFilter = applyCQLToLayerMapEvent.getCqlFilterValue();
|
||||
olMapMng.getOLMap().setCQLFilterToWMSLayer(layerName, setCqlFilter);
|
||||
}
|
||||
|
||||
layerManager.setCQLForLayerToIndexLayer(layerName, setCqlFilter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class AddedLayerToMapEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Nov 18, 2020
|
||||
*/
|
||||
public class ApplyCQLToLayerMapEvent extends GwtEvent<ApplyCQLToLayerMapEventHandler> {
|
||||
public static Type<ApplyCQLToLayerMapEventHandler> TYPE = new Type<ApplyCQLToLayerMapEventHandler>();
|
||||
private IndexLayerDV theIndeLayer;
|
||||
private String cqlFilterValue;
|
||||
|
||||
/**
|
||||
* Instantiates a new apply CQL to layer map event.
|
||||
*
|
||||
* @param theIndeLayer the the inde layer
|
||||
* @param cqlFilter the cql filter
|
||||
*/
|
||||
public ApplyCQLToLayerMapEvent(IndexLayerDV theIndeLayer, String cqlFilterValue) {
|
||||
this.theIndeLayer = theIndeLayer;
|
||||
this.cqlFilterValue = cqlFilterValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
@Override
|
||||
public Type<ApplyCQLToLayerMapEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ApplyCQLToLayerMapEventHandler handler) {
|
||||
handler.onApplyCQL(this);
|
||||
|
||||
}
|
||||
|
||||
public IndexLayerDV getTheIndeLayer() {
|
||||
return theIndeLayer;
|
||||
}
|
||||
|
||||
public String getCqlFilterValue() {
|
||||
return cqlFilterValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ApplyCQLToLayerMapEvent [theIndeLayer=");
|
||||
builder.append(theIndeLayer);
|
||||
builder.append(", cqlFilterValue=");
|
||||
builder.append(cqlFilterValue);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
* The Interface ApplyCQLToLayerMapEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 31, 2023
|
||||
*/
|
||||
public interface ApplyCQLToLayerMapEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On apply CQL.
|
||||
*
|
||||
* @param applyCQLToLayerMapEvent the apply CQL to layer map event
|
||||
*/
|
||||
void onApplyCQL(ApplyCQLToLayerMapEvent applyCQLToLayerMapEvent);
|
||||
}
|
|
@ -741,12 +741,12 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
lcInner.add(overlayGroupDescr);
|
||||
// panelCustomOverlayLayers.add(overlayGroupDescr);
|
||||
}
|
||||
lcInner.add(new CrossFilteringLayerPanel(groupedLayerDV, applicationBus));
|
||||
CrossFilteringLayerPanel cfp = new CrossFilteringLayerPanel(collection, groupedLayerDV, applicationBus);
|
||||
cfp.setFilterButton(linkCrossFilteringLayers);
|
||||
lcInner.add(cfp);
|
||||
panelCrossFilteringLayers.add(lcInner);
|
||||
}
|
||||
|
||||
//panelCrossFilteringLayers.add(new CrossFilteringLayerPanel(groupedLayerDV, applicationBus));
|
||||
|
||||
linkCrossFilteringLayers.setVisible(listGroupedLayers.size() > 0);
|
||||
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ public class SearchFacilityUI extends Composite {
|
|||
*
|
||||
* @param profileID the profile ID
|
||||
* @param appManagerBus the app manager bus
|
||||
* @param displayByFields the display by fields
|
||||
* @param sortByFields the sort by fields
|
||||
* @param searchForFields the search for fields
|
||||
* @param initialSortFilter the initial sort filter
|
||||
|
@ -237,6 +238,9 @@ public class SearchFacilityUI extends Composite {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset current search.
|
||||
*/
|
||||
public void resetCurrentSearch() {
|
||||
searchField.setText("");
|
||||
resetSearch.setVisible(false);
|
||||
|
@ -356,7 +360,8 @@ public class SearchFacilityUI extends Composite {
|
|||
profileID);
|
||||
// here
|
||||
appManagerBus.fireEvent(new ClosedViewDetailsEvent());
|
||||
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_SEARCHED));
|
||||
appManagerBus.fireEvent(
|
||||
new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_SEARCHED));
|
||||
// appManagerBus.fireEvent(new ShowPopupOnCentroidEvent(profileID,
|
||||
// resultDoc.getProjectID(), resultDoc.getSpatialReference()));
|
||||
|
||||
|
|
|
@ -9,19 +9,26 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLaye
|
|||
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.CrossFilteringLayerDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ApplyCQLToLayerMapEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.OLGeoJSONUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.CheckBox;
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
import com.github.gwtbootstrap.client.ui.ControlLabel;
|
||||
import com.github.gwtbootstrap.client.ui.Controls;
|
||||
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||
import com.github.gwtbootstrap.client.ui.Fieldset;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
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.shared.HandlerManager;
|
||||
import com.google.gwt.http.client.Request;
|
||||
import com.google.gwt.http.client.RequestBuilder;
|
||||
|
@ -54,6 +61,9 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
@UiField
|
||||
Fieldset fieldSet;
|
||||
|
||||
@UiField
|
||||
Button buttonReset;
|
||||
|
||||
private CheckBox checkbox;
|
||||
|
||||
private GeoInformationForWMSRequest geoInformation;
|
||||
|
@ -72,6 +82,10 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
|
||||
private GroupedLayersDV<? extends LayerIDV> groupedLayersDV;
|
||||
|
||||
private GCubeCollection gCubeCollection;
|
||||
|
||||
private DropdownButton filterButton;
|
||||
|
||||
/**
|
||||
* The Interface LayerCollectionPanelUiBinder.
|
||||
*
|
||||
|
@ -82,74 +96,68 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
interface CrossFilteringLayerPanelUiBinder extends UiBinder<Widget, CrossFilteringLayerPanel> {
|
||||
}
|
||||
|
||||
public class SelectableItem {
|
||||
String key;
|
||||
String parentKey;
|
||||
String itemField;
|
||||
/**
|
||||
* Instantiates a new overlay custom layer panel.
|
||||
*
|
||||
* @param gCubeCollection the g cube collection
|
||||
* @param groupedLayersDV the grouped layers DV
|
||||
* @param applicationBus the application bus
|
||||
*/
|
||||
public CrossFilteringLayerPanel(GCubeCollection gCubeCollection,
|
||||
GroupedLayersDV<? extends LayerIDV> groupedLayersDV, HandlerManager applicationBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.applicationBus = applicationBus;
|
||||
this.groupedLayersDV = groupedLayersDV;
|
||||
this.gCubeCollection = gCubeCollection;
|
||||
GWT.log("Building cross-filtering for: " + groupedLayersDV);
|
||||
|
||||
String provenance; // layerName
|
||||
buttonReset.setType(ButtonType.LINK);
|
||||
|
||||
SelectableItem() {
|
||||
int level = 0;
|
||||
// Building mapInnestedFiltering
|
||||
recursivelyBuildSelectableLevels(level, groupedLayersDV.getListCustomLayers());
|
||||
|
||||
GWT.log("cross-filtering mapInnestedFiltering: " + mapInnestedFiltering);
|
||||
|
||||
for (Integer theLevel : mapInnestedFiltering.keySet()) {
|
||||
addListBoxesLevelToPanel(theLevel, mapInnestedFiltering.get(theLevel));
|
||||
}
|
||||
|
||||
fillSelectableLevel(level, null);
|
||||
|
||||
bindEvents();
|
||||
|
||||
}
|
||||
|
||||
public SelectableItem(String key, String parentKey, String itemField, String provenance) {
|
||||
super();
|
||||
this.key = key;
|
||||
this.parentKey = parentKey;
|
||||
this.itemField = itemField;
|
||||
this.provenance = provenance;
|
||||
}
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getParentKey() {
|
||||
return parentKey;
|
||||
}
|
||||
|
||||
public String getItemField() {
|
||||
return itemField;
|
||||
}
|
||||
|
||||
public String getProvenance() {
|
||||
return provenance;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void setParentKey(String parentKey) {
|
||||
this.parentKey = parentKey;
|
||||
}
|
||||
|
||||
public void setItemField(String itemField) {
|
||||
this.itemField = itemField;
|
||||
}
|
||||
|
||||
public void setProvenance(String provenance) {
|
||||
this.provenance = provenance;
|
||||
}
|
||||
buttonReset.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SelectableItem [key=");
|
||||
builder.append(key);
|
||||
builder.append(", parentKey=");
|
||||
builder.append(parentKey);
|
||||
builder.append(", itemField=");
|
||||
builder.append(itemField);
|
||||
builder.append(", provenance=");
|
||||
builder.append(provenance);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
public void onClick(ClickEvent event) {
|
||||
for (int i = 1; i < mapInnestedListBoxes.size(); i++) {
|
||||
resetListBoxLevel(i);
|
||||
}
|
||||
// Selecting the placeholder of the fist list box
|
||||
List<ListBox> listBox = mapInnestedListBoxes.get(0);
|
||||
listBox.get(0).setSelectedIndex(0);
|
||||
// Resetting CQL filtering
|
||||
applicationBus.fireEvent(new ApplyCQLToLayerMapEvent(gCubeCollection.getIndexes().get(0), null));
|
||||
setFilterHighLighted(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively build selectable levels.
|
||||
*
|
||||
* @param level the level
|
||||
* @param layersIDV the layers IDV
|
||||
*/
|
||||
private void recursivelyBuildSelectableLevels(int level, List<? extends LayerIDV> layersIDV) {
|
||||
|
||||
if (layersIDV == null)
|
||||
|
@ -169,49 +177,21 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new overlay custom layer panel.
|
||||
* Fill selectable level.
|
||||
*
|
||||
* @param listGroupedLayers the layer item
|
||||
* @param applicationBus the application bus
|
||||
* @param level the level
|
||||
* @param selectedItem the selected item
|
||||
*/
|
||||
public CrossFilteringLayerPanel(GroupedLayersDV<? extends LayerIDV> groupedLayersDV,
|
||||
HandlerManager applicationBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.applicationBus = applicationBus;
|
||||
this.groupedLayersDV = groupedLayersDV;
|
||||
GWT.log("Building cross-filtering for: " + groupedLayersDV);
|
||||
private void fillSelectableLevel(int level, SelectableItem selectedItem) {
|
||||
|
||||
int level = 0;
|
||||
// Building mapInnestedFiltering
|
||||
recursivelyBuildSelectableLevels(level, groupedLayersDV.getListCustomLayers());
|
||||
|
||||
GWT.log("cross-filtering mapInnestedFiltering: " + mapInnestedFiltering);
|
||||
|
||||
for (Integer theLevel : mapInnestedFiltering.keySet()) {
|
||||
addListBoxesLevelToPanel(theLevel, mapInnestedFiltering.get(theLevel));
|
||||
}
|
||||
|
||||
filleSelectableLevel(level, null);
|
||||
|
||||
}
|
||||
|
||||
private void filleSelectableLevel(int level, SelectableItem selectedItem) {
|
||||
|
||||
//HashMap<String, SelectableItem> mapOfFeatureAtLevel = mapInnestedFeatures.get(level);
|
||||
List<? extends LayerIDV> layersIDV = mapInnestedFiltering.get(level);
|
||||
List<ListBox> listBoxes = mapInnestedListBoxes.get(level);
|
||||
|
||||
if (layersIDV == null)
|
||||
return;
|
||||
|
||||
// final HashMap<String, SelectableItem> mapSelectableFeatures = mapOfFeatureAtLevel == null
|
||||
// ? new HashMap<String, SelectableItem>()
|
||||
// : mapOfFeatureAtLevel;
|
||||
|
||||
final HashMap<String, SelectableItem> mapSelectableFeatures = new HashMap<String, CrossFilteringLayerPanel.SelectableItem>();
|
||||
|
||||
// if (mapSelectableFeatures.isEmpty()) {
|
||||
|
||||
LayerIDV layerIDV = layersIDV.get(0); // Expected one
|
||||
|
||||
if (layerIDV instanceof CrossFilteringLayerDV) {
|
||||
|
@ -220,7 +200,7 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
|
||||
if (selectedItem != null) {
|
||||
|
||||
String cqlFilterValue = crossFilteringLayer.getTable_parent_key_field() + "=" + selectedItem.getKey();
|
||||
String cqlFilterValue = crossFilteringLayer.getTable_parent_key_field() + "=" + selectedItem.keyValue;
|
||||
wfsURL += "&CQL_FILTER=" + URL.encode(cqlFilterValue);
|
||||
|
||||
}
|
||||
|
@ -241,7 +221,7 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
|
||||
for (Feature feature : features) {
|
||||
JsPropertyMap<Object> properties = feature.getProperties();
|
||||
Object key = properties.get(crossFilteringLayer.getTable_key_field());
|
||||
Object keyValue = properties.get(crossFilteringLayer.getTable_key_field());
|
||||
Object itemField = properties.get(crossFilteringLayer.getTable_show_field());
|
||||
|
||||
Object parentKey = null;
|
||||
|
@ -251,14 +231,17 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
|
||||
parentKey = parentKey == null ? "" : parentKey;
|
||||
|
||||
SelectableItem selectableItem = new SelectableItem(key + "", parentKey + "", itemField + "",
|
||||
crossFilteringLayer.getName());
|
||||
GWT.log("select item: " + selectableItem);
|
||||
SelectableItem selectableItem = new SelectableItem(
|
||||
crossFilteringLayer.getTable_key_field() + "", keyValue + "",
|
||||
crossFilteringLayer.getTable_parent_key_field(), itemField + "",
|
||||
crossFilteringLayer.getName(), crossFilteringLayer.getTable_geometry_name());
|
||||
GWT.log("selectableItem: " + selectableItem);
|
||||
|
||||
String pathFeatureKey = pathFeatureKey(selectableItem);
|
||||
mapSelectableFeatures.put(pathFeatureKey, selectableItem);
|
||||
|
||||
}
|
||||
GWT.log("mapSelectableFeatures: " + mapSelectableFeatures);
|
||||
mapInnestedFeatures.put(level, mapSelectableFeatures);
|
||||
String placholder = placeholderLayer(layersIDV.get(0)); // Expected one
|
||||
fillListBoxLevel(level, mapSelectableFeatures, listBoxes, placholder);
|
||||
|
@ -269,23 +252,39 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
// Code omitted for clarity
|
||||
}
|
||||
}
|
||||
|
||||
// } else {
|
||||
//
|
||||
// String placholder = placeholderLayer(layersIDV.get(0)); // Expected one
|
||||
// fillListBoxLevel(level, mapInnestedFeatures.get(level), listBoxes, placholder);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Path feature key.
|
||||
*
|
||||
* @param selectableItem the selectable item
|
||||
* @return the string
|
||||
*/
|
||||
private String pathFeatureKey(SelectableItem selectableItem) {
|
||||
return "root_" + selectableItem.getParentKey() + "_"+selectableItem.getKey();
|
||||
return "root_" + selectableItem.parentKeyField + "_" + selectableItem.keyField + "_" + selectableItem.keyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Placeholder layer.
|
||||
*
|
||||
* @param layersIDV the layers IDV
|
||||
* @return the string
|
||||
*/
|
||||
private String placeholderLayer(LayerIDV layersIDV) {
|
||||
return "Select " + layersIDV.getTitle() + "...";
|
||||
String placeholder = "Select";
|
||||
if (layersIDV != null)
|
||||
placeholder += " " + layersIDV.getTitle() + "...";
|
||||
|
||||
placeholder += " ...";
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the list boxes level to panel.
|
||||
*
|
||||
* @param level the level
|
||||
* @param layersIDV the layers IDV
|
||||
*/
|
||||
private void addListBoxesLevelToPanel(int level, List<? extends LayerIDV> layersIDV) {
|
||||
|
||||
if (layersIDV == null)
|
||||
|
@ -312,18 +311,35 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
mapInnestedListBoxes.put(level, listBoxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled box.
|
||||
*
|
||||
* @param listBox the list box
|
||||
* @param bool the bool
|
||||
*/
|
||||
public void setEnabledBox(ListBox listBox, boolean bool) {
|
||||
listBox.setEnabled(bool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear list box.
|
||||
*
|
||||
* @param listBox the list box
|
||||
* @param bool the bool
|
||||
*/
|
||||
public void clearListBox(ListBox listBox, boolean bool) {
|
||||
listBox.setEnabled(bool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset list box level.
|
||||
*
|
||||
* @param level the level
|
||||
*/
|
||||
private void resetListBoxLevel(int level) {
|
||||
|
||||
List<ListBox> listBoxes = mapInnestedListBoxes.get(level);
|
||||
if(listBoxes!=null) {
|
||||
if (listBoxes != null) {
|
||||
for (ListBox listBox : listBoxes) {
|
||||
listBox.clear();
|
||||
setEnabledBox(listBox, false);
|
||||
|
@ -331,6 +347,14 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill list box level.
|
||||
*
|
||||
* @param level the level
|
||||
* @param mapSelectableFeatures the map selectable features
|
||||
* @param listBoxes the list boxes
|
||||
* @param placeholder the placeholder
|
||||
*/
|
||||
private void fillListBoxLevel(int level, HashMap<String, SelectableItem> mapSelectableFeatures,
|
||||
List<ListBox> listBoxes, String placeholder) {
|
||||
GWT.log("fillBox level: " + level + " map: " + mapSelectableFeatures);
|
||||
|
@ -345,7 +369,7 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
|
||||
for (String key : mapSelectableFeatures.keySet()) {
|
||||
SelectableItem selItem = mapSelectableFeatures.get(key);
|
||||
listBox.addItem(selItem.getItemField(), key);
|
||||
listBox.addItem(selItem.itemValue, key);
|
||||
}
|
||||
|
||||
listBox.addChangeHandler(new ChangeHandler() {
|
||||
|
@ -353,12 +377,44 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
loadInnerLevel(level, listBox.getSelectedValue());
|
||||
|
||||
for (int i = level + 1; i < mapInnestedListBoxes.size(); i++) {
|
||||
resetListBoxLevel(i);
|
||||
}
|
||||
|
||||
String key = listBox.getSelectedValue();
|
||||
SelectableItem selectableItem = mapSelectableFeatures.get(key);
|
||||
buildCrossFilteringCQLAndFireEvent(selectableItem);
|
||||
setFilterHighLighted(true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
setEnabledBox(listBox, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the cross filtering CQL and fire event.
|
||||
*
|
||||
* @param selectableItem the selectable item
|
||||
*/
|
||||
private void buildCrossFilteringCQLAndFireEvent(SelectableItem selectableItem) {
|
||||
String setCqlFilter = "INTERSECTS(geom,querySingle('" + selectableItem.layername + "','"
|
||||
+ selectableItem.theGeometryName + "','" + selectableItem.keyField + "=''" + selectableItem.keyValue
|
||||
+ "'''));INCLUDE";
|
||||
GWT.log("CQL FILTER built: " + setCqlFilter);
|
||||
|
||||
// olMapMng.getOLMap().setCQLFilterToWMSLayer(layerName, setCqlFilter);
|
||||
|
||||
applicationBus.fireEvent(new ApplyCQLToLayerMapEvent(gCubeCollection.getIndexes().get(0), setCqlFilter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load inner level.
|
||||
*
|
||||
* @param level the level
|
||||
* @param selectableItemValue the selectable item value
|
||||
*/
|
||||
private void loadInnerLevel(int level, String selectableItemValue) {
|
||||
GWT.log("selected level " + level + " selectableItemValue " + selectableItemValue);
|
||||
HashMap<String, SelectableItem> mapSelectableItem = mapInnestedFeatures.get(level);
|
||||
|
@ -368,24 +424,106 @@ public class CrossFilteringLayerPanel extends Composite {
|
|||
int innerLevel = level + 1;
|
||||
List<? extends LayerIDV> selectedLayers = mapInnestedFiltering.get(innerLevel);
|
||||
|
||||
//if layer filtering exists at this level
|
||||
// if layer filtering exists at this level
|
||||
if (selectedLayers != null) {
|
||||
|
||||
List<ListBox> selectedListBoxes = mapInnestedListBoxes.get(innerLevel);
|
||||
GWT.log("loading inner layers " + selectedLayers);
|
||||
GWT.log("loading selectedListBoxes " + selectedListBoxes);
|
||||
filleSelectableLevel(innerLevel, selectedItem);
|
||||
fillSelectableLevel(innerLevel, selectedItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public void resetCurrentSearch() {
|
||||
// searchField.setText("");
|
||||
// resetSearch.setVisible(false);
|
||||
// panelResults.clear();
|
||||
// latestResult = null;
|
||||
// appManagerBus.fireEvent(new SearchPerformedEvent(profileID, null, true));
|
||||
// setSearchEnabled(false);
|
||||
// }
|
||||
/**
|
||||
* Sets the filter high lighted.
|
||||
*
|
||||
* @param bool the new filter high lighted
|
||||
*/
|
||||
private void setFilterHighLighted(boolean bool) {
|
||||
if (bool) {
|
||||
filterButton.getElement().addClassName("highlight-button");
|
||||
} else {
|
||||
filterButton.getElement().removeClassName("highlight-button");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search button.
|
||||
*
|
||||
* @param searchFacilityButton the new search button
|
||||
*/
|
||||
public void setFilterButton(DropdownButton searchFacilityButton) {
|
||||
this.filterButton = searchFacilityButton;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class SelectableItem.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 31, 2023
|
||||
*/
|
||||
public class SelectableItem {
|
||||
protected String keyField;
|
||||
protected String keyValue;
|
||||
protected String parentKeyField;
|
||||
protected String itemValue;
|
||||
protected String layername;
|
||||
protected String theGeometryName;
|
||||
|
||||
/**
|
||||
* Instantiates a new selectable item.
|
||||
*/
|
||||
SelectableItem() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new selectable item.
|
||||
*
|
||||
* @param keyField the key field
|
||||
* @param keyValue the key value
|
||||
* @param parentKeyField the parent key field
|
||||
* @param itemValue the item value
|
||||
* @param layername the layername
|
||||
* @param theGeometryName the the geometry name
|
||||
*/
|
||||
public SelectableItem(String keyField, String keyValue, String parentKeyField, String itemValue,
|
||||
String layername, String theGeometryName) {
|
||||
super();
|
||||
this.keyField = keyField;
|
||||
this.keyValue = keyValue;
|
||||
this.parentKeyField = parentKeyField;
|
||||
this.itemValue = itemValue;
|
||||
this.layername = layername;
|
||||
this.theGeometryName = theGeometryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SelectableItem [keyField=");
|
||||
builder.append(keyField);
|
||||
builder.append(", keyValue=");
|
||||
builder.append(keyValue);
|
||||
builder.append(", parentKeyField=");
|
||||
builder.append(parentKeyField);
|
||||
builder.append(", itemValue=");
|
||||
builder.append(itemValue);
|
||||
builder.append(", layername=");
|
||||
builder.append(layername);
|
||||
builder.append(", theGeometryName=");
|
||||
builder.append(theGeometryName);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,14 @@
|
|||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<g:ScrollPanel>
|
||||
<g:HTMLPanel>
|
||||
<b:Form ui:field="panelForm">
|
||||
<b:Fieldset ui:field="fieldSet">
|
||||
</b:Fieldset>
|
||||
</b:Form>
|
||||
<b:Button icon="REMOVE_CIRCLE" ui:field="buttonReset"
|
||||
title="Reset the filter">Reset</b:Button>
|
||||
</g:HTMLPanel>
|
||||
</g:ScrollPanel>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -836,7 +836,8 @@ RESPONSIVE
|
|||
.overlay-panel-style-description {
|
||||
border: none !important;
|
||||
white-space: pre-line;
|
||||
padding: 5px 0px;
|
||||
padding: 10px 0px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.overlay-panel-style > div {
|
||||
|
@ -855,10 +856,15 @@ RESPONSIVE
|
|||
max-width: 350px;
|
||||
}
|
||||
|
||||
.filter-panel-style select {
|
||||
min-width: 310px;
|
||||
}
|
||||
|
||||
.filter-panel-style-description {
|
||||
border: none !important;
|
||||
white-space: pre-line;
|
||||
padding: 5px 0px;
|
||||
padding: 10px 0px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.filter-panel-style > div {
|
||||
|
@ -869,4 +875,11 @@ RESPONSIVE
|
|||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.filter-panel-style a {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.filter-panel-style label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue