Compare commits

...

5 Commits

@ -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

@ -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();
}
}

@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -65,15 +66,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 +88,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 +103,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 +163,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);
@ -188,13 +174,18 @@ import ol.style.TextOptions;
*
* @param mapServerHost the map server host
* @param layerName the layer name
* @param bbox
* @return the image
*/
public Image addWMSLayer(String mapServerHost, String layerName) {
public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) {
GWT.log("Adding wmsLayer with mapServerHost: "+mapServerHost+", layerName: "+layerName);
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerName);
//imageWMSParams.setSize(new Size(400,400));
//imageWMSParams.setVersion("1.1.0");
// if(bbox!=null)
// imageWMSParams.set("BBOX", bbox.getLowerLeftX()+","+bbox.getLowerLeftY()+","+bbox.getUpperRightX()+","+bbox.getUpperRightY());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(mapServerHost);

@ -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) {

@ -13,6 +13,7 @@ import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.TextAlign;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
@ -40,6 +41,9 @@ public class ImageView extends Composite {
@UiField
Paragraph paragraph1;
@UiField
Paragraph paragraph2;
@UiField
Button openImage;
@ -54,6 +58,12 @@ public class ImageView extends Composite {
heading.setText(imageDV.getTitolo());
paragraph1.setText(imageDV.getDidascalia());
paragraph1.getElement().getStyle().setTextAlign(TextAlign.LEFT);
if(!showView && imageDV.getLicenseID()!=null) {
paragraph2.setVisible(true);
paragraph2.setText("ID Licenza: "+imageDV.getLicenseID());
}
if(imageDV.getListWsContent()!=null && imageDV.getListWsContent().size()>0) {
latest = imageDV.getListWsContent().get(imageDV.getListWsContent().size()-1);

@ -21,7 +21,7 @@
<b:Heading size="4" ui:field="heading"></b:Heading>
<b:Paragraph ui:field="paragraph1">
</b:Paragraph>
<b:Paragraph ui:field="paragraph2">
<b:Paragraph ui:field="paragraph2" visible="false">
</b:Paragraph>
</b:Caption>
</g:HTMLPanel>

@ -45,7 +45,7 @@ public class ThumbnailImageView extends Composite {
initWidget(uiBinder.createAndBindUi(this));
ImageView imageView = new ImageView(imageDV, showView, showOpen);
String title = StringUtil.ellipsize(imageDV.getTitolo(), 20);
String title = StringUtil.ellipsize(imageDV.getTitolo(), 25);
imageView.setHeading(title);
String didascalia = StringUtil.ellipsize(imageDV.getDidascalia(), 50);

@ -128,9 +128,12 @@ import ol.OLFactory;
@Override
public void execute() {
olsm.addWMSLayer(mapServerHost, layerName);
ExtentWrapped ew = null;
BoundsMap theBBOX = bbox;
if (bbox != null) {
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326,
@ -139,14 +142,15 @@ import ol.OLFactory;
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326,
GeoportalDataViewerConstants.EPSG_3857);
ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null);
}
olsm.addWMSLayer(mapServerHost, layerName, theBBOX);
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());
// Size size = new Size(300, 300);
//olsm.getMap().getView().setCenter(invertCoordinate);
if (ew != null) {
olsm.getMap().getView().fit(ew);
}

@ -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);

@ -35,7 +35,7 @@ public class RelazioneScavoView extends Composite {
abstractParagraph.setText(relazioneScavoDV.getAbstractSection());
//customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime());
customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID());
//customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID());
customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), GeoportalDataViewerConstants.NEW_LINE_BR);
relazioneScavoPanel.add(customTable);
}

@ -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,40 @@ 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;
BoundsMap bounds = null;
//reading layer name from wmsLink
//string bbox
if(wmsLink!=null) {
layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink);
String bbox = URLParserUtil.extractValueOfParameterFromURL("bbox", wmsLink);
String wmsVersion = URLParserUtil.extractValueOfParameterFromURL("version", wmsLink);
bounds = toBoundMap(wmsVersion, bbox, ",");
LOG.debug("Built bounds from wmsLInk: "+bounds);
}
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());
if(bounds==null)
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 +344,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 +364,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()));
@ -341,5 +387,50 @@ public class ConvertToDataViewModel {
return new BoundsMap(bbox.getMinLong(), bbox.getMinLat(), bbox.getMaxLong(), bbox.getMaxLat(), null);
}
/**
* To bound map.
*
* @param bbox the bbox
* @return the bounds map
*/
public static BoundsMap toBoundMap(String wmsVersion, String bbox, String separator) {
if (bbox == null)
return null;
if(wmsVersion==null)
return null;
if(separator==null)
separator = ",";
try {
String[] bboxArr = bbox.split(separator);
if(wmsVersion.startsWith("1.3")) {
//is 1.3.x
return new BoundsMap(toDouble(bboxArr[1]), toDouble(bboxArr[0]), toDouble(bboxArr[3]), toDouble(bboxArr[2]), wmsVersion);
}else {
//should be 1.1.X
return new BoundsMap(toDouble(bboxArr[0]), toDouble(bboxArr[1]), toDouble(bboxArr[2]), toDouble(bboxArr[3]), wmsVersion);
}
}catch (Exception e) {
LOG.warn("Error on creating Bounds for wmsVersion "+wmsVersion+" and bbox "+bbox+" : ",e);
return null;
}
}
public static Double toDouble(String value) {
try {
return Double.parseDouble(value);
}catch (Exception e) {
LOG.warn("Error on parsing "+value+" as double: ",e);
return null;
}
}
}

@ -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();
}

@ -91,6 +91,7 @@ body {
#page-view-details .page-header {
margin-bottom: 22px;
padding-top: 5px;
}
@ -107,14 +108,15 @@ body {
}
#page-view-details .my-custom-flex-table {
margin-left: 20px;
margin-right: 40px;
margin-left: 10px;
/*margin-right: 40px;*/
font-size: 13px;
max-width: 98%;
max-width: 95%;
}
#page-view-details .my-custom-flex-table td {
padding: 5px;
padding-top: 5px;
padding-bottom: 5px;
}
#page-view-details .my-custom-flex-table tbody tr>td:first-child {
@ -211,7 +213,7 @@ body {
border: 1px solid #ddd;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055);
padding-right: 10px;
/*padding-right: 10px;*/
margin-bottom: 10px;
width: 98%;
}

Loading…
Cancel
Save