Implementing exporter

This commit is contained in:
Luca Frosini 2023-01-09 13:55:57 +01:00
parent 209cbe84bd
commit 436c117b8b
9 changed files with 254 additions and 47 deletions

167
exported-gcat.json Normal file
View File

@ -0,0 +1,167 @@
{
"name" : "gcat",
"short_description" : "gCube Catalogue (gCat) Service allows any client to publish on the gCube Catalogue.",
"publish" : "NONE",
"export" : "ALL",
"default_files" : [ {
"url" : "https://code-repo.d4science.org/gCubeSystem/{{name}}/archive/v{{version}}.zip",
"desired_name" : "{{name}}-v{{version}}.zip"
}, {
"url" : "https://code-repo.d4science.org/gCubeSystem/{{name}}/archive/v{{version}}.tar.gz",
"desired_name" : "{{name}}-v{{version}}.tar.gz"
}, {
"url" : "https://nexus.d4science.org/nexus/service/local/repo_groups/gcube-releases-all/content/org/gcube/data-publishing/{{name}}/{{version}}/{{name}}-{{version}}.war",
"desired_name" : "{{name}}-v{{version}}.war"
} ],
"default_code_location" : "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}",
"code_location_text" : "\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>",
"versions" : [ {
"version" : "1.0.0",
"date" : "2019-01-10",
"files" : [ {
"url" : "https://nexus.d4science.org/nexus/service/local/repositories/gcube-snapshots/content/org/gcube/data-publishing/gcat/1.0.0-SNAPSHOT/gcat-1.0.0-20190109.172827-2.war",
"desired_name" : "{{name}}-v{{version}}.war"
} ],
"gcube_release_version" : null,
"gcube_release_ticket" : null,
"code_location" : false,
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1139446"
}, {
"version" : "1.1.0",
"date" : "2019-02-26",
"files" : [ {
"url" : "https://nexus.d4science.org/nexus/service/local/repo_groups/gcube-releases-all/content/org/gcube/data-publishing/gcat/1.1.0-4.13.1-177071/gcat-1.1.0-4.13.1-177071-src.zip",
"desired_name" : "{{name}}-v{{version}}.zip"
}, {
"url" : "https://nexus.d4science.org/nexus/service/local/repo_groups/gcube-releases-all/content/org/gcube/data-publishing/gcat/1.1.0-4.13.1-177071/gcat-1.1.0-4.13.1-177071.war",
"desired_name" : "{{name}}-v{{version}}.war"
} ],
"gcube_release_version" : "4.13.1",
"gcube_release_ticket" : "https://support.d4science.org/issues/12988",
"code_location" : false,
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1140461"
}, {
"version" : "1.2.0",
"date" : "2019-05-20",
"files" : [ {
"url" : "https://nexus.d4science.org/nexus/service/local/repositories/gcube-snapshots/content/org/gcube/data-publishing/gcat/1.2.0-SNAPSHOT/gcat-1.2.0-20190520.132914-10.war",
"desired_name" : "{{name}}-v{{version}}.war"
} ],
"gcube_release_version" : null,
"gcube_release_ticket" : null,
"code_location" : false,
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1140750"
}, {
"version" : "1.3.0",
"date" : "2019-06-27",
"files" : [ {
"url" : "https://nexus.d4science.org/nexus/service/local/repo_groups/gcube-releases-all/content/org/gcube/data-publishing/gcat/1.3.0-4.14.0-179505/gcat-1.3.0-4.14.0-179505-src.zip",
"desired_name" : "{{name}}-v{{version}}.zip"
}, {
"url" : "https://nexus.d4science.org/nexus/service/local/repo_groups/gcube-releases-all/content/org/gcube/data-publishing/gcat/1.3.0-4.14.0-179505/gcat-1.3.0-4.14.0-179505.war",
"desired_name" : "{{name}}-v{{version}}.war"
} ],
"gcube_release_version" : "4.14.0",
"gcube_release_ticket" : "https://support.d4science.org/issues/16743",
"code_location" : false,
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1143572"
}, {
"version" : "1.4.0",
"date" : "2019-11-20",
"gcube_release_version" : "4.15.0",
"gcube_release_ticket" : "https://support.d4science.org/issues/17294",
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1143583"
}, {
"version" : "1.4.1",
"date" : "2019-12-20",
"gcube_release_version" : "4.18.0",
"gcube_release_ticket" : "https://support.d4science.org/issues/18335",
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1143585"
}, {
"version" : "1.4.2",
"date" : "2020-02-14",
"gcube_release_version" : "4.20.0",
"gcube_release_ticket" : "https://support.d4science.org/issues/18507",
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1143586"
}, {
"version" : "1.4.3",
"date" : "2020-06-16",
"gcube_release_version" : "4.23.0",
"gcube_release_ticket" : "https://support.d4science.org/issues/19322",
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1143587"
}, {
"version" : "1.4.4",
"date" : "2021-02-24",
"gcube_release_version" : "5.0.0",
"gcube_release_ticket" : "https://support.d4science.org/issues/20648",
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1143589"
}, {
"version" : "1.4.5",
"date" : "2021-05-31",
"gcube_release_version" : "5.1.0",
"gcube_release_ticket" : "https://support.d4science.org/issues/20920",
"concept_doi_url" : "https://doi.org/10.5072/zenodo.1139445",
"doi_url" : "https://doi.org/10.5072/zenodo.1143590"
} ],
"metadata" : {
"access_right" : "open",
"creators" : [ {
"affiliation" : "Istituto di Scienza e Tecnologie dell'Informazione \"A. Faedo\" - CNR, Italy",
"name" : "Frosini, Luca",
"orcid" : "0000-0003-3183-2291"
} ],
"description" : "<p><a href=\"https://www.gcube-system.org/\">gCube</a> Catalogue (gCat) Service allows any client to publish on 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>",
"grants" : [ {
"id" : "283644"
}, {
"id" : "283465"
}, {
"id" : "10.13039/501100000780::675680"
}, {
"id" : "10.13039/501100000780::818194"
}, {
"id" : "10.13039/501100000780::654142"
}, {
"id" : "10.13039/501100000780::871042"
}, {
"id" : "10.13039/501100000780::823914"
}, {
"id" : "239019"
}, {
"id" : "288754"
}, {
"id" : "10.13039/501100000780::654182"
}, {
"id" : "10.13039/501100000780::857650"
}, {
"id" : "10.13039/501100000780::862409"
}, {
"id" : "10.13039/501100000780::731001"
}, {
"id" : "10.13039/501100000780::654119"
}, {
"id" : "212488"
}, {
"id" : "10.13039/501100000780::824091"
}, {
"id" : "10.13039/501100000780::727610"
}, {
"id" : "10.13039/501100000780::654024"
} ],
"keywords" : [ "gCube", "Catalogue", "D4Science" ],
"license" : "EUPL-1.1",
"publication_date" : "{{date}}",
"title" : "gCube Catalogue (gCat) Service {{version}}",
"upload_type" : "software",
"version" : "{{version}}"
}
}

