diff --git a/pom.xml b/pom.xml index 0c5faeb..dba958b 100644 --- a/pom.xml +++ b/pom.xml @@ -84,4 +84,30 @@ + + + + + + kr.motd.maven + sphinx-maven-plugin + 2.10.0 + + ${project.build.directory}/${project.artifactId}-${project.version}/docs + html + ${basedir}/docs + ${basedir}/docs + + + + process-resources + + generate + + + + + + + diff --git a/src/main/java/org/gcube/common/software/analyser/Analyser.java b/src/main/java/org/gcube/common/software/analyser/Analyser.java index 1b1897d..fbd546f 100644 --- a/src/main/java/org/gcube/common/software/analyser/Analyser.java +++ b/src/main/java/org/gcube/common/software/analyser/Analyser.java @@ -13,7 +13,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.com.fasterxml.jackson.databind.ObjectMapper; import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode; import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode; -import org.gcube.common.software.export.SoftwareVersionExporter; +import org.gcube.common.software.export.SoftwareArtifactExporter; import org.gcube.common.software.model.ExporterConfig; import org.gcube.common.software.model.GlobalConfig; import org.gcube.common.software.model.SoftwareVersionConfig; @@ -118,7 +118,7 @@ public class Analyser { GlobalConfig globalConfig = getGlobalConfig(globalConfiguration); - Map> availableExporters = SoftwareVersionExporter.getAvailableExporters(); + Map> availableExporters = SoftwareArtifactExporter.getAvailableExporters(); Map requestedExporters = globalConfig.getExporters(); checkExporters(availableExporters.keySet(), requestedExporters.keySet()); @@ -148,12 +148,12 @@ public class Analyser { for(String className : requestedExporters.keySet()) { logger.debug("Going to export with {}", className); - Class exporterClass = availableExporters.get(className); + Class exporterClass = availableExporters.get(className); ExporterConfig exporterConfig = requestedExporters.get(className); exporterConfig = actualizeExporterConfig(exporterConfig, softwareVersionConfig); - SoftwareVersionExporter sve = exporterClass.newInstance(); + SoftwareArtifactExporter sve = exporterClass.newInstance(); sve.setOutputDirectory(outputDirectory); sve.setGlobalConfig(globalConfig); sve.setSoftwareVersionConfig(softwareVersionConfig); diff --git a/src/main/java/org/gcube/common/software/analyser/AnalyserFactory.java b/src/main/java/org/gcube/common/software/analyser/AnalyserFactory.java index 28af744..d77f0b2 100644 --- a/src/main/java/org/gcube/common/software/analyser/AnalyserFactory.java +++ b/src/main/java/org/gcube/common/software/analyser/AnalyserFactory.java @@ -15,8 +15,8 @@ public class AnalyserFactory { public static final String EXPORT_FILENAME_EXTENSION = ".json"; - public static final String GLOBAL_PROPERTY_NAME = "global"; - public static final String VERSIONS_PROPERTY_NAME = "versions"; + public static final String CONFIGURATION_PROPERTY_NAME = "configuration"; + public static final String ARTIFACTS_PROPERTY_NAME = "artifacts"; public static Analyser getAnalyser(File jsonFile) throws Exception { ObjectMapper objectMapper = Utils.getObjectMapper(); @@ -32,9 +32,9 @@ public class AnalyserFactory { public static Analyser getAnalyser(JsonNode jsonNode) throws Exception { Analyser analyser = new Analyser(); - ObjectNode originalGlobal = (ObjectNode) jsonNode.get(GLOBAL_PROPERTY_NAME); + ObjectNode originalGlobal = (ObjectNode) jsonNode.get(CONFIGURATION_PROPERTY_NAME); analyser.setGlobalConfiguration(originalGlobal); - ArrayNode originalVersions = (ArrayNode) jsonNode.get(VERSIONS_PROPERTY_NAME); + ArrayNode originalVersions = (ArrayNode) jsonNode.get(ARTIFACTS_PROPERTY_NAME); analyser.setVersionConfigurations(originalVersions); return analyser; } diff --git a/src/main/java/org/gcube/common/software/export/SoftwareVersionExporter.java b/src/main/java/org/gcube/common/software/export/SoftwareArtifactExporter.java similarity index 74% rename from src/main/java/org/gcube/common/software/export/SoftwareVersionExporter.java rename to src/main/java/org/gcube/common/software/export/SoftwareArtifactExporter.java index 483df59..4d0a95d 100644 --- a/src/main/java/org/gcube/common/software/export/SoftwareVersionExporter.java +++ b/src/main/java/org/gcube/common/software/export/SoftwareArtifactExporter.java @@ -4,8 +4,8 @@ import java.io.File; import java.util.HashMap; import java.util.Map; -import org.gcube.common.software.export.biblatex.BibLaTeXSoftwareVersionExporter; -import org.gcube.common.software.export.zenodo.ZenodoSoftwareVersionExporter; +import org.gcube.common.software.export.biblatex.BibLaTeXExporter; +import org.gcube.common.software.export.zenodo.ZenodoExporter; import org.gcube.common.software.model.ExporterConfig; import org.gcube.common.software.model.GlobalConfig; import org.gcube.common.software.model.SoftwareVersionConfig; @@ -13,21 +13,21 @@ import org.gcube.common.software.model.SoftwareVersionConfig; /** * @author Luca Frosini (ISTI - CNR) */ -public abstract class SoftwareVersionExporter { +public abstract class SoftwareArtifactExporter { - protected static Map> availableExporters; + protected static Map> availableExporters; static { availableExporters = new HashMap<>(); - add(ZenodoSoftwareVersionExporter.class); - add(BibLaTeXSoftwareVersionExporter.class); + add(ZenodoExporter.class); + add(BibLaTeXExporter.class); } - private static void add(Class clz) { + private static void add(Class clz) { availableExporters.put(clz.getSimpleName(), clz); } - public static Map> getAvailableExporters() { + public static Map> getAvailableExporters() { return availableExporters; } @@ -41,7 +41,7 @@ public abstract class SoftwareVersionExporter { protected final String exportFileNameExtension; - protected SoftwareVersionExporter(String exportFileNameExtension) { + protected SoftwareArtifactExporter(String exportFileNameExtension) { this.exportFileNameExtension = exportFileNameExtension; } diff --git a/src/main/java/org/gcube/common/software/export/biblatex/BibLaTeXSoftwareVersionExporter.java b/src/main/java/org/gcube/common/software/export/biblatex/BibLaTeXExporter.java similarity index 94% rename from src/main/java/org/gcube/common/software/export/biblatex/BibLaTeXSoftwareVersionExporter.java rename to src/main/java/org/gcube/common/software/export/biblatex/BibLaTeXExporter.java index b67dea3..5f1d69c 100644 --- a/src/main/java/org/gcube/common/software/export/biblatex/BibLaTeXSoftwareVersionExporter.java +++ b/src/main/java/org/gcube/common/software/export/biblatex/BibLaTeXExporter.java @@ -9,7 +9,7 @@ import java.util.Set; import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode; -import org.gcube.common.software.export.SoftwareVersionExporter; +import org.gcube.common.software.export.SoftwareArtifactExporter; import org.gcube.common.software.model.ElaborationType; import org.gcube.common.software.model.Variables; import org.gcube.common.software.utils.FileUtils; @@ -20,15 +20,15 @@ import org.slf4j.LoggerFactory; /** * @author Luca Frosini (ISTI - CNR) */ -public class BibLaTeXSoftwareVersionExporter extends SoftwareVersionExporter { +public class BibLaTeXExporter extends SoftwareArtifactExporter { - private static final Logger logger = LoggerFactory.getLogger(BibLaTeXSoftwareVersionExporter.class); + private static final Logger logger = LoggerFactory.getLogger(BibLaTeXExporter.class); public static final String EXPORT_FILENAME_EXTENSION = ".bib"; public static final String TEMPLATE_FILENAME = "biblatex.template"; - public BibLaTeXSoftwareVersionExporter() { - super(BibLaTeXSoftwareVersionExporter.EXPORT_FILENAME_EXTENSION); + public BibLaTeXExporter() { + super(BibLaTeXExporter.EXPORT_FILENAME_EXTENSION); } @Override diff --git a/src/main/java/org/gcube/common/software/export/zenodo/ZenodoSoftwareVersionExporter.java b/src/main/java/org/gcube/common/software/export/zenodo/ZenodoExporter.java similarity index 97% rename from src/main/java/org/gcube/common/software/export/zenodo/ZenodoSoftwareVersionExporter.java rename to src/main/java/org/gcube/common/software/export/zenodo/ZenodoExporter.java index 07ba556..4ae95e7 100644 --- a/src/main/java/org/gcube/common/software/export/zenodo/ZenodoSoftwareVersionExporter.java +++ b/src/main/java/org/gcube/common/software/export/zenodo/ZenodoExporter.java @@ -30,7 +30,7 @@ import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode; import org.gcube.common.gxhttp.request.GXHTTPStringRequest; import org.gcube.common.software.analyser.AnalyserFactory; import org.gcube.common.software.config.Config; -import org.gcube.common.software.export.SoftwareVersionExporter; +import org.gcube.common.software.export.SoftwareArtifactExporter; import org.gcube.common.software.model.ElaborationType; import org.gcube.common.software.model.SoftwareVersionConfig; import org.gcube.common.software.model.SoftwareVersionFile; @@ -45,9 +45,9 @@ import org.slf4j.LoggerFactory; /** * @author Luca Frosini (ISTI - CNR) */ -public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter { +public class ZenodoExporter extends SoftwareArtifactExporter { - private static final Logger logger = LoggerFactory.getLogger(ZenodoSoftwareVersionExporter.class); + private static final Logger logger = LoggerFactory.getLogger(ZenodoExporter.class); public static final String EXPORT_FILENAME_EXTENSION = ".json"; @@ -92,8 +92,8 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter { return map; } - public ZenodoSoftwareVersionExporter() { - super(ZenodoSoftwareVersionExporter.EXPORT_FILENAME_EXTENSION); + public ZenodoExporter() { + super(ZenodoExporter.EXPORT_FILENAME_EXTENSION); } protected void addFilesToDeposition(List files ) throws Exception { @@ -476,7 +476,7 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter { conf = Config.getProperties().getProperty(propertyName); } if(conf==null) { - throw new Exception("No configuration '" + propertyName + "' property found."); + throw new Exception("No configuration for '" + propertyName + "' property found."); } return conf; } @@ -540,7 +540,7 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter { protected ObjectNode getObjectNode() throws Exception { ObjectMapper objectMapper = Utils.getObjectMapper(); ObjectNode toBeExported = objectMapper.createObjectNode(); - toBeExported.replace(AnalyserFactory.GLOBAL_PROPERTY_NAME, globalConfig.getOriginalJson().deepCopy()); + toBeExported.replace(AnalyserFactory.CONFIGURATION_PROPERTY_NAME, globalConfig.getOriginalJson().deepCopy()); ArrayNode array = objectMapper.createArrayNode(); SoftwareVersionConfig previous = softwareVersionConfig; boolean firstNode = true; @@ -555,7 +555,7 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter { array.insert(0, node); previous = previous.getPrevious(); } - toBeExported.replace(AnalyserFactory.VERSIONS_PROPERTY_NAME, array); + toBeExported.replace(AnalyserFactory.ARTIFACTS_PROPERTY_NAME, array); return toBeExported; } diff --git a/src/main/java/org/gcube/common/software/model/SoftwareVersionConfig.java b/src/main/java/org/gcube/common/software/model/SoftwareVersionConfig.java index ba700be..70cfaf1 100644 --- a/src/main/java/org/gcube/common/software/model/SoftwareVersionConfig.java +++ b/src/main/java/org/gcube/common/software/model/SoftwareVersionConfig.java @@ -19,6 +19,7 @@ import org.gcube.common.software.utils.Utils; /** * @author Luca Frosini (ISTI - CNR) + * TO BE GENERALIZED */ public class SoftwareVersionConfig { diff --git a/src/main/java/org/gcube/common/software/utils/FileUtils.java b/src/main/java/org/gcube/common/software/utils/FileUtils.java index 6afa4e8..662646d 100644 --- a/src/main/java/org/gcube/common/software/utils/FileUtils.java +++ b/src/main/java/org/gcube/common/software/utils/FileUtils.java @@ -3,7 +3,7 @@ package org.gcube.common.software.utils; import java.io.File; import java.net.URL; -import org.gcube.common.software.export.biblatex.BibLaTeXSoftwareVersionExporter; +import org.gcube.common.software.export.biblatex.BibLaTeXExporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -15,7 +15,7 @@ public class FileUtils { private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); public static File getFileFromFilename(String fileName) throws Exception { - URL jsonFileURL = BibLaTeXSoftwareVersionExporter.class.getClassLoader().getResource(fileName); + URL jsonFileURL = BibLaTeXExporter.class.getClassLoader().getResource(fileName); File file = new File(jsonFileURL.toURI()); logger.trace("File is {}", file.getAbsolutePath()); return file; diff --git a/src/main/java/org/gcube/common/software/utils/Utils.java b/src/main/java/org/gcube/common/software/utils/Utils.java index 958409d..99f692b 100644 --- a/src/main/java/org/gcube/common/software/utils/Utils.java +++ b/src/main/java/org/gcube/common/software/utils/Utils.java @@ -41,8 +41,14 @@ public class Utils { return s.replaceAll("\\{\\{" + variableName + "\\}\\}", replace); } - /* - * Merge all the properties contained in version in concept + /** + * Clone node1 and merge all the properties contained in node2 into the cloned JsonNode. + * In other words, the properties contained in node2 + * will replace/add the properties contained in the clone of node1. + * Both node1 and node2 are not modified. + * @param node1 contains the properties to be merged with the properties contained in node2. + * @param node2 contains the properties will replace/add the properties in the clone of node1. + * @return a new JsonNode containing the merged properties. */ public static JsonNode merge(JsonNode node1, JsonNode node2) { ObjectNode cloned = node1.deepCopy(); diff --git a/src/test/java/org/gcube/common/software/analyser/AnalyserTest.java b/src/test/java/org/gcube/common/software/analyser/AnalyserTest.java index cd220f1..d4c5f0e 100644 --- a/src/test/java/org/gcube/common/software/analyser/AnalyserTest.java +++ b/src/test/java/org/gcube/common/software/analyser/AnalyserTest.java @@ -23,7 +23,7 @@ public class AnalyserTest { File file = FileUtils.getFileFromFilename(FILENAME); Analyser analyser = AnalyserFactory.getAnalyser(file); // analyser.setOutputDirectory(file.getParentFile()); - List files =analyser.analyse(); + List files = analyser.analyse(); logger.info("Generated the following files {}", files); } diff --git a/src/test/resources/gcat-from-scratch.json b/src/test/resources/gcat-from-scratch.json index 673136e..1141170 100644 --- a/src/test/resources/gcat-from-scratch.json +++ b/src/test/resources/gcat-from-scratch.json @@ -1,5 +1,5 @@ { - "global": { + "configuration": { "name": "gcat", "group": "data-catalogue", "title": "gCube Catalogue (gCat) Service {{version}}", @@ -136,17 +136,17 @@ ], "export_filename": "{{name}}", "exporters": { - "ZenodoSoftwareVersionExporter": { + "ZenodoExporter": { "elaboration": "NONE", "skip_grants": ["004260"], "additional_html_description": "\n\n

gCube is an open-source software toolkit used for building and operating Hybrid Data Infrastructures enabling the dynamic deployment of Virtual Research Environments, such as the D4Science Infrastructure, by favouring the realisation of reuse-oriented policies.

\n\n

gCube has been used to successfully build and operate infrastructures and virtual research environments for application domains ranging from biodiversity to environmental data management and cultural heritage.

\n\n

gCube offers components supporting typical data management workflows including data access, curation, processing, and visualisation on a large set of data typologies ranging from primary biodiversity data to geospatial and tabular data.

\n\n

D4Science is a Hybrid Data Infrastructure combining over 500 software components and integrating data from more than 50 different data providers into a coherent and managed system of hardware, software, and data resources. The D4Science infrastructure drastically reduces the cost of ownership, maintenance, and operation thanks to the exploitation of gCube.

\n\n

 

\n\n

The official source code location of this software version is available at:

\n\n

{{code_location}}

" }, - "BibLaTeXSoftwareVersionExporter": { + "BibLaTeXExporter": { "elaboration": "ALL" } } }, - "versions": [ + "artifacts": [ { "version": "1.0.0", "date": "2019-01-10", diff --git a/src/test/resources/gcat-test-sandbox.json b/src/test/resources/gcat-test-sandbox.json index 71a1160..2191b5f 100644 --- a/src/test/resources/gcat-test-sandbox.json +++ b/src/test/resources/gcat-test-sandbox.json @@ -1,5 +1,5 @@ { - "global": { + "configuration": { "name": "gcat", "group": "data-catalogue", "title": "gCube Catalogue (gCat) Service {{version}}", @@ -137,17 +137,17 @@ ], "export_filename": "{{name}}", "exporters": { - "ZenodoSoftwareVersionExporter": { + "ZenodoExporter": { "elaboration": "NONE", "skip_grants": ["004260"], "additional_html_description": "\n\n

gCube is an open-source software toolkit used for building and operating Hybrid Data Infrastructures enabling the dynamic deployment of Virtual Research Environments, such as the D4Science Infrastructure, by favouring the realisation of reuse-oriented policies.

\n\n

gCube has been used to successfully build and operate infrastructures and virtual research environments for application domains ranging from biodiversity to environmental data management and cultural heritage.

\n\n

gCube offers components supporting typical data management workflows including data access, curation, processing, and visualisation on a large set of data typologies ranging from primary biodiversity data to geospatial and tabular data.

\n\n

D4Science is a Hybrid Data Infrastructure combining over 500 software components and integrating data from more than 50 different data providers into a coherent and managed system of hardware, software, and data resources. The D4Science infrastructure drastically reduces the cost of ownership, maintenance, and operation thanks to the exploitation of gCube.

\n\n

 

\n\n

The official source code location of this software version is available at:

\n\n

{{code_location}}

" }, - "BibLaTeXSoftwareVersionExporter": { + "BibLaTeXExporter": { "elaboration": "ALL" } } }, - "versions": [ + "artifacts": [ { "version": "1.0.0", "date": "2019-01-10",