Legacy methods
This commit is contained in:
parent
fa58b5ba91
commit
1bcab915f0
43
pom.xml
43
pom.xml
|
@ -99,30 +99,30 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- Used to write centroids -->
|
<!-- Used to write centroids -->
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>net.postgis</groupId>
|
<groupId>net.postgis</groupId>
|
||||||
<artifactId>postgis-jdbc</artifactId>
|
<artifactId>postgis-jdbc</artifactId>
|
||||||
<version>2.5.0</version>
|
<version>2.5.0</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- jackson java time -->
|
<!-- jackson java time -->
|
||||||
<!-- Serialization from library -->
|
<!-- Serialization from library -->
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>2.8.8</version>
|
<version>2.8.8</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- GPKG -->
|
<!-- GPKG -->
|
||||||
<!-- Read Geopackage -->
|
<!-- Read Geopackage -->
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>mil.nga.geopackage</groupId>
|
<groupId>mil.nga.geopackage</groupId>
|
||||||
<artifactId>geopackage</artifactId>
|
<artifactId>geopackage</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.5.0</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
|
|
||||||
<!-- gCube SW -->
|
<!-- gCube SW -->
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.gcube.spatial.data</groupId>
|
<groupId>org.gcube.spatial.data</groupId>
|
||||||
<artifactId>sdi-library</artifactId>
|
<artifactId>sdi-library</artifactId>
|
||||||
<version>[1.0.0,2.0.0)</version>
|
<version>[1.0.0,2.0.0)</version>
|
||||||
|
@ -158,25 +158,25 @@
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
<version>[1.0.0,2.0.0)</version>
|
<version>[1.0.0,2.0.0)</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- HIBERNATE -->
|
<!-- HIBERNATE -->
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-core</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
<version>5.3.1.Final</version>
|
<version>5.3.1.Final</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- SIS -->
|
<!-- SIS -->
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.apache.sis.core</groupId>
|
<groupId>org.apache.sis.core</groupId>
|
||||||
<artifactId>sis-referencing</artifactId>
|
<artifactId>sis-referencing</artifactId>
|
||||||
<version>${sis.version}</version>
|
<version>${sis.version}</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
<!-- Common - basic -->
|
<!-- Common - basic -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -199,12 +199,12 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.eclipse.persistence</groupId>
|
<groupId>org.eclipse.persistence</groupId>
|
||||||
<artifactId>eclipselink</artifactId>
|
<artifactId>eclipselink</artifactId>
|
||||||
<version>2.5.0</version>
|
<version>2.5.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -225,13 +225,22 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.apache.derby</groupId>
|
<groupId>org.apache.derby</groupId>
|
||||||
<artifactId>derby</artifactId>
|
<artifactId>derby</artifactId>
|
||||||
<version>10.8.3.0</version>
|
<version>10.8.3.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>GeoSolutions</id>
|
||||||
|
<url>https://nexus.d4science.org/nexus/content/repositories/geo-solutions-snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>GeoToolkit</id>
|
||||||
|
<url>https://nexus.d4science.org/nexus/content/repositories/geotoolkit/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
</project>
|
</project>
|
|
@ -15,6 +15,10 @@ import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||||
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
import org.gcube.application.geoportal.managers.ConcessioneManager;
|
||||||
import org.gcube.application.geoportal.managers.ManagerFactory;
|
import org.gcube.application.geoportal.managers.ManagerFactory;
|
||||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||||
|
import org.gcube.application.geoportal.model.report.PublicationReport;
|
||||||
|
import org.gcube.application.geoportal.utils.Serialization;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@ -25,10 +29,12 @@ public class Concessioni {
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||||
public Concessione getById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
public String getById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
||||||
try {
|
try {
|
||||||
log.info("Loading Concessione by id {} ",id);
|
log.info("Loading Concessione by id {} ",id);
|
||||||
return (Concessione) ManagerFactory.getByRecordID(Long.parseLong(id)).getRecord();
|
Concessione toReturn=(Concessione) ManagerFactory.getByRecordID(Long.parseLong(id)).getRecord();
|
||||||
|
log.debug("Loaded object {} ",toReturn);
|
||||||
|
return toReturn.asJson();
|
||||||
}catch(WebApplicationException e){
|
}catch(WebApplicationException e){
|
||||||
log.warn("Unable to serve request",e);
|
log.warn("Unable to serve request",e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -41,12 +47,12 @@ public class Concessioni {
|
||||||
@PUT
|
@PUT
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Concessione registerNew(Concessione toRegister) {
|
public String registerNew(Concessione toRegister) {
|
||||||
try {
|
try {
|
||||||
log.info("Registering new Concessione "+toRegister);
|
log.info("Registering new Concessione "+toRegister);
|
||||||
ConcessioneManager manager=ManagerFactory.registerNew(toRegister);
|
ConcessioneManager manager=ManagerFactory.registerNew(toRegister);
|
||||||
manager.commitSafely(false);
|
PublicationReport report=manager.commitSafely(false);
|
||||||
return manager.getRecord();
|
return report.prettyPrint();
|
||||||
}catch(WebApplicationException e){
|
}catch(WebApplicationException e){
|
||||||
log.warn("Unable to serve request",e);
|
log.warn("Unable to serve request",e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -57,7 +63,7 @@ public class Concessioni {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Concessione addSection() {
|
public String addSection() {
|
||||||
try {
|
try {
|
||||||
log.info("Loading all projects..");
|
log.info("Loading all projects..");
|
||||||
throw new RuntimeException("Feature not yet available");
|
throw new RuntimeException("Feature not yet available");
|
||||||
|
@ -72,9 +78,15 @@ public class Concessioni {
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Collection<Concessione> getList(){
|
public String getList(){
|
||||||
try {
|
try {
|
||||||
return ManagerFactory.getList(Concessione.class);
|
Collection<Concessione> toReturn=ManagerFactory.getList(Concessione.class);
|
||||||
|
log.debug("Found "+toReturn.size()+" elements..");
|
||||||
|
JSONArray array=new JSONArray();
|
||||||
|
for(Concessione found:toReturn) {
|
||||||
|
array.put(found.asJson());
|
||||||
|
}
|
||||||
|
return array.toString();
|
||||||
}catch(WebApplicationException e){
|
}catch(WebApplicationException e){
|
||||||
log.warn("Unable to serve request",e);
|
log.warn("Unable to serve request",e);
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -23,8 +23,10 @@ import javax.ws.rs.core.MediaType;
|
||||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||||
import org.gcube.application.geoportal.managers.AbstractRecordManager;
|
import org.gcube.application.geoportal.managers.AbstractRecordManager;
|
||||||
import org.gcube.application.geoportal.managers.DefatulEMFProvider;
|
import org.gcube.application.geoportal.managers.DefatulEMFProvider;
|
||||||
|
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||||
import org.gcube.application.geoportal.service.GeoportalService;
|
import org.gcube.application.geoportal.service.GeoportalService;
|
||||||
import org.geotoolkit.style.DefaultExternalMark;
|
import org.gcube.application.geoportal.utils.Serialization;
|
||||||
|
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import org.glassfish.jersey.test.JerseyTest;
|
import org.glassfish.jersey.test.JerseyTest;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -56,10 +58,18 @@ public class Concessioni extends JerseyTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void list(){
|
public void list() throws JsonProcessingException, IOException{
|
||||||
WebTarget target=target(InterfaceConstants.Methods.CONCESSIONI);
|
WebTarget target=target(InterfaceConstants.Methods.CONCESSIONI);
|
||||||
System.err.println(target.getUri());
|
System.err.println(target.getUri());
|
||||||
System.out.println(target.request(MediaType.APPLICATION_JSON).get(Collection.class));
|
|
||||||
|
Collection coll=target.request(MediaType.APPLICATION_JSON).get(Collection.class);
|
||||||
|
System.out.println("Size of collection is "+coll.size());
|
||||||
|
System.out.println("Iterating through objects.. ");
|
||||||
|
for(Object o:coll) {
|
||||||
|
System.out.println("Object class is "+o.getClass());
|
||||||
|
System.out.println("Concessione is : "+Serialization.readObject(o.toString(), Concessione.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue