in progress on #24028

This commit is contained in:
Francesco Mangiacrapa 2022-11-03 17:03:15 +01:00
parent ed4f9bd204
commit a3b5045ef7
21 changed files with 417 additions and 52 deletions

View File

@ -13,6 +13,8 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat
* GWT-Bootstrap v.2.3.2.0. [GWT-Bootstrap](https://github.com/gwtbootstrap) is licensed under [[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* GWT-OpenLayers 3+ v.8.1.0-gwt2_9. [GWT-OL3](https://github.com/TDesjardins/gwt-ol)
* OpenLayers v.6.X. [OpenLayers](https://openlayers.org/) is licensed under [BSD 2-Clause "Simplified"](https://github.com/openlayers/openlayers/blob/main/LICENSE.md)
* Vis-Timeline v7.x [VisTimeline](https://github.com/visjs/vis-timeline) is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) and MIT
* Handlebarsjs v4.X [Handlebarsjs](https://handlebarsjs.com/) is licensed under MIT
## Documentation

View File

@ -9,6 +9,8 @@ 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.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
@ -32,6 +34,9 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEven
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent.EVENT_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent;
@ -41,6 +46,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.Ope
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation.TimelineRelationPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.util.ControlledCallBack;
@ -77,6 +83,8 @@ import ol.layer.Image;
*/
public class GeoportalDataViewer implements EntryPoint {
public static final String DIV_TIMELINE_DATA = "timeline-data";
/** The Constant APP_DIV. */
public final static String APP_DIV = "geoportal-data-viewer";
@ -110,7 +118,8 @@ public class GeoportalDataViewer implements EntryPoint {
int attempt = 0;
private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait");
private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait",
new com.google.gwt.user.client.ui.Image(GNAImages.ICONS.spinnerEarth()));
private HTML attributionDiv = new HTML();
@ -135,7 +144,9 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID);
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
RootPanel.get(APP_DIV).add(loaderApp);
// RootPanel.get(APP_DIV).add(loaderApp);
hideTimelineProjectRelations();
GeoportalDataViewerServiceAsync.Util.getInstance()
.getConfigListOfFieldsForSearching(new AsyncCallback<List<ItemFieldsResponse>>() {
@ -203,7 +214,7 @@ public class GeoportalDataViewer implements EntryPoint {
ScriptInjector.fromUrl(
"//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).inject();
GWT.log("Loading collections, count " + result.getAvailableCollections().size());
mainPanel.setAvailableCollections(result.getAvailableCollections().values());
@ -218,13 +229,13 @@ public class GeoportalDataViewer implements EntryPoint {
}
GeoportalItemReferences gir = new GeoportalItemReferences(paramGeonaItemID,
paramGeonaItemType);
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null));
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null, true));
}
// TODO LOAD INITIAL LAYERS
GWT.log("DONE INIT LOAD");
}
});
@ -241,20 +252,20 @@ public class GeoportalDataViewer implements EntryPoint {
bindEvents();
RootPanel.get(APP_DIV).add(attributionDiv);
new Timer() {
@Override
public void run() {
GWT.log("Instancing timeline");
TimelineRelationPanel timeline = new TimelineRelationPanel("concessione", "projectid");
RootPanel.get("timeline-data").add(timeline);
}
}.schedule(5000);
ProjectDV project = new ProjectDV();
project.setId("fake");
project.setProfileID("fake");
applicationBus.fireEvent(new TimelineProjectRelationsEvent(project, EVENT_TYPE.SHOW));
}
}.schedule(1000);
// Modal modal = new Modal(true, true);
// modal.setWidth(400);
//
@ -323,7 +334,7 @@ public class GeoportalDataViewer implements EntryPoint {
// Open Index Layer
layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID());
}
}
});
@ -350,7 +361,7 @@ public class GeoportalDataViewer implements EntryPoint {
applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
@Override
public void onShowDetails(ShowDetailsEvent showDetailsEvent) {
public void onShowDetails(final ShowDetailsEvent showDetailsEvent) {
GWT.log("Fired event: " + showDetailsEvent);
String projectID = showDetailsEvent.getProjectID();
@ -378,6 +389,17 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onSuccess(ProjectView result) {
mainPanel.showAsDetails(result, showDetailsEvent.getGeonaItemRef());
List<RelationshipDV> relationships = result.getTheProjectDV().getRelationships();
if (showDetailsEvent.isLoadTimelineRelationships()
&& relationships!= null && relationships.size() > 0) {
GWT.log("LoadTimelineRelationships is true and the project has Relationships");
showTimelineProjectRelations(result.getTheProjectDV());
} else {
hideTimelineProjectRelations();
}
}
});
@ -489,6 +511,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onClosed(ClosedViewDetailsEvent closedViewDetailsEvent) {
olMapMng.hidePopInfo();
applicationBus.fireEvent(new TimelineProjectRelationsEvent(null, EVENT_TYPE.HIDE));
}
});
@ -501,6 +524,26 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
applicationBus.addHandler(TimelineProjectRelationsEvent.TYPE, new TimelineProjectRelationsEventHandler() {
@Override
public void onTimelineRelationEvent(TimelineProjectRelationsEvent timelineProjectRelationsEvent) {
switch (timelineProjectRelationsEvent.getEventType()) {
case SHOW: {
showTimelineProjectRelations(timelineProjectRelationsEvent.getTheProjectDV());
break;
}
case HIDE:
default: {
hideTimelineProjectRelations();
break;
}
}
}
});
applicationBus.addHandler(DoActionOnDetailLayersEvent.TYPE, new DoActionOnDetailLayersEventHandler() {
@Override
@ -625,6 +668,20 @@ public class GeoportalDataViewer implements EntryPoint {
//
// }-*/;
private void showTimelineProjectRelations(ProjectDV theProject) {
GWT.log("Showing project relations for: " + theProject);
RootPanel.get(DIV_TIMELINE_DATA).clear();
RootPanel.get(DIV_TIMELINE_DATA).setVisible(true);
TimelineRelationPanel timeline = new TimelineRelationPanel(applicationBus, theProject);
RootPanel.get(DIV_TIMELINE_DATA).add(timeline);
}
private void hideTimelineProjectRelations() {
GWT.log("hideTimelineProjectRelations");
RootPanel.get(DIV_TIMELINE_DATA).setVisible(false);
RootPanel.get(DIV_TIMELINE_DATA).clear();
}
private void performWFSQueryOnCentroid(String projectID, Double centroidLong, Double centroidLat) {
GWT.log("Perform performWFSQueryOnCentroid: " + projectID + " long: " + centroidLong + ", lat: " + centroidLat);
if (projectID != null) {

View File

@ -417,7 +417,7 @@ public class LayerManager {
LayerObjectType layerObjectType = layerObject.getType();
return new ShowDetailsEvent(layerObjectType != null ? layerObjectType.name() : null,
layerObject.getProfileID(), productId, itemName, fRow);
layerObject.getProfileID(), productId, itemName, fRow, true);
}
return null;
@ -807,7 +807,7 @@ public class LayerManager {
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
applicationBus.fireEvent(new ShowDetailsEvent(lo.getType().name(),
lo.getProfileID(), newProjectID, null, null));
lo.getProfileID(), newProjectID, null, null, true));
}
}

View File

@ -19,6 +19,7 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
private String itemName;
private String profileID;
private String projectID;
private boolean loadTimelineRelationships;
/**
* Instantiates a new show details event.
@ -29,13 +30,13 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* @param featureRow the feature row
*/
public ShowDetailsEvent(String layerObjectType, String profileID, String projectID, String itemName,
FeatureRow featureRow) {
FeatureRow featureRow, boolean loadTimelineRelationships) {
this.layerObjectType = layerObjectType;
this.profileID = profileID;
this.projectID = projectID;
this.itemName = itemName;
this.featureRow = featureRow;
this.loadTimelineRelationships = loadTimelineRelationships;
}
/**
@ -44,13 +45,15 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* @param gir the gir
* @param itemName the item name
* @param featureRow the feature row
* @param loadTimelineRelationships the load timeline relationships
*/
public ShowDetailsEvent(GeoportalItemReferences gir, String itemName, FeatureRow featureRow) {
public ShowDetailsEvent(GeoportalItemReferences gir, String itemName, FeatureRow featureRow, boolean loadTimelineRelationships) {
this.layerObjectType = gir.getLayerObjectType();
this.profileID = gir.getProfileID();
this.projectID = gir.getProjectID();
this.itemName = itemName;
this.featureRow = featureRow;
this.loadTimelineRelationships = loadTimelineRelationships;
}
public static Type<ShowDetailsEventHandler> getTYPE() {
@ -116,6 +119,15 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
public void setItemName(String itemName) {
this.itemName = itemName;
}
/**
* Checks if is load timeline relationships.
*
* @return true, if is load timeline relationships
*/
public boolean isLoadTimelineRelationships() {
return loadTimelineRelationships;
}
/**
* Gets the geona item ref.
@ -126,4 +138,25 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
return new GeoportalItemReferences(projectID, profileID, layerObjectType);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ShowDetailsEvent [layerObjectType=");
builder.append(layerObjectType);
builder.append(", featureRow=");
builder.append(featureRow);
builder.append(", itemName=");
builder.append(itemName);
builder.append(", profileID=");
builder.append(profileID);
builder.append(", projectID=");
builder.append(projectID);
builder.append(", loadTimelineRelationships=");
builder.append(loadTimelineRelationships);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,80 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class TimelineProjectRelationsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 3, 2022
*/
public class TimelineProjectRelationsEvent extends GwtEvent<TimelineProjectRelationsEventHandler> {
public static Type<TimelineProjectRelationsEventHandler> TYPE = new Type<TimelineProjectRelationsEventHandler>();
private EVENT_TYPE eventType = EVENT_TYPE.HIDE; //default
private ProjectDV theProjectDV;
/**
* The Enum EVENT_TYPE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 3, 2022
*/
public enum EVENT_TYPE {
SHOW, HIDE
}
/**
* Instantiates a new timeline project relations event.
*
* @param theProjectDV the the project DV
* @param eventType the event type
*/
public TimelineProjectRelationsEvent(ProjectDV theProjectDV, EVENT_TYPE eventType) {
this.theProjectDV = theProjectDV;
this.eventType = eventType;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<TimelineProjectRelationsEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(TimelineProjectRelationsEventHandler handler) {
handler.onTimelineRelationEvent(this);
}
/**
* Gets the event type.
*
* @return the event type
*/
public EVENT_TYPE getEventType() {
return eventType;
}
/**
* Gets the the project DV.
*
* @return the the project DV
*/
public ProjectDV getTheProjectDV() {
return theProjectDV;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface TimelineProjectRelationsEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 3, 2022
*/
public interface TimelineProjectRelationsEventHandler extends EventHandler {
/**
* On timeline relation event.
*
* @param timelineProjectRelationsEvent the timeline project relations event
*/
void onTimelineRelationEvent(TimelineProjectRelationsEvent timelineProjectRelationsEvent);
}

View File

@ -17,7 +17,7 @@ public interface GNAImages extends ClientBundle {
* Our sample image icon. Makes the image resource for the gwt-compiler's css
* composer accessible
*/
@Source("map.png")
@Source("map1.png")
ImageResource map();
@Source("preset_location.png")
@ -46,5 +46,11 @@ public interface GNAImages extends ClientBundle {
@Source("layer_invisible.png")
ImageResource layerInvisible();
@Source("spinner_earth.gif")
ImageResource spinnerEarth();
@Source("spinner_clock2.gif")
ImageResource spinnerClock();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -70,7 +70,7 @@ public class DetailsPanel extends Composite {
detailsHTMLPanel.getParent().getElement().setScrollTop(0);
}
datailsContainerPanel.add(new ProjectViewer(geonaItemRef, result));
datailsContainerPanel.add(new ProjectViewer(applicationBus, geonaItemRef, result));
showPanelDetails();
}

View File

@ -10,6 +10,8 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent.EVENT_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
@ -25,6 +27,7 @@ import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
@ -73,16 +76,18 @@ public class ProjectViewer extends Composite {
private boolean openImageButtonVisible = true;
private HandlerManager applicationBus;
private ProjectViewer() {
initWidget(uiBinder.createAndBindUi(this));
pageViewDetails.getElement().setId("page-view-details");
}
public ProjectViewer(GeoportalItemReferences geoportalItemRefs, ProjectView projectView) {
this(geoportalItemRefs, projectView, true, true);
public ProjectViewer(HandlerManager applicationBus, GeoportalItemReferences geoportalItemRefs, ProjectView projectView) {
this(applicationBus, geoportalItemRefs, projectView, true, true);
}
public ProjectViewer(GeoportalItemReferences geoportalItemRefs, final ProjectView projectView,
public ProjectViewer(HandlerManager applicationBus, GeoportalItemReferences geoportalItemRefs, final ProjectView projectView,
boolean viewImageButtonVisible, boolean openImageButtonVisible) {
this();
GWT.log("Rendering " + projectView.getTheProjectDV().getId());
@ -90,6 +95,7 @@ public class ProjectViewer extends Composite {
this.geoportalItemReferences = geoportalItemRefs;
this.viewImageButtonVisible = viewImageButtonVisible;
this.openImageButtonVisible = openImageButtonVisible;
this.applicationBus = applicationBus;
final String theTitle = projectView.getTheProjectDV().getProfileName() != null
? projectView.getTheProjectDV().getProfileName()
@ -119,7 +125,7 @@ public class ProjectViewer extends Composite {
@Override
public void onClick(ClickEvent event) {
ProjectViewer cv = new ProjectViewer(geoportalItemReferences, theProjectView, false,
ProjectViewer cv = new ProjectViewer(applicationBus, geoportalItemReferences, theProjectView, false,
openImageButtonVisible);
cv.setExpandViewButtonVisible(false);
int width = Window.getClientWidth() * 75 / 100;
@ -142,6 +148,16 @@ public class ProjectViewer extends Composite {
relationshipsButton.setVisible(true);
} else
relationshipsButton.setVisible(false);
relationshipsButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
applicationBus.fireEvent(new TimelineProjectRelationsEvent(theProjectView.getTheProjectDV(), EVENT_TYPE.SHOW));
}
});
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
@ -172,8 +188,9 @@ public class ProjectViewer extends Composite {
GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px");
if (theProjectView != null && theProjectView.getTheProjectDV() != null) {
GeoJSON spatialReference = theProjectView.getTheProjectDV().getSpatialReference();
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
@ -182,6 +199,7 @@ public class ProjectViewer extends Composite {
mapView.addMarker(transfCoord, authenticatedUser);
centroidPanel.add(mapView);
}
} else if (theProjectView != null) {
GeoportalDataViewerConstants
.printJs("I cannot add centroid as maker one or both coordinates are null. Lat: " + theProjectView

View File

@ -2,17 +2,30 @@ 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.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.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Style.TextAlign;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
@ -21,13 +34,35 @@ public class TimelineRelationPanel extends Composite {
@UiField
ScrollPanel timelineContainer;
@UiField
HTMLPanel timelineTitle;
private LoaderIcon loaderData = new LoaderIcon("Loading data... please wait", new Image(GNAImages.ICONS.spinnerClock()));
private TimelineRelationPanel instance = this;
private String selectedProjectID;
private ProjectDV theProjectDV;
private HandlerManager applicationBus;
private static TimelineRelationPanelUiBinder uiBinder = GWT.create(TimelineRelationPanelUiBinder.class);
interface TimelineRelationPanelUiBinder extends UiBinder<Widget, TimelineRelationPanel> {
}
public TimelineRelationPanel(String profileID, String projectID) {
public TimelineRelationPanel(HandlerManager applicationBus, ProjectDV theProjectDV) {
initWidget(uiBinder.createAndBindUi(this));
this.theProjectDV = theProjectDV;
this.applicationBus = applicationBus;
String html = ProjectUtil.toHMLCode(theProjectDV.getTheDocument(), theProjectDV.getId());
HTML title = new HTML("Relationships of the Project: " + html);
timelineTitle.add(title);
loaderData.getElement().getStyle().setTextAlign(TextAlign.CENTER);
timelineTitle.add(loaderData);
timelineContainer.getElement().setId("visualization");
@ -35,8 +70,8 @@ public class TimelineRelationPanel extends Composite {
public void execute() {
GeoportalDataViewerServiceAsync.Util.getInstance().getRelationshipsForTimeline(profileID, projectID,
new AsyncCallback<List<String>>() {
GeoportalDataViewerServiceAsync.Util.getInstance().getRelationshipsForTimeline(
theProjectDV.getProfileID(), theProjectDV.getId(), new AsyncCallback<List<String>>() {
@Override
public void onSuccess(List<String> result) {
@ -46,13 +81,17 @@ public class TimelineRelationPanel extends Composite {
toJsonArr.set(i, JSONParser.parseStrict(result.get(i)));
}
instanceTimeline(timelineContainer.getElement().getId(), toJsonArr);
instanceTimeline(timelineContainer.getElement().getId(), toJsonArr, instance);
timelineTitle.remove(loaderData);
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
timelineTitle.remove(loaderData);
Alert alert = new Alert(caught.getMessage());
alert.setType(AlertType.ERROR);
alert.setClose(false);
timelineTitle.add(alert);
}
});
@ -61,7 +100,28 @@ public class TimelineRelationPanel extends Composite {
}
public static native String instanceTimeline(String idDivContainer, JSONArray jsonItems) /*-{
private void setSelectedProject(String projectID) {
this.selectedProjectID = projectID;
GWT.log("selectedProjectID: " + selectedProjectID);
String[] references = this.selectedProjectID.split(",");
GeoportalItemReferences gir = new GeoportalItemReferences(references[1],
references[0]);
ShowDetailsEvent event = new ShowDetailsEvent(gir, null, null, false);
GWT.log("fireEvetn: "+event);
//applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null, false));
}
public String getSelectedProjectID() {
return selectedProjectID;
}
public static native String instanceTimeline(String idDivContainer, JSONArray jsonItems,
TimelineRelationPanel instance) /*-{
console.log('showTimeline_instanceTimeline for json items: '
+ jsonItems);
@ -81,10 +141,15 @@ public class TimelineRelationPanel extends Composite {
// Create a DataSet (allows two way data-binding)
var items = new $wnd.vis.DataSet(myArray);
// Create a Timeline
var timeline = new $wnd.vis.Timeline(container, items,
$wnd.optionsTimeline);
timeline.on('select',function(properties, items) {
//console.log('selected: ' + $wnd.JSON.stringify(properties));
console.log('selected items: ' + properties.items);
instance.@org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation.TimelineRelationPanel::setSelectedProject(Ljava/lang/String;)(properties.items+'')
});
}-*/;
}

View File

@ -6,12 +6,20 @@
font-weight: bold;
}
.timeline_title {
padding: 5px;
background-color: rgba(0, 60, 136, 0.7);
color: white;
}
.timeline {
border: 1px solid lightgray;
/*border: 1px solid lightgray;*/
max-height: 400px;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="timelineTitle"
addStyleNames="{style.timeline_title}"></g:HTMLPanel>
<g:ScrollPanel ui:field="timelineContainer"
addStyleNames="{style.timeline}"></g:ScrollPanel>
</g:HTMLPanel>

View File

@ -131,8 +131,8 @@ public class SearchFacilityUI extends Composite {
* @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter
*/
public SearchFacilityUI(String profileID, HandlerManager appManagerBus,List<ItemFieldDV> displayByFields, List<ItemFieldDV> sortByFields,
List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
public SearchFacilityUI(String profileID, HandlerManager appManagerBus, List<ItemFieldDV> displayByFields,
List<ItemFieldDV> sortByFields, List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
initWidget(uiBinder.createAndBindUi(this));
this.profileID = profileID;
this.displayByFields = displayByFields;
@ -331,7 +331,7 @@ public class SearchFacilityUI extends Composite {
public void onClick(ClickEvent event) {
GeoportalItemReferences gir = new GeoportalItemReferences(resultDoc.getProjectID(),
profileID);
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null, true));
GeoJSON spatialReference = resultDoc.getSpatialReference();
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, null,

View File

@ -31,10 +31,29 @@ public class LoaderIcon extends HorizontalPanel{
setText(txtHTML);
}
/**
* Instantiates a new loader icon.
*
* @param txtHTML the txt html
*/
public LoaderIcon(String txtHTML, Image spinner) {
setText(txtHTML);
this.imgLoading = spinner!=null?spinner:imgLoading;
setStyleName("marginTop20");
add(imgLoading);
add(txtLoading);
}
/**
* Instantiates a new loader icon.
*/
public LoaderIcon() {
init();
}
private void init() {
setStyleName("marginTop20");
add(imgLoading);
add(txtLoading);

View File

@ -20,6 +20,7 @@ import org.gcube.application.geoportal.common.model.configuration.Configuration;
import org.gcube.application.geoportal.common.model.configuration.Index;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference;
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.Projects;
@ -81,6 +82,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option;
/**
* The server side implementation of the RPC service.
@ -1256,15 +1260,68 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
throw new Exception("Invalid parameter. Either profileID or projectID is null");
try {
LOG.info("Trying to getRelationshipChain for id " + profileID);
LOG.info("Trying to getRelationshipsForTimeline for id " + profileID);
List<String> listJSON = new ArrayList<String>();
try {
String template = "{\"content\": \"$._theDocument.nome\","
+ "\"start\" : \"$._theDocument.dataInizioProgetto\","
+ "\"end\" : \"$._theDocument.dataFineProgetto\"}";
JSONObject sourceJsonTemplate = new JSONObject(template);
JSONObject targetJsonObject = new JSONObject();
com.jayway.jsonpath.Configuration conf = com.jayway.jsonpath.Configuration.defaultConfiguration();
com.jayway.jsonpath.Configuration conf2 = conf.addOptions(Option.ALWAYS_RETURN_LIST);
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
List<Relationship> relationships = theProject.getRelationships();
for (Relationship relationship : relationships) {
targetJsonObject.put("id", relationship.getTargetUCD()+","+relationship.getTargetID());
Project targetProject = GeoportalClientCaller.projects().getProjectByID(relationship.getTargetUCD(),
relationship.getTargetID());
DocumentContext targetDoc = JsonPath.using(conf2).parse(targetProject.getTheDocument().toJson());
for (Object key : sourceJsonTemplate.keySet()) {
String theKey = key + "";
String jsonPath = sourceJsonTemplate.getString(theKey);
// Works fine
List<String> listValue = targetDoc.read(jsonPath);
String result = "";
for (int i = 0; i < listValue.size() - 1; i++) {
result += listValue.get(i) + ", ";
}
result += listValue.get(listValue.size() - 1);
targetJsonObject.put(theKey, result);
}
List<PayloadDV> images = getImagesForId(relationship.getTargetUCD(), relationship.getTargetID(),
true);
if (images.size() > 0) {
images.get(0).getLink();
targetJsonObject.put("image_url", images.get(0).getLink());
}
String theJSONResult = targetJsonObject.toString();
LOG.debug("Built jsonObject " + theJSONResult);
listJSON.add(theJSONResult);
}
} catch (Exception e) {
String erroMsg = "Error occurred on reading relatioships for id: " + projectID;
LOG.error(erroMsg, e);
}
// TODO LOAD AND APPLT TEMPLATING OF KIND
for (int i = 0; i < 5; i++) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", i);
jsonObject.put("title", "title " + i);
jsonObject.put("id", "UCD"+i+",ID"+i);
jsonObject.put("content",
"title moooooooooooooolto lungoooooooooooooooooooooooooooooooooooooooooooooooooo" + i);
jsonObject.put("start", "201" + i + "-04-1");
jsonObject.put("end", "201" + i + "-09-1");
if (i < 3)

View File

@ -552,7 +552,7 @@ body {
}
.vis-item-content table code {
color: gray;
color: red;
}
.vis-item-content table span {

View File

@ -50,7 +50,7 @@
</tr></td>
{{/if}}
<tr>
<th colspan="3" class="description" title="{{content}}">{{truncate title}}</th>
<th colspan="3" class="description">{{truncate_msg content}}</th>
</tr>
<tr>
<td><code>{{dateformat start}} / {{dateformat end}}</code></td>
@ -81,10 +81,9 @@
}
});
Handlebars.registerHelper("truncate", function(input, max_lenght) {
Handlebars.registerHelper("truncate_msg", function(input) {
if (!max_lenght)
max_lenght = 10;
max_lenght = 20;
if (input.length > max_lenght) {
return input.substring(0, max_lenght) + '...';
@ -99,7 +98,8 @@
var optionsTimeline = {
// specify a template for the items
template : templateHandlebars,
type : 'box'
type : 'box',
dataAttributes : 'all'
};
</script>
<!-- -->

View File

@ -58,13 +58,13 @@
</tr></td>
{{/if}}
<tr>
<th colspan="3" class="description" title="{{content}}">{{truncate title}}</th>
<th colspan="3" class="description">{{truncate_msg content}}</th>
</tr>
<tr>
<td><code>{{dateformat start}} / {{dateformat end}}</code></td>
</tr>
</table>
</script>
</script>
<script type="text/javascript">
Handlebars