Legacy implementation
This commit is contained in:
parent
a25a9be20e
commit
c5cb6b2df9
41
pom.xml
41
pom.xml
|
@ -5,14 +5,13 @@
|
|||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-service</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>Geoportal Logic</name>
|
||||
<name>Geoportal Service</name>
|
||||
|
||||
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.1.0</version>
|
||||
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@ -36,17 +35,10 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-smartgears-bom</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<version>2.0.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId> org.glassfish.jersey </groupId> -->
|
||||
<!-- <artifactId>jersey-bom</artifactId> -->
|
||||
<!-- <version>${jersey.version}</version> -->
|
||||
<!-- <type>pom</type> -->
|
||||
<!-- <scope>import</scope> -->
|
||||
<!-- </dependency> -->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -84,6 +76,27 @@
|
|||
</dependency>
|
||||
|
||||
<!-- INTERNAL LOGIC -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-logic</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- MONGO -->
|
||||
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Used to write centroids -->
|
||||
<dependency>
|
||||
|
@ -178,6 +191,14 @@
|
|||
</dependency>
|
||||
|
||||
<!-- TEST -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
|
||||
<artifactId>jersey-test-framework-provider-simple</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>eclipselink</artifactId>
|
||||
|
|
|
@ -2,7 +2,11 @@ package org.gcube.application.geoportal.service;
|
|||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
|
||||
import org.gcube.application.geoportal.service.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.service.rest.Concessioni;
|
||||
import org.gcube.application.geoportal.service.rest.Profiles;
|
||||
import org.gcube.application.geoportal.service.rest.Projects;
|
||||
import org.gcube.application.geoportal.service.rest.Sections;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
||||
@ApplicationPath(InterfaceConstants.APPLICATION_PATH)
|
||||
|
@ -11,8 +15,12 @@ public class GeoportalService extends ResourceConfig{
|
|||
|
||||
public GeoportalService() {
|
||||
super();
|
||||
//Register interrfaces
|
||||
registerClasses(Concessioni.class);
|
||||
registerClasses(Projects.class);
|
||||
registerClasses(Sections.class);
|
||||
registerClasses(Profiles.class);
|
||||
}
|
||||
|
||||
|
||||
// TODO register servlets
|
||||
// TODO register packages
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.application.geoportal.service.engine;
|
||||
|
||||
public interface Engine {
|
||||
|
||||
public void init();
|
||||
public void shustdown();
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
package org.gcube.application.geoportal.service.engine;
|
||||
|
||||
import org.gcube.application.geoportal.managers.AbstractRecordManager;
|
||||
import org.gcube.application.geoportal.service.engine.mongo.MongoClientProvider;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class ImplementationProvider {
|
||||
|
@ -14,11 +19,18 @@ public class ImplementationProvider {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private MongoClientProvider mongoClientProvider=null;
|
||||
|
||||
public void shutdown() {
|
||||
// Stop JPA
|
||||
AbstractRecordManager.shutdown();
|
||||
mongoClientProvider.shustdown();
|
||||
}
|
||||
|
||||
public void startup() {
|
||||
|
||||
mongoClientProvider.init();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package org.gcube.application.geoportal.service.engine;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.gcube.application.geoportal.service.model.Project;
|
||||
|
||||
public class ProjectsArchiveManager implements ProjectsArchiveManagerI {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Project getByID(String ID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Project> getByFilters() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project addSection() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project createNew(Project toCreate) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project publish(String id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project validate(String id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -6,11 +6,14 @@ import org.gcube.application.geoportal.service.model.Project;
|
|||
|
||||
public interface ProjectsArchiveManagerI {
|
||||
|
||||
public Project getByID();
|
||||
public Project getByID(String id);
|
||||
|
||||
public Collection<Project> getByFilters();
|
||||
|
||||
public Project addSection();
|
||||
|
||||
// public Project
|
||||
public Project createNew(Project toCreate);
|
||||
|
||||
public Project publish(String id);
|
||||
public Project validate(String id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.application.geoportal.service.engine.mongo;
|
||||
|
||||
import org.gcube.application.geoportal.service.engine.Engine;
|
||||
|
||||
import com.mongodb.MongoClient;
|
||||
|
||||
public interface MongoClientProvider extends Engine{
|
||||
|
||||
|
||||
public MongoClient getClient();
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.gcube.application.geoportal.service.engine.mongo;
|
||||
|
||||
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
|
||||
import org.gcube.application.geoportal.service.model.Project;
|
||||
|
||||
import com.mongodb.MongoClient;
|
||||
|
||||
public class MongoManager {
|
||||
|
||||
private MongoClient client=null;
|
||||
|
||||
public MongoManager() {
|
||||
client=ImplementationProvider.get().getMongoClientProvider().getClient();
|
||||
}
|
||||
|
||||
|
||||
//*********** PROJECTS
|
||||
public Project insert(Project proj) {
|
||||
// TODO check if existing DB
|
||||
// TODO check if existing collection
|
||||
client.
|
||||
|
||||
}
|
||||
public Project update(Project proj) {
|
||||
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
|
||||
}
|
||||
public Project load(String id) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//********** PROFILES
|
||||
|
||||
//
|
||||
}
|
|
@ -2,4 +2,28 @@ package org.gcube.application.geoportal.service.model;
|
|||
|
||||
public class Profile {
|
||||
|
||||
/**
|
||||
* Profile{
|
||||
_id :
|
||||
fields :[
|
||||
field : {
|
||||
label :
|
||||
description :
|
||||
type: String,Numeric,Date,
|
||||
File,Document,Layer
|
||||
cardinality:
|
||||
defaultValue :
|
||||
validation :{type : // e.g. regexp, list}
|
||||
}
|
||||
]
|
||||
default_compiler:{type : //XSLT,JAVA_CLAS}
|
||||
validator: {“}
|
||||
iso_mapper: {“}
|
||||
centroid_fields : {“}
|
||||
index_definition : }
|
||||
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package org.gcube.application.geoportal.service.rest;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Path(InterfaceConstants.Methods.CONCESSIONI)
|
||||
@Slf4j
|
||||
public class Concessioni {
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||
public Concessione getById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
||||
try {
|
||||
log.info("Loading Concessione by id {} ",id);
|
||||
return (Concessione) ManagerFactory.getByRecordID(Long.parseLong(id)).getRecord();
|
||||
}catch(WebApplicationException e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw e;
|
||||
}catch(Throwable e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw new WebApplicationException("Unable to serve request", e);
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Concessione registerNew(Concessione toRegister) {
|
||||
try {
|
||||
log.info("Registering new Concessione "+toRegister);
|
||||
ConcessioneManager manager=ManagerFactory.registerNew(toRegister);
|
||||
manager.commitSafely(false);
|
||||
return manager.getRecord();
|
||||
}catch(WebApplicationException e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw e;
|
||||
}catch(Throwable e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw new WebApplicationException("Unable to serve request", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Concessione addSection() {
|
||||
try {
|
||||
log.info("Loading all projects..");
|
||||
throw new RuntimeException("Feature not yet available");
|
||||
}catch(WebApplicationException e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw e;
|
||||
}catch(Throwable e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw new WebApplicationException("Unable to serve request", e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Collection<Concessione> getList(){
|
||||
try {
|
||||
return ManagerFactory.getList(Concessione.class);
|
||||
}catch(WebApplicationException e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw e;
|
||||
}catch(Throwable e){
|
||||
log.warn("Unable to serve request",e);
|
||||
throw new WebApplicationException("Unable to serve request", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package org.gcube.application.geoportal.service.rest;
|
||||
|
||||
public class InterfaceConstants {
|
||||
|
||||
public static final String APPLICATION_PATH="/srv/";
|
||||
public static final String SERVICE_CLASS="Application";
|
||||
public static final String SERVICE_NAME="GeoPortal";
|
||||
|
||||
public static final class Methods{
|
||||
public static final String PROFILES="profiles";
|
||||
public static final String SECTIONS="sections";
|
||||
public static final String PROJECTS="projects";
|
||||
}
|
||||
|
||||
public static final class Parameters{
|
||||
public static final String PROJECT_ID="project_id";
|
||||
public static final String SECTION_ID="section_id";
|
||||
public static final String PROFILE_ID="profile_id";
|
||||
|
||||
//INVESTIGATE CAPABILITIES
|
||||
public static final String ORDER_BY="order_by";
|
||||
public static final String LIMIT="limit";
|
||||
public static final String OFFSET="offset";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.service.model.Project;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.ws.rs.QueryParam;
|
|||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.service.model.Project;
|
||||
import org.gcube.application.geoportal.service.model.Section;
|
||||
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
package org.gcube.application.geoportal.service.legacy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
import javax.persistence.ValidationMode;
|
||||
import javax.persistence.spi.ClassTransformer;
|
||||
import javax.persistence.spi.PersistenceUnitInfo;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
import javax.sql.DataSource;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Application;
|
||||
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.service.GeoportalService;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class Concessioni extends JerseyTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected Application configure() {
|
||||
return new GeoportalService();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
AbstractRecordManager.setDefaultProvider(new DefaultEMFProvider() {
|
||||
|
||||
@Override
|
||||
public EntityManagerFactory getFactory() {
|
||||
System.err.println("***********************SETTING DEBUG CONTEXT******************");
|
||||
TokenSetter.set("/gcube/devNext/NexNext");
|
||||
return super.getF
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void list(){
|
||||
WebTarget target=target(InterfaceConstants.Methods.CONCESSIONI);
|
||||
System.err.println(target.getUri());
|
||||
System.out.println(target.request(MediaType.APPLICATION_JSON).get(Collection.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void createNew() {
|
||||
WebTarget target=target(InterfaceConstants.Methods.CONCESSIONI);
|
||||
// target.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static PersistenceUnitInfo archiverPersistenceUnitInfo() {
|
||||
|
||||
final List<String> MANAGED_CLASSES=Arrays.asList(new String[] {
|
||||
"org.gcube.application.geoportal.model.Record",
|
||||
"org.gcube.application.geoportal.model.concessioni.Concessione",
|
||||
"org.gcube.application.geoportal.model.concessioni.LayerConcessione",
|
||||
"org.gcube.application.geoportal.model.concessioni.RelazioneScavo",
|
||||
|
||||
"org.gcube.application.geoportal.model.content.AssociatedContent",
|
||||
"org.gcube.application.geoportal.model.content.GeoServerContent",
|
||||
"org.gcube.application.geoportal.model.content.OtherContent",
|
||||
"org.gcube.application.geoportal.model.content.PersistedContent",
|
||||
"org.gcube.application.geoportal.model.content.UploadedImage",
|
||||
"org.gcube.application.geoportal.model.content.WorkspaceContent",
|
||||
|
||||
"org.gcube.application.geoportal.model.gis.ShapeFileLayerDescriptor",
|
||||
"org.gcube.application.geoportal.model.gis.SDILayerDescriptor"});
|
||||
|
||||
|
||||
return new PersistenceUnitInfo() {
|
||||
@Override
|
||||
public String getPersistenceUnitName() {
|
||||
return "ApplicationPersistenceUnit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPersistenceProviderClassName() {
|
||||
return "org.hibernate.jpa.HibernatePersistenceProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistenceUnitTransactionType getTransactionType() {
|
||||
return PersistenceUnitTransactionType.RESOURCE_LOCAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getJtaDataSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getNonJtaDataSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMappingFileNames() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<URL> getJarFileUrls() {
|
||||
try {
|
||||
return Collections.list(this.getClass()
|
||||
.getClassLoader()
|
||||
.getResources(""));
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getPersistenceUnitRootUrl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getManagedClassNames() {
|
||||
return MANAGED_CLASSES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean excludeUnlistedClasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedCacheMode getSharedCacheMode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidationMode getValidationMode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getProperties() {
|
||||
return new Properties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPersistenceXMLSchemaVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getClassLoader() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTransformer(ClassTransformer transformer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getNewTempClassLoader() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package org.gcube.application.geoportal.service.legacy;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.gcube.application.geoportal.model.AccessPolicy;
|
||||
import org.gcube.application.geoportal.model.concessioni.Concessione;
|
||||
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
|
||||
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
||||
import org.gcube.application.geoportal.model.content.UploadedImage;
|
||||
|
||||
public class TestModel {
|
||||
|
||||
public static Concessione prepareEmptyConcessione() {
|
||||
Concessione concessione=new Concessione();
|
||||
|
||||
// Generic fields
|
||||
|
||||
|
||||
// Concessione fields
|
||||
|
||||
concessione.setNome("Italia, forse");
|
||||
concessione.setIntroduzione("This is my project");
|
||||
concessione.setDescrizioneContenuto("It contains this and that");
|
||||
|
||||
concessione.setAuthors(Arrays.asList(new String[] {"Some one","Some, oneelse"}));
|
||||
|
||||
concessione.setContributore("Contrib 1");
|
||||
concessione.setTitolari(Arrays.asList(new String[] {"Some one","Some, oneelse"}));
|
||||
concessione.setResponsabile("Someone");
|
||||
concessione.setEditore("Editore");
|
||||
|
||||
concessione.setFontiFinanziamento(Arrays.asList(new String[] {"Big pharma","Pentagon"}));
|
||||
|
||||
|
||||
concessione.setSoggetto(Arrays.asList(new String[] {"Research Excavation","Archeology"}));
|
||||
|
||||
|
||||
concessione.setDataInizioProgetto(LocalDateTime.now());
|
||||
concessione.setDataFineProgetto(LocalDateTime.now());
|
||||
|
||||
concessione.setLicenzaID("CC-BY");
|
||||
|
||||
concessione.setTitolareLicenza("Qualcun altro");
|
||||
concessione.setTitolareCopyright("Chiedilo in giro");
|
||||
|
||||
concessione.setParoleChiaveLibere(Arrays.asList(new String[] {"Robba","Stuff"}));
|
||||
concessione.setParoleChiaveICCD(Arrays.asList(new String[] {"vattelapesca","somthing something"}));
|
||||
|
||||
|
||||
concessione.setCentroidLat(43.0); //N-S
|
||||
concessione.setCentroidLong(9.0); //E-W
|
||||
|
||||
return concessione;
|
||||
}
|
||||
|
||||
public static Concessione prepareConcessione() {
|
||||
|
||||
Concessione concessione=prepareEmptyConcessione();
|
||||
|
||||
|
||||
|
||||
// Attachments
|
||||
|
||||
// Relazione scavo
|
||||
RelazioneScavo relScavo=new RelazioneScavo();
|
||||
|
||||
relScavo.setAbstractSection("simple abstract section");
|
||||
relScavo.setResponsabili(concessione.getAuthors());
|
||||
|
||||
concessione.setRelazioneScavo(relScavo);
|
||||
//Immagini rappresentative
|
||||
ArrayList<UploadedImage> imgs=new ArrayList<>();
|
||||
for(int i=0;i<5;i++) {
|
||||
UploadedImage img=new UploadedImage();
|
||||
img.setTitolo("My image number "+i);
|
||||
img.setDidascalia("You can see my image number "+i);
|
||||
img.setFormat("TIFF");
|
||||
img.setCreationTime(LocalDateTime.now());
|
||||
img.setResponsabili(concessione.getAuthors());
|
||||
imgs.add(img);
|
||||
}
|
||||
concessione.setImmaginiRappresentative(imgs);
|
||||
//Posizionamento
|
||||
LayerConcessione posizionamento=new LayerConcessione();
|
||||
posizionamento.setValutazioneQualita("Secondo me si");
|
||||
posizionamento.setMetodoRaccoltaDati("Fattobbene");
|
||||
posizionamento.setScalaAcquisizione("1:10000");
|
||||
posizionamento.setAuthors(concessione.getAuthors());
|
||||
concessione.setPosizionamentoScavo(posizionamento);
|
||||
|
||||
// Piante fine scavo
|
||||
ArrayList<LayerConcessione> piante=new ArrayList<LayerConcessione>();
|
||||
for(int i=0;i<4;i++) {
|
||||
LayerConcessione pianta=new LayerConcessione();
|
||||
pianta.setValutazioneQualita("Secondo me si");
|
||||
pianta.setMetodoRaccoltaDati("Fattobbene");
|
||||
pianta.setScalaAcquisizione("1:10000");
|
||||
pianta.setAuthors(concessione.getAuthors());
|
||||
pianta.setPolicy(AccessPolicy.RESTRICTED);
|
||||
piante.add(pianta);
|
||||
}
|
||||
concessione.setPianteFineScavo(piante);
|
||||
|
||||
return concessione;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.application.geoportal.service.legacy;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class TokenSetter {
|
||||
|
||||
|
||||
|
||||
private static Properties props=new Properties();
|
||||
|
||||
static{
|
||||
try {
|
||||
props.load(TokenSetter.class.getResourceAsStream("/tokens.properties"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("YOU NEED TO SET TOKEN FILE IN CONFIGURATION");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void set(String scope){
|
||||
try{
|
||||
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
||||
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
||||
}catch(Throwable e){
|
||||
}
|
||||
ScopeProvider.instance.set(scope);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
|
||||
<persistence-unit name="gna_internal_db" transaction-type="RESOURCE_LOCAL">
|
||||
|
||||
<class>org.gcube.application.geoportal.model.Record</class>
|
||||
<!-- Concessioni -->
|
||||
<class>org.gcube.application.geoportal.model.concessioni.Concessione</class>
|
||||
<class>org.gcube.application.geoportal.model.concessioni.LayerConcessione</class>
|
||||
<class>org.gcube.application.geoportal.model.concessioni.RelazioneScavo</class>
|
||||
|
||||
<!-- Content -->
|
||||
<class>org.gcube.application.geoportal.model.content.AssociatedContent</class>
|
||||
<class>org.gcube.application.geoportal.model.content.GeoServerContent</class>
|
||||
<class>org.gcube.application.geoportal.model.content.OtherContent</class>
|
||||
<class>org.gcube.application.geoportal.model.content.PersistedContent</class>
|
||||
<class>org.gcube.application.geoportal.model.content.UploadedImage</class>
|
||||
<class>org.gcube.application.geoportal.model.content.WorkspaceContent</class>
|
||||
|
||||
<!-- GIS -->
|
||||
<class>org.gcube.application.geoportal.model.gis.ShapeFileLayerDescriptor</class>
|
||||
<class>org.gcube.application.geoportal.model.gis.SDILayerDescriptor</class>
|
||||
|
||||
|
||||
<properties>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:unit-testing-geona;create=true"/>
|
||||
<!-- <property name="javax.persistence.jdbc.user" value="user"/>
|
||||
<property name="javax.persistence.jdbc.password" value="xxxx"/> -->
|
||||
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
|
||||
<property name="eclipselink.ddl-generation" value="create-or-extend-tables"/>
|
||||
<property name="eclipselink.logging.logger" value="org.eclipse.persistence.logging.DefaultSessionLog"/>
|
||||
<property name="eclipselink.logging.level" value="INFO"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
|
@ -0,0 +1,8 @@
|
|||
log4j.rootLogger=DEBUG, stdout
|
||||
|
||||
#CONSOLE
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Threshold=INFO
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %d{dd MMM yyyy ;HH:mm:ss.SSS} - %m%n
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss} | %-5p | [%thread] %logger{5}:%L - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT" />
|
||||
|
||||
</root>
|
||||
|
||||
</configuration>
|
Reference in New Issue