improved solution

This commit is contained in:
Luca Frosini 2023-01-31 14:25:31 +01:00
parent 2ee0e60530
commit 18e77c9089
8 changed files with 81 additions and 54 deletions

View File

@ -61,6 +61,7 @@ public class Analyser {
}
protected SoftwareVersionConfig actualizeSoftwareVersionConfig(JsonNode version) throws Exception {
((ObjectNode) version).remove(GlobalConfig.EXPORTERS_PROPERTY_NAME);
Variables variables = objectMapper.treeToValue(version, Variables.class);
Set<String> missingVariables = variables.parse();
int size = missingVariables.size();
@ -84,13 +85,26 @@ public class Analyser {
return softwareVersionConfig;
}
protected GlobalConfig actualizeGlobalConfig(JsonNode node) throws Exception {
protected GlobalConfig getGlobalConfig(JsonNode node) throws Exception {
Variables variables = objectMapper.treeToValue(node, Variables.class);
variables.parse();
JsonNode sc = objectMapper.convertValue(variables.getProperties(), JsonNode.class);
return objectMapper.treeToValue(sc, GlobalConfig.class);
GlobalConfig globalConfig = objectMapper.treeToValue(sc, GlobalConfig.class);
globalConfig.setOriginalJson(globalConfiguration);
return globalConfig;
}
protected ExporterConfig actualizeExporterConfig(ExporterConfig exporterConfig, SoftwareVersionConfig softwareVersionConfig) throws Exception {
ObjectNode versionNode = objectMapper.valueToTree(softwareVersionConfig);
Variables versionVariables = objectMapper.treeToValue(versionNode, Variables.class);
ObjectNode node = objectMapper.valueToTree(exporterConfig);
Variables variables = objectMapper.treeToValue(node, Variables.class);
variables.parseWith(versionVariables);
JsonNode ec = objectMapper.convertValue(variables.getProperties(), JsonNode.class);
return objectMapper.treeToValue(ec, ExporterConfig.class);
}
protected void checkExporters(Set<String> availableExporterNames, Set<String> requestedExporterNames) throws Exception {
if(!availableExporterNames.containsAll(requestedExporterNames)) {
@ -102,9 +116,8 @@ public class Analyser {
public List<File> analyse() throws Exception {
GlobalConfig globalConfig = actualizeGlobalConfig(globalConfiguration);
globalConfig.setOriginalJson(globalConfiguration);
GlobalConfig globalConfig = getGlobalConfig(globalConfiguration);
Map<String, Class<? extends SoftwareVersionExporter>> availableExporters = SoftwareVersionExporter.getAvailableExporters();
Map<String,ExporterConfig> requestedExporters = globalConfig.getExporters();
checkExporters(availableExporters.keySet(), requestedExporters.keySet());
@ -124,9 +137,9 @@ public class Analyser {
for(i=0; i<versionConfigurations.size(); i++) {
ObjectNode versionConfig = (ObjectNode) versionConfigurations.get(i).deepCopy();
JsonNode actualizedVersionConfig = Utils.merge(globalConfiguration, versionConfig);
JsonNode mergedVersionConfig = Utils.merge(globalConfiguration, versionConfig);
SoftwareVersionConfig softwareVersionConfig = actualizeSoftwareVersionConfig(actualizedVersionConfig);
SoftwareVersionConfig softwareVersionConfig = actualizeSoftwareVersionConfig(mergedVersionConfig);
softwareVersionConfig.setOriginalJson(versionConfig);
softwareVersionConfig.setPrevious(previous);
@ -138,7 +151,8 @@ public class Analyser {
Class<? extends SoftwareVersionExporter> exporterClass = availableExporters.get(className);
ExporterConfig exporterConfig = requestedExporters.get(className);
exporterConfig = actualizeExporterConfig(exporterConfig, softwareVersionConfig);
SoftwareVersionExporter sve = exporterClass.newInstance();
sve.setOutputDirectory(outputDirectory);
sve.setGlobalConfig(globalConfig);

View File

@ -58,6 +58,7 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter {
public static final String SKIP_GRANTS_CONFIG_FIELD_NAME = "skip_grants";
public static final String METADATA_FIELD_NAME = "metadata";
public static final String COMMUNITIES_FIELD_NAME = "communities";
public static final String PREVIOUS = "PREVIOUS";
@ -326,6 +327,10 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter {
}
return keywordsArrayNode;
}
private ArrayNode getCommunities() {
return (ArrayNode) softwareVersionConfig.getAdditionalProperty(COMMUNITIES_FIELD_NAME);
}
private String getLicense() {
return softwareVersionConfig.getLicense().get("id").asText();
@ -344,6 +349,7 @@ public class ZenodoSoftwareVersionExporter extends SoftwareVersionExporter {
metadata.put("upload_type", "software");
metadata.replace("creators", getAuthors());
metadata.put("description", getDescription());
metadata.replace("communities", getCommunities());
metadata.replace("grants", getGrants());
metadata.replace("keywords", getKeywords());
metadata.put("license", getLicense());

View File

@ -50,6 +50,9 @@ public class SoftwareVersionConfig {
@JsonIgnore
protected ObjectNode originalJson;
@JsonProperty(NAME_PROPERTY_NAME)
protected String name;
@JsonProperty(VERSION_PROPERTY_NAME)
protected String version;
@ -145,6 +148,10 @@ public class SoftwareVersionConfig {
this.originalJson = originalJson;
}
public String getName() {
return name;
}
public String getVersion() {
return version;
}

View File

@ -44,14 +44,14 @@ public class Utils {
/*
* Merge all the properties contained in version in concept
*/
public static JsonNode merge(JsonNode concept, JsonNode version) {
ObjectNode clonedConcept = concept.deepCopy();
Iterator<String> iterator = version.fieldNames();
public static JsonNode merge(JsonNode node1, JsonNode node2) {
ObjectNode cloned = node1.deepCopy();
Iterator<String> iterator = node2.fieldNames();
while (iterator.hasNext()) {
String fieldName = iterator.next();
JsonNode value = version.get(fieldName);
clonedConcept.replace(fieldName, value.deepCopy());
JsonNode value = node2.get(fieldName);
cloned.replace(fieldName, value.deepCopy());
}
return clonedConcept;
return cloned;
}
}

View File

@ -15,8 +15,8 @@ public class AnalyserTest {
private static final Logger logger = LoggerFactory.getLogger(Analyser.class);
// public static final String FILENAME = "gcat-test-sandbox.json";
public static final String FILENAME = "gcat-from-scratch.json";
public static final String FILENAME = "gcat-test-sandbox.json";
// public static final String FILENAME = "gcat-from-scratch.json";
@Test
public void testUsingTestFile() throws Exception {

View File

@ -1,2 +1,3 @@
/config.properties
/zenodo.properties
/config.properties.prod

View File

@ -9,6 +9,7 @@
},
"keywords": ["gCube", "Catalogue", "D4Science"],
"description": "gCube Catalogue (gCat) Service allows the publication of items in the gCube Catalogue.",
"html_description": "<p>{{description}}</p>",
"authors": [
{
"affiliation": "Istituto di Scienza e Tecnologie dell'Informazione \"A. Faedo\" - CNR, Italy",
@ -30,7 +31,12 @@
"desired_name": "{{name}}-v{{version}}.war"
}
],
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}",
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}",
"communities": [
{
"identifier": "gcube-system"
}
],
"grants": [
{
"id": "004260",
@ -129,12 +135,11 @@
}
],
"export_filename": "{{name}}",
"exporters": {
"ZenodoSoftwareVersionExporter": {
"exporters": {
"ZenodoSoftwareVersionExporter": {
"elaboration": "NONE",
"html_description": "<p><a href=\"https://www.gcube-system.org/\">gCube</a> Catalogue (gCat) Service allows any client to publish items in the gCube Catalogue.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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 <a href=\"https://www.d4science.org/\">D4Science Infrastructure</a>, by favouring the realisation of reuse-oriented policies.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.d4science.org/\">D4Science</a> 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.</p>\n\n<p>&nbsp;</p>",
"html_code_location": "\n\n<p>The official source code location of this software version is available at:</p>\n\n<p><a href=\"{{code_location}}\">{{code_location}}</a></p>",
"skip_grants": ["004260"]
"skip_grants": ["004260"],
"additional_html_description": "\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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 <a href=\"https://www.d4science.org/\">D4Science Infrastructure</a>, by favouring the realisation of reuse-oriented policies.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.d4science.org/\">D4Science</a> 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.</p>\n\n<p>&nbsp;</p>\n\n<p>The official source code location of this software version is available at:</p>\n\n<p><a href=\"{{code_location}}\">{{code_location}}</a></p>"
},
"BibLaTeXSoftwareVersionExporter": {
"elaboration": "ALL"
@ -156,7 +161,7 @@
"gcube_release_ticket": null,
"concept_doi_url": null,
"version_doi_url": null,
"code_location": null
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
},
{
"version": "1.1.0",
@ -176,7 +181,7 @@
"gcube_release_ticket": "https://support.d4science.org/issues/12988",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": null
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
},
{
"version": "1.2.0",
@ -192,7 +197,7 @@
"gcube_release_ticket": null,
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": null
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
},
{
"version": "1.3.0",
@ -212,7 +217,7 @@
"gcube_release_ticket": "https://support.d4science.org/issues/16743",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": null
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}"
},
{
"version": "1.4.0",
@ -221,8 +226,7 @@
"gcube_release_version": "4.15.0",
"gcube_release_ticket": "https://support.d4science.org/issues/17294",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "1.4.1",
@ -231,8 +235,7 @@
"gcube_release_version": "4.18.0",
"gcube_release_ticket": "https://support.d4science.org/issues/18335",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "1.4.2",
@ -241,8 +244,7 @@
"gcube_release_version": "4.20.0",
"gcube_release_ticket": "https://support.d4science.org/issues/18507",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "1.4.3",
@ -251,8 +253,7 @@
"gcube_release_version": "4.23.0",
"gcube_release_ticket": "https://support.d4science.org/issues/19322",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "1.4.4",
@ -261,8 +262,7 @@
"gcube_release_version": "5.0.0",
"gcube_release_ticket": "https://support.d4science.org/issues/20648",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "1.4.5",
@ -271,16 +271,14 @@
"gcube_release_version": "5.1.0",
"gcube_release_ticket": "https://support.d4science.org/issues/20920",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "2.0.0",
"date": "2021-05-04",
"gcube_release_version": "5.2.0",
"concept_doi_url": null,
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "2.1.0",
@ -288,16 +286,15 @@
"gcube_release_version": "5.7.0",
"gcube_release_ticket": "https://support.d4science.org/issues/21685/",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "2.2.0",
"date": "2022-05-12",
"gcube_release_version": "5.11.0",
"gcube_release_ticket": "https://support.d4science.org/issues/22943",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"concept_doi_url": "PREVIOUS",
"version_doi_url": null
},
{
"version": "2.3.0",
@ -305,8 +302,7 @@
"gcube_release_version": "5.13.0",
"gcube_release_ticket": "https://support.d4science.org/issues/23374",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "2.4.0",
@ -314,8 +310,7 @@
"gcube_release_version": "5.13.1",
"gcube_release_ticket": "https://support.d4science.org/issues/23650",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
},
{
"version": "2.4.1",
@ -323,8 +318,7 @@
"gcube_release_version": "5.14.0",
"gcube_release_ticket": "https://support.d4science.org/issues/23885",
"concept_doi_url": "PREVIOUS",
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
"version_doi_url": null
}
]
}

View File

@ -9,7 +9,7 @@
},
"keywords": ["gCube", "Catalogue", "D4Science"],
"description": "gCube Catalogue (gCat) Service allows the publication of items in the gCube Catalogue.",
"html_description": "<p><a href=\"https://www.gcube-system.org/\">gCube</a> Catalogue (gCat) Service allows any client to publish items in the gCube Catalogue.</p>",
"html_description": "<p>{{description}}</p>",
"authors": [
{
"affiliation": "Istituto di Scienza e Tecnologie dell'Informazione \"A. Faedo\" - CNR, Italy",
@ -31,8 +31,13 @@
"desired_name": "{{name}}-v{{version}}.war"
}
],
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}",
"concept_doi_url": "https://doi.org/10.5072/zenodo.1139068",
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}",
"communities": [
{
"identifier": "gcube-system"
}
],
"grants": [
{
"id": "004260",
@ -133,9 +138,9 @@
"export_filename": "{{name}}",
"exporters": {
"ZenodoSoftwareVersionExporter": {
"elaboration": "NONE",
"elaboration": "UPDATE_ONLY",
"skip_grants": ["004260"],
"additional_html_description": "\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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 <a href=\"https://www.d4science.org/\">D4Science Infrastructure</a>, by favouring the realisation of reuse-oriented policies.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.d4science.org/\">D4Science</a> 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.</p>\n\n<p>&nbsp;</p>\n\n<p>The official source code location of this software version is available at:</p>\n\n<p><a href=\"{{code_location}}\">{{code_location}}</a></p>",
"additional_html_description": "\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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 <a href=\"https://www.d4science.org/\">D4Science Infrastructure</a>, by favouring the realisation of reuse-oriented policies.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.gcube-system.org/\">gCube</a> 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.</p>\n\n<p><a href=\"https://www.d4science.org/\">D4Science</a> 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.</p>\n\n<p>&nbsp;</p>\n\n<p>The official source code location of this software version is available at:</p>\n\n<p><a href=\"{{code_location}}\">{{code_location}}</a></p>"
},
"BibLaTeXSoftwareVersionExporter": {
"elaboration": "ALL"