task_22027
#4
Merged
francesco.mangiacrapa
merged 14 commits from task_22027
into master
2 years ago
@ -1,4 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.0.0
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.1.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
@ -1,21 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
<wb-module deploy-name="geoportal-data-viewer-app-2.0.0">
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-viewer-app-2.1.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="context-root" value="geoportal-data-viewer-app"/>
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
</project-modules>
|
||||
|
@ -0,0 +1,57 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ChangeMapLayerEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 12, 2021
|
||||
*/
|
||||
public class ChangeMapLayerEvent extends GwtEvent<ChangeMapLayerEventHandler> {
|
||||
public static Type<ChangeMapLayerEventHandler> TYPE = new Type<ChangeMapLayerEventHandler>();
|
||||
private BaseMapLayer baseMapLayer;
|
||||
|
||||
/**
|
||||
* Instantiates a new change map layer event.
|
||||
*
|
||||
* @param baseMapLayer the base map layer
|
||||
*/
|
||||
public ChangeMapLayerEvent(BaseMapLayer baseMapLayer) {
|
||||
this.baseMapLayer = baseMapLayer;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
@Override
|
||||
public Type<ChangeMapLayerEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ChangeMapLayerEventHandler handler) {
|
||||
handler.onChangeBaseMapLayer(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base map layer.
|
||||
*
|
||||
* @return the base map layer
|
||||
*/
|
||||
public BaseMapLayer getBaseMapLayer() {
|
||||
return baseMapLayer;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
* The Interface ChangeMapLayerEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 12, 2021
|
||||
*/
|
||||
public interface ChangeMapLayerEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On change base map layer.
|
||||
*
|
||||
* @param changeMapLayerEvent the change map layer event
|
||||
*/
|
||||
void onChangeBaseMapLayer(ChangeMapLayerEvent changeMapLayerEvent);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* The Class LayerOrder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 12, 2021
|
||||
*/
|
||||
public class LayerOrder {
|
||||
|
||||
/**
|
||||
* The Enum LAYER_TYPE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 12, 2021
|
||||
*/
|
||||
public static enum LAYER_TYPE {
|
||||
BASE_MAP, BASE_WMS, WMS_DETAIL, VECTOR
|
||||
}
|
||||
|
||||
public static final HashMap<LAYER_TYPE, Integer> LAYER_OFFSET = new HashMap<LAYER_TYPE, Integer>(5);
|
||||
|
||||
static {
|
||||
|
||||
LAYER_OFFSET.put(LAYER_TYPE.BASE_MAP, 0);
|
||||
LAYER_OFFSET.put(LAYER_TYPE.BASE_WMS, 70);
|
||||
LAYER_OFFSET.put(LAYER_TYPE.WMS_DETAIL, 140);
|
||||
LAYER_OFFSET.put(LAYER_TYPE.VECTOR, 210);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new layer order.
|
||||
*/
|
||||
public LayerOrder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the offset.
|
||||
*
|
||||
* @param layerType the layer type
|
||||
* @return the offset
|
||||
*/
|
||||
public Integer getOffset(LAYER_TYPE layerType) {
|
||||
return LAYER_OFFSET.get(layerType);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.constants.BaseIconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
|
||||
public interface GNAIcons extends ClientBundle {
|
||||
|
||||
/** My custom base icon collection */
|
||||
public enum CustomIconType implements BaseIconType {
|
||||
|
||||
MAP("map"),
|
||||
PRESET_LOCATION("preset_location"),
|
||||
LAYERS("layers");
|
||||
|
||||
/** Inject the icon's css once at first usage */
|
||||
static {
|
||||
GNAImages icons = GWT.create(GNAImages.class);
|
||||
icons.css().ensureInjected();
|
||||
}
|
||||
|
||||
private static final String PREFIX = "myBaseIcon_";
|
||||
private String className;
|
||||
|
||||
private CustomIconType(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String get() {
|
||||
return PREFIX + className;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
public interface GNAImages extends ClientBundle {
|
||||
|
||||
/** Get access to the css resource during gwt compilation */
|
||||
@Source("baseIcons.css")
|
||||
CssResource css();
|
||||
|
||||
public static final GNAImages ICONS = GWT.create(GNAImages.class);
|
||||
|
||||
/** Our sample image icon. Makes the image resource for the gwt-compiler's css composer accessible */
|
||||
@Source("map.png")
|
||||
ImageResource map();
|
||||
|
||||
@Source("preset_location.png")
|
||||
ImageResource preset_location();
|
||||
|
||||
@Source("layers.png")
|
||||
ImageResource layers();
|
||||
|
||||
@Source("loading.gif")
|
||||
ImageResource loading();
|
||||
|
||||
@Source("map-marker-icon.png")
|
||||
ImageResource mapMarkerIcon();
|
||||
|
||||
@Source("icon_share.png")
|
||||
ImageResource shareIcon();
|
||||
|
||||
@Source("italy.png")
|
||||
ImageResource italyIcon();
|
||||
|
||||
@Source("world.png")
|
||||
ImageResource worldIcon();
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
public interface Images extends ClientBundle {
|
||||
|
||||
public static final Images ICONS = GWT.create(Images.class);
|
||||
|
||||
@Source("loading.gif")
|
||||
ImageResource loading();
|
||||
|
||||
@Source("map-marker-icon.png")
|
||||
ImageResource mapMarkerIcon();
|
||||
|
||||
@Source("icon_share.png")
|
||||
ImageResource shareIcon();
|
||||
|
||||
@Source("italy.png")
|
||||
ImageResource italyIcon();
|
||||
|
||||
@Source("world.png")
|
||||
ImageResource worldIcon();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/* Prevent our icons from css obfuscation */
|
||||
@external .myBaseIcon_*; /* Do some css stuff */
|
||||
@sprite .myBaseIcon_map {
|
||||
gwt-image: "map";
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 17px !important;
|
||||
height: 17px !important;
|
||||
}
|
||||
|
||||
@sprite .myBaseIcon_preset_location {
|
||||
gwt-image: "preset_location";
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 17px !important;
|
||||
height: 17px !important;
|
||||
}
|
||||
|
||||
@sprite .myBaseIcon_layers {
|
||||
gwt-image: "layers";
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 17px !important;
|
||||
height: 17px !important;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 403 B |
Binary file not shown.
After Width: | Height: | Size: 465 B |
Binary file not shown.
After Width: | Height: | Size: 500 B |
Binary file not shown.
After Width: | Height: | Size: 581 B |
Binary file not shown.
After Width: | Height: | Size: 683 B |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,111 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.server;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer.OL_BASE_MAP;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class GNABaseMapsResourceReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 18, 2021
|
||||
*/
|
||||
public class GNABaseMapsResourceReader {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(GNABaseMapsResourceReader.class);
|
||||
|
||||
private static final String SE_PROFILE_NAME = "GNABaseMaps";
|
||||
private static final String SE_CATEGORY_NAME = "Application";
|
||||
|
||||
/**
|
||||
* Gets the list base maps.
|
||||
*
|
||||
* @return the list base maps
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static List<BaseMapLayer> getListBaseMaps() throws Exception {
|
||||
|
||||
List<BaseMapLayer> lstBaseMaps = new ArrayList<BaseMapLayer>();
|
||||
|
||||
LOG.info("Searching SE in the scope: " + ScopeProvider.instance.get() + " with profile name: " + SE_PROFILE_NAME
|
||||
+ " and category name: " + SE_CATEGORY_NAME);
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Name/text() eq '" + SE_PROFILE_NAME + "'");
|
||||
query.addCondition("$resource/Profile/Category/text() eq '" + SE_CATEGORY_NAME + "'");
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
List<ServiceEndpoint> resources = client.submit(query);
|
||||
|
||||
if (resources.size() > 0)
|
||||
LOG.info("The query returned " + resources.size() + " ServiceEndpoint/s");
|
||||
else
|
||||
throw new RuntimeException("ServiceEndpoint not found. Searching for profile name: " + SE_PROFILE_NAME
|
||||
+ " and category name: " + SE_CATEGORY_NAME + ", in the scope: " + ScopeProvider.instance.get());
|
||||
|
||||
ServiceEndpoint se = resources.get(0);
|
||||
Collection<AccessPoint> theAccessPoints = se.profile().accessPoints().asCollection();
|
||||
for (AccessPoint accessPoint : theAccessPoints) {
|
||||
BaseMapLayer bml = new BaseMapLayer();
|
||||
bml.setName(accessPoint.name());
|
||||
bml.setAttribution(accessPoint.description());
|
||||
String url = accessPoint.address();
|
||||
String apiTokenName = accessPoint.username();
|
||||
String apiTokenPwd = accessPoint.password();
|
||||
LOG.debug("Found API_TOKEN name: " + apiTokenName + ", encrypted token: " + apiTokenPwd);
|
||||
// decrypting the pwd
|
||||
try {
|
||||
if (isValorized(apiTokenPwd)) {
|
||||
apiTokenPwd = StringEncrypter.getEncrypter().decrypt(apiTokenPwd);
|
||||
LOG.debug("Token decrypted is: " + apiTokenPwd.substring(0, apiTokenPwd.length() / 2)
|
||||
+ "_MASKED_TOKEN_");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error on decrypting the pwd: ", e);
|
||||
}
|
||||
if (isValorized(apiTokenName) && isValorized(apiTokenPwd)) {
|
||||
url = String.format("%s?%s=%s", url, apiTokenName, apiTokenPwd);
|
||||
}
|
||||
bml.setUrl(url);
|
||||
|
||||
// SETTING MAP TYPE
|
||||
String urlLower = bml.getUrl().toLowerCase();
|
||||
if (urlLower.contains("mapbox")) {
|
||||
bml.setType(OL_BASE_MAP.MAPBOX);
|
||||
} else if (urlLower.contains("openstreetmap")) {
|
||||
bml.setType(OL_BASE_MAP.OSM);
|
||||
} else
|
||||
bml.setType(OL_BASE_MAP.OTHER);
|
||||
|
||||
lstBaseMaps.add(bml);
|
||||
}
|
||||
|
||||
LOG.debug("Read base maps: "+lstBaseMaps);
|
||||
LOG.info("Returning " + lstBaseMaps.size() + " base maps");
|
||||
return lstBaseMaps;
|
||||
|
||||
}
|
||||
|
||||
private static boolean isValorized(String value) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class BaseMapLayer.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 11, 2021
|
||||
*/
|
||||
public class BaseMapLayer implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6204769725053516674L;
|
||||
|
||||
/**
|
||||
* The Enum OL_BASE_MAP.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 11, 2021
|
||||
*/
|
||||
public static enum OL_BASE_MAP {
|
||||
OSM, MAPBOX, OTHER
|
||||
};
|
||||
|
||||
private String name;
|
||||
private String url;
|
||||
private String attribution;
|
||||
private OL_BASE_MAP type;
|
||||
|
||||
/**
|
||||
* Instantiates a new base map layer.
|
||||
*/
|
||||
public BaseMapLayer() {
|
||||
|
||||
}
|
||||
|
||||
public BaseMapLayer(String name, String url, String attribution, OL_BASE_MAP type) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.attribution = attribution;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getAttribution() {
|
||||
return attribution;
|
||||
}
|
||||
|
||||
public OL_BASE_MAP getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setAttribution(String attribution) {
|
||||
this.attribution = attribution;
|
||||
}
|
||||
|
||||
public void setType(OL_BASE_MAP type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("BaseMapLayer [name=");
|
||||
builder.append(name);
|
||||
builder.append(", url=");
|
||||
builder.append(url);
|
||||
builder.append(", attribution=");
|
||||
builder.append(attribution);
|
||||
builder.append(", type=");
|
||||
builder.append(type);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GNABaseMaps {
|
||||
|
||||
private static final String SCOPE = "/gcube/devsec/devVRE";
|
||||
|
||||
@Test
|
||||
public void readBaseMaps() {
|
||||
System.out.println("called readBaseMaps test");
|
||||
ScopeProvider.instance.set(SCOPE);
|
||||
GNABaseMapsResourceReader gnaBaseMapsR = new GNABaseMapsResourceReader();
|
||||
List<BaseMapLayer> lstBML = null;
|
||||
try {
|
||||
lstBML = gnaBaseMapsR.getListBaseMaps();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Read base map layers: " + lstBML);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue