added the recordId for the QueryDataEvent

This commit is contained in:
Francesco Mangiacrapa 2020-11-25 18:44:09 +01:00
parent a4b38a3dfc
commit e2034659f2
7 changed files with 101 additions and 64 deletions

62
pom.xml
View File

@ -49,31 +49,31 @@
</developer>
</developers>
<dependencyManagement>
<!-- <dependencies> -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.distribution</groupId> -->
<!-- <artifactId>maven-portal-bom</artifactId> -->
<!-- <version>3.6.0</version> -->
<!-- <type>pom</type> -->
<!-- <scope>import</scope> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-user</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-servlet</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-dev</artifactId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
<!-- </dependencies> -->
</dependencyManagement>
<!-- <dependencyManagement> -->
<!-- <dependencies> -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.distribution</groupId> -->
<!-- <artifactId>maven-portal-bom</artifactId> -->
<!-- <version>3.6.0</version> -->
<!-- <type>pom</type> -->
<!-- <scope>import</scope> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-user</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-servlet</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-dev</artifactId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
<!-- </dependencies> -->
<!-- </dependencyManagement> -->
<dependencies>
<dependency>
@ -128,12 +128,6 @@
<version>[1.1.0, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.portlets.user</groupId> -->
<!-- <artifactId>gcube-url-shortener</artifactId> -->
<!-- <version>[1.0.0,2.0.0-SNAPSHOT)</version> -->
<!-- <scope>compile</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
@ -211,9 +205,9 @@
<version>${gwt.version}</version>
<executions>
<execution>
<configuration>
<style>${gwt.compiler.style}</style>
</configuration>
<!-- <configuration> -->
<!-- <style>${gwt.compiler.style}</style> -->
<!-- </configuration> -->
<goals>
<goal>compile</goal>
<!-- <goal>test</goal> -->

View File

@ -247,6 +247,8 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
//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));
@ -256,7 +258,7 @@ public class GeoportalDataViewer implements EntryPoint {
Double y = concessioneDV.getCentroidLat();
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord));
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId()));
}
}

View File

@ -93,6 +93,8 @@ public class LayerManager {
if(queryEvent.getGeoQuery()!=null) {
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
Long recordId = queryEvent.getRecordId();
GWT.log("("+selectDataInfo.getX1()+","+selectDataInfo.getY1()+")("+selectDataInfo.getX2()+","+selectDataInfo.getY2()+")");
for (LayerObject layerObj : layerObjects){
@ -162,7 +164,29 @@ public class LayerManager {
//USING ONLY THE FIRST FEATURE IN THE LIST
if(features!=null && features.size()>0) {
feature = features.get(0);
//I need to show exaclty the feature with produc_id == recordId
if(recordId!=null) {
for (FeatureRow fRow : features) {
List<String> productIdLst = fRow.getMapProperties().get("product_id");
String thePID = productIdLst.get(0);
try {
long productId = Long.parseLong(thePID);
if(productId==recordId) {
feature = fRow;
GWT.log("Found recorId == product_id with id: "+productId);
break;
}
}catch (Exception e) {
// TODO: handle exception
}
}
}
//If recordId not passed, I'm using the first feature returned
if(feature==null)
feature = features.get(0);
Map<String, List<String>> entries = feature.getMapProperties();
String nome = "";

View File

@ -66,7 +66,7 @@ public class OLMapManager {
// }
GeoQuery select = toDataPointQuery(coordinate);
layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate));
layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null));
}
@ -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()));
layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null));
}
}
else if(zoomStart!=null && zoomEnd!=null) {

View File

@ -17,15 +17,16 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>();
private GeoQuery select;
private Coordinate oLCoordinate;
private Long recordId;
/**
* Instantiates a new table row selected event.
* @param coordinate
*/
public QueryDataEvent(GeoQuery select, Coordinate coordinate) {
public QueryDataEvent(GeoQuery select, Coordinate coordinate, Long recordId) {
this.select = select;
this.oLCoordinate = coordinate;
this.recordId = recordId;
}
/**
@ -37,6 +38,16 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public Type<QueryDataEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Gets the record id.
*
* @return the record id
*/
public Long getRecordId() {
return recordId;
}
/**
* Dispatch.

View File

@ -156,7 +156,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
}
geoDAO.setSourceLayerObject(layerObject);
LOG.info("Fo layer name: "+layerObject.getLayerItem().getName() +" got "+features.size()+" feature/s");
LOG.info("For layer name: "+layerObject.getLayerItem().getName() +" got "+features.size()+" feature/s");
listDAO.add(geoDAO);
}
LOG.info("returning "+listDAO+" geona data objects");
@ -173,9 +173,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
*/
@Override
public List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception{
LOG.info("getConcessioneForId "+id+ "called");
LOG.info("getUploadedImagesForId "+id+ " called");
if(itemType==null)
throw new Exception("Invalid parameter. The itemType is null");
@ -185,27 +184,29 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
List<UploadedImageDV> listUI = null;
try {
LOG.info("Trying to get record for id "+id);
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
ConcessioniManager concessioniManager = new ConcessioniManager();
Concessione record = concessioniManager.getById(id+"");
//AbstractRecordManager<Record> abmRecord = ManagerFactory.getByRecordID(id);
Concessione concessione = null;
if (record != null) {
concessione = (Concessione) record;
List<UploadedImage> images = concessione.getImmaginiRappresentative();
if (images != null) {
listUI = new ArrayList<UploadedImageDV>();
int max = maxImages < images.size() ? maxImages : images.size();
for (int i = 0; i < max; i++) {
UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i));
listUI.add(ui);
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
if(itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id "+id);
ConcessioniManager concessioniManager = new ConcessioniManager();
Concessione concessione = concessioniManager.getById(id+"");
if (concessione != null) {
LOG.info("For id "+id+", got concessione "+concessione.getNome() +" from service");
List<UploadedImage> images = concessione.getImmaginiRappresentative();
if (images != null) {
listUI = new ArrayList<UploadedImageDV>();
int max = maxImages < images.size() ? maxImages : images.size();
for (int i = 0; i < max; i++) {
UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i));
listUI.add(ui);
}
LOG.info("For id "+id+", got "+listUI.size() +" image/s");
}
}
}else
throw new Exception("Concessione with id: "+id +" not available");
}
@ -257,7 +258,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
if(concessionDV==null)
throw new Exception("Concessione not retrieved");
throw new Exception("Concessione with id: "+id +" not available");
return concessionDV;

View File

@ -29,7 +29,12 @@ public class GetConcessione {
try {
LOG.info("Trying to get record for id "+id);
Concessione concessione = new ConcessioniManager().getById(id+"");
LOG.info("Got concessione for id "+id);
LOG.info("For id "+id+", got concessione "+concessione);
LOG.info("Immagini Rappresentative are: "+concessione.getImmaginiRappresentative());
LOG.info("Relazione scavo: "+concessione.getRelazioneScavo());
LOG.info("Pianta Fine scavo: "+concessione.getPianteFineScavo());
LOG.info("Posizionamento scavo: "+concessione.getPosizionamentoScavo());
if(concessione !=null) {
concessionDV = ConvertToDataViewModel.toConcessione(concessione);
}