Synchronized the Timeline selected project with the showing popoup on

centroid
This commit is contained in:
Francesco Mangiacrapa 2022-11-21 15:16:36 +01:00
parent 2e2ecfa41d
commit c4ebdcf003
7 changed files with 105 additions and 64 deletions

View File

@ -88,7 +88,7 @@ import ol.layer.Image;
public class GeoportalDataViewer implements EntryPoint { public class GeoportalDataViewer implements EntryPoint {
public static final String DIV_TIMELINE_DATA = "timeline-data"; public static final String DIV_TIMELINE_DATA = "timeline-data";
public static final String APP_NOTIFIER = "app-notifier"; public static final String APP_NOTIFIER = "app-notifier";
/** The Constant APP_DIV. */ /** The Constant APP_DIV. */
@ -229,7 +229,8 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("Loading collections, count " + result.getAvailableCollections().size()); GWT.log("Loading collections, count " + result.getAvailableCollections().size());
mainPanel.setAvailableCollections(result.getAvailableCollections().values(), paramGeonaItemType); mainPanel.setAvailableCollections(result.getAvailableCollections().values(),
paramGeonaItemType);
if (paramGeonaItemID != null) { if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) { if (paramGeonaItemType == null) {
@ -243,9 +244,9 @@ public class GeoportalDataViewer implements EntryPoint {
paramGeonaItemType); paramGeonaItemType);
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, true)); applicationBus.fireEvent(new ShowDetailsEvent(gir, null, true));
} }
mainPanel.openCollectionMenu(); mainPanel.openCollectionMenu();
GWT.log("DONE INIT LOAD"); GWT.log("DONE INIT LOAD");
} }
@ -357,7 +358,8 @@ public class GeoportalDataViewer implements EntryPoint {
if (addLayerToMapEvent.getTheProjectDV() != null) { if (addLayerToMapEvent.getTheProjectDV() != null) {
layerManager.addLayerToMapForProject(addLayerToMapEvent.getTheProjectDV().getProfileID(), layerManager.addLayerToMapForProject(addLayerToMapEvent.getTheProjectDV().getProfileID(),
addLayerToMapEvent.getTheProjectDV().getId(), addLayerToMapEvent.getTheProjectDV(), addLayerToMapEvent.isNotifyClashing()); addLayerToMapEvent.getTheProjectDV().getId(), addLayerToMapEvent.getTheProjectDV(),
addLayerToMapEvent.isNotifyClashing());
} }
} }
@ -612,9 +614,14 @@ public class GeoportalDataViewer implements EntryPoint {
@Override @Override
public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) { public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) {
if (showPopupOnCentroiEvent.getDocument() != null) if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) {
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getDocument().getProjectID(), GWT.log("ShowPopupOnCentroiEvent: "+showPopupOnCentroiEvent);
showPopupOnCentroiEvent.getCentroidLong(), showPopupOnCentroiEvent.getCentroidLat()); Coordinate transfCoord = MapUtils
.geoJSONTToBBoxCenter(showPopupOnCentroiEvent.getSpatialReference(), null, null);
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getProjectID(), transfCoord.getX(),
transfCoord.getY());
}
} }
}); });
@ -693,7 +700,7 @@ public class GeoportalDataViewer implements EntryPoint {
} }
} }
public static void showPopover(final Widget w, String message, String heading) { public static void showPopover(final Widget w, String message, String heading) {
final Popover popover = new Popover(); final Popover popover = new Popover();

View File

@ -7,6 +7,7 @@ import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter; 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; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
@ -169,4 +170,13 @@ public interface GeoportalDataViewerService extends RemoteService {
*/ */
List<String> getRelationshipsForTimeline(String profileID, String projectID) throws Exception; List<String> getRelationshipsForTimeline(String profileID, String projectID) throws Exception;
/**
* Gets the spatial reference.
*
* @param profileID the profile ID
* @param projectID the project ID
* @return the spatial reference
*/
GeoJSON getSpatialReference(String profileID, String projectID);
} }

View File

@ -7,6 +7,7 @@ import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter; 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; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
@ -72,4 +73,6 @@ public interface GeoportalDataViewerServiceAsync {
void getRelationshipsForTimeline(String profileID, String projectID, AsyncCallback<List<String>> callback); void getRelationshipsForTimeline(String profileID, String projectID, AsyncCallback<List<String>> callback);
void getSpatialReference(String profileID, String projectID, AsyncCallback<GeoJSON> callback);
} }

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events; package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
@ -13,9 +13,9 @@ import com.google.gwt.event.shared.GwtEvent;
*/ */
public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHandler> { public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHandler> {
public static Type<ShowPopupOnCentroiEventHandler> TYPE = new Type<ShowPopupOnCentroiEventHandler>(); public static Type<ShowPopupOnCentroiEventHandler> TYPE = new Type<ShowPopupOnCentroiEventHandler>();
private DocumentDV document; private String profileID;
private Double centroidLong; private String projectID;
private Double centroidLat; private GeoJSON spatialReference;
/** /**
* Instantiates a new show details event. * Instantiates a new show details event.
@ -25,10 +25,10 @@ public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHan
* @param itemName the item name * @param itemName the item name
* @param featureRow the feature row * @param featureRow the feature row
*/ */
public ShowPopupOnCentroiEvent(DocumentDV document, Double centroidLong, Double centroidLat) { public ShowPopupOnCentroiEvent(String profileID, String projectID, GeoJSON spatialReference) {
this.document = document; this.profileID = profileID;
this.centroidLong = centroidLong; this.projectID = projectID;
this.centroidLat = centroidLat; this.spatialReference = spatialReference;
} }
@ -53,16 +53,29 @@ public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHan
} }
public DocumentDV getDocument() { public String getProfileID() {
return document; return profileID;
} }
public Double getCentroidLat() { public String getProjectID() {
return centroidLat; return projectID;
} }
public Double getCentroidLong() { public GeoJSON getSpatialReference() {
return centroidLong; return spatialReference;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ShowPopupOnCentroiEvent [profileID=");
builder.append(profileID);
builder.append(", projectID=");
builder.append(projectID);
builder.append(", spatialReference=");
builder.append(spatialReference);
builder.append("]");
return builder.toString();
} }
} }

View File

@ -3,9 +3,11 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relati
import java.util.List; import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; 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.resources.GNAImages; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
@ -39,7 +41,7 @@ public class TimelineRelationPanel extends Composite {
@UiField @UiField
HTMLPanel timelineHeader; HTMLPanel timelineHeader;
@UiField @UiField
Anchor timelinePopupCloser; Anchor timelinePopupCloser;
@ -48,7 +50,7 @@ public class TimelineRelationPanel extends Composite {
private TimelineRelationPanel instance = this; private TimelineRelationPanel instance = this;
private String selectedProjectID; private String selectedTimelineProjectID;
private ProjectDV theProjectDV; private ProjectDV theProjectDV;
@ -75,18 +77,17 @@ public class TimelineRelationPanel extends Composite {
timelineContainer.getElement().setId("visualization"); timelineContainer.getElement().setId("visualization");
timelineContainer.add(loaderData); timelineContainer.add(loaderData);
timelinePopupCloser.addClickHandler(new ClickHandler() { timelinePopupCloser.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
if(timelineContainer.isVisible()) if (timelineContainer.isVisible())
setTimelineContainerVisible(false); setTimelineContainerVisible(false);
else else
setTimelineContainerVisible(true); setTimelineContainerVisible(true);
} }
}); });
@ -124,30 +125,52 @@ public class TimelineRelationPanel extends Composite {
}); });
} }
public void setTimelineContainerVisible(boolean bool) { public void setTimelineContainerVisible(boolean bool) {
timelineContainer.setVisible(bool); timelineContainer.setVisible(bool);
} }
private void setSelectedProject(String projectID) { private void setSelectedProject(String theComposedProjectID) {
this.selectedProjectID = projectID; this.selectedTimelineProjectID = theComposedProjectID;
GWT.log("selectedProjectID: " + selectedProjectID); //selectedTimelineProjectID is the couple ProfileID,ProjectID
GWT.log("selectedTimelineProjectID: " + selectedTimelineProjectID);
if(selectedProjectID == null || selectedProjectID.isEmpty())
if (selectedTimelineProjectID == null || selectedTimelineProjectID.isEmpty())
return; return;
String[] references = this.selectedProjectID.split(","); String[] references = this.selectedTimelineProjectID.split(",");
GeoportalItemReferences gir = new GeoportalItemReferences(references[1], references[0]); final String thePofileID = references[0];
final String theProjectID = references[1];
GeoportalItemReferences gir = new GeoportalItemReferences(theProjectID, thePofileID);
ShowDetailsEvent showDetailsEvent = new ShowDetailsEvent(gir, null, false); ShowDetailsEvent showDetailsEvent = new ShowDetailsEvent(gir, null, false);
GWT.log("fireEvetn: " + showDetailsEvent); GWT.log("fireEvetn: " + showDetailsEvent);
applicationBus.fireEvent(showDetailsEvent); applicationBus.fireEvent(showDetailsEvent);
GeoportalDataViewerServiceAsync.Util.getInstance().getSpatialReference(thePofileID, theProjectID,
new AsyncCallback<GeoJSON>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(GeoJSON spatialReference) {
if (spatialReference != null) {
applicationBus.fireEvent(
new ShowPopupOnCentroiEvent(thePofileID, theProjectID, spatialReference));
}
}
});
} }
public String getSelectedProjectID() { public String getSelectedProjectID() {
return selectedProjectID; return selectedTimelineProjectID;
} }
public static native String instanceTimeline(String idDivContainer, JSONArray jsonItems, public static native String instanceTimeline(String idDivContainer, JSONArray jsonItems,

View File

@ -15,12 +15,10 @@ import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent; 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.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
@ -52,8 +50,6 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
/** /**
* The Class SearchFacilityUI. * The Class SearchFacilityUI.
* *
@ -332,21 +328,8 @@ public class SearchFacilityUI extends Composite {
GeoportalItemReferences gir = new GeoportalItemReferences(resultDoc.getProjectID(), GeoportalItemReferences gir = new GeoportalItemReferences(resultDoc.getProjectID(),
profileID); profileID);
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, true)); appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, true));
GeoJSON spatialReference = resultDoc.getSpatialReference();
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, null,
null);
Double centerLong = null;
Double centerLat = null;
if (transfCoord != null) {
centerLong = transfCoord.getX();
centerLat = transfCoord.getY();
}
appManagerBus appManagerBus
.fireEvent(new ShowPopupOnCentroiEvent(resultDoc, centerLong, centerLat)); .fireEvent(new ShowPopupOnCentroiEvent(profileID, resultDoc.getProjectID(), resultDoc.getSpatialReference()));
} }
}); });

View File

@ -1035,7 +1035,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
} }
if (layerObject.getProjectDV().getSpatialReference() == null) { if (layerObject.getProjectDV().getSpatialReference() == null) {
GeoJSON geoJson = spatialReference(layerObject.getProfileID(), layerObject.getProjectID()); GeoJSON geoJson = getSpatialReference(layerObject.getProfileID(),
layerObject.getProjectID());
layerObject.getProjectDV().setSpatialReference(geoJson); layerObject.getProjectDV().setSpatialReference(geoJson);
} }
@ -1149,13 +1150,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
} }
/** /**
* Spatial reference. * Gets the spatial reference.
* *
* @param profileID the profile ID * @param profileID the profile ID
* @param projectID the project ID * @param projectID the project ID
* @return the geo JSON * @return the spatial reference
*/ */
private GeoJSON spatialReference(String profileID, String projectID) { @Override
public GeoJSON getSpatialReference(String profileID, String projectID) {
LOG.trace("spatialReference for profileID: " + profileID + ", projectID: " + projectID + "called"); LOG.trace("spatialReference for profileID: " + profileID + ", projectID: " + projectID + "called");
try { try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());