Compare commits
No commits in common. "master" and "1.0.8" have entirely different histories.
25
CHANGELOG.md
25
CHANGELOG.md
|
@ -2,31 +2,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.application.geoportal-logic
|
||||
|
||||
## [v1.0.15-SNAPSHOT] - 2021-07-29
|
||||
Exposed PostgisDB connection descriptor
|
||||
|
||||
## [v1.0.14] - 2020-12-11
|
||||
Fixes "no transaction" issue
|
||||
|
||||
|
||||
## [v1.0.13] - 2020-12-11
|
||||
Geoserver filename clash
|
||||
Updated model concessioni
|
||||
|
||||
|
||||
## [v1.0.12] - 2020-12-11
|
||||
Fixed missing centroid
|
||||
|
||||
## [v1.0.11] - 2020-12-11
|
||||
Fixed wms url
|
||||
Fixed duplicate posizionamento
|
||||
|
||||
## [v1.0.10] - 2020-12-11
|
||||
Fixed filenames
|
||||
|
||||
## [v1.0.9] - 2020-12-9
|
||||
Exclude gcube 5 libraries
|
||||
|
||||
## [v1.0.8] - 2020-12-9
|
||||
Restrict gis dependencies version
|
||||
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-logic</artifactId>
|
||||
<version>1.0.15-SNAPSHOT</version>
|
||||
<version>1.0.8</version>
|
||||
<name>Geoportal Logic</name>
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>2.0.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -44,8 +44,6 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-csv</artifactId>
|
||||
|
|
|
@ -198,8 +198,8 @@ public abstract class AbstractRecordManager<T extends Record> {
|
|||
|
||||
private void commit() {
|
||||
log.debug("Successufully committing "+theRecord);
|
||||
// entityManager.flush();
|
||||
// entityManager.clear();
|
||||
entityManager.flush();
|
||||
entityManager.clear();
|
||||
transaction.commit();
|
||||
log.debug("Calling postCommit");
|
||||
postcommit();
|
||||
|
@ -228,20 +228,18 @@ public abstract class AbstractRecordManager<T extends Record> {
|
|||
toReturn.addChild(contentHandler.storeChanges());
|
||||
|
||||
commit();
|
||||
|
||||
transaction.begin();
|
||||
|
||||
if(publish) {
|
||||
transaction.begin();
|
||||
toReturn.addChild(contentHandler.publish());
|
||||
commit();
|
||||
|
||||
log.debug("Registering centroid of "+theRecord);
|
||||
transaction.begin();
|
||||
registerCentroid();
|
||||
registerCentroid();
|
||||
toReturn.addMessage(ValidationStatus.PASSED, "Inserito centroide per record "+theRecord.getId());
|
||||
commit();
|
||||
}
|
||||
|
||||
|
||||
log.debug("Committing session for "+theRecord);
|
||||
commit();
|
||||
} catch (PersistenceException e) {
|
||||
toReturn.addChild(e.getReport());
|
||||
log.warn("Unexpected internal exception ",e);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ConcessioneManager extends AbstractRecordManager<Concessione> {
|
|||
}
|
||||
if(getRecord().getPosizionamentoScavo()!=null) {
|
||||
LayerConcessione l=getRecord().getPosizionamentoScavo();
|
||||
// entityManager.createNativeQuery("Update layerconcessione set record_id="+getRecord().getId()+" where id = "+l.getId()).executeUpdate();
|
||||
entityManager.createNativeQuery("Update layerconcessione set record_id="+getRecord().getId()+" where id = "+l.getId()).executeUpdate();
|
||||
if(l.getWmsLink()!=null) {
|
||||
entityManager.createNativeQuery("Update layerconcessione set wmslink='"+l.getWmsLink()+"' where id = "+l.getId()).executeUpdate();
|
||||
// entityManager.createNativeQuery("Update sdilayerdescriptor set wmslink='"+l.getWMSLink()+"' where id = "+l.getId()).executeUpdate();
|
||||
|
@ -84,14 +84,7 @@ public class ConcessioneManager extends AbstractRecordManager<Concessione> {
|
|||
}
|
||||
}
|
||||
|
||||
if(getRecord().getCentroidLat()!=null) {
|
||||
entityManager.createNativeQuery(
|
||||
String.format("Update concessione set centroidlat=%1$f where id=%2$d", getRecord().getCentroidLat(),getRecord().getId())).executeUpdate();
|
||||
}
|
||||
if(getRecord().getCentroidLong()!=null) {
|
||||
entityManager.createNativeQuery(
|
||||
String.format("Update concessione set centroidlong=%1$f where id=%2$d", getRecord().getCentroidLong(),getRecord().getId())).executeUpdate();
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,6 @@ public class RelazioneScavo extends AssociatedContent {
|
|||
@Type(type="text")
|
||||
private String abstractSection;
|
||||
|
||||
@Type(type="text")
|
||||
private String abstractIta;
|
||||
@Type(type="text")
|
||||
private String abstractEng;
|
||||
|
||||
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
@ElementCollection(targetClass=String.class)
|
||||
private List<String> responsabili;
|
||||
|
|
|
@ -131,14 +131,9 @@ public class PostgisDBManager implements PostgisDBManagerI {
|
|||
target.setObjectInPreparedStatement(field, value, stmt, 1);
|
||||
return stmt.executeUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseConnection getConnectionDescriptor() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.geoportal.PostgisDBManagerI#deleteTable(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.gcube.application.geoportal.model.db.DatabaseConnection;
|
||||
import org.gcube.application.geoportal.model.db.PostgisTable;
|
||||
import org.gcube.application.geoportal.model.db.PostgisTable.Field;
|
||||
import org.gcube.application.geoportal.model.db.PostgisTable.POINT;
|
||||
|
@ -38,5 +37,5 @@ public interface PostgisDBManagerI {
|
|||
|
||||
int deleteByFieldValue(PostgisTable target, Field field, Object value) throws SQLException;
|
||||
|
||||
DatabaseConnection getConnectionDescriptor();
|
||||
|
||||
}
|
|
@ -84,7 +84,7 @@ public class SDIManager {
|
|||
}
|
||||
|
||||
|
||||
// GEOSERVER-PERSISTENCE-ID / GNA / PROJECT-ID/ LAYER-ID /FILENAME(no extension)/...
|
||||
// GEOSERVER-PERSISTENCE-ID / GNA / PROJECT-ID/ FILENAME
|
||||
|
||||
public GeoServerContent pushShapeLayerFileSet(SDILayerDescriptor currentElement,String workspace) throws SDIInteractionException{
|
||||
try {
|
||||
|
@ -96,34 +96,27 @@ public class SDIManager {
|
|||
GeoServerContent content=new GeoServerContent();
|
||||
content.setGeoserverHostName(geoserverHostName);
|
||||
content.setWorkspace(workspace);
|
||||
|
||||
WorkspaceManager wsManager=new WorkspaceManager(currentElement.getRecord());
|
||||
|
||||
|
||||
currentElement.getActualContent().forEach((PersistedContent c)->{
|
||||
try {
|
||||
if(c instanceof WorkspaceContent) {
|
||||
WorkspaceContent wc=(WorkspaceContent) c;
|
||||
FileContainer fc=wsManager.getFileById(wc.getStorageID());
|
||||
|
||||
String completeFilename=Files.fixFilename(fc.get().getName());
|
||||
String filename=completeFilename.contains(".")?completeFilename.substring(0, completeFilename.lastIndexOf(".")):completeFilename;
|
||||
String filename=fc.get().getName();
|
||||
|
||||
|
||||
Destination destination=new Destination(completeFilename);
|
||||
Destination destination=new Destination(filename);
|
||||
destination.setCreateSubfolders(true);
|
||||
destination.setOnExistingFileName(DestinationClashPolicy.REWRITE);
|
||||
destination.setOnExistingSubFolder(DestinationClashPolicy.APPEND);
|
||||
|
||||
destination.setOnExistingSubFolder(DestinationClashPolicy.ADD_SUFFIX);
|
||||
destination.setPersistenceId("geoserver");
|
||||
destination.setSubFolder("GNA/"+currentElement.getRecord().getId()+"/"+
|
||||
currentElement.getId()+"/"+filename);
|
||||
|
||||
destination.setSubFolder("GNA/"+currentElement.getRecord().getId()+"/"+filename);
|
||||
log.debug("Sending "+wc+" to "+destination);
|
||||
TransferResult result=dtGeoServer.httpSource(fc.getPublicLink(), destination);
|
||||
log.debug("Transferred "+result);
|
||||
|
||||
|
||||
content.getFileNames().add(completeFilename);
|
||||
content.getFileNames().add(filename);
|
||||
|
||||
content.setGeoserverPath(result.getRemotePath().substring(0,result.getRemotePath().lastIndexOf("/")));
|
||||
}
|
||||
|
@ -134,24 +127,18 @@ public class SDIManager {
|
|||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(content.getFileNames().isEmpty())
|
||||
throw new SDIInteractionException("No Persisted content found in "+currentElement);
|
||||
|
||||
String completeFileName=content.getFileNames().get(0);
|
||||
String filename=completeFileName.contains(".")?completeFileName.substring(0, completeFileName.lastIndexOf(".")):completeFileName;
|
||||
String fileName=content.getFileNames().get(0);
|
||||
String remoteFolder=content.getGeoserverPath().substring(0,content.getGeoserverPath().lastIndexOf("/"));
|
||||
|
||||
String remoteFolder=content.getGeoserverPath();
|
||||
|
||||
String toSetLayerName=filename;
|
||||
String toSetLayerName=fileName.substring(0,fileName.lastIndexOf("."));
|
||||
int count=0;
|
||||
while(gis.getCurrentGeoServer().getReader().getLayer(workspace,toSetLayerName)!=null){
|
||||
count++;
|
||||
toSetLayerName=filename+"_"+count;
|
||||
log.debug("layer for "+filename+" already existing, trying "+toSetLayerName);
|
||||
toSetLayerName=fileName.substring(0,fileName.lastIndexOf("."))+"_"+count;
|
||||
log.debug("layer for "+fileName+" already existing, trying "+toSetLayerName);
|
||||
};
|
||||
|
||||
|
||||
|
@ -164,7 +151,7 @@ public class SDIManager {
|
|||
createWorkspace(workspace);
|
||||
log.debug("Publishing remote folder "+remoteFolder);
|
||||
|
||||
URL directoryPath=new URL("file:"+remoteFolder+"/"+filename+".shp");
|
||||
URL directoryPath=new URL("file:"+remoteFolder+"/"+toSetLayerName+".shp");
|
||||
|
||||
|
||||
//TODO Evaluate SRS
|
||||
|
@ -195,7 +182,7 @@ public class SDIManager {
|
|||
|
||||
|
||||
currentElement.setWmsLink(
|
||||
String.format("https://%1$s/geoserver/%2$s/wms?"
|
||||
String.format("http://%1$s/geoserver/%2$s/wms?"
|
||||
+"service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
|
||||
+ "styles=&bbox=%4$f,%5$f,%6$f,%7$f&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
|
||||
geoserverHostName,
|
||||
|
|
|
@ -46,13 +46,4 @@ public class Files {
|
|||
IOUtils.copy(is,toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static String fixFilename(String toFix) {
|
||||
if(toFix.contains(".")) {
|
||||
String prefix=toFix.substring(toFix.lastIndexOf("."));
|
||||
toFix=toFix.substring(0,toFix.lastIndexOf("."));
|
||||
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_")+prefix;
|
||||
}
|
||||
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.gcube.application.geoportal.model.db.DatabaseConnection;
|
||||
import org.gcube.application.geoportal.model.db.PostgisTable;
|
||||
import org.gcube.application.geoportal.model.db.PostgisTable.Field;
|
||||
import org.gcube.application.geoportal.model.db.PostgisTable.POINT;
|
||||
|
@ -26,12 +25,7 @@ public class PostgisMockup implements PostgisDBManagerI {
|
|||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseConnection getConnectionDescriptor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteTable(String tableName) throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -18,10 +18,10 @@ public class ShapeFilesTest {
|
|||
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("Opening : "+shp.toURI().toURL());
|
||||
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()));
|
||||
|
||||
|
@ -29,11 +29,6 @@ public class ShapeFilesTest {
|
|||
|
||||
|
||||
System.out.println(inputDataStore.getTypeNames());
|
||||
|
||||
|
||||
// String filename="some Une+* / \\ []() l:];kaj.sd\"sfl.blah";
|
||||
// System.out.println(Files.fixFilename(filename));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ public class TestModel {
|
|||
RelazioneScavo relScavo=new RelazioneScavo();
|
||||
|
||||
relScavo.setAbstractSection("simple abstract section");
|
||||
relScavo.setAbstractEng("simple abstract section ENG ");
|
||||
relScavo.setAbstractIta("semplice abstract ITA ");
|
||||
relScavo.setResponsabili(concessione.getAuthors());
|
||||
|
||||
concessione.setRelazioneScavo(relScavo);
|
||||
|
@ -94,7 +92,7 @@ public class TestModel {
|
|||
|
||||
// Piante fine scavo
|
||||
ArrayList<LayerConcessione> piante=new ArrayList<LayerConcessione>();
|
||||
for(int i=0;i<5;i++) {
|
||||
for(int i=0;i<1;i++) {
|
||||
LayerConcessione pianta=new LayerConcessione();
|
||||
pianta.setValutazioneQualita("Secondo me si");
|
||||
pianta.setMetodoRaccoltaDati("Fattobbene");
|
||||
|
|
|
@ -1,21 +1,38 @@
|
|||
package org.gcube.application.geoportal;
|
||||
|
||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.application.geoportal.model.content.GeoServerContent;
|
||||
import org.gcube.application.geoportal.model.fault.SDIInteractionException;
|
||||
import org.gcube.application.geoportal.model.gis.SDILayerDescriptor;
|
||||
import org.gcube.application.geoportal.storage.SDIManager;
|
||||
import org.gcube.application.geoportal.utils.Files;
|
||||
import org.gcube.application.geoportal.utils.Workspace;
|
||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||
import org.gcube.spatial.data.gis.GISInterface;
|
||||
import org.geotoolkit.storage.DataStoreException;
|
||||
|
||||
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||
|
||||
public class TestSDI {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
TokenSetter.set("/gcube/devNext/NextNext");
|
||||
|
||||
// String workspaceName="gna_conc_"+UUID.randomUUID().toString();
|
||||
//
|
||||
// FileContainer file=Workspace.getClient().getWSRoot().uploadFile(
|
||||
// new FileInputStream(Files.getFileFromResources("concessioni/pos.shp")), "posizionamento", "test layer");
|
||||
//
|
||||
SDIManager sdiManager=new SDIManager();
|
||||
// SDIManager sdiManager=new SDIManager();
|
||||
|
||||
// sdiManager.createWorkspace(workspaceName);
|
||||
// sdiManager.configureCentroidLayer("centroids_concessioni", "gna:test", "gna_test_postgis");
|
||||
|
@ -25,38 +42,33 @@ public class TestSDI {
|
|||
//
|
||||
// GeoServerContent content=sdiManager.pushLayerFile(Files.getFileFromResources("concessioni/pos.shp"), "pos.shp", 123, 1);
|
||||
// System.out.println("content is "+content);
|
||||
|
||||
// GeoServerContent content =
|
||||
//
|
||||
// SDILayerDescriptor desc=TestModel.prepareConcessione().getPosizionamentoScavo();
|
||||
//
|
||||
// sdiManager.pushShapeLayerFileSet(desc,new Workspace());
|
||||
// sdiManager.publishShapeFileDirectory(workspaceName, content.getGeoserverPath());
|
||||
|
||||
|
||||
// GISInterface gis=GISInterface.get();
|
||||
// String workspace="gna";
|
||||
// String toSetLayerName="centroids_concessioni";
|
||||
// String geoserverHostName=new URL(gis.getCurrentGeoServer().getUrl()).getHost();
|
||||
//
|
||||
// GeoServerRESTReader reader=gis.getCurrentGeoServer().getReader();
|
||||
// RESTLayer l=reader.getLayer(workspace, toSetLayerName);
|
||||
// RESTFeatureType f= reader.getFeatureType(l);
|
||||
//
|
||||
// System.out.println(String.format("http://%1$s/geoserver/%2$s/wms?"
|
||||
// +"service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
|
||||
// + "styles=&bbox=%4$f,%5$f,%6$f,%7$f&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
|
||||
// geoserverHostName,
|
||||
// workspace,
|
||||
// toSetLayerName,
|
||||
// f.getMinX(),
|
||||
// f.getMinY(),
|
||||
// f.getMaxX(),
|
||||
// f.getMaxY(),
|
||||
// "EPSG:4326",
|
||||
// 400,
|
||||
// 400)
|
||||
// );
|
||||
//
|
||||
GISInterface gis=GISInterface.get();
|
||||
String workspace="gna";
|
||||
String toSetLayerName="centroids_concessioni";
|
||||
String geoserverHostName=new URL(gis.getCurrentGeoServer().getUrl()).getHost();
|
||||
|
||||
GeoServerRESTReader reader=gis.getCurrentGeoServer().getReader();
|
||||
RESTLayer l=reader.getLayer(workspace, toSetLayerName);
|
||||
RESTFeatureType f= reader.getFeatureType(l);
|
||||
|
||||
System.out.println(String.format("http://%1$s/geoserver/%2$s/wms?"
|
||||
+"service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
|
||||
+ "styles=&bbox=%4$f,%5$f,%6$f,%7$f&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
|
||||
geoserverHostName,
|
||||
workspace,
|
||||
toSetLayerName,
|
||||
f.getMinX(),
|
||||
f.getMinY(),
|
||||
f.getMaxX(),
|
||||
f.getMaxY(),
|
||||
"EPSG:4326",
|
||||
400,
|
||||
400)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.application.geoportal;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportal.managers.AbstractRecordManager;
|
||||
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
||||
|
@ -36,7 +35,7 @@ public class UseCases {
|
|||
|
||||
|
||||
//CREATE NEW
|
||||
int numConcessioni=3 ;
|
||||
int numConcessioni=1;
|
||||
Concessione registered=null;
|
||||
System.out.println("Try to create.. "+numConcessioni);
|
||||
for(int i=0;i<numConcessioni;i++)
|
||||
|
@ -118,17 +117,15 @@ public class UseCases {
|
|||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.shp")),"pos.shp"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.shx")),"pos.shx"));
|
||||
|
||||
List<LayerConcessione> ls=TestModel.prepareConcessione().getPianteFineScavo();
|
||||
for(int i=0;i<ls.size();i++) {
|
||||
LayerConcessione layer=ls.get(i);
|
||||
for(LayerConcessione layer:TestModel.prepareConcessione().getPianteFineScavo())
|
||||
//Istruisco il manager per gestire il/i payload del layer, specificando i nomi dei file originali
|
||||
manager.addPiantaFineScavo(layer,
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.dbf")),"qualche Pianta "+i+".dbf"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.prj")),"qualche Pianta "+i+".prj"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.qpj")),"qualche Pianta "+i+".qpj"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.shp")),"qualche Pianta "+i+".shp"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.shx")),"qualche Pianta "+i+".shx"));
|
||||
}
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.dbf")),"pianta.dbf"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.prj")),"pianta.prj"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.qpj")),"pianta.qpj"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.shp")),"pianta.shp"),
|
||||
new InputStreamDescriptor(new FileInputStream(Files.getFileFromResources("concessioni/pos.shx")),"pianta.shx"));
|
||||
|
||||
|
||||
//If true -> data are published into the SDI
|
||||
Boolean publish=true;
|
||||
|
@ -149,8 +146,8 @@ public class UseCases {
|
|||
*scrittura sul DB di applicazione sia dei meta che dei vari link */
|
||||
|
||||
//Metodo con eccezioni
|
||||
// Concessione registered=manager.commit(publish);
|
||||
manager.commitSafely(true);
|
||||
Concessione registered=manager.commit(publish);
|
||||
|
||||
|
||||
//Metodo con report
|
||||
// PublicationReport pubReport=manager.commitSafely(publish);
|
||||
|
@ -161,8 +158,8 @@ public class UseCases {
|
|||
// System.out.println("Report is "+pubReport.prettyPrint());
|
||||
// Assert.assertFalse(pubReport.getStatus().equals(ValidationStatus.ERROR));
|
||||
|
||||
// manager.close();
|
||||
return manager.getRecord();
|
||||
manager.close();
|
||||
return registered;
|
||||
//--- FINALLY --/
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package org.gcube.application.geoportal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportal.utils.Workspace;
|
||||
import org.gcube.common.storagehub.client.dsl.ContainerType;
|
||||
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.ListResolver;
|
||||
import org.gcube.common.storagehub.client.dsl.ListResolverTyped;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
|
@ -15,32 +11,22 @@ import org.gcube.common.storagehub.model.items.Item;
|
|||
public class WSTests {
|
||||
|
||||
public static void main(String[] args) throws StorageHubException {
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
TokenSetter.set("/gcube/devNext/NextNext");
|
||||
|
||||
StorageHubClient client=Workspace.getClient();
|
||||
String id="f835cd8a-0a92-4266-8c33-0b05e202ed94";
|
||||
String id="9e397c1f-0b52-4b59-b247-e5ef301978ed";
|
||||
|
||||
// FolderContainer item=client.open(id).asFolder();
|
||||
|
||||
FolderContainer item=client.openVREFolder().openByRelativePath(".GNA_RECORDS").asFolder();
|
||||
ItemContainer item=client.open(id).asItem();
|
||||
System.out.println(item.get().getPath());
|
||||
// switch(item.getType()) {
|
||||
// case FILE :
|
||||
// FileContainer file=(FileContainer) item;
|
||||
// file.getAnchestors();
|
||||
// case FOLDER :
|
||||
// }
|
||||
// System.out.println(path(item));
|
||||
//
|
||||
// System.out.println("TREE : ");
|
||||
|
||||
boolean showHidden=true;
|
||||
printTree("", item,showHidden);
|
||||
System.out.println(path(item));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String path(ItemContainer item) throws StorageHubException {
|
||||
StringBuilder builder=new StringBuilder();
|
||||
ListResolver resolver=item.getAnchestors();
|
||||
|
@ -50,22 +36,4 @@ public class WSTests {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void printTree(String padding,ItemContainer item,boolean showHidden){
|
||||
System.out.println(padding + "" +item.get().getName() +" [ID : "+item.getId()+", hidden = "+item.get().isHidden()+"]" );
|
||||
if(item.getType().equals(ContainerType.FOLDER)) {
|
||||
FolderContainer c =((FolderContainer)item);
|
||||
String newPadding=padding+"\t";
|
||||
List<? extends ItemContainer> l;
|
||||
try {
|
||||
ListResolverTyped lt=c.list();
|
||||
if(showHidden)lt.includeHidden();
|
||||
l = lt.getContainers();
|
||||
} catch (StorageHubException e) {
|
||||
throw new RuntimeException("Errore",e);
|
||||
}
|
||||
l.forEach((ItemContainer i)->{printTree(newPadding, i,showHidden);});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
log4j.rootLogger=ERROR, stdout
|
||||
log4j.rootLogger=WARN, stdout
|
||||
|
||||
log4j.logger.org.gcube.application=DEBUG, stdout
|
||||
#CONSOLE
|
||||
|
|
Loading…
Reference in New Issue