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 static final String DIV_TIMELINE_DATA = "timeline-data";
public static final String APP_NOTIFIER = "app-notifier";
/** The Constant APP_DIV. */
@ -229,7 +229,8 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("Loading collections, count " + result.getAvailableCollections().size());
mainPanel.setAvailableCollections(result.getAvailableCollections().values(), paramGeonaItemType);
mainPanel.setAvailableCollections(result.getAvailableCollections().values(),
paramGeonaItemType);
if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) {
@ -243,9 +244,9 @@ public class GeoportalDataViewer implements EntryPoint {
paramGeonaItemType);
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, true));
}
mainPanel.openCollectionMenu();
GWT.log("DONE INIT LOAD");
}
@ -357,7 +358,8 @@ public class GeoportalDataViewer implements EntryPoint {
if (addLayerToMapEvent.getTheProjectDV() != null) {
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
public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) {
if (showPopupOnCentroiEvent.getDocument() != null)
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getDocument().getProjectID(),
showPopupOnCentroiEvent.getCentroidLong(), showPopupOnCentroiEvent.getCentroidLat());
if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) {
GWT.log("ShowPopupOnCentroiEvent: "+showPopupOnCentroiEvent);
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) {
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.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;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
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;
/**
* 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.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;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
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 getSpatialReference(String profileID, String projectID, AsyncCallback<GeoJSON> callback);
}

View File

@ -1,6 +1,6 @@
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;
@ -13,9 +13,9 @@ import com.google.gwt.event.shared.GwtEvent;
*/
public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHandler> {
public static Type<ShowPopupOnCentroiEventHandler> TYPE = new Type<ShowPopupOnCentroiEventHandler>();
private DocumentDV document;
private Double centroidLong;
private Double centroidLat;
private String profileID;
private String projectID;
private GeoJSON spatialReference;
/**
* Instantiates a new show details event.
@ -25,10 +25,10 @@ public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHan
* @param itemName the item name
* @param featureRow the feature row
*/
public ShowPopupOnCentroiEvent(DocumentDV document, Double centroidLong, Double centroidLat) {
this.document = document;
this.centroidLong = centroidLong;
this.centroidLat = centroidLat;
public ShowPopupOnCentroiEvent(String profileID, String projectID, GeoJSON spatialReference) {
this.profileID = profileID;
this.projectID = projectID;
this.spatialReference = spatialReference;
}
@ -53,16 +53,29 @@ public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHan
}
public DocumentDV getDocument() {
return document;
public String getProfileID() {
return profileID;
}
public Double getCentroidLat() {
return centroidLat;
public String getProjectID() {
return projectID;
}
public Double getCentroidLong() {
return centroidLong;
public GeoJSON getSpatialReference() {
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 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.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
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.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
@ -39,7 +41,7 @@ public class TimelineRelationPanel extends Composite {
@UiField
HTMLPanel timelineHeader;
@UiField
Anchor timelinePopupCloser;
@ -48,7 +50,7 @@ public class TimelineRelationPanel extends Composite {
private TimelineRelationPanel instance = this;
private String selectedProjectID;
private String selectedTimelineProjectID;
private ProjectDV theProjectDV;
@ -75,18 +77,17 @@ public class TimelineRelationPanel extends Composite {
timelineContainer.getElement().setId("visualization");
timelineContainer.add(loaderData);
timelinePopupCloser.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(timelineContainer.isVisible())
if (timelineContainer.isVisible())
setTimelineContainerVisible(false);
else
setTimelineContainerVisible(true);
}
});
@ -124,30 +125,52 @@ public class TimelineRelationPanel extends Composite {
});
}
public void setTimelineContainerVisible(boolean bool) {
timelineContainer.setVisible(bool);
}
private void setSelectedProject(String projectID) {
this.selectedProjectID = projectID;
GWT.log("selectedProjectID: " + selectedProjectID);
if(selectedProjectID == null || selectedProjectID.isEmpty())
private void setSelectedProject(String theComposedProjectID) {
this.selectedTimelineProjectID = theComposedProjectID;
//selectedTimelineProjectID is the couple ProfileID,ProjectID
GWT.log("selectedTimelineProjectID: " + selectedTimelineProjectID);
if (selectedTimelineProjectID == null || selectedTimelineProjectID.isEmpty())
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);
GWT.log("fireEvetn: " + 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() {
return selectedProjectID;
return selectedTimelineProjectID;
}
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.ResultDocumentDV;
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.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.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
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.Widget;
import ol.Coordinate;
/**
* The Class SearchFacilityUI.
*
@ -332,21 +328,8 @@ public class SearchFacilityUI extends Composite {
GeoportalItemReferences gir = new GeoportalItemReferences(resultDoc.getProjectID(),
profileID);
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
.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) {
GeoJSON geoJson = spatialReference(layerObject.getProfileID(), layerObject.getProjectID());
GeoJSON geoJson = getSpatialReference(layerObject.getProfileID(),
layerObject.getProjectID());
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 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");
try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());