#24195 Integrated the temporal query. Fixing CQL on WFS during searching
enabled
This commit is contained in:
parent
0764d0770c
commit
189dc36f75
|
@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- [#23955] Implemented the Temporal facility to navigate temporal relations among (JSON) Projects
|
||||
- [#24028] Passed the spatial dimension to CMS-Project model
|
||||
- [#24136] Integrated the temporal dimension on the front-end side
|
||||
- [#24195] Integrated the temporal query
|
||||
|
||||
## [v2.4.1-SNAPSHOT] - 2022-09-28
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPa
|
|||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation.TimelineManagerStatus;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.ControlledCallBack;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
|
||||
|
@ -323,6 +324,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) {
|
||||
GWT.log("Unexpected empty indexes in collection " + toOpen);
|
||||
Window.alert("Cannot open collection index layer for " + toOpen.getUcd().getName() + ".");
|
||||
return;
|
||||
}
|
||||
// TODO Get Default Index Layer
|
||||
// For now we just take the first - only 1 is expected
|
||||
|
@ -639,22 +641,51 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
LinkedHashMap<String, ol.layer.Image> wmsMap = olMapMng.getOLMap().getWmsLayerMap();
|
||||
String firstWMSKey = wmsMap.keySet().iterator().next();
|
||||
List<String> result = searchPerformedEvent.getListProjectIDs();
|
||||
ViewerConfiguration viewerConfig = GeoportalDataViewer.getStatus().getViewerConfig();
|
||||
|
||||
String layerName = null;
|
||||
try {
|
||||
|
||||
GCubeCollection toOpen = viewerConfig.getAvailableCollections().get(searchPerformedEvent.getProfileID());
|
||||
// Check if indexes is empty
|
||||
if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) {
|
||||
GWT.log("SearchPerformedEvent Unexpected empty indexes in collection " + toOpen);
|
||||
return;
|
||||
}
|
||||
// TODO Get Default Index Layer
|
||||
// For now we just take the first - only 1 is expected
|
||||
IndexLayerDV layer = toOpen.getIndexes().get(0);
|
||||
// Open Index Layer
|
||||
|
||||
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
|
||||
layerName = URLUtil.extractValueOfParameterFromURL("layers", wmsLink);
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
String setCqlFilter = null; //default
|
||||
|
||||
if (result != null && result.size() > 0) {
|
||||
String cqlFilter = GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE + " IN(";
|
||||
for (String projectId : result) {
|
||||
cqlFilter += "'" + projectId + "',";
|
||||
}
|
||||
cqlFilter = cqlFilter.substring(0, cqlFilter.length() - 1) + ")";
|
||||
|
||||
setCqlFilter = cqlFilter;
|
||||
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, cqlFilter);
|
||||
|
||||
} else {
|
||||
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
|
||||
setCqlFilter = null; //is already null
|
||||
}
|
||||
|
||||
if (searchPerformedEvent.isSearchReset()) {
|
||||
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
|
||||
setCqlFilter = null; //is already null
|
||||
}
|
||||
|
||||
if(layerName!=null)
|
||||
layerManager.setCQLForLayerToIndexLayer(layerName, setCqlFilter);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -536,6 +536,16 @@ public class LayerManager {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setCQLForLayerToIndexLayer(String layerName, String cqlFilter) {
|
||||
LayerObject theLo = mapIndexLayerObjects.get(layerName);
|
||||
if(theLo!=null) {
|
||||
boolean isCQLFilter = cqlFilter!=null;
|
||||
theLo.getLayerItem().setCqlFilter(cqlFilter);
|
||||
theLo.getLayerItem().setCqlFilterAvailable(isCQLFilter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the index layer.
|
||||
|
|
|
@ -15,14 +15,17 @@ public class SearchPerformedEvent extends GwtEvent<SearchPerformedEventHandler>
|
|||
public static Type<SearchPerformedEventHandler> TYPE = new Type<SearchPerformedEventHandler>();
|
||||
private List<String> listProjectIDs;
|
||||
private boolean searchReset;
|
||||
private String profileID;
|
||||
|
||||
/**
|
||||
* Instantiates a new search performed event.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param listProjectIds the list project ids
|
||||
* @param searchReset the search reset
|
||||
*/
|
||||
public SearchPerformedEvent(List<String> listProjectIds, boolean searchReset) {
|
||||
public SearchPerformedEvent(String profileID, List<String> listProjectIds, boolean searchReset) {
|
||||
this.profileID = profileID;
|
||||
this.listProjectIDs = listProjectIds;
|
||||
this.searchReset = searchReset;
|
||||
}
|
||||
|
@ -48,6 +51,15 @@ public class SearchPerformedEvent extends GwtEvent<SearchPerformedEventHandler>
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the profile ID. It is equal to collectionID
|
||||
*
|
||||
* @return the profile ID
|
||||
*/
|
||||
public String getProfileID() {
|
||||
return profileID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list project Ids.
|
||||
*
|
||||
|
|
|
@ -242,7 +242,7 @@ public class SearchFacilityUI extends Composite {
|
|||
resetSearch.setVisible(false);
|
||||
panelResults.clear();
|
||||
latestResult = null;
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(null, true));
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(profileID, null, true));
|
||||
setSearchEnabled(false);
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ public class SearchFacilityUI extends Composite {
|
|||
@Override
|
||||
public void onSuccess(ResultSetPaginatedDataIDs result) {
|
||||
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(result.getResultSetProjectIDs(), false));
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(profileID, result.getResultSetProjectIDs(), false));
|
||||
|
||||
setSearchEnabled(true);
|
||||
latestResult = result;
|
||||
|
@ -305,10 +305,15 @@ public class SearchFacilityUI extends Composite {
|
|||
String message = "";
|
||||
if (allItems > returnedItems) {
|
||||
message = "Too many results found. Below are " + returnedItems + " out of " + allItems
|
||||
+ " results. Projects (with a centroid) matching your search are shown on the Map";
|
||||
} else {
|
||||
+ " results";
|
||||
} else if (returnedItems>0){
|
||||
message = "Found " + returnedItems;
|
||||
message += returnedItems > 0 ? " items" : " item";
|
||||
|
||||
}
|
||||
|
||||
if (returnedItems>0) {
|
||||
message += ". Projects (with a centroid) matching your search are shown on the Map";
|
||||
}
|
||||
|
||||
HTML resultMessage = new HTML(message);
|
||||
|
|
|
@ -1,95 +1,97 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class URLUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 29, 2020
|
||||
* Nov 28, 2022
|
||||
*/
|
||||
public class URLUtil {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value of parameter.
|
||||
*
|
||||
* @param paramName the param name
|
||||
* @param url the url
|
||||
* @param url the url
|
||||
* @return the value of parameter
|
||||
*/
|
||||
public static String getValueOfParameter(String paramName, String url) {
|
||||
// logger.trace("finding: "+wmsParam +" into "+url);
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase()+"="); //ADDING CHAR "=" IN TAIL TO BE SECURE IT IS A PARAMETER
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SECURE IT
|
||||
// IS A PARAMETER
|
||||
// logger.trace("start index of "+wmsParam+ " is: "+index);
|
||||
String value = "";
|
||||
if(index > -1){
|
||||
int start = index + paramName.length()+1; //add +1 for char '='
|
||||
if (index > -1) {
|
||||
int start = index + paramName.length() + 1; // add +1 for char '='
|
||||
String sub = url.substring(start, url.length());
|
||||
int indexOfSeparator = sub.indexOf("&");
|
||||
int end = indexOfSeparator!=-1?indexOfSeparator:sub.length();
|
||||
int end = indexOfSeparator != -1 ? indexOfSeparator : sub.length();
|
||||
value = sub.substring(0, end);
|
||||
}else
|
||||
} else
|
||||
return null;
|
||||
|
||||
// logger.trace("return value: "+value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the parameter to query string.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @param prefixAmpersand the prefix ampersand
|
||||
* @param suffixAmpersand the suffix ampersand
|
||||
* @return the string
|
||||
*/
|
||||
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand, boolean suffixAmpersand) {
|
||||
|
||||
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand,
|
||||
boolean suffixAmpersand) {
|
||||
|
||||
String queryParameter = "";
|
||||
|
||||
if(prefixAmpersand)
|
||||
queryParameter+="&";
|
||||
|
||||
queryParameter+=key+"="+value;
|
||||
|
||||
if(suffixAmpersand)
|
||||
queryParameter+="&";
|
||||
|
||||
|
||||
if (prefixAmpersand)
|
||||
queryParameter += "&";
|
||||
|
||||
queryParameter += key + "=" + value;
|
||||
|
||||
if (suffixAmpersand)
|
||||
queryParameter += "&";
|
||||
|
||||
return queryParameter;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value of parameter.
|
||||
*
|
||||
* @param wmsParam the wms param
|
||||
* @param wmsLink the wms link
|
||||
* @param newValue the new value
|
||||
* @param wmsParam the wms param
|
||||
* @param wmsLink the wms link
|
||||
* @param newValue the new value
|
||||
* @param addIfNotExists the add if not exists
|
||||
* @return the string
|
||||
*/
|
||||
public static String setValueOfParameter(String wmsParam, String wmsLink, String newValue, boolean addIfNotExists){
|
||||
public static String setValueOfParameter(String wmsParam, String wmsLink, String newValue, boolean addIfNotExists) {
|
||||
String toLowerWmsLink = wmsLink.toLowerCase();
|
||||
String toLowerWmsParam = wmsParam.toLowerCase();
|
||||
|
||||
int index = toLowerWmsLink.indexOf(toLowerWmsParam+"="); //END WITH CHAR "=" TO BE SURE THAT IT IS A PARAMETER
|
||||
if(index > -1){
|
||||
int indexStartValue = index + toLowerWmsParam.length()+1; //add +1 for char '='
|
||||
int indexOfSeparator = toLowerWmsLink.indexOf("&", indexStartValue); //GET THE FIRST "&" STARTING FROM INDEX VALUE
|
||||
int index = toLowerWmsLink.indexOf(toLowerWmsParam + "="); // END WITH CHAR "=" TO BE SURE THAT IT IS A
|
||||
// PARAMETER
|
||||
if (index > -1) {
|
||||
int indexStartValue = index + toLowerWmsParam.length() + 1; // add +1 for char '='
|
||||
int indexOfSeparator = toLowerWmsLink.indexOf("&", indexStartValue); // GET THE FIRST "&" STARTING FROM
|
||||
// INDEX VALUE
|
||||
// logger.trace("indexOfSeparator index of "+wmsParam+ " is: "+indexOfSeparator);
|
||||
int indexEndValue = indexOfSeparator!=-1?indexOfSeparator:toLowerWmsLink.length();
|
||||
int indexEndValue = indexOfSeparator != -1 ? indexOfSeparator : toLowerWmsLink.length();
|
||||
// logger.trace("end: "+indexEndValue);
|
||||
return wmsLink.substring(0, indexStartValue) + newValue +wmsLink.substring(indexEndValue, wmsLink.length());
|
||||
}else if (addIfNotExists){
|
||||
wmsLink+="&"+wmsParam+"="+newValue;
|
||||
return wmsLink.substring(0, indexStartValue) + newValue
|
||||
+ wmsLink.substring(indexEndValue, wmsLink.length());
|
||||
} else if (addIfNotExists) {
|
||||
wmsLink += "&" + wmsParam + "=" + newValue;
|
||||
}
|
||||
// logger.trace("return value: "+value);
|
||||
return wmsLink;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract value of parameter from URL.
|
||||
*
|
||||
|
@ -98,7 +100,8 @@ public class URLUtil {
|
|||
* @return the string
|
||||
*/
|
||||
public static String extractValueOfParameterFromURL(String paramName, String url) {
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT IT
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT
|
||||
// IT
|
||||
// IS A PARAMETER
|
||||
String value = "";
|
||||
if (index > -1) {
|
||||
|
@ -114,5 +117,4 @@ public class URLUtil {
|
|||
return value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -674,6 +674,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
//Total number of Projects are exactly listProjectIDs.size()
|
||||
int totalItems = listProjectIDs.size();
|
||||
searchedDataIDs.setTotalItems(totalItems);
|
||||
LOG.info("Total IDs read from query: " + totalItems);
|
||||
|
||||
//NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
|
||||
// SETTING ORIGINAL PROJECTION FROM CLIENT
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.slf4j.LoggerFactory;
|
|||
public class GisMakers {
|
||||
|
||||
public static final String CQL_FILTER_PARAMETER = "CQL_FILTER";
|
||||
|
||||
public static final String GEOM_NAME_BOUNDED = "geom";
|
||||
|
||||
// MAP SERVER PIVOT
|
||||
public static final String WXS = "wxs";
|
||||
|
@ -107,12 +109,12 @@ public class GisMakers {
|
|||
|
||||
|
||||
if (layerItem.getCqlFilter() != null && !layerItem.getCqlFilter().isEmpty()) {
|
||||
if (layerItem.getCqlFilter().contains("BBOX(the_geom")) {
|
||||
if (layerItem.getCqlFilter().contains("BBOX("+GEOM_NAME_BOUNDED+"")) {
|
||||
// THE BBOX IS ALREADY USED INTO CQL FILTERING, SO USING IT DIRECTLY
|
||||
link += "&" + CQL_FILTER_PARAMETER + "=" + layerItem.getCqlFilter();
|
||||
} else {
|
||||
// I NEED TO ENCODE THE BBOX INTO CQL FILTERING,
|
||||
String cqlFilterValue = "BBOX(the_geom," + boundingBox + ")" + " AND " + layerItem.getCqlFilter();
|
||||
String cqlFilterValue = "BBOX("+GEOM_NAME_BOUNDED+"," + boundingBox + ")" + " AND " + layerItem.getCqlFilter();
|
||||
|
||||
link += "&" + CQL_FILTER_PARAMETER + "=" + cqlFilterValue;
|
||||
}
|
||||
|
|
|
@ -722,7 +722,7 @@ public class LayerItem implements Serializable, Cloneable {
|
|||
public String getCqlFilter() {
|
||||
return cqlFilter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the cql filter.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue