Improved capabilities

This commit is contained in:
Luca Frosini 2023-01-05 17:31:47 +01:00
parent b7447c8ae2
commit 28c12f8436
5 changed files with 74 additions and 37 deletions

View File

@ -2,7 +2,9 @@ package org.gcube.common.deposition.executor;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.common.deposition.executor.zenodo.ZenodoDepositionVersionExecutor;
import org.gcube.common.deposition.model.Deposition;
import org.gcube.common.deposition.model.DepositionVersion;
import org.gcube.common.deposition.model.Elaborate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,12 +39,20 @@ public abstract class DepositionVersionExecutor {
}
public void deposit() throws Exception {
String name = depositionVersion.getDeposition().getName();
Deposition deposition = depositionVersion.getDeposition();
String name = deposition.getName();
if(deposition.getDeposit()==Elaborate.NONE) {
logger.info("Deposit is disabled for deposition {} {}.",
name , depositionVersion.getVersion());
return;
}
if(depositionVersion.getDOIURL()!=null) {
depositionVersion.setNewDeposition(false);
if(depositionVersion.getUpdate()) {
if(deposition.getDeposit()==Elaborate.ALL || deposition.getDeposit()==Elaborate.UPDATE_ONLY) {
logger.info("Going to update deposition {} {}.",
name , depositionVersion.getVersion());
update();
@ -52,14 +62,16 @@ public abstract class DepositionVersionExecutor {
}
}else {
logger.info("Going to deposit {} {}",
name , depositionVersion.getVersion());
depositionVersion.setNewDeposition(true);
if(depositionVersion.getConceptDOIURL()==null) {
create();
}else {
newVersion();
if(deposition.getDeposit()==Elaborate.ALL || deposition.getDeposit()==Elaborate.NEW) {
logger.info("Going to deposit {} {}",
name , depositionVersion.getVersion());
depositionVersion.setNewDeposition(true);
if(depositionVersion.getConceptDOIURL()==null) {
create();
}else {
newVersion();
}
}
}
}

View File

@ -2,6 +2,7 @@ package org.gcube.common.deposition.model;
import java.util.List;
import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
@ -11,7 +12,8 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
public class Deposition {
public static final String NAME_PROPERTY_NAME = "name";
public static final String DEFAULT_UPDATE_PROPERTY_NAME = "default_update";
public static final String DEPOSIT_PROPERTY_NAME = "deposit";
public static final String EXPORT_PROPERTY_NAME = "export";
public static final String DEFAULT_FILES_PROPERTY_NAME = "default_files";
public static final String DEFAULT_CODE_LOCATION_PROPERTY_NAME = "default_code_location";
public static final String CODE_LOCATION_TEXT_PROPERTY_NAME = "code_location_text";
@ -21,8 +23,13 @@ public class Deposition {
@JsonProperty(NAME_PROPERTY_NAME)
protected String name;
@JsonProperty(DEFAULT_UPDATE_PROPERTY_NAME)
protected Boolean defaultUpdate;
@JsonProperty(DEPOSIT_PROPERTY_NAME)
@JsonFormat(shape=JsonFormat.Shape.STRING)
protected Elaborate deposit;
@JsonProperty(EXPORT_PROPERTY_NAME)
@JsonFormat(shape=JsonFormat.Shape.STRING)
protected Elaborate export;
@JsonProperty(DEFAULT_FILES_PROPERTY_NAME)
protected List<DepositionFile> defaultFiles;
@ -43,8 +50,12 @@ public class Deposition {
return name;
}
public Boolean getDefaultUpdate() {
return defaultUpdate;
public Elaborate getDeposit() {
return deposit;
}
public Elaborate getExport() {
return export;
}
public List<DepositionFile> getDefaultFiles() {

View File

@ -44,7 +44,7 @@ public class DepositionVersion {
public static final String CODE_LOCATION_PROPERTY_NAME = "code_location";
public static final String CONCEPT_DOI_URL_PROPERTY_NAME = "concept_doi_url";
public static final String DOI_URL_PROPERTY_NAME = "doi_url";
public static final String UPDATE_PROPERTY_NAME = "update";
// public static final String UPDATE_PROPERTY_NAME = "update";
public static final String METADATA_PROPERTY_NAME = "metadata";
@JsonIgnore
@ -84,8 +84,8 @@ public class DepositionVersion {
@JsonProperty(DOI_URL_PROPERTY_NAME)
protected URL doiURL;
@JsonProperty(UPDATE_PROPERTY_NAME)
protected Boolean update;
// @JsonProperty(UPDATE_PROPERTY_NAME)
// protected Boolean update;
@JsonProperty(METADATA_PROPERTY_NAME)
protected JsonNode metadata;
@ -293,24 +293,24 @@ public class DepositionVersion {
}
}
@JsonIgnore
public Boolean getUpdate() {
if(update!=null) {
return update;
}
return deposition.getDefaultUpdate();
}
@JsonGetter(UPDATE_PROPERTY_NAME)
@JsonInclude(Include.NON_NULL)
public Boolean getUpdateForSerialization() {
return update;
}
@JsonSetter(UPDATE_PROPERTY_NAME)
public void setUpdate(Boolean update) {
this.update = update;
}
// @JsonIgnore
// public Boolean getUpdate() {
// if(update!=null) {
// return update;
// }
// return deposition.getDefaultUpdate();
// }
//
// @JsonGetter(UPDATE_PROPERTY_NAME)
// @JsonInclude(Include.NON_NULL)
// public Boolean getUpdateForSerialization() {
// return update;
// }
//
// @JsonSetter(UPDATE_PROPERTY_NAME)
// public void setUpdate(Boolean update) {
// this.update = update;
// }
@JsonIgnore
protected ObjectNode parseObjectNode(ObjectNode objectNode) {

View File

@ -0,0 +1,13 @@
package org.gcube.common.deposition.model;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public enum Elaborate {
ALL,
UPDATE_ONLY,
NEW,
NONE
}

View File

@ -1,6 +1,7 @@
{
"name": "gcat",
"default_update": true,
"deposit": "NONE",
"export": "ALL",
"default_files":
[
{