View File

@ -12,6 +12,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
public class SoftwareConcept {
public static final String NAME_PROPERTY_NAME = "name";
public static final String SHORT_DESCRIPTION_PROPERTY_NAME = "short_description";
public static final String PUBLISH_PROPERTY_NAME = "publish";
public static final String EXPORT_PROPERTY_NAME = "export";
public static final String DEFAULT_FILES_PROPERTY_NAME = "default_files";
@ -23,6 +24,9 @@ public class SoftwareConcept {
@JsonProperty(NAME_PROPERTY_NAME)
protected String name;
@JsonProperty(SHORT_DESCRIPTION_PROPERTY_NAME)
protected String shortDescription;
@JsonProperty(PUBLISH_PROPERTY_NAME)
@JsonFormat(shape=JsonFormat.Shape.STRING)
protected ElaborationType publish;
@ -50,12 +54,16 @@ public class SoftwareConcept {
return name;
}
public String getShortDescription() {
return shortDescription;
}
public ElaborationType getPublish() {
return publish;
}
public ElaborationType getExport() {
return publish;
return export;
}
public List<SoftwareVersionFile> getDefaultFiles() {

View File

@ -4,25 +4,20 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.common.software.model.ElaborationType;
import org.gcube.common.software.model.SoftwareConcept;
import org.gcube.common.software.model.SoftwareVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.common.software.process.export.biblatex.BibLaTeXSoftwareVersionExporter;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public abstract class SoftwareVersionExporter {
private static final Logger logger = LoggerFactory.getLogger(SoftwareVersionExporter.class);
public static List<SoftwareVersionExporter> getExporters() {
List<SoftwareVersionExporter> sves = new ArrayList<>();
sves.add(new BibLaTeXSoftwareVersionExporter());
return sves;
}
protected SoftwareVersion softwareVersion;
protected ObjectMapper objectMapper;
@ -42,36 +37,6 @@ public abstract class SoftwareVersionExporter {
this.objectMapper = objectMapper;
}
public void export() throws Exception {
SoftwareConcept softwareConcept = softwareVersion.getSoftwareConcept();
String name = softwareConcept.getName();
if(softwareConcept.getPublish()==ElaborationType.NONE) {
logger.info("Export is disabled for {} {}.",
SoftwareConcept.class.getSimpleName(), name);
return;
}
if(softwareVersion.isNewDeposition()) {
if(softwareConcept.getPublish()==ElaborationType.ALL ||
softwareConcept.getPublish()==ElaborationType.NEW) {
logger.info("Going to export {} {}.",
SoftwareConcept.class.getSimpleName(),
name, softwareVersion.getVersion());
}
}else {
if(softwareConcept.getPublish()==ElaborationType.ALL ||
softwareConcept.getPublish()==ElaborationType.UPDATE_ONLY) {
logger.info("Going to export {} {}.",
name, softwareVersion.getVersion());
}else {
return;
}
}
}
public abstract void export() throws Exception;
}

View File

@ -0,0 +1,60 @@
package org.gcube.common.software.process.export.biblatex;
import org.gcube.common.software.model.SoftwareConcept;
import org.gcube.common.software.process.export.SoftwareVersionExporter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class BibLaTeXSoftwareVersionExporter extends SoftwareVersionExporter {
private static final Logger logger = LoggerFactory.getLogger(BibLaTeXSoftwareVersionExporter.class);
public void export() throws Exception {
SoftwareConcept softwareConcept = softwareVersion.getSoftwareConcept();
String name = softwareConcept.getName();
switch (softwareConcept.getExport()) {
case ALL:
generate();
break;
case UPDATE_ONLY:
if(softwareVersion.isNewDeposition()) {
logger.info("Skipping export for {} {}.",
name, softwareVersion.getVersion());
return;
}
generate();
break;
case NEW:
if(!softwareVersion.isNewDeposition()) {
logger.info("Skipping export for {} {}.",
name, softwareVersion.getVersion());
return;
}
generate();
break;
case NONE:
default:
logger.info("Skipping export for {} {}.",
name, softwareVersion.getVersion());
return;
}
}
private void generate() throws Exception {
SoftwareConcept softwareConcept = softwareVersion.getSoftwareConcept();
String name = softwareConcept.getName();
logger.info("Going to export in BibLaTex format {} {}.",
name, softwareVersion.getVersion());
// TODO
}
}

View File

@ -6,16 +6,12 @@ import java.util.List;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.common.software.model.SoftwareVersion;
import org.gcube.common.software.process.publish.zenodo.ZenodoSoftwareVersionPublisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public abstract class SoftwareVersionPublisher {
private static final Logger logger = LoggerFactory.getLogger(SoftwareVersionPublisher.class);
public static List<SoftwareVersionPublisher> getPublishers() {
List<SoftwareVersionPublisher> svps = new ArrayList<>();
svps.add(new ZenodoSoftwareVersionPublisher());

View File

@ -398,7 +398,7 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
String name = softwareConcept.getName();
if(softwareConcept.getPublish()==ElaborationType.NONE) {
logger.info("Deposit is disabled for softwareConcept {} {}.",
logger.info("Deposit is disabled for {} {}.",
name , softwareVersion.getVersion());
return;
}
@ -409,11 +409,11 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
if(softwareConcept.getPublish()==ElaborationType.ALL ||
softwareConcept.getPublish()==ElaborationType.UPDATE_ONLY) {
logger.info("Going to update SoftwareConcept {} {}.",
logger.info("Going to update {} {}.",
name , softwareVersion.getVersion());
update();
}else {
logger.info("SoftwareConcept {} {} has been already deposited.",
logger.info("{} {} has been already deposited.",
name , softwareVersion.getVersion());
}

View File

@ -0,0 +1,10 @@
@software{{{citation_id}},
title = {{title}},
url = {{doi}},
abstract = {{short_description}},
version = {{version}},
author = {{author}},
date = {{date}},
note = {{}},
keywords = {{keywords}},
}

View File

@ -2,6 +2,7 @@
"name": "gcat",
"publish": "NONE",
"export": "ALL",
"short_description": "gCube Catalogue (gCat) Service allows any client to publish on the gCube Catalogue.",
"default_files":
[
{

View File

@ -10,7 +10,7 @@
<logger name="org.gcube" level="ERROR" />
<logger name="org.gcube.common.deposition" level="INFO" />
<logger name="org.gcube.common.software" level="INFO" />
<root level="WARN">
<appender-ref ref="STDOUT" />