Integrated with spatialReference. Setting the IndexFlag according to

user logged-in or not
This commit is contained in:
Francesco Mangiacrapa 2022-10-27 15:09:07 +02:00
parent 56f3c29d6d
commit b3345a4b5f
12 changed files with 261 additions and 130 deletions

View File

@ -198,7 +198,6 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>

View File

@ -7,6 +7,7 @@ import java.util.Set;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
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.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
@ -403,8 +404,24 @@ public class GeoportalDataViewer implements EntryPoint {
if (record != null) {
this.cancel();
GWT.log("cancelled timer");
performWFSQueryOnCentroid(record.getTheProjectDV().getId(),
record.getCentroidLong(), record.getCentroidLat());
GeoJSON spatialReference = record.getTheProjectDV().getSpatialReference();
if (spatialReference == null) {
GWT.log("No spatial reference found, cancelling timer");
this.cancel();
}
try {
ExtentWrapped ew = new ExtentWrapped(spatialReference.getBbox().getMinX(),
spatialReference.getBbox().getMinY(),
spatialReference.getBbox().getMaxX(),
spatialReference.getBbox().getMaxY());
Coordinate centerCoordinate = ew.getCenter();
performWFSQueryOnCentroid(record.getTheProjectDV().getId(),
centerCoordinate.getX(), centerCoordinate.getY());
} catch (Exception e) {
GWT.log("Error on calculating center of the extent " + e.getMessage());
}
}
if (attempt > MAX_RETRY) {
@ -562,7 +579,7 @@ public class GeoportalDataViewer implements EntryPoint {
List<? extends DocumentDV> result = searchPerformedEvent.getData();
if (result != null && result.size() > 0) {
String cqlFilter = GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE+" IN(";
String cqlFilter = GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE + " IN(";
for (DocumentDV documentDV : result) {
cqlFilter += "'" + documentDV.getProjectID() + "',";
}
@ -602,7 +619,7 @@ public class GeoportalDataViewer implements EntryPoint {
// }-*/;
private void performWFSQueryOnCentroid(String projectID, Double centroidLong, Double centroidLat) {
GWT.log("Perform performWFSQueryOnCentroid: "+projectID+ " long: "+centroidLong + ", lat: "+centroidLat);
GWT.log("Perform performWFSQueryOnCentroid: " + projectID + " long: " + centroidLong + ", lat: " + centroidLat);
if (projectID != null) {
Double x = centroidLong;
Double y = centroidLat;

View File

@ -1,5 +1,9 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import com.google.gwt.core.client.GWT;
import ol.Collection;
import ol.Coordinate;
import ol.control.Attribution;
@ -10,50 +14,46 @@ import ol.control.ZoomSlider;
import ol.geom.LineString;
import ol.proj.Projection;
/**
* The Class MapUtils.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 12, 2020
* Nov 12, 2020
*/
public final class MapUtils {
/**
* Creates some default controls and adds it to the collection.
*
* @param controls collection with controls
*/
public static void addDefaultControls(final Collection<Control> controls) {
/**
* Creates some default controls and adds it to the collection.
*
* @param controls collection with controls
*/
public static void addDefaultControls(final Collection<Control> controls) {
controls.push(new FullScreen());
controls.push(new ZoomSlider());
MousePosition mousePosition = new MousePosition();
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
controls.push(mousePosition);
controls.push(new FullScreen());
controls.push(new ZoomSlider());
MousePosition mousePosition = new MousePosition();
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
controls.push(mousePosition);
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
controls.push(attribution);
//controls.push(new ZoomToExtent());
// controls.push(new ZoomToExtent());
}
}
/**
* Transform coordiante.
*
* @param centerCoordinate the center coordinate
* @param source the source
* @param target the target
* @param source the source
* @param target the target
* @return the coordinate
*/
public static Coordinate transformCoordiante(Coordinate centerCoordinate, String source, String target) {
return Projection.transform(centerCoordinate, source, target);
}
/**
* Distance between centroid.
@ -63,10 +63,9 @@ public final class MapUtils {
* @return the long
*/
public static long distanceBetweenCentroid(ExtentWrapped ex1, ExtentWrapped ex2) {
return distanceBetween(ex1.getCenter(),ex2.getCenter());
return distanceBetween(ex1.getCenter(), ex2.getCenter());
}
/**
* Distance between.
*
@ -84,15 +83,43 @@ public final class MapUtils {
// GWT.log("Line length is: "+ls);
return Math.round(ls.getLength() * 100) / 100;
}
/**
* Reverse coordinate.
*
* @param coord the coord
* @return the coordinate
*/
public static Coordinate reverseCoordinate(Coordinate coord){
public static Coordinate reverseCoordinate(Coordinate coord) {
return new Coordinate(coord.getY(), coord.getX());
}
/**
* Geo JSONT to B box center.
*
* @param spatialReference the spatial reference
* @param transforFrom the transfor from
* @param transformTo the transform to
* @return the coordinate
*/
public static Coordinate geoJSONTToBBoxCenter(GeoJSON spatialReference, String transforFrom, String transformTo) {
try {
if (spatialReference != null) {
ExtentWrapped ew = new ExtentWrapped(spatialReference.getBbox().getMinX(),
spatialReference.getBbox().getMinY(), spatialReference.getBbox().getMaxX(),
spatialReference.getBbox().getMaxY());
Coordinate center = ew.getCenter();
if (transforFrom != null && transformTo != null)
center = transformCoordiante(center, transforFrom, transformTo);
return center;
}
} catch (Exception e) {
GWT.log("geoJSONTToBBoxCenter error: " + e.getMessage());
}
return null;
}
}

View File

@ -196,13 +196,18 @@ public class GeonaDataViewMainPanel extends Composite {
//navLink.setText(ucd.getName());
navLink.addClickHandler(new ClickHandler() {
private SearchFacilityUI currentSearchFacility;
@Override
public void onClick(ClickEvent event) {
if(this.currentSearchFacility!=null)
this.currentSearchFacility.resetCurrentSearch();
searchFacilityPanel.clear();
SearchFacilityUI searchFacility = new SearchFacilityUI(ucd.getProfileID(), applicationBus, sortByFields, searchByFields,
this.currentSearchFacility = new SearchFacilityUI(ucd.getProfileID(), applicationBus, sortByFields, searchByFields,
initialSortFilter);
searchFacilityPanel.add(searchFacility);
searchFacility.setSearchButton(searchFacilityButton);
searchFacilityPanel.add(currentSearchFacility);
currentSearchFacility.setSearchButton(searchFacilityButton);
}
});

View File

@ -3,12 +3,15 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
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.OLUtil;
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.ui.ModalWindow;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
@ -56,7 +59,7 @@ public class ProjectViewer extends Composite {
@UiField
Button expandButton;
@UiField
Button relationshipsButton;
@ -81,8 +84,8 @@ public class ProjectViewer extends Composite {
this(geoportalItemRefs, projectView, true, true);
}
public ProjectViewer(GeoportalItemReferences geoportalItemRefs, final ProjectView projectView, boolean viewImageButtonVisible,
boolean openImageButtonVisible) {
public ProjectViewer(GeoportalItemReferences geoportalItemRefs, final ProjectView projectView,
boolean viewImageButtonVisible, boolean openImageButtonVisible) {
this();
GWT.log("Rendering " + projectView.getTheProjectDV().getId());
this.theProjectView = projectView;
@ -92,7 +95,7 @@ public class ProjectViewer extends Composite {
final String theTitle = projectView.getTheProjectDV().getProfileName() != null
? projectView.getTheProjectDV().getProfileName()
: "Project ID: "+projectView.getTheProjectDV().getId();
: "Project ID: " + projectView.getTheProjectDV().getId();
headerPanel.add(new HTML(theTitle));
@ -118,7 +121,8 @@ public class ProjectViewer extends Composite {
@Override
public void onClick(ClickEvent event) {
ProjectViewer cv = new ProjectViewer(geoportalItemReferences, theProjectView, false, openImageButtonVisible);
ProjectViewer cv = new ProjectViewer(geoportalItemReferences, theProjectView, false,
openImageButtonVisible);
cv.setExpandViewButtonVisible(false);
int width = Window.getClientWidth() * 75 / 100;
int height = Window.getClientHeight() * 70 / 100;
@ -130,17 +134,16 @@ public class ProjectViewer extends Composite {
}
});
relationshipsButton.setType(ButtonType.LINK);
relationshipsButton.setIcon(IconType.LINK);
relationshipsButton.setTitle("Show Relationships of this Project");
List<RelationshipDV> relationships = projectView.getTheProjectDV().getRelationships();
if(relationships!=null && relationships.size()>0) {
if (relationships != null && relationships.size() > 0) {
relationshipsButton.setVisible(true);
}else
} else
relationshipsButton.setVisible(false);
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
@ -170,19 +173,21 @@ public class ProjectViewer extends Composite {
MapView mapView = new MapView(transformedCenterCoordinate,
GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px");
if (theProjectView != null && theProjectView.getCentroidLat() != null
&& theProjectView.getCentroidLong() != null) {
Coordinate coord = new Coordinate(theProjectView.getCentroidLong(), theProjectView.getCentroidLat());
Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(),
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());
// Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord);
boolean authenticatedUser = myLogin != null ? true : false;
mapView.addMarker(transfCoord, authenticatedUser);
centroidPanel.add(mapView);
if (transfCoord != null) {
boolean authenticatedUser = myLogin != null ? true : false;
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.getCentroidLong() + ", Long:" + theProjectView.getCentroidLat());
.printJs("I cannot add centroid as maker one or both coordinates are null. Lat: " + theProjectView
+ ", Long:" + theProjectView);
}
}

View File

@ -15,10 +15,13 @@ import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
@ -50,6 +53,8 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
/**
* The Class SearchFacilityUI.
*
@ -224,17 +229,21 @@ public class SearchFacilityUI extends Composite {
@Override
public void onClick(ClickEvent event) {
searchField.setText("");
resetSearch.setVisible(false);
panelResults.clear();
latestResult = null;
appManagerBus.fireEvent(new SearchPerformedEvent(null, true));
setSearchEnabled(false);
resetCurrentSearch();
}
});
}
public void resetCurrentSearch() {
searchField.setText("");
resetSearch.setVisible(false);
panelResults.clear();
latestResult = null;
appManagerBus.fireEvent(new SearchPerformedEvent(null, true));
setSearchEnabled(false);
}
/**
* Sets the search enabled.
*
@ -307,28 +316,42 @@ public class SearchFacilityUI extends Composite {
i = 1;
for (DocumentDV documentDV : result.getData()) {
ResultDocumentDV resultDoc = (ResultDocumentDV) documentDV;
ResultDocumentDV resultDoc = (ResultDocumentDV) documentDV;
NavLink locateOnMap = new NavLink("Show");
locateOnMap.setTitle("Open this project and show details");
locateOnMap.setTitle("Locate this project on Map and show details");
locateOnMap.setIcon(IconType.MAP_MARKER);
locateOnMap.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GeoportalItemReferences gir = new GeoportalItemReferences(documentDV.getProjectID(),
GeoportalItemReferences gir = new GeoportalItemReferences(resultDoc.getProjectID(),
profileID);
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(documentDV, resultDoc.getCentroidLong(), resultDoc.getCentroidLat()));
GeoJSON spatialReference = resultDoc.getSpatialReference();
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, null,
null);
Double centerLong = null;
Double centerLat = null;
if (transfCoord != null) {
centerLong = transfCoord.getX();
centerLat = transfCoord.getY();
}
appManagerBus
.fireEvent(new ShowPopupOnCentroiEvent(resultDoc, centerLong, centerLat));
}
});
//First column
// First column
ft.setWidget(i, 0, locateOnMap);
int j = 0;
//Other columns
// Other columns
for (ItemFieldDV itemField : searchForFields) {
if (j > MAX_COLUMNS_RESULTS) {
@ -336,7 +359,7 @@ public class SearchFacilityUI extends Composite {
}
String firstJsonField = itemField.getJsonFields().get(0);
GWT.log("The json fields is: "+firstJsonField);
GWT.log("The json fields is: " + firstJsonField);
String key = firstJsonField.replace(DEFAULT_DOCUMENT_PROJECTION_NAME + ".", "");
Object value = documentDV.getDocumentAsMap().get(key);
@ -357,7 +380,7 @@ public class SearchFacilityUI extends Composite {
toReturn += "</ul>";
GWT.log("Array returning: " + key + " is instance of: " + value.getClass()
+ " to return: " + toReturn);
toTitle = toDisplayTitle;
objectToRender = StringUtil.ellipsize(toReturn, MAX_TEXT_DIMENSION);
} else {
@ -365,8 +388,8 @@ public class SearchFacilityUI extends Composite {
toTitle = valueStr;
objectToRender = StringUtil.ellipsize(valueStr, MAX_TEXT_DIMENSION);
}
GWT.log("The key is: "+key+" objectToRender is: "+objectToRender);
GWT.log("The key is: " + key + " objectToRender is: " + objectToRender);
HTML htmlValue = new HTML(objectToRender);
htmlValue.setTitle(toTitle);
ft.setWidget(i, ++j, htmlValue);

View File

@ -36,5 +36,8 @@ public class OGCUtils {
// }
}
}
}

View File

@ -20,6 +20,7 @@ import org.bson.Document;
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.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.Projects;
@ -38,9 +39,11 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferencesTYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
@ -692,18 +695,27 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// TODO TO Check index flag should be in configuration or evaluated according to
// user credentials
String toCheckFlag = "internal";
String indexFlag = "public"; //default
GeoportalServiceIdentityProxy gsp = getGeoportalServiceProxy();
if(gsp.isUser()) {
indexFlag = "internal";
LOG.info("user logged - using indexFlag: "+indexFlag);
}else if(gsp.isIAMClient()) {
indexFlag = "public";
LOG.info("user not logged - using indexFlag: "+indexFlag);
}
// TODO constant
coll.setIndexes(new ArrayList());
LOG.debug("Checking if " + u.getId() + " is GIS Indexed. Index flag needed is "
+ toCheckFlag);
+ indexFlag);
for (Index index : ucdConfig.getIndexes()) {
try {
IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
if (toAdd.getFlag().equals(toCheckFlag)) {
if (toAdd.getFlag().equals(indexFlag)) {
coll.getIndexes().add(toAdd);
}
} catch (Exception e) {
@ -1109,7 +1121,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level
* @return the data result
* @throws Exception
* @throws Exception
*/
@Override
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
@ -1120,7 +1132,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
", mapSrsName: " + mapSrsName + ", selectBBOX: " + selectBBOX + ", maxWFSFeature: " + maxWFSFeature
+ ", zoomLevel: " + zoomLevel);
}
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
try {
@ -1168,7 +1180,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// Sets only profileID and profileName into ProjectDV
if (layerObject.getProjectDV() == null) {
ProjectDV projectDV = minimaProjectDV(profileID, projectID);
ProjectDV projectDV = minimalProjectDV(profileID, projectID);
layerObject.setProjectDV(projectDV);
}
}
@ -1191,10 +1203,15 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// Mininal set of info for displaying into popup
if (layerObject.getProjectDV() == null) {
ProjectDV projectDV = minimaProjectDV(layerObject.getProfileID(),
ProjectDV projectDV = minimalProjectDV(layerObject.getProfileID(),
layerObject.getProjectID());
layerObject.setProjectDV(projectDV);
}
if(layerObject.getProjectDV().getSpatialReference()==null) {
GeoJSON geoJson = spatialReference(layerObject.getProfileID(), layerObject.getProjectID());
layerObject.getProjectDV().setSpatialReference(geoJson);
}
if (layerObject.getProjectDV().getTheDocument() == null) {
try {
@ -1225,19 +1242,19 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
}
} catch (Exception e) {
String erroMsg = "Error occurred on getting data results";
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
LOG.info("returning " + listDAO + " geona data objects");
return listDAO;
}
private ProjectDV minimaProjectDV(String profileID, String projectID) {
private ProjectDV minimalProjectDV(String profileID, String projectID) {
LOG.trace("minimalProjectDV for profileID: " + profileID + ", projectID: " + projectID + "called");
QueryRequest request = new QueryRequest();
request.setFilter(
@ -1264,6 +1281,23 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return projectDV;
}
private GeoJSON spatialReference(String profileID, String projectID) {
LOG.trace("spatialReference for profileID: " + profileID + ", projectID: " + projectID + "called");
try {
List<IdentificationReference> listIR = projects(profileID).build().getById(projectID)
.getIdentificationReferenceByType(IdentificationReferencesTYPE.SPATIAL_REFERENCE.getType());
if (listIR != null && !listIR.isEmpty()) {
String _identificationReferenceString = listIR.get(0).toJson(); // one expected
LOG.debug("converting for profileID: " + profileID + ", projectID: " + projectID + "called");
return ConvertToDataValueObjectModel.toSpatialReference(_identificationReferenceString);
}
} catch (Exception e1) {
// silent
}
return new GeoJSON();
}
/**
* Gets the entry sets document for project ID.
*

View File

@ -22,6 +22,10 @@ public class GeoportalServiceIdentityProxy {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalServiceIdentityProxy.class);
private GcubeIdentity gCubeIdentity;
private boolean isUser = false;
private boolean isIAMClient = false;
/**
* Instantiates a new concessioni mongo service proxy.
@ -42,48 +46,23 @@ public class GeoportalServiceIdentityProxy {
username = null; // to be sure that is null and not empty string
}
if (username != null) {
isUser = true;
LOG.info("User detected, using its identity");
gCubeIdentity = new UserIdentity();
} else {
isIAMClient = true;
LOG.info("User not detected, using IAM Client identity");
gCubeIdentity = new IAMClientIdentity();
}
gCubeIdentity.setIdentity(request);
}
// /**
// * Gets the project by ID.
// *
// * @param profileID the profile ID
// * @param projectID the project ID
// * @return the project by ID
// * @throws Exception the exception
// */
// public ProjectDV getProjectByID(String profileID, String projectID) throws Exception {
// ProjectsCaller clientPrj = GeoportalClientCaller.projects();
// Project theProject = clientPrj.getProjectByID(profileID, projectID);
// ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
// return ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
// /*
// * try { // Obtain the client ConcessioniMongoService concessioniManager = new
// * ConcessioniMongoService(); // Returning item by Id return
// * concessioniManager.getItemById(mongoItemId); }catch(Exception e) {
// * LOG.error("Error on reading itemById: "+mongoItemId, e); throw(e); }finally {
// * gCubeIdentity.resetIdentity(); }
// */
// }
// /**
// * Gets the UCD by ID.
// *
// * @param profileID the profile ID
// * @return the UCD by ID
// * @throws Exception the exception
// */
// public UseCaseDescriptorDV getUCDByID(String profileID) throws Exception {
// UseCaseDescriptorCaller ucdCaller = GeoportalClientCaller.useCaseDescriptors();
// UseCaseDescriptor ucd = ucdCaller.getUCDForId(profileID);
// return ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null);
// }
public boolean isUser() {
return isUser;
}
public boolean isIAMClient() {
return isIAMClient;
}
}

View File

@ -15,6 +15,7 @@ public abstract class ContextRequest<T> {
private static final Logger LOG = LoggerFactory.getLogger(ContextRequest.class);
private static List<Runnable> preoperations = new ArrayList<>();
private GeoportalServiceIdentityProxy geoportalServiceProxy;
public static void addPreoperation(Runnable preoperation) {
preoperations.add(preoperation);
@ -35,7 +36,7 @@ public abstract class ContextRequest<T> {
r.run();
}
new GeoportalServiceIdentityProxy(request);
geoportalServiceProxy = new GeoportalServiceIdentityProxy(request);
LOG.debug("Context is " + SessionUtil.getCurrentContext(request, true));
LOG.debug("Context is " + SessionUtil.getCurrentToken(request, true) == null ? null : "***");
LOG.trace("Executing actual method..");
@ -53,6 +54,10 @@ public abstract class ContextRequest<T> {
public T getResult() {
return result;
}
public GeoportalServiceIdentityProxy getGeoportalServiceProxy() {
return geoportalServiceProxy;
}
protected abstract T run() throws Exception, ControlledError;
}

View File

@ -37,11 +37,4 @@ public class ViewerConfiguration implements Serializable {
public void setAvailableCollections(Map<String, GCubeCollection> availableCollections) {
this.availableCollections = availableCollections;
}
// TODO
// public List<String> displayedCollections;
//
//
// public Map<String,String> selectedProjects;
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.bson.Document;
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.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
@ -13,6 +14,9 @@ import org.gcube.application.geoportalcommon.ProjectDVBuilder;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
import org.gcube.application.geoportalcommon.geoportal.util.GisUtil;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.Crs;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
@ -20,7 +24,9 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.Geoportal_JSON_Mapper;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
/**
* The Class GeoportalViewer_Tests.
@ -39,10 +45,10 @@ public class GeoportalViewer_Tests {
// private static String TOKEN = ""; //preVRE
private static String CONTEXT = "/gcube/devsec/devVRE";
private static String TOKEN = ""; // devVRE
private static String TOKEN = "c41a00c0-7897-48d2-a67a-05190d6ce5e6-98187548"; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "634fc41ecd343e6571ed3db0";
private static String PROJECT_ID = "6356ad1dde985906377eef3f";
private static String USERNAME = "francesco.mangiacrapa";
@ -110,7 +116,42 @@ public class GeoportalViewer_Tests {
}
//@Test
@Test
public void getSpatialReference() {
System.out.println("getSpatialReference [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called");
try {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
Project project = clientProjects.getProjectByID(PROFILE_ID, PROJECT_ID);
List<IdentificationReference> itentificationReference = project.getIdentificationReferences();
for (IdentificationReference identificationReference : itentificationReference) {
String geoJSON = identificationReference.get("geoJSON").toString();
JSONObject jsonObject = new JSONObject(geoJSON);
GeoJSON geoJson = new GeoJSON();
geoJson.setType(jsonObject.getString("type"));
geoJson.setBbox(GisUtil.fromJSONArray(jsonObject.getJSONArray("bbox")));
Crs crs = org.gcube.application.geoportal.client.utils.Serialization
.convert(jsonObject.getJSONObject("crs").toString(), Crs.class);
geoJson.setCrs(crs);
geoJson.setGeoJSON(geoJSON);
System.out.println(geoJson);
}
} catch (Exception e) {
String erroMsg = "getSpatialReference not available for profileID " + PROFILE_ID + " with projectID "
+ PROJECT_ID;
System.out.println(erroMsg);
e.printStackTrace();
}
}
// @Test
public void getImagesForId() {
System.out.println("getImagesForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called");
@ -137,8 +178,8 @@ public class GeoportalViewer_Tests {
}
}
//@Test
// @Test
public void testUCDQuery() {
QueryRequest request = new QueryRequest();
request.setFilter(