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 -->
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>net.postgis</groupId>
|
||||
<artifactId>postgis-jdbc</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
|
||||
<!-- jackson java time -->
|
||||
<!-- Serialization from library -->
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>2.8.8</version>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
<!-- GPKG -->
|
||||
<!-- Read Geopackage -->
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>mil.nga.geopackage</groupId>
|
||||
<artifactId>geopackage</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
|
||||
|
@ -130,7 +130,7 @@
|
|||
|
||||
<!-- gCube SW -->
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>sdi-library</artifactId>
|
||||
<version>[1.0.0,2.0.0)</version>
|
||||
|
@ -158,25 +158,25 @@
|
|||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<version>[1.0.0,2.0.0)</version>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
<!-- HIBERNATE -->
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>5.3.1.Final</version>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
|
||||
<!-- SIS -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.apache.sis.core</groupId>
|
||||
<artifactId>sis-referencing</artifactId>
|
||||
<version>${sis.version}</version>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
<!-- Common - basic -->
|
||||
<dependency>
|
||||
|
@ -199,12 +199,12 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>eclipselink</artifactId>
|
||||
<version>2.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -225,13 +225,22 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.apache.derby</groupId>
|
||||
<artifactId>derby</artifactId>
|
||||
<version>10.8.3.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency> -->
|
||||
|
||||
</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>
|
|
@ -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.ManagerFactory;
|
||||
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;
|
||||
|
||||
|
@ -25,10 +29,12 @@ public class Concessioni {
|
|||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@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 {
|
||||
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){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw e;
|
||||
|
@ -41,12 +47,12 @@ public class Concessioni {
|
|||
@PUT
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Concessione registerNew(Concessione toRegister) {
|
||||
public String registerNew(Concessione toRegister) {
|
||||
try {
|
||||
log.info("Registering new Concessione "+toRegister);
|
||||
ConcessioneManager manager=ManagerFactory.registerNew(toRegister);
|
||||
manager.commitSafely(false);
|
||||
return manager.getRecord();
|
||||
PublicationReport report=manager.commitSafely(false);
|
||||
return report.prettyPrint();
|
||||
}catch(WebApplicationException e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw e;
|
||||
|
@ -57,7 +63,7 @@ public class Concessioni {
|
|||
}
|
||||
|
||||
|
||||
public Concessione addSection() {
|
||||
public String addSection() {
|
||||
try {
|
||||
log.info("Loading all projects..");
|
||||
throw new RuntimeException("Feature not yet available");
|
||||
|
@ -72,9 +78,15 @@ public class Concessioni {
|
|||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Collection<Concessione> getList(){
|
||||
public String getList(){
|
||||
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){
|
||||
log.warn("Unable to serve request",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.managers.AbstractRecordManager;
|
||||
import org.gcube.application.geoportal.managers.DefatulEMFProvider;
|
||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||
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.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -56,10 +58,18 @@ public class Concessioni extends JerseyTest {
|
|||
|
||||
|
||||
@Test
|
||||
public void list(){
|
||||
public void list() throws JsonProcessingException, IOException{
|
||||
WebTarget target=target(InterfaceConstants.Methods.CONCESSIONI);
|
||||
System.err.println(target.getUri());
|
||||
System.out.println(target.request(MediaType.APPLICATION_JSON).get(Collection.class));
|
||||
System.err.println(target.getUri());
|
||||
|
||||
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