Improved search facility

This commit is contained in:
Francesco Mangiacrapa 2023-06-09 10:28:46 +02:00
parent 6361c1c0b9
commit 3644685fe5
3 changed files with 20 additions and 15 deletions

View File

@ -853,15 +853,15 @@ public class GeoportalDataViewer implements EntryPoint {
String newCqlFilter = null; // default
// setCqlFilter = "INTERSECTS(geom,querySingle('limiti_amministrativi:regioni','the_geom','DEN_REG=''Calabria'''));INCLUDE";
// GWT.log("HARD-CODED CQL FILTER: "+setCqlFilter);
if (layerName == null) {
GWT.log("CQL FILTER skipped, layerName is NULL!!");
return;
}
if (result != null && result.size() > 0) {
// Applying CQL filter only if there are results and its number are less or
// equal to SEARCH_LIMIT_RESULTS_TO_MAXIMUM
if (result != null && result.size() > 0
&& result.size() <= GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM) {
String cqlFilter = GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE + " IN(";
for (String projectId : result) {
cqlFilter += "'" + projectId + "',";
@ -883,6 +883,7 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("New CQL Filter is: " + newCqlFilter);
// Resetting CQL Filter
if (layerName != null)
layerManager.setCQLForLayerToIndexLayer(layerName, newCqlFilter);

View File

@ -25,7 +25,9 @@ public class GeoportalDataViewerConstants {
public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.name();
public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name();
public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name();
public static final int SEARCH_LIMIT_RESULTS_TO_MAXIMUM = 50;
public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy");
public static enum MapEventType {
@ -152,7 +154,8 @@ public class GeoportalDataViewerConstants {
var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue);
if (theValue !== null && Object.prototype.toString.call(theValue) === '[object Array]') {
if (theValue !== null
&& Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = "";
for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k];

View File

@ -15,6 +15,7 @@ import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
@ -61,8 +62,6 @@ import com.google.gwt.user.client.ui.Widget;
*/
public class SearchFacilityUI extends Composite {
private static final int SEARCHING_LIMIT_RESULTS_TO = 50;
private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
protected static final int MIN_LENGHT_SERCHING_STRING = 3;
@ -272,8 +271,9 @@ public class SearchFacilityUI extends Composite {
panelResults.clear();
panelResults.add(new HTML("<hr>"));
panelResults.add(new LoaderIcon("Searching..."));
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, SEARCHING_LIMIT_RESULTS_TO,
filter, false, new AsyncCallback<ResultSetPaginatedDataIDs>() {
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0,
GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM, filter, false,
new AsyncCallback<ResultSetPaginatedDataIDs>() {
@Override
public void onFailure(Throwable caught) {
@ -313,13 +313,14 @@ public class SearchFacilityUI extends Composite {
+ "). Please find below the top " + returnedItems + ".<br>";
} else if (returnedItems > 0) {
message = "Found " + returnedItems;
message += returnedItems > 0 ? " items" : " item";
message += ". ";
message += returnedItems > 0 ? " projects" : " project";
message += ".";
}
// if (returnedItems > 0) {
// message += "On the map you can see all the projects with a centroid matching the query";
// }
if (returnedItems > 0
&& returnedItems <= GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM) {
message += "On the map you can see all the projects with a centroid matching the query";
}
HTML resultMessage = new HTML(message);
resultMessage.getElement().addClassName("search_result_msg");