From 2330c6ab6d133b2019192ec2a802498f5b154bf6 Mon Sep 17 00:00:00 2001 From: "fabio.sinibaldi" Date: Wed, 29 Jan 2020 16:47:34 +0100 Subject: [PATCH] Added interface Snapshot --- .../perform/service/ServiceConstants.java | 8 ++- .../service/engine/PerformanceManager.java | 3 ++ .../engine/impl/PerformanceManagerImpl.java | 6 +++ .../perform/service/rest/Import.java | 2 + .../perform/service/rest/Snapshot.java | 52 +++++++++++++++++++ src/main/webapp/WEB-INF/config.properties | 2 +- 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/gcube/application/perform/service/rest/Snapshot.java diff --git a/src/main/java/org/gcube/application/perform/service/ServiceConstants.java b/src/main/java/org/gcube/application/perform/service/ServiceConstants.java index bb6f47f..1e141d8 100644 --- a/src/main/java/org/gcube/application/perform/service/ServiceConstants.java +++ b/src/main/java/org/gcube/application/perform/service/ServiceConstants.java @@ -27,9 +27,15 @@ public interface ServiceConstants { public static final String EXCEL_FILE_VERSION_PARAMETER="source_version"; public static final String STATUS_PARAMETER="status"; public static final String LAST_METHOD="last"; + + public static final String SNAPSHOT_METHOD="snapshot"; } - + public static interface Snapshot{ + public static final String PATH="snapshot"; + public static final String BATCH_TYPE_PARAMETER="batch_type"; + public static final String FARM_ID_PARAMETER="farmid"; + } public static interface Performance{ public static final String PATH="performance"; public static final String FARM_ID_PARAMETER="farmid"; diff --git a/src/main/java/org/gcube/application/perform/service/engine/PerformanceManager.java b/src/main/java/org/gcube/application/perform/service/engine/PerformanceManager.java index f17b46b..6a0cda0 100644 --- a/src/main/java/org/gcube/application/perform/service/engine/PerformanceManager.java +++ b/src/main/java/org/gcube/application/perform/service/engine/PerformanceManager.java @@ -18,4 +18,7 @@ public interface PerformanceManager { public void loadOutputData(ImportRoutineDescriptor desc)throws SQLException, InvalidRequestException, InternalException, IOException, DMException; public Map getStatistics(AnalysisType type)throws SQLException, InvalidRequestException, InternalException, IOException; + + + public void snapshotImportedData(ImportRoutineDescriptor desc)throws SQLException, InvalidRequestException, InternalException, IOException; } diff --git a/src/main/java/org/gcube/application/perform/service/engine/impl/PerformanceManagerImpl.java b/src/main/java/org/gcube/application/perform/service/engine/impl/PerformanceManagerImpl.java index 7bd98a3..69d6fa9 100644 --- a/src/main/java/org/gcube/application/perform/service/engine/impl/PerformanceManagerImpl.java +++ b/src/main/java/org/gcube/application/perform/service/engine/impl/PerformanceManagerImpl.java @@ -293,6 +293,12 @@ public class PerformanceManagerImpl implements PerformanceManager{ } } + + @Override + public void snapshotImportedData(ImportRoutineDescriptor desc) + throws SQLException, InvalidRequestException, InternalException, IOException { + throw new RuntimeException("Method not yet implemented"); + } // ************************** SCHEMA PARSING private static final String FLOAT_REGEX="\\d*\\.\\d*"; diff --git a/src/main/java/org/gcube/application/perform/service/rest/Import.java b/src/main/java/org/gcube/application/perform/service/rest/Import.java index edc12c9..2c252b7 100644 --- a/src/main/java/org/gcube/application/perform/service/rest/Import.java +++ b/src/main/java/org/gcube/application/perform/service/rest/Import.java @@ -118,4 +118,6 @@ public class Import { } } + + } diff --git a/src/main/java/org/gcube/application/perform/service/rest/Snapshot.java b/src/main/java/org/gcube/application/perform/service/rest/Snapshot.java new file mode 100644 index 0000000..0125675 --- /dev/null +++ b/src/main/java/org/gcube/application/perform/service/rest/Snapshot.java @@ -0,0 +1,52 @@ +package org.gcube.application.perform.service.rest; + +import java.util.List; + +import javax.inject.Inject; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; + +import org.gcube.application.perform.service.PerformServiceManager; +import org.gcube.application.perform.service.ServiceConstants; +import org.gcube.application.perform.service.engine.Importer; +import org.gcube.application.perform.service.engine.model.DBField; +import org.gcube.application.perform.service.engine.model.DBQueryDescriptor; +import org.gcube.application.perform.service.engine.model.importer.ImportRoutineDescriptor; +import org.gcube.smartgears.annotations.ManagedBy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +@Path(ServiceConstants.Snapshot.PATH) +@ManagedBy(PerformServiceManager.class) +public class Snapshot { + + private static final Logger log= LoggerFactory.getLogger(Snapshot.class); + + @Inject + private Importer importer; + + @PUT + public void snapshot(@QueryParam(ServiceConstants.Snapshot.BATCH_TYPE_PARAMETER) String batchType, + @QueryParam(ServiceConstants.Snapshot.FARM_ID_PARAMETER)Long farmid) { + + InterfaceCommons.checkMandatory(batchType, ServiceConstants.Snapshot.BATCH_TYPE_PARAMETER); + InterfaceCommons.checkMandatory(farmid, ServiceConstants.Snapshot.FARM_ID_PARAMETER); + try { + List found=importer.getDescriptors(new DBQueryDescriptor().add( + DBField.ImportRoutine.fields.get(DBField.ImportRoutine.FARM_ID), farmid). + add(DBField.ImportRoutine.fields.get(DBField.ImportRoutine.BATCH_TYPE), batchType)); + + + + }catch(Throwable t) { + log.warn("Unexpected Exception ",t); + throw new WebApplicationException("Unexpected Exception.", t,Response.Status.INTERNAL_SERVER_ERROR); + } + + } + +} diff --git a/src/main/webapp/WEB-INF/config.properties b/src/main/webapp/WEB-INF/config.properties index 2f096de..aad256e 100644 --- a/src/main/webapp/WEB-INF/config.properties +++ b/src/main/webapp/WEB-INF/config.properties @@ -13,5 +13,5 @@ schema.load.skipError=true schema.load.commit=true deanonimization.default_include_SNAPSHOT=false -performance.default_exclude_SNAPSHOT=false +performance.default_include_SNAPSHOT=false \ No newline at end of file