From 0764d0770c77a51507cd46152abb08d25d69b17b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Nov 2022 09:49:46 +0100 Subject: [PATCH 1/7] Integrated temporal query for YEAR --- .settings/org.eclipse.wst.common.component | 63 +++++++-- .../client/GeoportalDataViewer.java | 33 +++-- .../client/GeoportalDataViewerService.java | 4 +- .../GeoportalDataViewerServiceAsync.java | 4 +- .../client/events/SearchPerformedEvent.java | 20 ++- .../client/resources/GNAImages.java | 3 + .../client/resources/geoporta_error.png | Bin 0 -> 6555 bytes .../ui/cms/search/SearchFacilityUI.java | 37 ++++- .../ui/cms/search/SearchFacilityUI.ui.xml | 6 +- .../GeoportalDataViewerServiceImpl.java | 69 +++++++--- .../server/Geoportal_JSON_Mapper.java | 130 ++++++++++++++---- .../shared/MetaDataProfileBeanExt.java | 98 ++++++++++++- .../shared/ResultSetPaginatedDataIDs.java | 67 +++++++++ src/main/webapp/GeoportalDataViewer.css | 22 +++ .../GeoportalViewer_Tests.java | 108 +++++++++++++-- 15 files changed, 561 insertions(+), 103 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/geoporta_error.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ResultSetPaginatedDataIDs.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 3bca87b..639f519 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,9 @@ - + + + + + @@ -34,7 +38,11 @@ - + + + + + @@ -69,7 +77,11 @@ - + + + + + @@ -104,7 +116,11 @@ - + + + + + @@ -139,7 +155,11 @@ - + + + + + @@ -174,7 +194,11 @@ - + + + + + @@ -209,7 +233,14 @@ - + + uses + + + + + + @@ -244,7 +275,11 @@ - + + + + + @@ -279,7 +314,11 @@ - + + + + + @@ -314,7 +353,11 @@ - + + + + + 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..fe5948a 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; @@ -71,12 +70,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 +163,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 +194,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 @@ -615,7 +618,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,14 +636,14 @@ 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 result = searchPerformedEvent.getData(); + List result = searchPerformedEvent.getListProjectIDs(); 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) + ")"; @@ -722,4 +725,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/events/SearchPerformedEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java index 15b1eff..3010480 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,17 @@ import com.google.gwt.event.shared.GwtEvent; */ public class SearchPerformedEvent extends GwtEvent { public static Type TYPE = new Type(); - private List data; + private List listProjectIDs; private boolean searchReset; /** * Instantiates a new search performed event. * - * @param data the data - * @param searchReset the search reset + * @param listProjectIds the list project ids + * @param searchReset the search reset */ - public SearchPerformedEvent(List data, boolean searchReset) { - this.data = data; + public SearchPerformedEvent(List listProjectIds, boolean searchReset) { + this.listProjectIDs = listProjectIds; this.searchReset = searchReset; } @@ -51,12 +49,12 @@ public class SearchPerformedEvent extends GwtEvent } /** - * Gets the data. + * Gets the list project Ids. * - * @return the data + * @return the list project Ids */ - public List getData() { - return data; + 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 0000000000000000000000000000000000000000..1ee4353245a8714274cf793e3b8bced71b0c7874 GIT binary patch literal 6555 zcmV;M8D!>(P)eY@`M+ue2hcH{hTzwYVnR@M3I z)TvXaPNk6r-WfXLX!dY1yT-F?7`qCo3#otxc5PzUT6V1*yZO`4%s!Z=dXWhp!oHhb z6Wy*!7qnnCyJj*XY%;zPMgS)K>)FFnc6r?{br-avgp|Ir29mFTfAaS2L*BA7$|^0P%;F--EGVFi++0e_ z%nbR?!S;6QXlkPNefy}relNAv)KW`T6}9aAj{MuU(Sfa%)LOmU?W*a*bfF120Rm(G zI!ZycpYHQg-Z3L7fAq1G$86TzVMkGBp)dqV>?ZTg({Gn=Y$-N&^5lMU4AZ*jW` zVgU+08a9C-z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#t_V2|(Y;77Fx;R9j=sGa*`RS#$S?RoL9 z5kIRF2`2!6rR0HkE-;NJFanJY-vP*gUS%8-A`u~4?O+V_uoApc-DB7id;jd-59|3@ z)bVfIo@i0HLjVpY!15`VQ15H5G7T?N0R#XMKnMs!Wgl1(K^6+0oAq+}d5GW-1_a;n zz3}ln5I6*HHJ>*Ez5csDK1x+9o{lM)LkHX=Kmdp_>{oFU6`yu$)ZZ0*<3)lbQ~MyD zU1UB)2p9!!*7L=^#2y4yT9!ya0O$54%c73q(+$@NAW(SniPU$-bkltYks$AxgOf#! z!zztH{D1hiaPcS`cH(srbu7ZYV@;HexcwdXF6Vjsk^vw<1A8op`%)|k~7bso|jKi?n+K2G<~s|s-9Rub+5na+Bk244?%#1?8%(Cf65``A9pPExZqb* zJbtV)Q%N!cnK`g+Z1;1|N8F$9G8TaV$O7f8zfl8_t_IuGOD3L0xva>^=n8K7^fRhm z^BUilZIzZKi7C4)j$Q7wWE?3!k;bv2(zRDnqVoV;Be3dOF->ch@LN?G^GPJ!7@rA!>|jM zKnnJm81s#9Sk9#aQ^bqeHJ)7{g)`Pw7jy&OT?l(EyH+y6e`fZ<{|861ziT_3Ff#xE N002ovPDHLkV1lSUSEc{} literal 0 HcmV?d00001 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..fe073dd 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(); } @@ -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(result.getResultSetProjectIDs(), false)); setSearchEnabled(true); latestResult = result; @@ -295,6 +299,23 @@ 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. Projects (with a centroid) matching your search are shown on the Map"; + } else { + message = "Found " + returnedItems; + message += returnedItems > 0 ? " items" : " item"; + } + + 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 +348,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/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index ea86346..4590bd0 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,65 @@ 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); + + //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 data = searchedData.getData(); + List 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); 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/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/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/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)); + + } } From 189dc36f751f3ba3ff09da41900e53e15639520b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Nov 2022 15:20:21 +0100 Subject: [PATCH 2/7] #24195 Integrated the temporal query. Fixing CQL on WFS during searching enabled --- CHANGELOG.md | 1 + .../client/GeoportalDataViewer.java | 33 ++++++- .../client/LayerManager.java | 10 +++ .../client/events/SearchPerformedEvent.java | 14 ++- .../ui/cms/search/SearchFacilityUI.java | 13 ++- .../client/util/URLUtil.java | 88 ++++++++++--------- .../GeoportalDataViewerServiceImpl.java | 1 + .../server/gis/GisMakers.java | 6 +- .../shared/gis/LayerItem.java | 2 +- 9 files changed, 116 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cae1dd..c552093 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 fe5948a..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 @@ -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 wmsMap = olMapMng.getOLMap().getWmsLayerMap(); String firstWMSKey = wmsMap.keySet().iterator().next(); 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 (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); } 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 3010480..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 @@ -15,14 +15,17 @@ public class SearchPerformedEvent extends GwtEvent public static Type TYPE = new Type(); private List 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 listProjectIds, boolean searchReset) { + public SearchPerformedEvent(String profileID, List listProjectIds, boolean searchReset) { + this.profileID = profileID; this.listProjectIDs = listProjectIds; this.searchReset = searchReset; } @@ -48,6 +51,15 @@ public class SearchPerformedEvent extends GwtEvent } + /** + * Gets the profile ID. It is equal to collectionID + * + * @return the profile ID + */ + public String getProfileID() { + return profileID; + } + /** * Gets the list project Ids. * 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 fe073dd..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 @@ -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); 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 4590bd0..aa628ba 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 @@ -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 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/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. * From 0b16d37c1bc4fb56eff989c0498d19a0e7b0b686 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Nov 2022 15:32:14 +0100 Subject: [PATCH 3/7] Refactored the GeoPortalDataViewerAppPortlet to GeoPortalDataViewerApp --- src/main/webapp/WEB-INF/liferay-display.xml | 2 +- .../webapp/WEB-INF/liferay-plugin-package.properties | 2 +- src/main/webapp/WEB-INF/liferay-portlet.xml | 2 +- src/main/webapp/WEB-INF/portlet.xml | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) 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..9485492 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-App + GeoPortal-DataViewer-App From a55d771e6d62c0b372ebc3b4d304dbe89e6e15a8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Nov 2022 15:35:03 +0100 Subject: [PATCH 4/7] Refactored title and short-title --- src/main/webapp/WEB-INF/portlet.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml index 9485492..3418c44 100644 --- a/src/main/webapp/WEB-INF/portlet.xml +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -12,8 +12,8 @@ VIEW - GeoPortal-DataViewer-App - GeoPortal-DataViewer-App + GeoPortal DataViewer Application + GeoPortal DataViewer App From 5ebab16836360056303e1bdd5467bccae7d0f3c0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Nov 2022 15:44:58 +0100 Subject: [PATCH 5/7] Moved one log to DEBUG --- .../server/GeoportalDataViewerServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 aa628ba..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 @@ -1128,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; } From 9f8421b6dfc979cedf432aab69d6a158cc8f9073 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Nov 2022 17:40:23 +0100 Subject: [PATCH 6/7] Updated --- .settings/org.eclipse.wst.common.component | 3 --- 1 file changed, 3 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 639f519..8c9fb8b 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -233,9 +233,6 @@ - - uses - From 62c02216af29490868023adcb972a86279d00419 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Nov 2022 17:44:54 +0100 Subject: [PATCH 7/7] copied from master --- .settings/org.eclipse.wst.common.component | 50 +++++----------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 8c9fb8b..25ec451 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,8 +1,5 @@ - - - - + @@ -38,10 +35,7 @@ - - - - + @@ -77,10 +71,7 @@ - - - - + @@ -116,10 +107,7 @@ - - - - + @@ -155,10 +143,7 @@ - - - - + @@ -194,10 +179,7 @@ - - - - + @@ -233,10 +215,7 @@ - - - - + @@ -272,10 +251,7 @@ - - - - + @@ -311,10 +287,7 @@ - - - - + @@ -350,10 +323,7 @@ - - - - +