Merge pull request '1.0.7' (#6) from 1.0.7 into master

This commit is contained in:
Fabio Sinibaldi 2020-12-07 17:05:20 +01:00
commit 3e01305eaa
11 changed files with 95 additions and 26 deletions

View File

@ -2,6 +2,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.application.geoportal-logic
## [v1.0.7] - 2020-12-7
Concessione : Automatic coordinates from posizionamento scavo
## [v1.0.6-SNAPSHOT] - 2020-12-4
Fix layer coordinates
Geoserver folder management
## [v1.0.5] - 2020-12-1
Deletion feature

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-logic</artifactId>
<version>1.0.5</version>
<version>1.0.7</version>
<name>Geoportal Logic</name>

View File

@ -179,13 +179,13 @@ public abstract class AbstractRecordManager<T extends Record> {
contentHandler.publish();
commit();
transaction.begin();
log.debug("Registering centroid of "+theRecord);
registerCentroid();
// storeInfo();
commit();
}
log.debug("Successufully committing "+theRecord);
return theRecord;
}catch(ValidationException | PublishException | PersistenceException e) {
@ -197,6 +197,7 @@ public abstract class AbstractRecordManager<T extends Record> {
private void commit() {
log.debug("Successufully committing "+theRecord);
entityManager.flush();
entityManager.clear();
transaction.commit();

View File

@ -214,6 +214,28 @@ public class ConcessioneManager extends AbstractRecordManager<Concessione> {
centroidsRow.put(DBConstants.Concessioni.ANNO, record.getDataInizioProgetto().getYear()+"");
centroidsRow.put(DBConstants.Concessioni.NOME, record.getNome());
centroidsRow.put(DBConstants.Concessioni.REGIONE, ""); //TODO
if(record.getCentroidLat()==null||record.getCentroidLat()==0)
try {
log.debug("Evaluating Centroid latitude for record "+record);
record.setCentroidLat((record.getPosizionamentoScavo().getBbox().getMaxLat()+
record.getPosizionamentoScavo().getBbox().getMinLat())/2);
}catch (Throwable t) {
log.warn("Unable to evaluate centroid latitude "+t);
}
if(record.getCentroidLong()==null||record.getCentroidLong()==0)
try {
log.debug("Evaluating Centroid Longituted for record "+record);
record.setCentroidLong((record.getPosizionamentoScavo().getBbox().getMaxLong()+
record.getPosizionamentoScavo().getBbox().getMinLong())/2);
}catch (Throwable t) {
log.warn("Unable to evaluate centroid latitude "+t);
}
centroidsRow.put(DBConstants.Defaults.XCOORD_FIELD, record.getCentroidLong()+"");
centroidsRow.put(DBConstants.Defaults.YCOORD_FIELD, record.getCentroidLat()+"");

View File

@ -197,11 +197,11 @@ public class Concessione extends Record{
validator.checkMandatory(authors, "Lista Autori");
if(validator.checkMandatory(centroidLat, "Latitudine"))
if(centroidLat>90||centroidLat<-90) validator.addMessage(ValidationStatus.ERROR, "Latitudine non valida : "+centroidLat);
if(validator.checkMandatory(centroidLong, "Longitudine"))
if(centroidLong>180||centroidLong<-180) validator.addMessage(ValidationStatus.ERROR, "Longitudine non valida : "+centroidLong);
// if(validator.checkMandatory(centroidLat, "Latitudine"))
// if(centroidLat>90||centroidLat<-90) validator.addMessage(ValidationStatus.ERROR, "Latitudine non valida : "+centroidLat);
//
// if(validator.checkMandatory(centroidLong, "Longitudine"))
// if(centroidLong>180||centroidLong<-180) validator.addMessage(ValidationStatus.ERROR, "Longitudine non valida : "+centroidLong);
validator.checkMandatory(contributore, "Contributore");
if(validator.checkMandatory(dataFineProgetto, "Data Fine Progetto") &&
@ -273,6 +273,8 @@ public class Concessione extends Record{
public void setDefaults() {
super.setDefaults();
setCentroidLat(centroidLat);
setDescrizioneContenuto(ConstraintCheck.defaultFor(getDescrizioneContenuto(),
"Relazione di fine scavo e relativo abstract; selezione di immagini rappresentative;"
+ " posizionamento topografico dell'area indagata, pianta di fine scavo.").evaluate());

View File

@ -32,6 +32,8 @@ public class LayerConcessione extends SDILayerDescriptor{
//layer
private String layerName;
private String workspace;
@Type(type="text")
private String wmsLink;

View File

@ -22,7 +22,9 @@ public abstract class SDILayerDescriptor extends AssociatedContent{
public abstract void setLayerName(String layerName);
public abstract String getWmsLink();
public abstract void setWmsLink(String wmsLink);
public abstract void setWorkspace(String workspace);
public abstract String getWorkspace();
public abstract BBOX getBbox();
public abstract void setBbox(BBOX toSet);
}

View File

@ -8,6 +8,7 @@ import org.gcube.application.geoportal.model.content.GeoServerContent;
import org.gcube.application.geoportal.model.content.PersistedContent;
import org.gcube.application.geoportal.model.content.WorkspaceContent;
import org.gcube.application.geoportal.model.fault.SDIInteractionException;
import org.gcube.application.geoportal.model.gis.BBOX;
import org.gcube.application.geoportal.model.gis.SDILayerDescriptor;
import org.gcube.application.geoportal.utils.Files;
import org.gcube.common.storagehub.client.dsl.FileContainer;
@ -16,6 +17,7 @@ import org.gcube.data.transfer.library.TransferResult;
import org.gcube.data.transfer.library.faults.RemoteServiceException;
import org.gcube.data.transfer.model.Destination;
import org.gcube.data.transfer.model.DestinationClashPolicy;
import org.gcube.data.transfer.model.RemoteFileDescriptor;
import org.gcube.spatial.data.gis.GISInterface;
import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor;
@ -27,6 +29,7 @@ import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder;
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@ -37,6 +40,7 @@ public class SDIManager {
private GISInterface gis;
@Getter
private DataTransferClient dtGeoServer;
private String geoserverHostName;
@ -61,6 +65,11 @@ public class SDIManager {
}
}
public RemoteFileDescriptor getGeoServerRemoteFolder() throws RemoteServiceException {
return dtGeoServer.getWebClient().getInfo("geoserver/GNA");
}
public String createWorkspace(String toCreate) throws SDIInteractionException {
try {
if(!gis.getCurrentGeoServer().getReader().getWorkspaceNames().contains(toCreate)) {
@ -186,6 +195,11 @@ public class SDIManager {
DEFAULT_CRS,
400,
400));
currentElement.setWorkspace(workspace);
currentElement.setBbox(new BBOX(f.getMaxY(), f.getMaxX(), f.getMinY(), f.getMinX()));
// TODO Metadata
return content;
// } catch (InvalidSourceException | SourceNotSetException | FailedTransferException | InitializationException

View File

@ -1,22 +1,21 @@
package org.gcube.application.geoportal;
import org.gcube.application.geoportal.managers.ConcessioneManager;
import org.gcube.application.geoportal.managers.ManagerFactory;
import org.gcube.application.geoportal.model.concessioni.Concessione;
import org.gcube.application.geoportal.model.fault.ConfigurationException;
import org.gcube.application.geoportal.model.fault.PersistenceException;
import org.gcube.application.geoportal.model.fault.PublishException;
import org.gcube.application.geoportal.model.fault.ValidationException;
import org.gcube.application.geoportal.model.fault.SDIInteractionException;
import org.gcube.application.geoportal.storage.SDIManager;
import org.gcube.application.geoportal.storage.WorkspaceManager;
import org.gcube.application.geoportal.utils.ISUtils;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.data.transfer.library.utils.ScopeUtils;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.data.transfer.library.faults.RemoteServiceException;
import org.gcube.data.transfer.model.RemoteFileDescriptor;
public class CheckContextConfiguration {
public static void main(String[] args) throws ConfigurationException, StorageHubException {
public static void main(String[] args) throws ConfigurationException, StorageHubException, SDIInteractionException, RemoteServiceException {
// TokenSetter.set("/gcube/devNext/NextNext");
// TokenSetter.set("/pred4s/preprod/preVRE");
@ -54,8 +53,19 @@ public class CheckContextConfiguration {
System.out.println(ISUtils.queryForDB("postgis", "Concessioni"));
WorkspaceManager wsManager=new WorkspaceManager(null);
FolderContainer folder=wsManager.getApplicationBaseFolder();
System.out.println("Base folder path : "+folder.get().getPath());
System.out.println("Content : ");
for(Item item:wsManager.getApplicationBaseFolder().list().getItems()) {
System.out.println(item.getName());
}
SDIManager sdiManager=new SDIManager();
RemoteFileDescriptor remoteGSFolder=sdiManager.getGeoServerRemoteFolder();
System.out.println("GS Folder is "+remoteGSFolder);
System.out.println("Base folder path : "+new WorkspaceManager(null).getApplicationBaseFolder().get().getPath());
// System.out.println("Inspecting internal DB ");

View File

@ -2,11 +2,11 @@ package org.gcube.application.geoportal;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import org.gcube.application.geoportal.utils.Files;
import org.geotoolkit.data.DataStore;
import org.geotoolkit.data.DataStoreFactory;
import org.geotoolkit.data.DataStoreFinder;
import org.geotoolkit.storage.DataStoreException;
@ -15,10 +15,19 @@ public class ShapeFilesTest {
public static void main(String[] args) throws MalformedURLException, DataStoreException {
File shp=Files.getFileFromResources("concessioni/pos.shp");
DataStoreFinder.scanForPlugins();
System.out.println("File "+shp.getAbsolutePath()+" : "+shp.getTotalSpace()+"b");
// DataStoreFinder.scanForPlugins();
System.out.println("Factories are");
DataStoreFinder.getAllFactories(null).forEach((DataStoreFactory f)->{
System.out.println(f.getDisplayName()+"\t"+f.getDescription());
});
System.out.println();
DataStore inputDataStore = DataStoreFinder.open(
Collections.singletonMap("url", shp.toURI().toURL()));
System.out.println("Datastore is "+inputDataStore);
System.out.println(inputDataStore.getTypeNames());
}

View File

@ -48,10 +48,10 @@ public class TestModel {
concessione.setParoleChiaveLibere(Arrays.asList(new String[] {"Robba","Stuff"}));
concessione.setParoleChiaveICCD(Arrays.asList(new String[] {"vattelapesca","somthing something"}));
concessione.setCentroidLat(Double.parseDouble("33."+System.currentTimeMillis())); //N-S
concessione.setCentroidLong(Double.parseDouble("11."+System.currentTimeMillis())); //E-W
//
// concessione.setCentroidLat(Double.parseDouble("33."+System.currentTimeMillis())); //N-S
// concessione.setCentroidLong(Double.parseDouble("11."+System.currentTimeMillis())); //E-W
//
return concessione;
}