minor fixes on Date etc.
This commit is contained in:
parent
4e02aa7931
commit
cb2c0eb3c4
|
@ -4,6 +4,6 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.0.0] - 2020-12-03
|
||||
## [v1.0.0-SNAPSHOT] - 2020-12-03
|
||||
|
||||
[#20004] First release
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>geoportal-data-viewer-app</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>GeoPortal Data Viewer App</name>
|
||||
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Gis GUI</description>
|
||||
|
||||
|
@ -128,25 +128,21 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
<!-- <version>[1.0.0, 2.0.0-SNAPSHOT)</version> -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<!-- <version>[1.1.0, 2.0.0-SNAPSHOT)</version> -->
|
||||
<!-- <scope>compile</scope> -->
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<!-- <version>[2.4.1,3.0.0-SNAPSHOT)</version> -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<!-- <version>[2.4.1,3.0.0-SNAPSHOT)</version> -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -249,8 +249,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
@Override
|
||||
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
|
||||
GWT.log("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
|
||||
GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
|
||||
|
||||
//GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
|
||||
|
||||
try {
|
||||
|
||||
|
@ -268,7 +267,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
if(record!=null) {
|
||||
this.cancel();
|
||||
GWT.log("cancelled timer");
|
||||
performWFS();
|
||||
performWFSQueryOnCentroid(record);
|
||||
}
|
||||
|
||||
if(attempt>MAX_RETRY) {
|
||||
|
@ -285,22 +284,6 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
// TODO: handle exception
|
||||
}
|
||||
|
||||
// //the parameter gid has been passed in the query string
|
||||
// if(paramGeonaItemID!=null && mainPanel.getDisplyedRecord()!=null) {
|
||||
// RecordDV record = mainPanel.getDisplyedRecord();
|
||||
// GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
|
||||
// GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
|
||||
// if(record instanceof ConcessioneDV) {
|
||||
// ConcessioneDV concessioneDV = (ConcessioneDV) record;
|
||||
// Double x = concessioneDV.getCentroidLong();
|
||||
// Double y = concessioneDV.getCentroidLat();
|
||||
// Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
// GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
|
||||
// GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
|
||||
// layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId()));
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -326,20 +309,18 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
}
|
||||
|
||||
private void performWFS() {
|
||||
//the parameter gid has been passed in the query string
|
||||
if(mainPanel.getDisplyedRecord()!=null) {
|
||||
RecordDV record = mainPanel.getDisplyedRecord();
|
||||
private void performWFSQueryOnCentroid(RecordDV record) {
|
||||
if(record!=null) {
|
||||
GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
|
||||
GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
|
||||
//GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
|
||||
if(record instanceof ConcessioneDV) {
|
||||
ConcessioneDV concessioneDV = (ConcessioneDV) record;
|
||||
Double x = concessioneDV.getCentroidLong();
|
||||
Double y = concessioneDV.getCentroidLat();
|
||||
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
|
||||
GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
|
||||
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId()));
|
||||
//GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
|
||||
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,9 +52,9 @@ public class GeoportalDataViewerConstants {
|
|||
*
|
||||
* @param msg the msg
|
||||
*/
|
||||
public static native void print(String msg)/*-{
|
||||
console.log("js console: "+msg);
|
||||
}-*/;
|
||||
// public static native void print(String msg)/*-{
|
||||
// console.log("js console: "+msg);
|
||||
// }-*/;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ import ol.Coordinate;
|
|||
*/
|
||||
public class LayerManager {
|
||||
|
||||
|
||||
|
||||
/** The ol map. */
|
||||
private OpenLayerOSM olMap;
|
||||
|
||||
|
@ -90,7 +92,7 @@ public class LayerManager {
|
|||
|
||||
@Override
|
||||
public void onQueryInteraction(final QueryDataEvent queryEvent) {
|
||||
GeoportalDataViewerConstants.print("fired QueryDataEvent: "+queryEvent.toString());
|
||||
//GeoportalDataViewerConstants.print("fired QueryDataEvent: "+queryEvent.toString());
|
||||
|
||||
if(queryEvent.getGeoQuery()!=null) {
|
||||
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
|
||||
|
@ -136,21 +138,20 @@ public class LayerManager {
|
|||
|
||||
GWT.log("Bounds is: "+mapBBOX);
|
||||
GWT.log("MAX_WFS_FEATURES is: "+GeoportalDataViewerConstants.MAX_WFS_FEATURES);
|
||||
|
||||
GeoportalDataViewerConstants.print("calling getDataResult");
|
||||
//GeoportalDataViewerConstants.print("calling getDataResult");
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GeoportalDataViewerConstants.print("on Failure DataResult: "+caught.getMessage());
|
||||
//GeoportalDataViewerConstants.print("on Failure DataResult: "+caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
|
||||
|
||||
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||
GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||
//GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||
|
||||
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
|
||||
return;
|
||||
|
@ -215,7 +216,7 @@ public class LayerManager {
|
|||
}
|
||||
}
|
||||
|
||||
GeoportalDataViewerConstants.print("0: "+nome);
|
||||
//GeoportalDataViewerConstants.print("0: "+nome);
|
||||
flex.setHTML(0, 0, new HTML(nome).toString());
|
||||
try {
|
||||
descrizione = StringUtil.ellipsize(descrizione, 100);
|
||||
|
@ -223,9 +224,10 @@ public class LayerManager {
|
|||
} catch (Exception e) {
|
||||
GWT.log("error: "+e.getMessage());
|
||||
}
|
||||
GeoportalDataViewerConstants.print("1: "+descrizione);
|
||||
//GeoportalDataViewerConstants.print("1: "+descrizione);
|
||||
flex.setText(1, 0, descrizione);
|
||||
GeoportalDataViewerConstants.print("2: "+date);
|
||||
//GeoportalDataViewerConstants.print("2: "+date);
|
||||
date = StringUtil.formatDate(date);
|
||||
flex.setHTML(2, 0, new HTML("<code>"+date+"</code>").toString());
|
||||
|
||||
if(geoNaDataObject.getMapImages()!=null) {
|
||||
|
@ -238,7 +240,7 @@ public class LayerManager {
|
|||
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
|
||||
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
|
||||
GWT.log("theImgHTML: "+theImgHTML);
|
||||
GeoportalDataViewerConstants.print("The row are: "+flex.getRowCount());
|
||||
//GeoportalDataViewerConstants.print("The row are: "+flex.getRowCount());
|
||||
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +255,7 @@ public class LayerManager {
|
|||
return;
|
||||
|
||||
GWT.log("The selected Feature is: "+feature);
|
||||
GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
||||
//GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
||||
FeatureRow theFeature = feature;
|
||||
Button button = null;
|
||||
if(!featureFound) {
|
||||
|
@ -293,8 +295,9 @@ public class LayerManager {
|
|||
}
|
||||
}
|
||||
|
||||
//fallback
|
||||
if(centerTo==null)
|
||||
centerTo = queryEvent.getoLCoordinate();
|
||||
centerTo = queryEvent.getOnFailureCenterTo();
|
||||
|
||||
olMap.showPopup(vpPanel.toString(), centerTo);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class OLMapManager {
|
|||
// }
|
||||
|
||||
GeoQuery select = toDataPointQuery(coordinate);
|
||||
layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null));
|
||||
layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true));
|
||||
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ public class OLMapManager {
|
|||
GWT.log("the distance is: " + dist);
|
||||
if (dist > 5000 || startExt.containsExtent(endExt)) {
|
||||
GeoQuery select = toDataBoxQuery(dragEndExtent);
|
||||
layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null));
|
||||
layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null, false));
|
||||
}
|
||||
}
|
||||
else if(zoomStart!=null && zoomEnd!=null) {
|
||||
|
|
|
@ -16,17 +16,24 @@ import ol.Coordinate;
|
|||
public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
|
||||
public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>();
|
||||
private GeoQuery select;
|
||||
private Coordinate oLCoordinate;
|
||||
private Coordinate onFailureCenterTo;
|
||||
private Long recordId;
|
||||
private boolean onInit;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new table row selected event.
|
||||
* @param coordinate
|
||||
* Instantiates a new query data event.
|
||||
*
|
||||
* @param select the select
|
||||
* @param onFailureCenterTo the on failure center to
|
||||
* @param recordId the record id
|
||||
* @param onInit the on init
|
||||
*/
|
||||
public QueryDataEvent(GeoQuery select, Coordinate coordinate, Long recordId) {
|
||||
public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, Long recordId, boolean onInit) {
|
||||
this.select = select;
|
||||
this.oLCoordinate = coordinate;
|
||||
this.onFailureCenterTo = onFailureCenterTo;
|
||||
this.recordId = recordId;
|
||||
this.onInit = onInit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,6 +56,14 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
|
|||
return recordId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is on init.
|
||||
*
|
||||
* @return true, if is on init
|
||||
*/
|
||||
public boolean isOnInit() {
|
||||
return onInit;
|
||||
}
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
|
@ -60,12 +75,18 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the geo query.
|
||||
*
|
||||
* @return the geo query
|
||||
*/
|
||||
public GeoQuery getGeoQuery() {
|
||||
return select;
|
||||
}
|
||||
|
||||
public Coordinate getoLCoordinate() {
|
||||
return oLCoordinate;
|
||||
|
||||
public Coordinate getOnFailureCenterTo() {
|
||||
return onFailureCenterTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,13 +94,19 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("QueryDataEvent [select=");
|
||||
builder.append(select);
|
||||
builder.append(", oLCoordinate=");
|
||||
builder.append(oLCoordinate);
|
||||
builder.append(", onFailureCenterTo=");
|
||||
builder.append(onFailureCenterTo);
|
||||
builder.append(", recordId=");
|
||||
builder.append(recordId);
|
||||
builder.append(", onInit=");
|
||||
builder.append(onInit);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -65,15 +65,12 @@ import ol.style.TextOptions;
|
|||
|
||||
private String markerURL = Images.ICONS.mapMarkerIcon().getURL();
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new open layer OSM.
|
||||
*
|
||||
* @param divTargetId the div target id
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see de.desjardins.ol3.demo.client.example.Example#show()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Instantiates a new light open layer OSM.
|
||||
*
|
||||
* @param divTargetId the div target id
|
||||
*/
|
||||
public LightOpenLayerOSM(String divTargetId) {
|
||||
|
||||
// create a OSM-layer
|
||||
|
@ -90,18 +87,10 @@ import ol.style.TextOptions;
|
|||
|
||||
Projection projection = new Projection(projectionOptions);
|
||||
viewOptions.setProjection(projection);
|
||||
viewOptions.setMaxZoom(19);
|
||||
//viewOptions.setExtent(new Extent(-180, -90, 180, 90));
|
||||
viewOptions.setMaxZoom(20);
|
||||
|
||||
// create a view
|
||||
view = new View(viewOptions);
|
||||
|
||||
// //EPSG_4326_TO_ITALY
|
||||
// Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
|
||||
// Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
//
|
||||
// view.setCenter(transformedCenterCoordinate);
|
||||
// view.setZoom(5);
|
||||
|
||||
// create the map
|
||||
MapOptions mapOptions = OLFactory.createOptions();
|
||||
|
@ -113,10 +102,6 @@ import ol.style.TextOptions;
|
|||
map.addLayer(osmLayer);
|
||||
//map.addLayer(tileDebugLayer);
|
||||
|
||||
// add some controls
|
||||
// map.addControl(OLFactory.createScaleLine());
|
||||
// DemoUtils.addDefaultControls(map.getControls());
|
||||
|
||||
Attribution attribution = new Attribution();
|
||||
attribution.setCollapsed(true);
|
||||
|
||||
|
@ -177,7 +162,7 @@ import ol.style.TextOptions;
|
|||
/**
|
||||
* Sets the center.
|
||||
*
|
||||
* @param centerCoordinate the new center
|
||||
* @param zoom the new zoom
|
||||
*/
|
||||
public void setZoom(int zoom) {
|
||||
view.setZoom(zoom);
|
||||
|
|
|
@ -215,7 +215,7 @@ public abstract class OpenLayerOSM {
|
|||
|
||||
public void showPopup(String html, Coordinate coordinate) {
|
||||
GWT.log("Showing popup on: "+coordinate);
|
||||
GeoportalDataViewerConstants.print("Showing popup on: "+coordinate);
|
||||
//GeoportalDataViewerConstants.print("Showing popup on: "+coordinate);
|
||||
Element elPopup = DOM.getElementById("popup");
|
||||
elPopup.getStyle().setVisibility(Visibility.VISIBLE);
|
||||
if(popupOverlay==null) {
|
||||
|
|
|
@ -131,6 +131,7 @@ import ol.OLFactory;
|
|||
olsm.addWMSLayer(mapServerHost, layerName);
|
||||
|
||||
if (bbox != null) {
|
||||
|
||||
|
||||
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
|
||||
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326,
|
||||
|
@ -139,9 +140,8 @@ import ol.OLFactory;
|
|||
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
|
||||
Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326,
|
||||
GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
||||
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(),
|
||||
upperCoord.getY());
|
||||
|
||||
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
||||
//Coordinate center = ew.getCenter();
|
||||
//GWT.log("center: "+center);
|
||||
//Coordinate invertCoordinate = new Coordinate(center.getY(), center.getX());
|
||||
|
|
|
@ -35,13 +35,14 @@ public class LayerConcessioneView extends Composite {
|
|||
initWidget(uiBinder.createAndBindUi(this));
|
||||
GWT.log("Showing: "+layerDV);
|
||||
|
||||
//customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime());
|
||||
customTable.addNextKeyValue("Abstract", layerDV.getAbstractSection());
|
||||
customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita());
|
||||
customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati());
|
||||
customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione());
|
||||
customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
||||
layerConcessionePanel.add(customTable);
|
||||
|
||||
GWT.log("WMS LINK: "+layerDV.getWmsLink());
|
||||
if(layerDV.getLayerName()!=null && layerDV.getWmsLink()!=null) {
|
||||
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
||||
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
||||
/**
|
||||
* The Class StringUtil.
|
||||
|
@ -12,6 +16,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
|||
* Nov 16, 2020
|
||||
*/
|
||||
public class StringUtil {
|
||||
|
||||
private static final String NO_TIME = "_00-00-00";
|
||||
|
||||
/**
|
||||
* Ellipsize.
|
||||
|
@ -31,4 +37,27 @@ public class StringUtil {
|
|||
|
||||
return input.substring(0, maxCharacters)+"...";
|
||||
}
|
||||
|
||||
public static String formatDate(String date) {
|
||||
if(date==null)
|
||||
return date;
|
||||
|
||||
Date theDate = null;
|
||||
try {
|
||||
if(date.endsWith(NO_TIME)) {
|
||||
date = date.replaceAll(NO_TIME, "");
|
||||
theDate = DateTimeFormat.getFormat("yyyyMMdd").parse(date);
|
||||
}else {
|
||||
theDate = DateTimeFormat.getFormat("yyyyMMdd_HH-mm-ss").parse(date);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
Window.alert(e.toString());
|
||||
}
|
||||
|
||||
if(theDate!=null) {
|
||||
return DateTimeFormat.getFormat("dd-MM-yyyy").format(theDate);
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.server;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatterBuilder;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,6 +14,7 @@ import org.gcube.application.geoportal.common.model.legacy.PersistedContent;
|
|||
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
|
||||
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||
import org.gcube.application.geoportal.common.model.legacy.WorkspaceContent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.OtherContentDV;
|
||||
|
@ -33,17 +34,17 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class ConvertToDataViewModel {
|
||||
|
||||
private static final String NO_TIME = "T00:00";
|
||||
|
||||
/** The Constant LOG. */
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ConvertToDataViewModel.class);
|
||||
|
||||
public static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||
public static final String DATE_FORMAT = "dd-MM-yyyy";
|
||||
|
||||
public static final String HOURS_MINUTES_SEPARATOR = ":";
|
||||
|
||||
public static final String TIME_FORMAT = "HH" + HOURS_MINUTES_SEPARATOR + "mm";
|
||||
|
||||
public static final DateTimeFormatterBuilder dtf = new DateTimeFormatterBuilder()
|
||||
.appendPattern(DATE_FORMAT + " " + TIME_FORMAT);
|
||||
|
||||
/**
|
||||
* To concessione.
|
||||
|
@ -66,10 +67,10 @@ public class ConvertToDataViewModel {
|
|||
theConcessione.setCentroidLat(concessione.getCentroidLat());
|
||||
theConcessione.setCentroidLong(concessione.getCentroidLong());
|
||||
theConcessione.setContributore(concessione.getContributore());
|
||||
theConcessione.setCreationTime(toDateString(concessione.getCreationTime()));
|
||||
theConcessione.setCreationTime(toDateFormatString(concessione.getCreationTime()));
|
||||
theConcessione.setCreationUser(toUser(concessione.getCreationUser()));
|
||||
theConcessione.setDataFineProgetto(toDateString(concessione.getDataFineProgetto()));
|
||||
theConcessione.setDataInizioProgetto(toDateString(concessione.getDataInizioProgetto()));
|
||||
theConcessione.setDataFineProgetto(toDateFormatString(concessione.getDataFineProgetto()));
|
||||
theConcessione.setDataInizioProgetto(toDateFormatString(concessione.getDataInizioProgetto()));
|
||||
theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto());
|
||||
theConcessione.setEditore(concessione.getEditore());
|
||||
theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento());
|
||||
|
@ -77,7 +78,7 @@ public class ConvertToDataViewModel {
|
|||
theConcessione.setNome(concessione.getNome());
|
||||
|
||||
theConcessione.setIntroduzione(concessione.getIntroduzione());
|
||||
theConcessione.setLastUpdateTime(toDateString(concessione.getLastUpdateTime()));
|
||||
theConcessione.setLastUpdateTime(toDateFormatString(concessione.getLastUpdateTime()));
|
||||
theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser()));
|
||||
theConcessione.setLicenzaID(concessione.getLicenzaID());
|
||||
theConcessione.setNome(concessione.getNome());
|
||||
|
@ -172,11 +173,31 @@ public class ConvertToDataViewModel {
|
|||
|
||||
}
|
||||
|
||||
public static String toDateString(LocalDateTime dateTime) {
|
||||
public static String toDateFormatString(LocalDateTime dateTime) {
|
||||
|
||||
if(dateTime==null)
|
||||
return null;
|
||||
|
||||
String time = dateTime.toString();
|
||||
DateTimeFormatter formatter = null;
|
||||
try {
|
||||
if(!time.endsWith(NO_TIME)) {
|
||||
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT);
|
||||
}else {
|
||||
time = time.replace(NO_TIME, "");
|
||||
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Parsing error: ",e);
|
||||
}
|
||||
|
||||
try {
|
||||
if(formatter!=null)
|
||||
return dateTime.format(formatter);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Date format error: ",e);
|
||||
}
|
||||
|
||||
return dateTime.toString();
|
||||
}
|
||||
|
||||
|
@ -194,7 +215,7 @@ public class ConvertToDataViewModel {
|
|||
|
||||
RelazioneScavoDV theRelazioneDiScavo = new RelazioneScavoDV();
|
||||
theRelazioneDiScavo.setAbstractSection(relazioneScavo.getAbstractSection());
|
||||
theRelazioneDiScavo.setCreationTime(toDateString(relazioneScavo.getCreationTime()));
|
||||
theRelazioneDiScavo.setCreationTime(toDateFormatString(relazioneScavo.getCreationTime()));
|
||||
theRelazioneDiScavo.setId(relazioneScavo.getId());
|
||||
theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID());
|
||||
theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy()));
|
||||
|
@ -220,7 +241,7 @@ public class ConvertToDataViewModel {
|
|||
return null;
|
||||
|
||||
UploadedImageDV theUploadedImageDV = new UploadedImageDV();
|
||||
theUploadedImageDV.setCreationTime(toDateString(uploadedImage.getCreationTime()));
|
||||
theUploadedImageDV.setCreationTime(toDateFormatString(uploadedImage.getCreationTime()));
|
||||
theUploadedImageDV.setDidascalia(uploadedImage.getDidascalia());
|
||||
theUploadedImageDV.setFormat(uploadedImage.getFormat());
|
||||
theUploadedImageDV.setId(uploadedImage.getId());
|
||||
|
@ -279,15 +300,31 @@ public class ConvertToDataViewModel {
|
|||
if (layerConcessione == null)
|
||||
return null;
|
||||
|
||||
LOG.debug("Converting: "+layerConcessione);
|
||||
LayerConcessioneDV theLayerConessione = new LayerConcessioneDV();
|
||||
theLayerConessione.setAbstractSection(layerConcessione.getAbstractSection());
|
||||
theLayerConessione.setLayerName(layerConcessione.getLayerName());
|
||||
|
||||
String wmsLink = layerConcessione.getWmsLink();
|
||||
String layerName = null;
|
||||
|
||||
//reading layer name from wmsLink
|
||||
if(wmsLink!=null) {
|
||||
layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink);
|
||||
}
|
||||
|
||||
if(layerName!=null)
|
||||
theLayerConessione.setLayerName(layerName);
|
||||
else
|
||||
theLayerConessione.setLayerName(layerConcessione.getLayerName());
|
||||
|
||||
|
||||
theLayerConessione.setWmsLink(wmsLink);
|
||||
theLayerConessione.setLayerID(layerConcessione.getLayerID());
|
||||
theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID());
|
||||
theLayerConessione.setAuthors(layerConcessione.getAuthors());
|
||||
BoundsMap bounds = toBoundMap(layerConcessione.getBbox());
|
||||
theLayerConessione.setBbox(bounds);
|
||||
theLayerConessione.setCreationTime(toDateString(layerConcessione.getCreationTime()));
|
||||
theLayerConessione.setCreationTime(toDateFormatString(layerConcessione.getCreationTime()));
|
||||
theLayerConessione.setId(layerConcessione.getId());
|
||||
theLayerConessione.setLicenseID(layerConcessione.getLicenseID());
|
||||
theLayerConessione.setMetodoRaccoltaDati(layerConcessione.getMetodoRaccoltaDati());
|
||||
|
@ -298,7 +335,7 @@ public class ConvertToDataViewModel {
|
|||
theLayerConessione.setTitolo(layerConcessione.getTitolo());
|
||||
theLayerConessione.setTopicCategory(layerConcessione.getTopicCategory());
|
||||
theLayerConessione.setValutazioneQualita(layerConcessione.getValutazioneQualita());
|
||||
theLayerConessione.setWmsLink(layerConcessione.getWmsLink());
|
||||
|
||||
|
||||
LOG.debug("Returning: " + theLayerConessione);
|
||||
return theLayerConessione;
|
||||
|
@ -318,7 +355,7 @@ public class ConvertToDataViewModel {
|
|||
return null;
|
||||
|
||||
OtherContentDV theOtherContent = new OtherContentDV();
|
||||
theOtherContent.setCreationTime(toDateString(otherContent.getCreationTime()));
|
||||
theOtherContent.setCreationTime(toDateFormatString(otherContent.getCreationTime()));
|
||||
theOtherContent.setId(otherContent.getId());
|
||||
theOtherContent.setLicenseID(otherContent.getLicenseID());
|
||||
theOtherContent.setPolicy(toPolicy(otherContent.getPolicy()));
|
||||
|
|
|
@ -124,6 +124,10 @@ public class LayerConcessioneDV extends SDILayerDescriptorDV implements IsSerial
|
|||
builder.append(scalaAcquisizione);
|
||||
builder.append(", authors=");
|
||||
builder.append(authors);
|
||||
builder.append(", wmsLink=");
|
||||
builder.append(super.getWmsLink());
|
||||
builder.append(", layerName=");
|
||||
builder.append(super.getLayerName());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue