Generalised solution

This commit is contained in:
Luca Frosini 2023-01-16 13:58:51 +01:00
parent de9066a4f7
commit 5c3209d07e
14 changed files with 323 additions and 228 deletions

View File

@ -8,10 +8,9 @@ import java.util.concurrent.TimeUnit;
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.JsonNodeType;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.common.software.model.SoftwareConcept;
import org.gcube.common.software.model.SoftwareVersion;
import org.gcube.common.software.model.SoftwareGlobalConfig;
import org.gcube.common.software.model.SoftwareVersionConfig;
import org.gcube.common.software.model.Variables;
import org.gcube.common.software.utils.Utils;
import org.slf4j.Logger;
@ -20,31 +19,29 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class SoftwareConceptAnalyser {
public class SoftwareConfigAnalyser {
private static final Logger logger = LoggerFactory.getLogger(SoftwareConceptAnalyser.class);
private static final Logger logger = LoggerFactory.getLogger(SoftwareConfigAnalyser.class);
public static final String CONCEPT_FILENAME_EXTENSION = ".json";
public static final String EXPORT_FILENAME_EXTENSION = ".json";
public static final String CONCEPT_PROPERTY_NAME = "concept";
public static final String GLOBAL_PROPERTY_NAME = "global";
public static final String VERSIONS_PROPERTY_NAME = "versions";
public static final String PUBLISHERS_PROPERTY_NAME = "publishers";
public static final String EXPORTERS_PROPERTY_NAME = "exporters";
protected ObjectMapper objectMapper;
protected JsonNode jsonNode;
public SoftwareConceptAnalyser(File jsonFile) throws Exception {
public SoftwareConfigAnalyser(File jsonFile) throws Exception {
this.objectMapper = Utils.getObjectMapper();
this.jsonNode = objectMapper.readTree(jsonFile);
}
public SoftwareConceptAnalyser(String json) throws Exception {
public SoftwareConfigAnalyser(String json) throws Exception {
this.objectMapper = Utils.getObjectMapper();
this.jsonNode = objectMapper.readTree(json);
}
protected SoftwareVersion actualize(JsonNode version) throws Exception {
protected SoftwareVersionConfig actualize(JsonNode version) throws Exception {
Variables variables = objectMapper.treeToValue(version, Variables.class);
Set<String> missingVariables = variables.parse();
int size = missingVariables.size();
@ -53,18 +50,20 @@ public class SoftwareConceptAnalyser {
missingVariables.toArray(new String[size]).toString());
}
JsonNode swVersion = objectMapper.convertValue(variables.getProperties(), JsonNode.class);
SoftwareVersion softwareVersion = objectMapper.treeToValue(swVersion, SoftwareVersion.class);
SoftwareVersionConfig softwareVersion = objectMapper.treeToValue(swVersion, SoftwareVersionConfig.class);
// softwareVersion.setVariables(variables);
return softwareVersion;
}
public void analyse() throws Exception {
ObjectNode concept = (ObjectNode) jsonNode.get(CONCEPT_PROPERTY_NAME).deepCopy();
SoftwareConcept softwareConcept = objectMapper.treeToValue(concept, SoftwareConcept.class);
ObjectNode originalGlobal = (ObjectNode) jsonNode.get(GLOBAL_PROPERTY_NAME).deepCopy();
SoftwareGlobalConfig softwareGlobalConfig = objectMapper.treeToValue(originalGlobal, SoftwareGlobalConfig.class);
softwareGlobalConfig.setOriginalJson(originalGlobal);
ArrayNode versions = (ArrayNode) jsonNode.get(VERSIONS_PROPERTY_NAME);
String name = softwareConcept.getName();
SoftwareVersion previous = null;
String name = softwareGlobalConfig.getName();
SoftwareVersionConfig previous = null;
int i = 0;
@ -73,9 +72,11 @@ public class SoftwareConceptAnalyser {
for(i=0; i<versions.size(); i++) {
ObjectNode originalVersion = (ObjectNode) versions.get(i).deepCopy();
exportingVersions.add(originalVersion);
JsonNode version = Utils.merge(concept, originalVersion);
SoftwareVersion softwareVersion = actualize(version);
JsonNode version = Utils.merge(originalGlobal, originalVersion);
SoftwareVersionConfig softwareVersion = actualize(version);
softwareVersion.setOriginalJson(originalVersion);
boolean newDOI = false;
if(softwareVersion.getDOIURL()==null) {
@ -93,8 +94,8 @@ public class SoftwareConceptAnalyser {
softwareVersion.getPrevious()!=null ? softwareVersion.getPrevious().getVersion(): null);
try {
SoftwareVersionAnalyser softwareVersionAnalyser = new SoftwareVersionAnalyser(softwareVersion);
softwareVersionAnalyser.setOriginalJson(jsonNode);
SoftwareVersionConfigAnalyser softwareVersionAnalyser = new SoftwareVersionConfigAnalyser(softwareVersion);
softwareVersionAnalyser.setSoftwareGlobalConfig(softwareGlobalConfig);
softwareVersionAnalyser.setFirst(i==0);
softwareVersionAnalyser.analyse();
@ -104,16 +105,16 @@ public class SoftwareConceptAnalyser {
/* Need to export the original file with the DOI and Version DOI */
URL doiURL = softwareVersion.getDOIURL();
if(doiURL!=null) {
originalVersion.put(SoftwareVersion.DOI_URL_PROPERTY_NAME, doiURL.toString());
originalVersion.put(SoftwareVersionConfig.DOI_URL_PROPERTY_NAME, doiURL.toString());
}
if(softwareVersion.getVersionDOIURL()!=null) {
originalVersion.put(SoftwareVersion.VERSION_DOI_URL_PROPERTY_NAME, softwareVersion.getVersionDOIURL().toString());
originalVersion.put(SoftwareVersionConfig.VERSION_DOI_URL_PROPERTY_NAME, softwareVersion.getVersionDOIURL().toString());
}
if(newDOI) {
softwareConcept.setDOIURL(doiURL);
concept.put(SoftwareConcept.DOI_URL_PROPERTY_NAME, doiURL.toString());
softwareGlobalConfig.setDOIURL(doiURL);
originalGlobal.put(SoftwareGlobalConfig.DOI_URL_PROPERTY_NAME, doiURL.toString());
}
}
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
@ -126,28 +127,27 @@ public class SoftwareConceptAnalyser {
throw e;
}finally {
ObjectNode toBeExported = objectMapper.createObjectNode();
toBeExported.replace(CONCEPT_PROPERTY_NAME, concept);
toBeExported.replace(GLOBAL_PROPERTY_NAME, originalGlobal);
// if(originalGlobal.has(SoftwareGlobalConfig.DOI_URL_PROPERTY_NAME)
// && originalGlobal.get(SoftwareGlobalConfig.DOI_URL_PROPERTY_NAME).getNodeType()!=JsonNodeType.NULL) {
// String conceptDOIURL = originalGlobal.get(SoftwareGlobalConfig.DOI_URL_PROPERTY_NAME).asText();
//
// for(i=0; i<exportingVersions.size(); i++) {
// ObjectNode v = (ObjectNode) exportingVersions.get(i);
// if(v.has(SoftwareVersionConfig.DOI_URL_PROPERTY_NAME)
// && v.get(SoftwareVersionConfig.DOI_URL_PROPERTY_NAME).getNodeType()!=JsonNodeType.NULL){
// String vDOI = v.get(SoftwareVersionConfig.DOI_URL_PROPERTY_NAME).asText();
// if(conceptDOIURL.compareTo(vDOI)==0) {
// v.remove(SoftwareVersionConfig.DOI_URL_PROPERTY_NAME);
// }
// }
// }
// }
if(concept.has(SoftwareConcept.DOI_URL_PROPERTY_NAME)
&& concept.get(SoftwareConcept.DOI_URL_PROPERTY_NAME).getNodeType()!=JsonNodeType.NULL) {
String conceptDOIURL = concept.get(SoftwareConcept.DOI_URL_PROPERTY_NAME).asText();
for(i=0; i<exportingVersions.size(); i++) {
ObjectNode v = (ObjectNode) exportingVersions.get(i);
if(v.has(SoftwareVersion.DOI_URL_PROPERTY_NAME)
&& v.get(SoftwareVersion.DOI_URL_PROPERTY_NAME).getNodeType()!=JsonNodeType.NULL){
String vDOI = v.get(SoftwareVersion.DOI_URL_PROPERTY_NAME).asText();
if(conceptDOIURL.compareTo(vDOI)==0) {
v.remove(SoftwareVersion.DOI_URL_PROPERTY_NAME);
}
}
}
}
toBeExported.replace(VERSIONS_PROPERTY_NAME, exportingVersions);
toBeExported.replace(PUBLISHERS_PROPERTY_NAME, jsonNode.get(PUBLISHERS_PROPERTY_NAME).deepCopy());
toBeExported.replace(EXPORTERS_PROPERTY_NAME, jsonNode.get(EXPORTERS_PROPERTY_NAME).deepCopy());
File file = new File(name+CONCEPT_FILENAME_EXTENSION);
File file = new File(name+EXPORT_FILENAME_EXTENSION);
objectMapper.writeValue(file, toBeExported);
}

View File

@ -1,75 +0,0 @@
package org.gcube.common.software.analyser;
import java.net.URL;
import java.util.List;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.common.software.model.SoftwareVersion;
import org.gcube.common.software.model.SoftwareVersionFile;
import org.gcube.common.software.model.Variables;
import org.gcube.common.software.process.export.SoftwareVersionExporter;
import org.gcube.common.software.process.publish.SoftwareVersionPublisher;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class SoftwareVersionAnalyser {
protected JsonNode originalJson;
protected SoftwareVersion softwareVersion;
protected boolean first;
public SoftwareVersionAnalyser(SoftwareVersion softwareVersion) {
this.softwareVersion = softwareVersion;
}
public boolean isFirst() {
return first;
}
public void setFirst(boolean first) {
this.first = first;
}
public void setOriginalJson(JsonNode jsonNode) {
this.originalJson = jsonNode;
}
public void analyse() throws Exception {
Variables variables = softwareVersion.getVariables();
List<SoftwareVersionFile> svfs = softwareVersion.getFiles();
for(SoftwareVersionFile svf : svfs) {
URL url = svf.getURL();
String urlString = variables.replaceAllVariables(url.toString());
svf.setURL(new URL(urlString));
String desiredName = svf.getDesiredName();
desiredName = variables.replaceAllVariables(desiredName);
svf.setDesiredName(desiredName);
}
ObjectNode publishers = (ObjectNode) originalJson.get(SoftwareConceptAnalyser.PUBLISHERS_PROPERTY_NAME).deepCopy();
List<SoftwareVersionPublisher> svps = SoftwareVersionPublisher.getPublishers();
for(SoftwareVersionPublisher svp: svps) {
JsonNode conf = publishers.get(svp.getClass().getSimpleName());
svp.setSpecificConfiguration(conf);
svp.setSoftwareVersion(softwareVersion);
svp.setFirst(first);
svp.publish();
}
ObjectNode exporters = (ObjectNode) originalJson.get(SoftwareConceptAnalyser.EXPORTERS_PROPERTY_NAME).deepCopy();
List<SoftwareVersionExporter> sves = SoftwareVersionExporter.getExporters();
for(SoftwareVersionExporter sve: sves) {
JsonNode conf = publishers.get(exporters.getClass().getSimpleName());
sve.setSpecificConfiguration(conf);
sve.setSoftwareVersion(softwareVersion);
sve.setFirst(first);
sve.export();
}
}
}

View File

@ -0,0 +1,89 @@
package org.gcube.common.software.analyser;
import java.net.URL;
import java.util.List;
import java.util.Map;
import org.gcube.common.software.model.ProcessorConfig;
import org.gcube.common.software.model.SoftwareGlobalConfig;
import org.gcube.common.software.model.SoftwareVersionConfig;
import org.gcube.common.software.model.SoftwareVersionFile;
import org.gcube.common.software.model.Variables;
import org.gcube.common.software.process.export.SoftwareVersionExporter;
import org.gcube.common.software.process.publish.SoftwareVersionPublisher;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class SoftwareVersionConfigAnalyser {
protected SoftwareGlobalConfig softwareGlobalConfig;
protected SoftwareVersionConfig softwareVersionConfig;
protected boolean first;
public SoftwareVersionConfigAnalyser(SoftwareVersionConfig softwareVersionConfig) {
this.softwareVersionConfig = softwareVersionConfig;
}
public SoftwareGlobalConfig getSoftwareGlobalConfig() {
return softwareGlobalConfig;
}
public void setSoftwareGlobalConfig(SoftwareGlobalConfig softwareGlobalConfig) {
this.softwareGlobalConfig = softwareGlobalConfig;
}
public SoftwareVersionConfig getSoftwareVersionConfig() {
return softwareVersionConfig;
}
public void setSoftwareVersionConfig(SoftwareVersionConfig softwareVersionConfig) {
this.softwareVersionConfig = softwareVersionConfig;
}
public boolean isFirst() {
return first;
}
public void setFirst(boolean first) {
this.first = first;
}
public void analyse() throws Exception {
Variables variables = softwareVersionConfig.getVariables();
List<SoftwareVersionFile> svfs = softwareVersionConfig.getFiles();
for(SoftwareVersionFile svf : svfs) {
URL url = svf.getURL();
String urlString = variables.replaceAllVariables(url.toString());
svf.setURL(new URL(urlString));
String desiredName = svf.getDesiredName();
desiredName = variables.replaceAllVariables(desiredName);
svf.setDesiredName(desiredName);
}
Map<String,ProcessorConfig> processors = softwareVersionConfig.getPublishers();
List<SoftwareVersionPublisher> svps = SoftwareVersionPublisher.getPublishers();
for(SoftwareVersionPublisher svp: svps) {
ProcessorConfig processorConfig = processors.get(svp.getClass().getSimpleName());
svp.setProcessorConfig(processorConfig);
svp.setSoftwareVersion(softwareVersionConfig);
svp.setFirst(first);
svp.publish();
}
Map<String,ProcessorConfig> exporters = softwareVersionConfig.getExporters();
List<SoftwareVersionExporter> sves = SoftwareVersionExporter.getExporters();
for(SoftwareVersionExporter sve: sves) {
ProcessorConfig processorConfig = exporters.get(sve.getClass().getSimpleName());
sve.setProcessorConfig(processorConfig);
sve.setSoftwareVersion(softwareVersionConfig);
sve.setFirst(first);
sve.export();
}
}
}

View File

@ -0,0 +1,49 @@
package org.gcube.common.software.model;
import java.util.LinkedHashMap;
import java.util.Map;
import org.gcube.com.fasterxml.jackson.annotation.JsonAnyGetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ProcessorConfig {
public static final String ELABORATION_PROPERTY_NAME = "elaboration";
@JsonProperty(ELABORATION_PROPERTY_NAME)
@JsonFormat(shape=JsonFormat.Shape.STRING)
protected ElaborationType elaboration;
protected Map<String, JsonNode> properties;
public ProcessorConfig() {
properties = new LinkedHashMap<>();
}
public ElaborationType getElaboration() {
return elaboration;
}
@JsonAnyGetter
public Map<String, JsonNode> getProperties() {
return properties;
}
@JsonAnySetter
public void addProperty(String key, JsonNode value) {
this.properties.put(key, value);
}
@JsonIgnore
public JsonNode getProperty(String key) {
return this.properties.get(key);
}
}

View File

@ -2,17 +2,19 @@ package org.gcube.common.software.model;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class SoftwareConcept {
public class SoftwareGlobalConfig {
public static final String NAME_PROPERTY_NAME = "name";
public static final String GROUP_PROPERTY_NAME = "group";
@ -25,9 +27,12 @@ public class SoftwareConcept {
public static final String CODE_LOCATION_PROPERTY_NAME = "code_location";
public static final String DOI_URL_PROPERTY_NAME = "doi_url";
public static final String GRANTS_PROPERTY_NAME = "grants";
public static final String PUBLISH_PROPERTY_NAME = "publish";
public static final String EXPORT_PROPERTY_NAME = "export";
public static final String PUBLISHERS_PROPERTY_NAME = "publishers";
public static final String EXPORTERS_PROPERTY_NAME = "exporters";
@JsonIgnore
protected ObjectNode originalJson;
@JsonProperty(NAME_PROPERTY_NAME)
protected String name;
@ -61,14 +66,22 @@ public class SoftwareConcept {
@JsonProperty(GRANTS_PROPERTY_NAME)
protected JsonNode grants;
@JsonProperty(PUBLISH_PROPERTY_NAME)
@JsonFormat(shape=JsonFormat.Shape.STRING)
protected ElaborationType publish;
@JsonProperty(PUBLISHERS_PROPERTY_NAME)
protected Map<String,ProcessorConfig> publishers;
@JsonProperty(EXPORT_PROPERTY_NAME)
@JsonFormat(shape=JsonFormat.Shape.STRING)
protected ElaborationType export;
@JsonProperty(EXPORTERS_PROPERTY_NAME)
protected Map<String,ProcessorConfig> exporters;
@JsonIgnore
public ObjectNode getOriginalJson() {
return originalJson;
}
@JsonIgnore
public void setOriginalJson(ObjectNode originalJson) {
this.originalJson = originalJson;
}
public String getName() {
return name;
}
@ -117,12 +130,12 @@ public class SoftwareConcept {
return grants;
}
public ElaborationType getPublish() {
return publish;
public Map<String,ProcessorConfig> getPublishers() {
return publishers;
}
public ElaborationType getExport() {
return export;
public Map<String,ProcessorConfig> getExporters() {
return exporters;
}
}

View File

@ -16,7 +16,7 @@ import org.gcube.common.software.utils.Utils;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class SoftwareVersion extends SoftwareConcept {
public class SoftwareVersionConfig extends SoftwareGlobalConfig {
public static final String VERSION_PROPERTY_NAME = "version";
public static final String DATE_PROPERTY_NAME = "date";
@ -25,10 +25,10 @@ public class SoftwareVersion extends SoftwareConcept {
public static final String VERSION_DOI_URL_PROPERTY_NAME = "version_doi_url";
@JsonIgnore
protected SoftwareVersion previous;
protected SoftwareVersionConfig previous;
@JsonIgnore
protected SoftwareVersion next;
protected SoftwareVersionConfig next;
@JsonIgnore
protected Boolean newDeposition;
@ -50,27 +50,27 @@ public class SoftwareVersion extends SoftwareConcept {
protected URL versionDOIURL;
public SoftwareVersion() {
public SoftwareVersionConfig() {
this.newDeposition = false;
}
@JsonIgnore
public SoftwareVersion getPrevious() {
public SoftwareVersionConfig getPrevious() {
return previous;
}
@JsonIgnore
public void setPrevious(SoftwareVersion previous) {
public void setPrevious(SoftwareVersionConfig previous) {
this.previous = previous;
}
@JsonIgnore
public SoftwareVersion getNext() {
public SoftwareVersionConfig getNext() {
return next;
}
@JsonIgnore
public void setNext(SoftwareVersion next) {
public void setNext(SoftwareVersionConfig next) {
this.next = next;
}

View File

@ -54,14 +54,19 @@ public class Variables {
Set<String> variableNames = findVariables(value);
for(String variableName : variableNames) {
if(properties.containsKey(variableName)) {
String variableValue = properties.get(variableName).toString();
value = Utils.replaceVariable(variableName, variableValue, value);
try {
String variableValue = properties.get(variableName).toString();
value = Utils.replaceVariable(variableName, variableValue, value);
}catch (Exception e) {
missingVariables.add(variableName);
}
}else {
missingVariables.add(variableName);
}
}
if(missingVariables.size()>0) {
throw new Exception("The following varibles cannot be replaced because they don't exists " + missingVariables.toString());
throw new Exception("The following variables cannot be replaced because they don't exists " + missingVariables.toString());
}
return value;
}

View File

@ -1,22 +1,23 @@
package org.gcube.common.software.process;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.common.software.model.SoftwareVersion;
import org.gcube.common.software.model.ProcessorConfig;
import org.gcube.common.software.model.SoftwareVersionConfig;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public abstract class SoftwareVersionProcessor {
protected SoftwareVersion softwareVersion;
protected JsonNode configuration;
protected SoftwareVersionConfig softwareVersion;
protected ProcessorConfig processorConfig;
protected boolean first;
public SoftwareVersion getSoftwareVersion() {
public SoftwareVersionConfig getSoftwareVersion() {
return softwareVersion;
}
public void setSoftwareVersion(SoftwareVersion softwareVersion) {
public void setSoftwareVersion(SoftwareVersionConfig softwareVersion) {
this.softwareVersion = softwareVersion;
}
@ -28,8 +29,12 @@ public abstract class SoftwareVersionProcessor {
this.first = first;
}
public void setSpecificConfiguration(JsonNode conf) {
this.configuration = conf;
public ProcessorConfig getProcessorConfig() {
return processorConfig;
}
public void setProcessorConfig(ProcessorConfig processorConfig) {
this.processorConfig = processorConfig;
}
}

View File

@ -30,7 +30,7 @@ public class BibLaTeXSoftwareVersionExporter extends SoftwareVersionExporter {
public void export() throws Exception {
String name = softwareVersion.getName();
ElaborationType export = softwareVersion.getExport();
ElaborationType export = processorConfig.getElaboration();
switch (export) {
case ALL:

View File

@ -25,6 +25,7 @@ import javax.ws.rs.core.Response;
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.JsonNodeType;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
import org.gcube.common.software.config.Config;
@ -48,13 +49,17 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
public static final String GUCBE_ZENODO_SOFTWARE_DEPOSIT = "gCubeSoftwareDeposit";
public static final String HTML_DESCRIPTION_CONFIG_FIELD_NAME = "html_description";
public static final String HTML_CODE_LOCATION_CONFIG_FIELD_NAME = "html_code_location";
public static final String SKIP_GRANTS_CONFIG_FIELD_NAME = "skip_grants";
public static final String METADATA_FIELD_NAME = "metadata";
private static final String SANDBOX_BASE_PATH = "https://sandbox.zenodo.org";
private static final String SANDBOX_DOI_URL_BASE_PATH = "https://doi.org/10.5072/zenodo.";
private static final String PRODUCTION_BASE_PATH = "https://zenodo.org";
private static final String PRODUCTION_DOI_URL_BASE_PATH = "https://doi.org/10.5281/zenodo.";
// private static final String SANDBOX_BASE_PATH = "https://sandbox.zenodo.org";
// private static final String SANDBOX_DOI_URL_BASE_PATH = "https://doi.org/10.5072/zenodo.";
//
// private static final String PRODUCTION_BASE_PATH = "https://zenodo.org";
// private static final String PRODUCTION_DOI_URL_BASE_PATH = "https://doi.org/10.5281/zenodo.";
public static final String DEPOSITIONS_COLLECTION_PATH = "/api/deposit/depositions";
public static final String DEPOSITION_PATH = DEPOSITIONS_COLLECTION_PATH + "/:id";
@ -88,24 +93,7 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
return map;
}
public ZenodoSoftwareVersionPublisher() {
try {
this.zenodoBaseURL = new URL(Config.getProperties().getProperty("zenodo_base_url"));
this.accessToken = Config.getProperties().getProperty("zenodo_access_token");
this.doiBaseURL = Config.getProperties().getProperty("doi_base_url");
if(doiBaseURL==null) {
if(zenodoBaseURL.toString().compareTo(SANDBOX_BASE_PATH)==0) {
doiBaseURL = SANDBOX_DOI_URL_BASE_PATH;
}else if(zenodoBaseURL.toString().compareTo(PRODUCTION_BASE_PATH)==0) {
doiBaseURL = PRODUCTION_DOI_URL_BASE_PATH;
}else {
throw new RuntimeException("Please set 'doi_base_url' in your config file");
}
}
}catch (Exception e) {
throw new RuntimeException(e);
}
}
public ZenodoSoftwareVersionPublisher() {}
protected void addFilesToDeposition(List<File> files ) throws Exception {
String depositID = getZenodoIDFromDOIURL(softwareVersion.getVersionDOIURL());
@ -298,11 +286,11 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
private String getDescription() {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(configuration.get("html_description").asText());
stringBuffer.append(processorConfig.getProperty(HTML_DESCRIPTION_CONFIG_FIELD_NAME).asText());
String codeLocation = softwareVersion.getCodeLocation();
if(codeLocation!=null) {
String htmlCodeLocation = configuration.get("html_code_location").asText();
String htmlCodeLocation = processorConfig.getProperty(HTML_CODE_LOCATION_CONFIG_FIELD_NAME).asText();
htmlCodeLocation = Utils.replaceVariable("code_location", codeLocation, htmlCodeLocation);
stringBuffer.append(htmlCodeLocation);
}
@ -313,7 +301,7 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
private ArrayNode getGrants(){
ObjectMapper objectMapper = Utils.getObjectMapper();
ArrayNode grants = objectMapper.createArrayNode();
ArrayNode arrayNode = (ArrayNode) configuration.get("skip_grants");
ArrayNode arrayNode = (ArrayNode) processorConfig.getProperty(SKIP_GRANTS_CONFIG_FIELD_NAME);
Set<String> idToSkip = new HashSet<>();
for(JsonNode idNode : arrayNode) {
idToSkip.add(idNode.asText());
@ -476,10 +464,31 @@ public class ZenodoSoftwareVersionPublisher extends SoftwareVersionPublisher {
finalize();
}
protected String getConfig(String propertyName) throws Exception {
String conf = null;
JsonNode node = processorConfig.getProperty(propertyName);
if(node == null || node.getNodeType()==JsonNodeType.NULL) {
conf = Config.getProperties().getProperty(propertyName);
}
if(conf==null) {
throw new Exception("No configuration '" + propertyName + "' property found.");
}
return conf;
}
protected void getZenodoConnectionConfig() throws Exception {
this.zenodoBaseURL = new URL(getConfig("zenodo_base_url"));
this.accessToken = getConfig("zenodo_access_token");
this.doiBaseURL = getConfig("doi_base_url");
}
@Override
public void publish() throws Exception {
getZenodoConnectionConfig();
String name = softwareVersion.getName();
ElaborationType publish = softwareVersion.getPublish();
ElaborationType publish = processorConfig.getElaboration();
if(publish==ElaborationType.NONE) {
logger.info("Deposit is disabled for {} {}.",

View File

@ -17,7 +17,7 @@ public class SoftwareConceptAnalyserTest {
@Test
public void testUsingTestFile() throws Exception {
File file = FileUtils.getFileFromFilename(FILENAME);
SoftwareConceptAnalyser softwareConceptAnalyser = new SoftwareConceptAnalyser(file);
SoftwareConfigAnalyser softwareConceptAnalyser = new SoftwareConfigAnalyser(file);
softwareConceptAnalyser.analyse();
}

View File

@ -1,5 +1,5 @@
{
"concept":
"global":
{
"name": "gcat",
"group": "data-catalogue",
@ -139,8 +139,19 @@
"url": "https://cordis.europa.eu/project/id/871042"
}
],
"publish": "NONE",
"export": "ALL"
"publishers": {
"ZenodoSoftwareVersionPublisher": {
"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"]
}
},
"exporters": {
"BibLaTeXSoftwareVersionExporter": {
"elaboration": "ALL"
}
}
},
"versions":
[
@ -327,19 +338,5 @@
"version_doi_url": "https://doi.org/10.5072/zenodo.1145788",
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
}
],
"publishers":
{
"ZenodoSoftwareVersionPublisher":
{
"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"
]
}
},
"exporters":
{}
]
}

View File

@ -1,5 +1,5 @@
{
"concept": {
"global": {
"name": "gcat",
"group": "data-catalogue",
"title": "gCube Catalogue (gCat) Service {{version}}",
@ -129,8 +129,19 @@
"url": "https://cordis.europa.eu/project/id/871042"
}
],
"publish": "NONE",
"export": "ALL"
"publishers": {
"ZenodoSoftwareVersionPublisher": {
"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"]
}
},
"exporters": {
"BibLaTeXSoftwareVersionExporter": {
"elaboration": "ALL"
}
}
},
"versions": [
{
@ -303,15 +314,5 @@
"version_doi_url": null,
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
}
],
"publishers": {
"ZenodoSoftwareVersionPublisher" :{
"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"]
}
},
"exporters": {
}
]
}

View File

@ -1,6 +1,7 @@
{
"concept": {
"global": {
"name": "gcat",
"group": "data-catalogue",
"title": "gCube Catalogue (gCat) Service {{version}}",
"license": {
"id": "EUPL-1.1",
@ -128,8 +129,19 @@
"url": "https://cordis.europa.eu/project/id/871042"
}
],
"publish": "NONE",
"export": "ALL"
"publishers": {
"ZenodoSoftwareVersionPublisher": {
"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"]
}
},
"exporters": {
"BibLaTeXSoftwareVersionExporter": {
"elaboration": "ALL"
}
}
},
"versions": [
{
@ -312,15 +324,5 @@
"version_doi_url" : "https://doi.org/10.5072/zenodo.1144799",
"code_location": "https://code-repo.d4science.org/gCubeSystem/{{name}}/releases/tag/v{{version}}"
}
],
"publishers": {
"ZenodoSoftwareVersionPublisher" :{
"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"]
}
},
"exporters": {
}
]
}