Register UCD

This commit is contained in:
Fabio Sinibaldi 2022-04-27 19:36:10 +02:00
parent 8cb1f8f447
commit 1b7658315c
24 changed files with 209 additions and 216 deletions

View File

@ -0,0 +1,8 @@
package org.gcube.application.cms.caches;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
public interface ObjectManager<T>{
public T insert(T object) throws ConfigurationException;
}

View File

@ -37,6 +37,10 @@ public class DefaultISProvider implements ISInterface, Engine<ISInterface> {
return ISUtils.getGenericResources(secondaryType,name);
}
@Override
public GenericResource createUpdateGR(GenericResource resource) {
return ISUtils.writeGR(resource);
}
// ** ENGINE

View File

@ -15,4 +15,7 @@ public interface ISInterface {
public String encryptString(String toEncrypt);
public List<GenericResource> getGenericResource(String secondaryType,String name);
public GenericResource createUpdateGR(GenericResource res);
}

View File

@ -26,10 +26,13 @@ public class ImplementationProvider {
}
public <T> T getEngineByManagedClass(Class<T> clazz) throws ConfigurationException {
public <T> T getProvidedObjectByClass(Class<T> clazz) throws ConfigurationException {
return (T) implementationsRegistry.get(clazz).getObject();
}
public <T> Engine<T> getEngineByManagedClass(Class<T> clazz) throws ConfigurationException {
return implementationsRegistry.get(clazz);
}
private ConcurrentHashMap<Class,Engine> implementationsRegistry=new ConcurrentHashMap<>();

View File

@ -88,9 +88,16 @@
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>registry-publisher</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>registry-publisher</artifactId>
</dependency>
</dependencies>
</dependencies>
</project>

View File

@ -6,9 +6,13 @@ import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.common.encryption.encrypter.StringEncrypter;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.Resource;
import org.gcube.common.resources.gcore.Resources;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
@ -65,6 +69,14 @@ public class ISUtils {
}
public static<T extends Resource> T writeGR(T toRegister) {
RegistryPublisher rp= RegistryPublisherFactory.create();
if(toRegister.scopes().isEmpty())
return rp.create(toRegister);
else
return rp.update(toRegister);
}
public static String decryptString(String toDecrypt){
try{
return StringEncrypter.getEncrypter().decrypt(toDecrypt);

View File

@ -24,6 +24,7 @@ public class WorkspaceManager {
private StorageHubClient sgClient=null;
@Getter
private FolderContainer appBase=null;
@Getter
@ -59,7 +60,7 @@ public class WorkspaceManager {
}
public WorkspaceManager() throws ConfigurationException, StorageHubException {
sgClient= ImplementationProvider.get().getEngineByManagedClass(StorageHubClient.class);
sgClient= ImplementationProvider.get().getProvidedObjectByClass(StorageHubClient.class);
appBase=getApplicationBaseFolder(sgClient);
}

View File

@ -1,8 +1,6 @@
package org.gcube.application.geoportal.service.engine.mongo;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.mongodb.client.MongoDatabase;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.bson.Document;
@ -251,7 +249,7 @@ public class ConcessioniMongoManager extends MongoManager{
log.info("Persisting {} files for path {} in concessione ",files.size(),destinationPath,id);
try{
Concessione c = getById(id);
StorageUtils storage=ImplementationProvider.get().getEngineByManagedClass(StorageUtils.class);
StorageUtils storage=ImplementationProvider.get().getProvidedObjectByClass(StorageUtils.class);
WorkspaceManager ws=new WorkspaceManager();
//Check Init Base folder
FolderContainer baseFolder=null;

View File

@ -3,7 +3,6 @@ package org.gcube.application.geoportal.service.engine.mongo;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.FindOneAndReplaceOptions;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
@ -15,8 +14,6 @@ import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.geoportal.service.model.internal.db.Mongo;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import javax.print.Doc;
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Sorts.ascending;
import static com.mongodb.client.model.Sorts.descending;
@ -38,7 +35,7 @@ public abstract class MongoManager {
protected static final Document asDoc(String json) {return Document.parse(json);}
public MongoManager() throws ConfigurationException {
client=ImplementationProvider.get().getEngineByManagedClass(Mongo.class);
client=ImplementationProvider.get().getProvidedObjectByClass(Mongo.class);
log.trace("Cached client is {} ",client);
}

View File

@ -17,7 +17,6 @@ import org.gcube.application.cms.plugins.faults.InsufficientPrivileges;
import org.gcube.application.cms.plugins.faults.StepException;
import org.gcube.application.cms.plugins.faults.UnrecognizedStepException;
import org.gcube.application.geoportal.common.model.plugins.LifecycleManagerDescriptor;
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
import org.gcube.application.cms.plugins.reports.DocumentHandlingReport;
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
import org.gcube.application.cms.plugins.requests.BaseRequest;
@ -86,8 +85,8 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
// Check UseCaseDescriptor ID
log.info("Loading useCaseDescriptor ID {} ",profileId);
if(profileId==null) throw new InvalidParameterException("UseCaseDescriptor ID cannot be null");
Map<String, UseCaseDescriptor> profiles=ImplementationProvider.get().getEngineByManagedClass(ProfileMap.class);
useCaseDescriptor = ImplementationProvider.get().getEngineByManagedClass(UCDManagerI.class).getById(profileId);
Map<String, UseCaseDescriptor> profiles=ImplementationProvider.get().getProvidedObjectByClass(ProfileMap.class);
useCaseDescriptor = ImplementationProvider.get().getProvidedObjectByClass(UCDManagerI.class).getById(profileId);
if(useCaseDescriptor == null )
throw new WebApplicationException("UseCaseDescriptor " + profileId + " not registered", Response.Status.NOT_FOUND);
@ -199,7 +198,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
// Loading Lifecycle Manager
log.debug("Looking for handler {} ",lcHandlerDeclaration);
toReturn=(LifecycleManager) ImplementationProvider.get().
getEngineByManagedClass(PluginManager.PluginMap.class).get(lcHandlerDeclaration.getId());
getProvidedObjectByClass(PluginManager.PluginMap.class).get(lcHandlerDeclaration.getId());
if(toReturn==null) throw new ConfigurationException("Unable to find Lifecycle Manager Plugin. ID "+lcHandlerDeclaration.getId());
return toReturn;
@ -511,7 +510,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
doc.getLifecycleInformation().setLastOperationStatus(LifecycleInformation.Status.OK);
WorkspaceManager ws = new WorkspaceManager();
StorageUtils storage = ImplementationProvider.get().getEngineByManagedClass(StorageUtils.class);
StorageUtils storage = ImplementationProvider.get().getProvidedObjectByClass(StorageUtils.class);
log.debug("Checking field {} definition in {}", request.getFieldDefinitionPath(), useCaseDescriptor.getId());

View File

@ -24,7 +24,7 @@ public class PostgisDBManager implements PostgisDBManagerI {
// TODO GENERIC
DatabaseConnection defaultConfiguration=
ImplementationProvider.get().getEngineByManagedClass(ISInterface.class)
ImplementationProvider.get().getProvidedObjectByClass(ISInterface.class)
.queryForDatabase("Database","postgis", "GNA_DB","Concessioni");
log.debug("Found configuration : "+defaultConfiguration);

View File

@ -39,7 +39,7 @@ public class PostgisIndex {
private SDIManager sdiManager;
private String wmsLink=null;
private static PostgisDBManager getDB() throws ConfigurationException {
return ImplementationProvider.get().getEngineByManagedClass(PostgisDBManager.class);
return ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManager.class);
};
public PostgisIndex() throws SDIInteractionException, SQLException, ConfigurationException {

View File

@ -25,7 +25,7 @@ public class MongoClientProvider extends AbstractScopedMap<Mongo> {
@Override
protected Mongo retrieveObject(String context) throws ConfigurationException {
MongoConnection conn=performQueryForMongoDB(ImplementationProvider.get().
getEngineByManagedClass(ISInterface.class),
getProvidedObjectByClass(ISInterface.class),
ServiceConstants.SE_GNA_DB_CATEGORY,
ServiceConstants.MONGO_SE_PLATFORM,
ServiceConstants.SE_GNA_DB_FLAG,

View File

@ -3,24 +3,32 @@ package org.gcube.application.geoportal.service.engine.providers.ucd;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.caches.AbstractScopedMap;
import org.gcube.application.cms.caches.ObjectManager;
import org.gcube.application.cms.implementations.ISInterface;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.service.engine.WorkspaceManager;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.storagehub.client.dsl.FolderContainer;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.lang.reflect.GenericArrayType;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
@ -38,7 +46,10 @@ import java.util.Scanner;
*
*/
@Slf4j
public class SingleISResourceUCDProvider extends AbstractScopedMap<ProfileMap> {
public class SingleISResourceUCDProvider extends AbstractScopedMap<ProfileMap> implements ObjectManager<UseCaseDescriptor> {
private static final String GR_SECONDARY_TYPE="CMS";
private static final String GR_NAME="UCDs";
public SingleISResourceUCDProvider() {
@ -46,6 +57,67 @@ public class SingleISResourceUCDProvider extends AbstractScopedMap<ProfileMap> {
setTTL(Duration.of(2, ChronoUnit.MINUTES));
}
@Override
public UseCaseDescriptor insert(UseCaseDescriptor object) throws ConfigurationException{
try{
log.info("Registering UCID {}",object.getId());
log.debug("Full UCD {} ",object);
// Register entity in WS
WorkspaceManager manager =new WorkspaceManager();
WorkspaceManager.FolderOptions fo=new WorkspaceManager.FolderOptions();
fo.setFolderName("UCDs");
fo.setParent(manager.getAppBase());
fo.setFolderDescription("UCDs registered from server");
FolderContainer folder = manager.createFolder(fo);
String jsonString = Serialization.write(object);
WorkspaceManager.FileOptions fileOptions=new WorkspaceManager.FileOptions(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8)));
fileOptions.setFileName(object.getId());
fileOptions.setFileDescription(object.getName()+", ID : "+object.getId());
fileOptions.setParent(folder);
RegisteredFile f = manager.registerFile(fileOptions);
log.info("Registered File {}",f);
// Create / Update GR
ISInterface is = ImplementationProvider.get().getProvidedObjectByClass(ISInterface.class);
List<GenericResource> l = is.getGenericResource(GR_SECONDARY_TYPE,GR_NAME);
log.debug("Found {} resources ",l.size());
GenericResource toupdate = null;
ISBean bean = new ISBean();
// If GR present, then use it
try{
toupdate = l.get(0);
log.debug("GR IS {}",toupdate);
bean = read(toupdate.profile().bodyAsString());
}catch (Throwable t){
log.warn("Unable to read from selected GR, creating it..",t);
toupdate = new GenericResource();
toupdate.newProfile().name(GR_NAME).type(GR_SECONDARY_TYPE).
description("Generated by service at "+ LocalDateTime.now());
}
if(bean.getRecords()==null) bean.setRecords(new ArrayList<>());
ISBean.Record record = new ISBean.Record();
record.setUcdUrl(f.getLink());
record.setLabel(object.getName());
bean.getRecords().add(record);
log.debug("Inserting record {} ",record);
String xml = write(bean).replaceFirst("<\\?.*\\?>","");
//remove processing instructions
toupdate.profile().newBody(xml);
log.info("Creating / Updating GR {} ",toupdate);
is.createUpdateGR(toupdate);
}catch(ConfigurationException e){
throw e;
} catch (Throwable e) {
throw new ConfigurationException(e);
}
return object;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "UCDs")
@Data
@ -88,17 +160,20 @@ public class SingleISResourceUCDProvider extends AbstractScopedMap<ProfileMap> {
marshaller = jaxbContext.createMarshaller();
unmarshaller = jaxbContext.createUnmarshaller();
}
private static JAXBContext jaxbContext=null;
private static Marshaller marshaller=null;
private static Unmarshaller unmarshaller = null;
private static JAXBContext jaxbContext=null;
private static Marshaller marshaller=null;
private static Unmarshaller unmarshaller = null;
static ISBean read(String xml) throws JAXBException {
log.trace("Loading from xml {}",xml);
if(xml == null || xml.isEmpty()) return new ISBean();
return (ISBean) unmarshaller.unmarshal(new StringReader(xml));
}
static String write(ISBean obj) throws JAXBException {
log.trace("Writing {} to xml",obj);
StringWriter writer = new StringWriter();
@ -111,8 +186,8 @@ public class SingleISResourceUCDProvider extends AbstractScopedMap<ProfileMap> {
protected ProfileMap retrieveObject(String key) throws ConfigurationException {
try {
log.info("Loading UCDs for context {} ",key);
ISInterface is = ImplementationProvider.get().getEngineByManagedClass(ISInterface.class);
List<GenericResource> l = is.getGenericResource("CMS","UCDs");
ISInterface is = ImplementationProvider.get().getProvidedObjectByClass(ISInterface.class);
List<GenericResource> l = is.getGenericResource(GR_SECONDARY_TYPE,GR_NAME);
log.debug("Found {} resources ",l.size());
ProfileMap toReturn = new ProfileMap();
@ -130,6 +205,8 @@ public class SingleISResourceUCDProvider extends AbstractScopedMap<ProfileMap> {
"UTF-8").useDelimiter("\\A").next();
log.trace("JSON IS {} ",json);
UseCaseDescriptor ucd = Serialization.read(json, UseCaseDescriptor.class);
if(toReturn.containsKey(ucd.getId()))
log.warn("DUPLICATE UCID found {} in resource {} ",ucd.getId(),g.id());
toReturn.put(ucd.getId(), ucd);
}catch (Throwable t){
log.warn("Unable to read record {} from GR ID {} ",record,g.id(),t);

View File

@ -2,6 +2,8 @@ package org.gcube.application.geoportal.service.engine.providers.ucd;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.caches.AbstractScopedMap;
import org.gcube.application.cms.caches.Engine;
import org.gcube.application.cms.caches.ObjectManager;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
@ -17,6 +19,8 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import static java.lang.Thread.sleep;
@Slf4j
public class UCDManager extends AbstractScopedMap<UCDManagerI> implements UCDManagerI {
@ -55,9 +59,19 @@ public class UCDManager extends AbstractScopedMap<UCDManagerI> implements UCDMan
// TODO validate UPDATE
// TODO STORE UCD
// forceUpdateCache();
throw new WebApplicationException("TO IMPLEMENT ", Response.Status.INTERNAL_SERVER_ERROR);
} else
throw new WebApplicationException("No Matching UCD with ID "+desc.getId(), Response.Status.NOT_FOUND);
throw new WebApplicationException("Update Feature is yet TO IMPLEMENT ", Response.Status.INTERNAL_SERVER_ERROR);
} else {
// create new
registerNew(desc);
do{
log.info("Waiting for backend to update.. ");
try{sleep(1000);}catch (Throwable t){}
forceUpdateCache();
found =getById(desc.getId());
} while(found == null);
return found;
}
}
@Override
@ -79,10 +93,17 @@ public class UCDManager extends AbstractScopedMap<UCDManagerI> implements UCDMan
private ProfileMap getLiveMap() throws ConfigurationException {
return ImplementationProvider.get().getEngineByManagedClass(ProfileMap.class);
return ImplementationProvider.get().getProvidedObjectByClass(ProfileMap.class);
};
private void registerNew(UseCaseDescriptor ucd) throws ConfigurationException {
Engine<ProfileMap> engine=ImplementationProvider.get().getEngineByManagedClass(ProfileMap.class);
if(engine instanceof ObjectManager){
((ObjectManager<UseCaseDescriptor>)engine).insert(ucd);
} else throw new ConfigurationException("Profile Map Engine is not Object Manager. Actual implementation is "+engine.getClass());
}
private UCDMongoManager getMongoManager() throws ConfigurationException {
return new UCDMongoManager();
}

View File

@ -4,10 +4,8 @@ package org.gcube.application.geoportal.service.rest;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.plugins.Plugin;
import org.gcube.application.geoportal.common.model.configuration.Configuration;
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.service.engine.providers.ConfigurationCache;
import org.gcube.application.geoportal.service.engine.providers.PluginManager;
import javax.ws.rs.*;
@ -28,7 +26,7 @@ public class Plugins {
@Override
protected List<PluginDescriptor> run() throws Exception, WebApplicationException {
List<PluginDescriptor> toReturn=new ArrayList<>();
ImplementationProvider.get().getEngineByManagedClass(PluginManager.PluginMap.class).
ImplementationProvider.get().getProvidedObjectByClass(PluginManager.PluginMap.class).
forEach((s, plugin) -> {try {
toReturn.add(plugin.getDescriptor());
}catch (Throwable t){ log.error("Unable to get Descriptor for {}",s,t);}});
@ -44,7 +42,7 @@ public class Plugins {
return new GuardedMethod<PluginDescriptor>(){
@Override
protected PluginDescriptor run() throws Exception, WebApplicationException {
Map<String, Plugin> m=ImplementationProvider.get().getEngineByManagedClass(PluginManager.PluginMap.class);
Map<String, Plugin> m=ImplementationProvider.get().getProvidedObjectByClass(PluginManager.PluginMap.class);
if(m.containsKey(pluginID))
return m.get(pluginID).getDescriptor();
else throw new WebApplicationException("Plugin \""+pluginID+"\" not found", Response.Status.NOT_FOUND);

View File

@ -41,7 +41,7 @@ public class ProfiledDocuments {
@Override
protected Configuration run() throws Exception, WebApplicationException {
return ImplementationProvider.get().getEngineByManagedClass(ConfigurationCache.ConfigurationMap.class).get(profileID);
return ImplementationProvider.get().getProvidedObjectByClass(ConfigurationCache.ConfigurationMap.class).get(profileID);
}
}.execute().getResult();
}

View File

@ -1,6 +1,5 @@
package org.gcube.application.geoportal.service.rest;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.serialization.Serialization;
@ -19,7 +18,7 @@ public class UseCaseDescriptors {
private UCDManagerI getManager(){
try{
return ImplementationProvider.get().getEngineByManagedClass(UCDManagerI.class);
return ImplementationProvider.get().getProvidedObjectByClass(UCDManagerI.class);
}catch(Throwable t){
log.error("Unable to get UCD Engine",t);
throw new WebApplicationException("Unable to access UC Engine", Response.Status.INTERNAL_SERVER_ERROR);
@ -40,6 +39,9 @@ public class UseCaseDescriptors {
if(toCreate.getMongoId()!=null) throw new WebApplicationException("Cannot register Use Case Descriptor with mongo ID", Response.Status.BAD_REQUEST);
if(toCreate.getId()==null) throw new WebApplicationException("Missing mandatory field ID", Response.Status.BAD_REQUEST);
UseCaseDescriptor toReturn = getManager().put(toCreate);
if(toReturn == null){
log.warn("NB Cached backend implementation is slow beware of that");
}
log.info("Created new UseCaseDescriptor (ID {})",toReturn.getId());
return toReturn;
}

View File

@ -12,7 +12,7 @@ public class StorageTests {
public static void main(String[] args) throws ConfigurationException, IOException {
TokenSetter.set("/gcube/devsec/devVRE");
StorageClientProvider storage= ImplementationProvider.get().getEngineByManagedClass(StorageClientProvider.class);
StorageClientProvider storage= ImplementationProvider.get().getProvidedObjectByClass(StorageClientProvider.class);
String id="614de23b647cef06aecdfb28";
System.out.println("FROM PROVIDER " + storage.getObject().getURL(id));

View File

@ -2,7 +2,11 @@ package org.gcube.application.geoportal.service;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.cms.tests.TestProfiles;
import org.gcube.application.cms.tests.TestSchemas;
import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.cms.tests.model.BasicTests;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
@ -15,6 +19,7 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import java.util.Iterator;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import static junit.framework.TestCase.assertTrue;
@ -54,4 +59,18 @@ public class UCDTests extends BasicServiceTestUnit{
query(request).forEachRemaining(u->l.incrementAndGet());
assertTrue(l.get()>0);
}
@Test
public void registerNew() throws Exception {
UseCaseDescriptor randomUCD=TestProfiles.profiles.get("basic");
randomUCD.setId(UUID.randomUUID().toString());
randomUCD.setName("Test UCD");
UseCaseDescriptor ucd =check(baseTarget().request(MediaType.APPLICATION_JSON).
post(Entity.entity(Serialization.write(randomUCD),
MediaType.APPLICATION_JSON)), UseCaseDescriptor.class);
}
}

View File

@ -113,7 +113,7 @@ public class Caches extends BasicServiceTestUnit {
AtomicLong executed = new AtomicLong(0);
AtomicLong launched = new AtomicLong(0);
final StorageUtils storage=ImplementationProvider.get().getEngineByManagedClass(StorageUtils.class);
final StorageUtils storage=ImplementationProvider.get().getProvidedObjectByClass(StorageUtils.class);
String id =storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"))[0].getId();

View File

@ -47,7 +47,7 @@ public abstract class SDIAbstractPlugin extends AbstractPlugin implements Initia
@Override
protected DatabaseConnection retrieveObject(String context) throws ConfigurationException {
try {
DatabaseConnection db = ImplementationProvider.get().getEngineByManagedClass(ISInterface.class).
DatabaseConnection db = ImplementationProvider.get().getProvidedObjectByClass(ISInterface.class).
queryForDatabase("Database","postgis", "GNA_DB","Concessioni");
log.debug("Postgis Connection in {} is {} ", context,db);
return db;

View File

@ -10,182 +10,6 @@
}
},
"_schema" :{
"CD" : {"_min":1, "_label" : "IDENTIFICAZIONE","_children" :{
"TSK" : {"_min":1,"_type": "DIRECT-CL", "_values": ["MOSI"],"_label":"Tipo modulo"},
"CMD" : {"_min":1,"_label":"Codice modulo"}, # ?? Auto generate
"ESC" : {"_min":1,"_label":"Ente schedatore"}, # ?? Auto generate
"ECP" : {"_min":1,"_label":"Ente competente per tutela"}, # ?? Auto generate
"CBC" : {"_label":"Identificativo scheda bene culturale"},
"ACC" : {"_max":-1,"_label":"ALTRO CODICE", "_children": {
"ACCE" : {"_label": "Ente/soggetto responsabile","_type": "DIRECT-CL", "_values": ["MATTM","Regione","Ente Territoriale","GNA"]},
"ACCC" : {"_label": "Codice Identificativo","_type": "DIRECT-CL", "_values": ["MATTM","Regione","Ente Territoriale","GNA"]},
"ACCS" : {"_label" : "Note"}}}}},
"OG" : {"_label": "AREA/SITO","_children": {
"AMB": {"_label":"Ambito di tutela MiBAC","_min":1,"_type" : "STRING-CONSTANT", "_value":"archelogico"},
"AMA": {"_label":"Ambito di applicazione","_min":1,"_type" : "STRING-CONSTANT", "_value":"archeologia preventiva"},
"OGD": {"_min":1,"_label":"Definizione","_type": "DIRECT-CL", "_values": [
{"ogd" : "area di materiale mobile", "ogt": []},
{"ogd" : "area di uso funerario", "ogt": ["necropoli","monumento funerario"]},
{"ogd" : "deposizione di materiale", "ogt": []},
{"ogd" : "elemento per la confinazione", "ogt": []},
{"ogd" : "elemento toponomastico", "ogt": []},
{"ogd" : "giacimento in cavita' naturale", "ogt": []},
{"ogd" : "giacimento palentonlogico", "ogt": []},
{"ogd" : "giacimento subacqueo", "ogt": ["carico di materiale di bordo"]},
{"ogd" : "infrastruttura agraria", "ogt": ["canalizzazione","terrazzamento a scopo agricolo","tracce di coltivazione"]},
{"ogd" : "infrastruttura assistenziale", "ogt": []},
{"ogd" : "infrastruttura di consolidamento", "ogt": []},
{"ogd" : "infrastruttura di servizio", "ogt": []},
{"ogd" : "infrastruttura idrica", "ogt": []},
{"ogd" : "infrastruttura portuale", "ogt": []},
{"ogd" : "infrastruttura viaria", "ogt": []},
{"ogd" : "insediamento", "ogt": ["villaggio nuragico"]},
{"ogd" : "luogo ad uso pubblico", "ogt": []},
{"ogd" : "luogo di attivita' produttiva", "ogt": []},
{"ogd" : "monumento", "ogt": []},
{"ogd" : "ritrovamento sporadico", "ogt": []},
{"ogd" : "sito non identificato", "ogt": ["strutture murarie","pavimentazione"]},
{"ogd" : "sito pluristratificato", "ogt": []},
{"ogd" : "struttura abitativa", "ogt": []},
{"ogd" : "struttura di fortificazione", "ogt": ["fossato","rocca","porta","torre"]},
{"ogd" : "strutture per il culto", "ogt": []},
{"ogd" : "tracce di frequentazione", "ogt": []},
{"ogd" : "area priva di tracce archeologiche", "ogt": []}]},
"OGT": {"_label":"Tipologia","_type": "Derivate-CL-Field", "_sourcePath": "$.OG.OGD","_field": "ogt"},
"OGN" : {"_label" : "Denominazione"}}},
"LC" : {"_label": "LOCALIZZAZIONE","_min":1,"_children": {
"LCS": {"_label":"Stato","_min":1,"_type": "DIRECT-STRING-CL", "_values": ["Italia"]},
"LCR": {"_label":"Regione","_min":1,"_type": "REMOTE-CL", "_url" : "","_mediatype": "application/json","_field": "lcs"},
"LCP": {"_label":"Provincia","_min":1,"_type": "Derivate-CL-Field", "_sourcePath": "$.LC.LCR","_field": "lcr"},
"LCC": {"_label":"Comune","_min":1,"_type": "Derivate-CL-Field", "_sourcePath": "$.LC.LCP","_field": "lcp"},
"LCI": {"_label":"Indirizzo"},
"PVL": {"_label":"Toponimo"},
"PVZ": {"_label":"Tipo di contesto","_type": "DIRECT-STRING-CL", "_values": ["contesto urbano","contesto suburbano","contesto territoriale","contesto subacqueo"]},
"ACB" : {"_label":"ACCESSIBILITA'","_children": {
"ACBA": {"_label":"Accessibilita'","_type": "DIRECT-STRING-CL", "_values": ["si","no","in parte","disponibile"]},
"ACBS": {"_label":"Note"}}}}},
"DT" : {"_label":"CRONOLOGIA","_min":1,"_children": {
"DTR": {"_label":"Riferimento tecnologico","_min":1},# TODO CHECK CRONOLOGIA
"DTT": {"_label":"Note"}}},
"DA" : {"_label":"DATI ANALITICI","_min":1,"_children":{
"DES": {"_label":"Descrizione","_min":1},
"OGM": {"_label":"Modalita' di individuazione","_type": "DIRECT-STRING-CL", "_values": ["analisi di testimonianze materiali provenienti dall'area in esame[specificare in nota d'ambito il significato del lemma]",
"cartografia storica","dati bibliografici","dati di archivio","documentazione di indagini archeologiche pregresse", "fonti orali","fotointerpretazione/fotorestituzione",
"indagini geomorfiche [carotaggi etc.]","prospezioni geofisiche", "riprese da drone","ricognizione archologica/survey"]}}},
"GE" : {"_min":1,"_label":"GEOREFERENZIAZIONE","_children": {
"GEL": {"_min":1,"_label":"Tipo di localizzazione","_type": "DIRECT-STRING-CL", "_values": ["localizzazione fisica"]},
"GET": {"_min":1,"_label":"Tipo di georeferenziazione","_type": "DIRECT-STRING-CL", "_values": ["georeferenziazione puntuale","georeferenziazione lineare","georeferenziazione areale"]},
"GEP": {"_min":1,"_label":"Sistema di riferimento","_type": "DIRECT-STRING-CL", "_values": ["WGS84"]},
"GEC" : {"_min":1,"_label":"COORDINATE","_children": {
"GECX": {"_min":1,"_label":"Coordinata x"},
"GECY": {"_min":1,"_label":"Coordinata y"}}},
"GPT": {"_min":1,"_label":"Tecnica di georeferenziazione","_type": "DIRECT-STRING-CL", "_values": ["rilievo da cartografia con sopralluogo","rilievo da cartografia senza sopralluogo",
"rilievo da foto aerea con sopralluogo","rilievo da foto aerea senza sopralluogo","rilievo da satellite","rilievo tradizionale","rilievo tramite GPS",
"rilievo tramite punti d'appoggio fiduciari o trigonometrici","stereofotogrammetria"]},
"GPM": {"_min":1,"_label":"Metodo di posizionamento","_type": "DIRECT-STRING-CL", "_values": ["posizionamento esatto","posizionamento approssimato",
"posizionamento con rappresentazione simbolica"]},
"GPB" : {"_min":1,"_label":"BASE CARTOGRAFICA","_children": {
"GPBB": {"_label":"Descrizione sintetica"}}}}},
"TU" : {"_min":1,"_label":"CONDIZIONE GIURIDICA E PROVVEDIMENTI DI TUTELA","_children": {
"CDG": {"_min":1,"_label":"CONDIZIONE GIURIDICA"},"_children" :{
"CDGG": {"_min":1,"_label":"Indicazione generica","_type": "DIRECT-STRING-CL", "_values": ["proprieta' Stato","proprieta' Ente pubblico territoriale",
"proprieta' Ente pubblico non territoriale","proprieta' privata","proprieta' Ente religioso cattolico","proprieta' Ente religioso non cattolico","proprieta' Ente straniero in Italia",
"proprieta' mista pubblica/privata","proprieta' mista pubblica/ecclesiastica","proprieta' mista privata/ecclesiastica","proprieta' persona giuridica senza scopo di lucro",
"detenzione Stato","detenzione Ente religioso cattolico","detenzione Ente religioso non cattolico","detenzione Ente straniero in Italia","detenzione mista pubblica/ privata",
"detenzione mista pubblica/ecclesiastica","detenzione mista privata/ ecclesiastica", "detenzione persona giuridica senza scopo di lucro","condizione giuridica mista","dato non disponibile","NR (recupero pregresso)"]}},
"BPT": {"_min":1,"_label":"Provvedimenti di tutela - sintesi","_type": "DIRECT-STRING-CL", "_values": ["si","no","dato non disponibile"]},
"NVC": {"_max":-1,"_label":"PROVVEDIMENTI DI TUTELA","_children": {
"NVCT": {"_label":"Normativa di riferimento","_type": "DIRECT-STRING-CL", "_values": ["L. 364/1909","L. 778/1922","L. 1089/1939","L. 1497/1939","D.Lgs. 490/1999","D.Lgs 42/2004"]},
"NVCM": {"_label":"Provvedimento di tutela","_type": "DIRECT-STRING-CL", "_values": ["tutela diretta","tutela indiretta","tutela ope legis [art. 142, co. 1, lett. m]"]},
"NVCE": {"_label":"Estremi provvedimento"},
"NVCP": {"_label":"Estensione del vincolo"},
"NWCN": {"_label":"Note"}}},
"STU":{"_label": "STRUMENTI URBANISTICO-TERRITORIALI","_children": {
"STUE": {"_label":"Ente/amministrazione"},
"STUT": {"_label":"Tipo strumento"},
"STUS": {"_label":"Note"}}}}},
"RE" : {"_min":1,"_label":"INDAGINI","_children": {
"RCG": {"_min":1,"_label":"RICOGNIZIONE ARCHEOLOGICA","_children": {
"RCGV": {"_min":1,"_label":"Denominazione ricognizione"},
"RCGD": {"_min":1,"_label":"Riferimento cronologico"},
"RCGT": {"_label":"Situazione ambientale"},
"RCGE": {"_label":"Motivo","_type": "DIRECT-STRING-CL", "_values": ["archeologia preventiva"]}}},
"MTP" : {"_min":1,"_label":"PRESENZA DI MATERIALI","_children": {
"MTPC": {"_label":"Categoria materiale","_type": "DIRECT-STRING-CL", "_values": ["AMBRA","CERAMICA","CORALLO","CUOIO","INDUSTRIA LITICA","INTONACO","INTONACO DIPINTO","LATERIZI",
"MATERIALE LAPIDEO","LEGNO","METALLO","OSSO-CORNO-AVORIO","PIETRE DURE-GEMME","PIETRA OLLARE","REPERTI ANTROPOLOGICI","REPERTI ARCHEOBOTANICI","REPERTI NUMISMATICI","REPERTI FITTILI",
"REPERTI ARCHEOLOGICI","REPERTI ORGANICI","REPERTI SCULTOREI","SCARTI DI PRODUZIONE","TESSUTO","VETRO"]},
"MTPZ": {"_label":"Note"}}},
"MTZ": {"_label":"Assenza di materiali","_type": "DIRECT-STRING-CL", "_values": ["MNP","NR"]},
"FOI" : {"_label" :"FOTOINTERPRETAZIONE/FOTORESTITUZIONE","_children": {
"FOIT" : {"_label": "Tipo immagine", "_type": "DIRECT-STRING-CL", "_values": ["fotografia aerea","fotografia satellitare"]},
"FOIR" : {"_label": "Riferimento cronologico"},
"FOIA" : {"_label": "Origine anomalia","_type": "DIRECT-STRING-CL", "_values": ["origine naturale","origine antropica","origine incerta"]},
"FOIQ" : {"_label": "Tipo anomalia","_type": "DIRECT-STRING-CL", "_values": ["anomalia puntuale","anomalia lineare","anomalia areale"]},
"FOIF" : {"_label": "Classificazione anomalia","_max":-1,"_type": "DIRECT-STRING-CL", "_values": ["affioramento","allineamento","macchia circolare","microrilievo","paleoalveo","tracce non identificate"]},
"FOIO" : {"_label": "Affidabilita'","_type": "DIRECT-STRING-CL", "_values": ["scarsa","discreta","buona","ottima"]},
"FOIN" : {"_label": "Note"}}}}},
"IP" : {"_label": "INDAGINI PREGRESSE","_children": {
"IAP" : {"_label": "INDAGINI ARCHEOLOGICHE PREGRESSE","_min": -1,"_children": {
"IAPN" : {"_label": "Denominazione indagine - Obbligatorieta' di contesto"},
"IAPR" : {"_label": "Riferimento cronologico - Obbligatorieta' di contesto"},
"IAPI" : {"_label": "Informazioni sull'indagine"},
"IAPS" : {"_label": "Note"}}}}},
"MT" : {"_label": "DATI TECNICI","children": {
"MIS" : {"_label": "MISURE","_children": {
"MISZ" : {"_label": "Tipo di misura","_type": "DIRECT-STRING-CL", "_values": ["area"]},
"MISU" : {"_label": "Unita' di misura","_type": "DIRECT-STRING-CL", "_values": ["mq"]},
"MISM" : {"_label": "valore"}}},
"MTA" : {"_label" : "ALTIMETRIA/QUOTE","_max": -1,"_children" : {
"MTAP" : {"_label" : "Riferimento"},
"MTAM" : {"_label" : "Quota minima s.l.m."},
"MTAX" : {"_label" : "Quota massima s.l.m."},
"MTAR" : {"_label" : "Quota relativa"},
"MTAS" : {"_label" : "Note"}}}}},
"VR" : {"_label": "VALUTAZIONE/INTERPRETAZIONE","_min": 1,"_children": {
"VRP" : {"_label": "VALUTAZIONE POTENZIALE ARCHEOLOGICO","_min": 1,"_children": {
"VRPI" : {"_label": "Interpretazione","_min": 1},
"VRPA" : {"_label": "Affidabilita'","_min": 1,"_type": "DIRECT-STRING-CL", "_values": ["scarsa","discreta","buona","ottima"]}
"VRPV" : {"_label": "Valutazione nell'ambito del contesto"},
"VRPS" : {"_label": "Potenziale - sintesi","_min": 1,"_type": "DIRECT-STRING-CL", "_values": ["potenziale alto","potenziale medio","potenziale basso","potenziale nullo","potenziale non valutabile"]},
"VRPN" : {"_label": "Note"}}},
"VRR" : {"_label" : "VALUTAZIONE RISCHIO ARCHEOLOGICO", "_min": 1,"_max": -1,"_children": {
"VRRP" : {"_label": "Codice progetto di riferimento","_min": 1},
"VRRO" : {"_label": "Distanza dall'opera in progetto","_min": 1},
"VRRR" : {"_label": "Valutazione rispetto all'opera in progetto","_min": 1},
"VRRS" : {"_label": "Rischio - sintesi","_min": 1,"_type": "DIRECT-STRING-CL","_values": ["rischio alto","rischio medio","rischio basso","rischio nullo"]},
"VRRN" : {"_label": "Note"}}}}},
"DO" : {"_label" : "DOCUMENTAZIONE", "_min": 1,"_children": {
"FTA" : {"_label" : "DOCUMENTAZIONE FOTOGRAFICA","_min": 1,"_children": {
"FTAN" : {"_label": "Codice identificativo"},
"FTAX" : {"_label": "Genere","_min": 1,"_type": "DIRECT-STRING-CL", "_values": ["documentazione allegata","documentazione esistente"]},
"FTAP" : {"_label": "Tipo", "_min": 1,"_type": "DIRECT-STRING-CL", "_values": ["immagine area","immagine satellitare","immagine b/n","immagine colore"]},
"FTAC" : {"_label": "Collocazione"}}},
"DRA" : {"_label" : "DOCUMENTAZIONE GRAFICA E CARTOGRAFICA","_children": {
"DRAN" : {"_label": "Codice identificativo"},
"DRAX" : {"_label": "Genere","_type": "DIRECT-STRING-CL", "_values": ["documentazione allegata","documentazione esistente"]},
"DRAT" : {"_label": "Tipo", "_type": "DIRECT-STRING-CL", "_values": ["cartografia storica","planimetria","posizionamento topografico","prospetto","sezione"]},
"DRAC" : {"_label": "Collocazione"},
"DRAK" : {"_label": "Nome file digitale"}}},
"FNT" : {"_label" : "FONTI E DOCUMENTI","_children" : {
"FNTI" : {"_label": "Codice identificativo"},
"FNTX" : {"_label": "Genere","_type": "DIRECT-STRING-CL", "_values": ["documentazione allegata","documentazione esistente"]},
"FNTP" : {"_label": "Tipo", "_type": "DIRECT-STRING-CL", "_values": ["relazione di verifica preventiva dell'interesse archeologico","scheda dell'area",
"documentazione di ricognizione archeologica","documentazione di scavo archeologico","referto di indagine archeometrica/diagnostica","fonte d'archivio","pubblicazione"]},
"FNTS" : {"_label": "Collocazione"},
"FNTK" : {"_label": "Nome file digitale"}}},
"BIB" : {"_label": "BIBLIOGRAFIA","_max":-1,"_children": {
"BIBR" : {"_label": "Abbreviazione"},
"BIBX" : {"_label": "Genere","_type": "DIRECT-STRING-CL","_values": ["bibliografia specifica"]},
"BIBM" : {"_label": "Riferimento bibliografico completo"},
"BIBN" : {"_label": "Note"}}}}},
"CM" : {"_label": "CERTIFICAZIONE E GESTIONE DI DATI","_min":1,"_children": {
"FUR" : {"_label" : "Funzionario responsabile","_min": 1},
"CMR" : {"_label" : "Responsabile contenuti","_min": 1},
"CMC" : {"_label" : "Responsabile redazione modulo","_min": 1},
"CMA" : {"_label" : "Anno di redazione","_min": 1},
"ADP" : {"_label" : "Profilo di accesso","_min": 1,"_type": "DIRECT-STRING-CL","_values": ["1","2","3"]}}}},
"_dataAccessPolicies" : [
{"_policy" : {"_read" : "own", "_write" : "own"}, "_roles":[]},

View File

@ -0,0 +1,20 @@
package org.gcube.application.cms.usecases.UCDs;
import org.gcube.application.geoportal.common.utils.ContextUtils;
import java.io.File;
public class RegisterUCD {
//TODO read from args
static String srcType = "file";
static String method = "SIR";
static String ucid="GNA-MOSI";
public static void main(String[] args) {
}
}