diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a52af0..9c6a3c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java
index 6b067a2..5f9d878 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java
@@ -6,7 +6,6 @@ import java.util.Set;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
-import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
@@ -52,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;
@@ -71,12 +71,13 @@ import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
-import ol.layer.Image;
/**
* Entry point classes define onModuleLoad()
.
@@ -163,8 +164,9 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
- // TODO Auto-generated method stub
-
+ RootPanel.get(APP_DIV).remove(loaderApp);
+ Window.alert(caught.getMessage());
+ RootPanel.get(APP_DIV).add(getGeneralErrorPanel());
}
@Override
@@ -193,7 +195,9 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onFailure(Throwable caught) {
+ RootPanel.get(APP_DIV).remove(loaderApp);
Window.alert(caught.getMessage());
+ RootPanel.get(APP_DIV).add(getGeneralErrorPanel());
}
@Override
@@ -320,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
@@ -615,7 +620,7 @@ public class GeoportalDataViewer implements EntryPoint {
public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) {
if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) {
- GWT.log("ShowPopupOnCentroiEvent: "+showPopupOnCentroiEvent);
+ GWT.log("ShowPopupOnCentroiEvent: " + showPopupOnCentroiEvent);
Coordinate transfCoord = MapUtils
.geoJSONTToBBoxCenter(showPopupOnCentroiEvent.getSpatialReference(), null, null);
@@ -633,25 +638,54 @@ public class GeoportalDataViewer implements EntryPoint {
if (searchPerformedEvent != null) {
- LinkedHashMap wmsMap = olMapMng.getOLMap().getWmsLayerMap();
+ LinkedHashMap wmsMap = olMapMng.getOLMap().getWmsLayerMap();
String firstWMSKey = wmsMap.keySet().iterator().next();
- List extends DocumentDV> result = searchPerformedEvent.getData();
+ List 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 (DocumentDV documentDV : result) {
- cqlFilter += "'" + documentDV.getProjectID() + "',";
+ 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);
}
@@ -722,4 +756,16 @@ public class GeoportalDataViewer implements EntryPoint {
timer.schedule(3000);
}
+ private FlowPanel getGeneralErrorPanel() {
+ Image geoportalError = new Image(GNAImages.ICONS.geoportaServiceError());
+ FlowPanel errorPanelMsg = new FlowPanel();
+ errorPanelMsg.getElement().addClassName("general_error");
+ errorPanelMsg.add(geoportalError);
+ errorPanelMsg.add(new HTML("D4S GeoPortal"));
+ HTML erroMessage = new HTML(
+ "Oops something went wrong, please refresh and try again. Feel free to contact us if the problem persists");
+ errorPanelMsg.add(erroMessage);
+ return errorPanelMsg;
+ }
+
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java
index 15e0752..7c1e751 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java
@@ -5,7 +5,6 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
-import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
@@ -13,6 +12,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
+import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
@@ -138,7 +138,7 @@ public interface GeoportalDataViewerService extends RemoteService {
* @return the list projects
* @throws Exception the exception
*/
- ResultSetPaginatedData getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter,
+ ResultSetPaginatedDataIDs getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter,
boolean reloadFromService) throws Exception;
/**
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java
index 080e2ef..5e31f69 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java
@@ -5,7 +5,6 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
-import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
@@ -13,6 +12,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
+import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
@@ -64,7 +64,7 @@ public interface GeoportalDataViewerServiceAsync {
void getProjectViewForId(String profileID, String projectID, AsyncCallback callback);
void getListProjects(String theProfileID, Integer start, Integer limit, SearchingFilter filter,
- boolean reloadFromService, AsyncCallback callback);
+ boolean reloadFromService, AsyncCallback callback);
void getInitialConfiguration(AsyncCallback callback);
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java
index c43f58d..e1d5792 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java
@@ -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.
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java
index 15b1eff..41557c7 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java
@@ -2,8 +2,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client.events;
import java.util.List;
-import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
-
import com.google.gwt.event.shared.GwtEvent;
/**
@@ -15,17 +13,20 @@ import com.google.gwt.event.shared.GwtEvent;
*/
public class SearchPerformedEvent extends GwtEvent {
public static Type TYPE = new Type();
- private List extends DocumentDV> data;
+ private List listProjectIDs;
private boolean searchReset;
+ private String profileID;
/**
* Instantiates a new search performed event.
*
- * @param data the data
- * @param searchReset the search reset
+ * @param profileID the profile ID
+ * @param listProjectIds the list project ids
+ * @param searchReset the search reset
*/
- public SearchPerformedEvent(List extends DocumentDV> data, boolean searchReset) {
- this.data = data;
+ public SearchPerformedEvent(String profileID, List listProjectIds, boolean searchReset) {
+ this.profileID = profileID;
+ this.listProjectIDs = listProjectIds;
this.searchReset = searchReset;
}
@@ -51,12 +52,21 @@ public class SearchPerformedEvent extends GwtEvent
}
/**
- * Gets the data.
+ * Gets the profile ID. It is equal to collectionID
*
- * @return the data
+ * @return the profile ID
*/
- public List extends DocumentDV> getData() {
- return data;
+ public String getProfileID() {
+ return profileID;
+ }
+
+ /**
+ * Gets the list project Ids.
+ *
+ * @return the list project Ids
+ */
+ public List getListProjectIDs() {
+ return listProjectIDs;
}
/**
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java
index 30bbdaa..961ab67 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java
@@ -52,5 +52,8 @@ public interface GNAImages extends ClientBundle {
@Source("spinner_clock.gif")
ImageResource spinnerClock();
+
+ @Source("geoporta_error.png")
+ ImageResource geoportaServiceError();
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/geoporta_error.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/geoporta_error.png
new file mode 100644
index 0000000..1ee4353
Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/geoporta_error.png differ
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.java
index dca2ec5..b3b381c 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.java
@@ -16,11 +16,13 @@ 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.GeoportalDataViewerServiceAsync;
+import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
+import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
@@ -59,6 +61,8 @@ 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;
@@ -140,7 +144,7 @@ public class SearchFacilityUI extends Composite {
resetSearch.setType(ButtonType.LINK);
listBoxSortBy.setWidth("180px");
- listBoxSearchFor.setWidth("140px");
+ // listBoxSearchFor.setWidth("140px");
bindEvents();
}
@@ -238,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);
}
@@ -264,8 +268,8 @@ public class SearchFacilityUI extends Composite {
panelResults.clear();
panelResults.add(new HTML("
"));
panelResults.add(new LoaderIcon("Searching..."));
- GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, 30, filter, false,
- new AsyncCallback() {
+ GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, SEARCHING_LIMIT_RESULTS_TO,
+ filter, false, new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
@@ -280,9 +284,9 @@ public class SearchFacilityUI extends Composite {
}
@Override
- public void onSuccess(ResultSetPaginatedData result) {
+ public void onSuccess(ResultSetPaginatedDataIDs result) {
- appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(), false));
+ appManagerBus.fireEvent(new SearchPerformedEvent(profileID, result.getResultSetProjectIDs(), false));
setSearchEnabled(true);
latestResult = result;
@@ -295,6 +299,28 @@ public class SearchFacilityUI extends Composite {
return;
}
+ int allItems = result.getResultSetProjectIDs().size();
+ int returnedItems = result.getData().size();
+
+ String message = "";
+ if (allItems > returnedItems) {
+ message = "Too many results found. Below are " + returnedItems + " out of " + allItems
+ + " 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);
+ resultMessage.getElement().addClassName("search_result_msg");
+
+ panelResults.add(resultMessage);
+
FlexTable ft = new FlexTable();
ft.getElement().setClassName("table-results");
int i = 0;
@@ -327,9 +353,11 @@ public class SearchFacilityUI extends Composite {
public void onClick(ClickEvent event) {
GeoportalItemReferences gir = new GeoportalItemReferences(resultDoc.getProjectID(),
profileID);
+ //here
+ appManagerBus.fireEvent(new ClosedViewDetailsEvent());
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, true));
- appManagerBus
- .fireEvent(new ShowPopupOnCentroiEvent(profileID, resultDoc.getProjectID(), resultDoc.getSpatialReference()));
+ appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(profileID,
+ resultDoc.getProjectID(), resultDoc.getSpatialReference()));
}
});
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.ui.xml
index c69f3ab..af66366 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.ui.xml
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/search/SearchFacilityUI.ui.xml
@@ -20,6 +20,10 @@
margin-right: 23px;
}
+ .listBoxSearchForStyle {
+ margin-right: 5px;
+ }
+
.margin-top-5 {
margin-top: 5px;
}
@@ -35,7 +39,7 @@
Search for:
+ addStyleNames="{style.listBoxSearchForStyle}">
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java
index 0f7bb55..d79b001 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java
@@ -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;
}
-
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java
index ea86346..8e50ff3 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java
@@ -12,6 +12,9 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -34,7 +37,6 @@ import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
-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;
@@ -64,6 +66,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.util.TemporalComparato
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
+import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
@@ -516,7 +519,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
} catch (Exception e) {
LOG.error("Error on reading handlerIds: " + handlersIds + ", in the UCDs", e);
- return null;
+ throw e;
}
if (listUseCaseDescriptor == null) {
@@ -627,7 +630,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception
*/
@Override
- public ResultSetPaginatedData getListProjects(String theProfileID, Integer start, Integer limit,
+ public ResultSetPaginatedDataIDs 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);
@@ -637,6 +640,16 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
ProjectsCaller client = GeoportalClientCaller.projects();
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
+ // Saving client PROJECTION
+ LinkedHashMap originalProjection = filter.getProjection();
+
+ // Setting PROJECTION ONLY FOR PROEJCT ID
+ LinkedHashMap projectionForIDs = new LinkedHashMap();
+ projectionForIDs.put(Project.ID, 1);
+ filter.setProjection(projectionForIDs);
+
+ ResultSetPaginatedDataIDs searchedDataIDs = new ResultSetPaginatedDataIDs();
+
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
theProfileID);
@@ -645,45 +658,66 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), theProfileID, totalProjectForProfile);
}
+ searchedDataIDs.setTotalItems(totalProjectForProfile);
LOG.info("Total Docs read from config: " + totalProjectForProfile);
- Iterator projects = client.queryOnMongo(theProfileID, totalProjectForProfile, start, limit,
+ // FIRST QUERY TO RETRIEVE IDs
+ // LIMIT IS NULL MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS
+ final Iterator projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, start, null,
filter);
- ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, false);
- searchedData.setTotalItems(totalProjectForProfile);
+ //Getting the Project IDs from the Iterable
+ Iterable itP = () -> projectsIDs;
+ Stream targetStream = StreamSupport.stream(itP.spliterator(), false);
+ List listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
+ searchedDataIDs.setResultSetProjectIDs(listProjectIDs);
+ //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
+ filter.setProjection(originalProjection);
+ // LIMIT IS FROM CLIENT
+ Iterator projects = client.queryOnMongo(theProfileID, totalItems, start, limit,
+ filter);
+
+ searchedDataIDs.setClientStartIndex(start);
+ searchedDataIDs.setLimit(limit);
+ searchedDataIDs.setServerSearchFinished(false);
List toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects);
-
- searchedData.setData(toReturnList);
+ searchedDataIDs.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 (filter.getConditions() != null) {
+// searchedDataIDs.setTotalItems(toReturnList.size());
+// int totalItems = searchedDataIDs.getResultSetProjectIDs().size();
+// searchedDataIDs.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());
+ searchedDataIDs
+ .setServerSearchFinished(newOffset > totalProjectForProfile || totalProjectForProfile == 0);
+ LOG.debug("is Search finished: " + searchedDataIDs.isServerSearchFinished());
}
if (LOG.isDebugEnabled()) {
- LOG.debug("returning {}", searchedData.getData());
+ LOG.debug("returning {}", searchedDataIDs.getData());
}
- List extends DocumentDV> data = searchedData.getData();
+ List extends DocumentDV> data = searchedDataIDs.getData();
if (data != null) {
LOG.info("returning {} project/s", data.size());
}
- return searchedData;
+ return searchedDataIDs;
} catch (Exception e) {
LOG.error("Error on loading paginated and filtered list of projects for id: ", e);
@@ -1094,7 +1128,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
throw new Exception(erroMsg);
}
- LOG.info("returning " + listDAO + " geona data objects");
+ LOG.info("returning " + listDAO.size() + " geona data objects");
+
+ if(LOG.isDebugEnabled())
+ LOG.info("returning " + listDAO + " geona data objects");
+
return listDAO;
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java
index 5c7f10c..b283dc9 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.function.Function;
import org.bson.Document;
import org.gcube.application.geoportal.client.utils.Serialization;
@@ -67,7 +68,7 @@ public class Geoportal_JSON_Mapper {
public static final String JSON_$_POINTER = "$";
public static final String _THEDOCUMENT = "_theDocument";
-
+
public static ProjectEdit loadProjectEdit(ProjectDV theProjectDV, String scope, String username) throws Exception {
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
@@ -112,14 +113,18 @@ public class Geoportal_JSON_Mapper {
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
- List listProfileBeansExt = new ArrayList();
+ //LinkedHashMap mapOfProfilesBeanExt = new LinkedHashMap();
+
+ ArrayList listOfProfilesBeanExt = new ArrayList();
// Reading the Project according to list of Profile defined in the UCD
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
-
+
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
- SectionView sectionView = new SectionView();
- sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
+// SectionView sectionView = new SectionView();
+// sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
+
+ System.out.println("\n\n##### Sto creando la sezione: "+gcubeProfileDV.getSectionTitle());
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
// Building JSON/section full PATH and section name
String sectionJSONPath = "";
@@ -174,17 +179,31 @@ public class Geoportal_JSON_Mapper {
List theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
- //Creating the corresponding MetaDataProfileBeanExt
- MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
- theProfileBeanExt.setCategories(theProfileBean.getCategories());
- theProfileBeanExt.setTitle(theProfileBean.getTitle());
- theProfileBeanExt.setType(theProfileBean.getType());
// For each bson.Document filling the MetaDataProfileBean and its file
for (int i = 0; i < listBSONDocument.size(); i++) {
+
+ System.out.println("DOCUMENT number "+i+ " of the section: "+theProfileBean.getTitle());
+ MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
+ theProfileBeanExt.setCategories(theProfileBean.getCategories());
+ theProfileBeanExt.setTitle(theProfileBean.getTitle());
+ theProfileBeanExt.setType(theProfileBean.getType());
+
+// System.out.println("\nPRINTING PROJECT VIEW ON START: ");
+// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
+// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
+// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
+// int z = 0;
+// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
+// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
+// }
+// }
+
+
Document fromSectionDoc = listBSONDocument.get(i);
-
-
+ LOG.debug("\n\nNew section DOC for index " + i + " is: " + new JSONObject(fromSectionDoc.toJson()).toString(2));
+ //Creating the corresponding MetaDataProfileBeanExt for each section
+
//Reading policy and license statically
//eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
Document docAccess = null;
@@ -202,12 +221,12 @@ public class Geoportal_JSON_Mapper {
e.printStackTrace();
}
-
-// SubDocumentView subDocumentView = new SubDocumentView();
-// Document toSectionDoc = new Document();
- // Filling the MetadataFieldWrapper metadata with the
- // metadataField.getFieldName() as currentValue
- for (MetadataFieldWrapper metadataField : theProfileBean.getMetadataFields()) {
+ //List copyOfMetadataFields = new ArrayList(theProfileBean.getMetadataFields());
+ //int forIndex = 0;
+
+ List cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
+
+ for (MetadataFieldWrapper metadataField : cloneListOfMFW) {
String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
: metadataField.getFieldName();
@@ -222,13 +241,17 @@ public class Geoportal_JSON_Mapper {
metadataField.setCurrentValue(access.getLicense());
}
}
-
+ //copyOfMetadataFields.set(forIndex++, metadataField);
}
- theProfileBeanExt.setMetadataFields(theProfileBean.getMetadataFields());
+ LOG.debug("Before assigning it Metadata fields are: "+cloneListOfMFW);
+
+ theProfileBeanExt.setMetadataFields(new ArrayList(cloneListOfMFW));
+ LOG.debug("Metadata fields are: "+theProfileBeanExt.getMetadataFields());
// Reading filePaths
List filePaths = gcubeProfileDV.getFilePaths();
+ List listLayers = new ArrayList();
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
if (filePaths != null) {
@@ -249,24 +272,73 @@ public class Geoportal_JSON_Mapper {
}
// Reading Fileset _materializations
- // listLayers = readGcubeSDILayersForFileset(filesetJSONPath,
- // fromSectionDocJSON);
+ //listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
+ //theProfileBeanExt.set
}
theProfileBeanExt.setListFileset(listFiles);
}
-
- listProfileBeansExt.add(theProfileBeanExt);
+
+ System.out.println("\nputting theProfileBeanExt: "+theProfileBeanExt);
+ listOfProfilesBeanExt.add(theProfileBeanExt);
+
+// System.out.println("\nPRINTING PROJECT VIEW ON END: ");
+// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
+// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
+// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
+// int z = 0;
+// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
+// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
+// }
+// }
+//
+// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
+ //Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
}
}
- projectView.setTheProfileBeans(listProfileBeansExt);
+ projectView.setTheProfileBeans(listOfProfilesBeanExt);
+ //Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
+
return projectView;
}
+ public static List cloneList(List list) {
+ List listCloned = new ArrayList(list.size());
+
+ Function cloneWrapper = (mfw) -> {
+
+ MetadataFieldWrapper newMfw = new MetadataFieldWrapper();
+ newMfw.setAsGroup(mfw.getAsGroup());
+ newMfw.setAsTag(mfw.getAsTag());
+ newMfw.setCurrentValue(mfw.getCurrentValue());
+ newMfw.setDefaultValue(mfw.getDefaultValue());
+ newMfw.setFieldId(mfw.getFieldId());
+ newMfw.setFieldName(mfw.getFieldName());
+ newMfw.setFieldNameFromCategory(mfw.getFieldNameFromCategory());
+ newMfw.setMandatory(mfw.getMandatory());
+ newMfw.setMaxOccurs(mfw.getMaxOccurs());
+ newMfw.setMultiSelection(mfw.isMultiSelection());
+ newMfw.setNote(mfw.getNote());
+ newMfw.setOwnerCategory(mfw.getOwnerCategory());
+ newMfw.setType(mfw.getType());
+ newMfw.setValidator(mfw.getValidator());
+ newMfw.setVocabulary(mfw.getVocabulary());
+
+ return newMfw;
+
+ };
+
+ for (MetadataFieldWrapper item : list) {
+ MetadataFieldWrapper cloned = cloneWrapper.apply(item);
+ listCloned.add(cloned);
+ }
+ return listCloned;
+ }
+
/**
* Load project view.
*
@@ -879,11 +951,12 @@ public class Geoportal_JSON_Mapper {
for (MetaDataProfileBeanExt mpb : projectEdit.getTheProfileBeans()) {
System.out.println("\n\n###### Title: " + mpb.getTitle() + " - Type: " + mpb.getType() + " ######");
int i = 1;
- for (MetadataFieldWrapper mfw : mpb.getMetadataFields()) {
+ for (MetadataFieldWrapper fieldWrapper : mpb.getMetadataFields()) {
System.out.println("## " + MetadataFieldWrapper.class.getSimpleName() + " n." + i);
System.out.println("***** Metadata");
- //System.out.println(mfw);
- System.out.println("\tfieldId: " + mfw.getFieldId() +", fieldName: "+mfw.getFieldName() +", CurrentValue: "+mfw.getCurrentValue());
+ // System.out.println(mfw);
+ System.out.println("\tfieldId: " + fieldWrapper.getFieldId() + ", fieldName: "
+ + fieldWrapper.getFieldName() + ", CurrentValue: " + fieldWrapper.getCurrentValue());
i++;
}
i = 1;
@@ -891,6 +964,7 @@ public class Geoportal_JSON_Mapper {
for (FilesetDV fileSet : mpb.getListFileset()) {
System.out.println("## " + FilesetDV.class.getSimpleName() + " n." + i);
System.out.println(fileSet);
+ i++;
}
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java
index faf168d..5018ea2 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java
@@ -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;
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/MetaDataProfileBeanExt.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/MetaDataProfileBeanExt.java
index a73cac9..abe93b4 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/MetaDataProfileBeanExt.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/MetaDataProfileBeanExt.java
@@ -4,42 +4,126 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
+import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
-public class MetaDataProfileBeanExt extends MetaDataProfileBean {
+/**
+ * The Class MetaDataProfileBeanExt.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Nov 23, 2022
+ */
+public class MetaDataProfileBeanExt extends MetaDataProfileBean implements Cloneable {
- private List listFileset = null;
/**
*
*/
- private static final long serialVersionUID = -7201955007623188104L;
+ private static final long serialVersionUID = 2518128223147908835L;
+ private List listFileset = null;
+ /**
+ * Instantiates a new meta data profile bean ext.
+ */
public MetaDataProfileBeanExt() {
super();
}
+ /**
+ * Instantiates a new meta data profile bean ext.
+ *
+ * @param type the type
+ * @param title the title
+ * @param metadataFields the metadata fields
+ * @param categories the categories
+ */
public MetaDataProfileBeanExt(String type, String title, List metadataFields,
List categories) {
super(type, title, metadataFields, categories);
}
+ /**
+ * Gets the list fileset.
+ *
+ * @return the list fileset
+ */
public List getListFileset() {
- if(listFileset==null)
+ if (listFileset == null)
listFileset = new ArrayList();
return listFileset;
}
-
+
+ /**
+ * Sets the list fileset.
+ *
+ * @param listFileset the new list fileset
+ */
public void setListFileset(List listFileset) {
this.listFileset = listFileset;
}
+ @Override
+ protected MetaDataProfileBeanExt clone() throws CloneNotSupportedException {
+
+ MetaDataProfileBeanExt clonedMDPBE = new MetaDataProfileBeanExt();
+ clonedMDPBE.setTitle(this.getTitle());
+ clonedMDPBE.setType(this.getType());
+ ArrayList newListFileset = new ArrayList();
+ for (FilesetDV filesetDV : this.getListFileset()) {
+ FilesetDV newFileset = new FilesetDV();
+ for (PayloadDV payloadDV : filesetDV.getListPayload()) {
+ PayloadDV newPayloadDV = new PayloadDV();
+ newPayloadDV.setLink(payloadDV.getLink());
+ newPayloadDV.setMimetype(payloadDV.getMimetype());
+ newPayloadDV.setName(payloadDV.getName());
+ newPayloadDV.setStorageID(payloadDV.getStorageID());
+ newFileset.addPayloadDV(newPayloadDV);
+ }
+
+ newListFileset.add(newFileset);
+ }
+ clonedMDPBE.setListFileset(newListFileset);
+
+ ArrayList newListMetadataFieldWrapper = new ArrayList();
+
+ for (MetadataFieldWrapper mfw : this.getMetadataFields()) {
+ MetadataFieldWrapper newMfw = new MetadataFieldWrapper();
+ newMfw.setAsGroup(mfw.getAsGroup());
+ newMfw.setAsTag(mfw.getAsTag());
+ newMfw.setCurrentValue(mfw.getCurrentValue());
+ newMfw.setDefaultValue(mfw.getDefaultValue());
+ newMfw.setFieldId(mfw.getFieldId());
+ newMfw.setFieldName(mfw.getFieldName());
+ newMfw.setFieldNameFromCategory(mfw.getFieldNameFromCategory());
+ newMfw.setMandatory(mfw.getMandatory());
+ newMfw.setMaxOccurs(mfw.getMaxOccurs());
+ newMfw.setMultiSelection(mfw.isMultiSelection());
+ newMfw.setNote(mfw.getNote());
+ newMfw.setOwnerCategory(mfw.getOwnerCategory());
+ newMfw.setType(mfw.getType());
+ newMfw.setValidator(mfw.getValidator());
+ newMfw.setVocabulary(mfw.getVocabulary());
+
+ newListMetadataFieldWrapper.add(newMfw);
+
+ }
+
+ clonedMDPBE.setMetadataFields(newListMetadataFieldWrapper);
+
+ return clonedMDPBE;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("MetaDataProfileBeanExt [listFileset=");
- builder.append(listFileset);
+ builder.append("MetaDataProfileBeanExt [getType()=");
+ builder.append(getType());
+ builder.append(", getTitle()=");
+ builder.append(getTitle());
+ builder.append(", getMetadataFields()=");
+ builder.append(getMetadataFields());
builder.append("]");
return builder.toString();
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ResultSetPaginatedDataIDs.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ResultSetPaginatedDataIDs.java
new file mode 100644
index 0000000..b4a5ff1
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ResultSetPaginatedDataIDs.java
@@ -0,0 +1,67 @@
+package org.gcube.portlets.user.geoportaldataviewer.shared;
+
+import java.util.List;
+
+import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
+
+
+/**
+ * The Class ResultSetPaginatedDataIDs.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Nov 25, 2022
+ */
+public class ResultSetPaginatedDataIDs extends ResultSetPaginatedData {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4847290903890912325L;
+
+ private List resultSetProjectIDs;
+
+ /**
+ * Instantiates a new result set paginated data I ds.
+ */
+ public ResultSetPaginatedDataIDs() {
+
+ }
+
+ public ResultSetPaginatedDataIDs(int offset, int limit, boolean isServerSearchFinished) {
+ super(offset,limit,isServerSearchFinished);
+ }
+
+ /**
+ * Gets the result set project I ds.
+ *
+ * @return the result set project I ds
+ */
+ public List getResultSetProjectIDs() {
+ return resultSetProjectIDs;
+ }
+
+ /**
+ * Sets the result set project I ds.
+ *
+ * @param resultSetProjectIDs the new result set project I ds
+ */
+ public void setResultSetProjectIDs(List resultSetProjectIDs) {
+ this.resultSetProjectIDs = resultSetProjectIDs;
+ }
+
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ResultSetPaginatedDataIDs [resultSetProjectIDs=");
+ builder.append(resultSetProjectIDs);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java
index 243060d..10c3f9c 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java
@@ -722,7 +722,7 @@ public class LayerItem implements Serializable, Cloneable {
public String getCqlFilter() {
return cqlFilter;
}
-
+
/**
* Sets the cql filter.
*
diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css
index 1addef1..078f00a 100644
--- a/src/main/webapp/GeoportalDataViewer.css
+++ b/src/main/webapp/GeoportalDataViewer.css
@@ -550,6 +550,12 @@ body {
text-align: justify;
}
+.search_result_msg {
+ font-size: 12px;
+ color: gray;
+ font-style: italic;
+}
+
/**
VIS TIMELINE CSS
@@ -690,6 +696,22 @@ Table Of Contents (TOC)
visibility: hidden;
}
+.general_error {
+ height: auto;
+ text-align: center;
+ font-size: 20px;
+ margin: 0;
+ position: absolute;
+ top: 50%;
+ width: 100%;
+ -ms-transform: translateY(-50%);
+ transform: translateY(-50%);
+}
+
+.general_error div {
+ padding: 20px;
+}
+
/******************************
RESPONSIVE
diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml
index 03d22a7..3eedcc7 100644
--- a/src/main/webapp/WEB-INF/liferay-display.xml
+++ b/src/main/webapp/WEB-INF/liferay-display.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties
index 24e0526..97777e3 100644
--- a/src/main/webapp/WEB-INF/liferay-plugin-package.properties
+++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties
@@ -1,4 +1,4 @@
-name=GeoPortalDataViewerAppPortlet
+name=GeoPortalDataViewerApp
module-group-id=liferay
module-incremental-version=2
tags=
diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml
index 551e405..35066a8 100644
--- a/src/main/webapp/WEB-INF/liferay-portlet.xml
+++ b/src/main/webapp/WEB-INF/liferay-portlet.xml
@@ -3,7 +3,7 @@
- GeoPortalDataViewerAppPortlet
+ GeoPortalDataViewerApp
false
false
false
diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml
index 70627d2..3418c44 100644
--- a/src/main/webapp/WEB-INF/portlet.xml
+++ b/src/main/webapp/WEB-INF/portlet.xml
@@ -1,9 +1,9 @@
- GeoPortalDataViewerApp Portlet
- GeoPortalDataViewerAppPortlet
- GeoPortal-DataViewer-Portlet
+ GeoPortalDataViewer Application
+ GeoPortalDataViewerApp
+ GeoPortal-DataViewer-App
org.gcube.portlets.user.geoportaldataviewer.portlet.GeoPortalDataViewerAppPortlet
0
@@ -12,8 +12,8 @@
VIEW
- GeoPortal-DataViewerApp-Portlet
- GeoPortal-DataViewerApp-Portlet
+ GeoPortal DataViewer Application
+ GeoPortal DataViewer App
diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java
index e08db2f..ee29a71 100644
--- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java
+++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java
@@ -2,7 +2,15 @@ package org.gcube.portlets.user.geoportaldataviewer;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.Project;
@@ -15,6 +23,10 @@ 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.util.GisUtil;
+import org.gcube.application.geoportalcommon.shared.SearchingFilter;
+import org.gcube.application.geoportalcommon.shared.WhereClause;
+import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
+import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.Crs;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
@@ -43,14 +55,14 @@ public class GeoportalViewer_Tests {
private ProjectsCaller clientProjects;
- // private static String CONTEXT = "/pred4s/preprod/preVRE";
- // private static String TOKEN = ""; //preVRE
+ private static String CONTEXT = "/pred4s/preprod/preVRE";
+ private static String TOKEN = "5c3c7551-870d-4259-bd77-a7e603fe4949-980114272"; //preVRE
- private static String CONTEXT = "/gcube/devsec/devVRE";
- private static String TOKEN = ""; // devVRE
+ //private static String CONTEXT = "/gcube/devsec/devVRE";
+ //private static String TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
- private static String PROJECT_ID = "6372470aa7b910781daaa8bc";
+ private static String PROJECT_ID = "637ceb4d21dd0d6fb9f24706";
private static String USERNAME = "francesco.mangiacrapa";
@@ -59,7 +71,7 @@ public class GeoportalViewer_Tests {
*
* @return the client
*/
- //@Before
+ @Before
public void getClient() {
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
ScopeProvider.instance.set(CONTEXT);
@@ -207,7 +219,7 @@ public class GeoportalViewer_Tests {
}
}
- // @Test
+ @Test
public void testReadProjectEdit() {
try {
@@ -217,13 +229,15 @@ public class GeoportalViewer_Tests {
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
projectBuilder.relationships(true);
ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
+ Geoportal_JSON_Mapper geojsonM = new Geoportal_JSON_Mapper();
ProjectEdit projectEdit = Geoportal_JSON_Mapper.loadProjectEdit(theProjectDV, CONTEXT, USERNAME);
Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectEdit);
// ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, CONTEXT, USERNAME);
// Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
-
+ System.out.println("testReadProjectEdit terminated");
} catch (Exception e) {
+ System.err.println("Error");
e.printStackTrace();
}
}
@@ -258,5 +272,83 @@ public class GeoportalViewer_Tests {
e.printStackTrace();
}
}
+
+
+ @Test
+ public void getResultsWithSize() throws Exception {
+ // List listOfProjects = client.getListForProfileID(PROFILE_ID);
+
+ long start = System.currentTimeMillis();
+ System.out.println("start at: "+start);
+ SearchingFilter filter = new SearchingFilter();
+
+ // Where Clause
+ List conditions = new ArrayList();
+ Map searchInto = new HashMap();
+ searchInto.put("_theDocument.dataInizioProgetto", "2021");
+ WhereClause whereClause = new WhereClause(LOGICAL_OP.OR, searchInto);
+
+ conditions.add(whereClause);
+ filter.setConditions(conditions);
+
+ //NEED TO GET projections
+
+ //SETTING PROJECTION ONLY FOR PROEJCT ID
+ LinkedHashMap projectionForIDs = new LinkedHashMap();
+ projectionForIDs.put(Project.ID, 1);
+ filter.setProjection(projectionForIDs);
+
+ //LIMIT IS NULL MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS
+ Integer totalDocs = clientProjects.getTotalDocument(PROFILE_ID);
+ Iterator projects = clientProjects.queryOnMongo(PROFILE_ID, totalDocs, 0, null, filter);
+
+ //CALCULATING SIZE OF THE ITERATOR OF PROJECT IDs
+ Iterable itP = () -> projects;
+ Stream targetStream = StreamSupport.stream(itP.spliterator(), false);
+ List listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
+
+ System.out.println("Total Ids are: "+listProjectIDs.size());
+ //listProjectIDs.stream().forEach(p -> System.out.println(p));
+
+ long end = System.currentTimeMillis();
+ System.out.println("IDS returned in ms: "+(end-start));
+
+ //RESETTIG FILTER AND PROJECT TO CLIENT QUERY
+ LinkedHashMap projection = new LinkedHashMap();
+ // default
+ //PROJECTION
+ projection.put(Project.ID, 1);
+ projection.put("_theDocument.nome", 1);
+ projection.put("_profileID", 1);
+ projection.put("_profileVersion", 1);
+ projection.put("_version", 1);
+ projection.put("_theDocument", 1);
+
+ projection.put("_theDocument.paroleChiaveLibere", 1);
+ projection.put("_theDocument.editore", 1);
+ projection.put("_theDocument.paroleChiaveICCD", 1);
+ projection.put("_theDocument.responsabile", 1);
+
+ projection.put("_theDocument.introduzione", 1);
+ projection.put("_theDocument.authors", 1);
+ projection.put("_theDocument.dataInizioProgetto", 1);
+ filter.setProjection(projection);
+
+
+ //Integer totalDocs = client.getTotalDocument(PROFILE_ID);
+ Iterator itProjects = clientProjects.queryOnMongo(PROFILE_ID, totalDocs, 0, 50, filter);
+
+ List results = ConvertToDataValueObjectModel.toListResultDocument(itProjects);
+ int i = 0;
+ for (ResultDocumentDV projectDV : results) {
+ System.out.println(++i + ") " + projectDV.getId() + " dataInizioProgetto: "+projectDV.getDocumentAsMap().get("dataInizioProgetto"));
+ }
+
+ System.out.println("Result listed has size: "+results.size());
+
+ end = System.currentTimeMillis();
+ System.out.println("Result listed in ms: "+(end-start));
+
+ }
}