rename dmp to plan

This commit is contained in:
amentis 2024-07-05 17:14:32 +03:00
parent 4c34f1f606
commit 5f9e1850a3
6 changed files with 103 additions and 105 deletions

View File

@ -11,15 +11,15 @@ After creating the jar from the project, environment variables should be set sin
### JSON configuration file
The following fields should be set:<br>
**depositType** - an integer representing how the dmp user can deposit in the repository,<br>
a. **0** stands for system deposition meaning the dmp is deposited using argos credentials to the repository,<br>
**depositType** - an integer representing how the plan user can deposit in the repository,<br>
a. **0** stands for system deposition meaning the plan is deposited using argos credentials to the repository,<br>
b. **1** stands for user deposition in which the argos user specifies his/her own credentials to the repository,<br>
c. **2** stands for both ways deposition if the repository allows the deposits of dmps to be made from both argos and users accounts<br>
c. **2** stands for both ways deposition if the repository allows the deposits of plans to be made from both argos and users accounts<br>
**repositoryId** - unique identifier for the repository<br>
**accessToken** - access token provided for the system type deposits<br>
**repositoryUrl** - repository's api url e.g "https://sandbox.zenodo.org/api/" <br>
**repositoryAuthorizationUrl** - repository's authorization url e.g. "https://sandbox.zenodo.org/oauth/authorize" <br>
**repositoryRecordUrl** - repository's record url, this url is used to index dmps that are created e.g. "https://sandbox.zenodo.org/record/" <br>
**repositoryRecordUrl** - repository's record url, this url is used to index plans that are created e.g. "https://sandbox.zenodo.org/record/" <br>
**repositoryAccessTokenUrl** - repository's access token url e.g. "https://sandbox.zenodo.org/oauth/token" <br>
**repositoryClientId** - repository's client id<br>
**repositoryClientSecret** - repository's client secret<br>

View File

@ -2,17 +2,17 @@ package org.opencdmp.deposit.zenodorepository.model.builder;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.commonmodels.enums.DmpAccessType;
import org.opencdmp.commonmodels.enums.DmpUserRole;
import org.opencdmp.commonmodels.models.DmpUserModel;
import org.opencdmp.commonmodels.enums.PlanAccessType;
import org.opencdmp.commonmodels.enums.PlanUserRole;
import org.opencdmp.commonmodels.models.PlanUserModel;
import org.opencdmp.commonmodels.models.description.*;
import org.opencdmp.commonmodels.models.descriptiotemplate.DefinitionModel;
import org.opencdmp.commonmodels.models.descriptiotemplate.fielddata.RadioBoxDataModel;
import org.opencdmp.commonmodels.models.descriptiotemplate.fielddata.SelectDataModel;
import org.opencdmp.commonmodels.models.dmp.DmpBlueprintValueModel;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commonmodels.models.dmpblueprint.SectionModel;
import org.opencdmp.commonmodels.models.dmpreference.DmpReferenceModel;
import org.opencdmp.commonmodels.models.plan.PlanBlueprintValueModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.commonmodels.models.planblueprint.SectionModel;
import org.opencdmp.commonmodels.models.planreference.PlanReferenceModel;
import org.opencdmp.commonmodels.models.reference.ReferenceFieldModel;
import org.opencdmp.commonmodels.models.reference.ReferenceModel;
import org.opencdmp.deposit.zenodorepository.configuration.funder.FunderProperties;
@ -29,9 +29,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -61,14 +59,14 @@ public class ZenodoBuilder {
this.zenodoServiceProperties = zenodoServiceProperties;
}
public ZenodoDeposit build(DmpModel dmp) {
public ZenodoDeposit build(PlanModel plan) {
ZenodoDeposit deposit = new ZenodoDeposit();
this.applyZenodoRelator(dmp, deposit);
deposit.getMetadata().setTitle(dmp.getLabel());
this.applyZenodoRelator(plan, deposit);
deposit.getMetadata().setTitle(plan.getLabel());
deposit.getMetadata().setUploadType(UPLOAD_TYPE);
deposit.getMetadata().setPublicationType(PUBLICATION_TYPE);
deposit.getMetadata().setDescription((dmp.getDescription() != null && !dmp.getDescription().isEmpty() ? dmp.getDescription() : "<p></p>"));
deposit.getMetadata().setVersion(String.valueOf(dmp.getVersion()));
deposit.getMetadata().setDescription((plan.getDescription() != null && !plan.getDescription().isEmpty() ? plan.getDescription() : "<p></p>"));
deposit.getMetadata().setVersion(String.valueOf(plan.getVersion()));
String zenodoCommunity = zenodoServiceProperties.getCommunity();
if(zenodoCommunity != null && !zenodoCommunity.isEmpty()) {
if (deposit.getMetadata().getCommunities() == null) deposit.getMetadata().setCommunities(new ArrayList<>());
@ -77,41 +75,41 @@ public class ZenodoBuilder {
deposit.getMetadata().getCommunities().add(community);
}
org.opencdmp.commonmodels.models.dmpblueprint.FieldModel fieldOfSemantic = this.getFieldOfSemantic(dmp, SEMANTIC_PUBLICATION_DATE);
org.opencdmp.commonmodels.models.planblueprint.FieldModel fieldOfSemantic = this.getFieldOfSemantic(plan, SEMANTIC_PUBLICATION_DATE);
if (fieldOfSemantic != null){
DmpBlueprintValueModel dmpBlueprintValueModel = this.getDmpBlueprintValue(dmp, fieldOfSemantic.getId());
if (dmpBlueprintValueModel != null && dmpBlueprintValueModel.getDateValue() != null) {
deposit.getMetadata().setPublicationDate(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(dmpBlueprintValueModel.getDateValue()));
} else if (dmpBlueprintValueModel != null && dmpBlueprintValueModel.getValue() != null && !dmpBlueprintValueModel.getValue().isBlank()){
PlanBlueprintValueModel planBlueprintValueModel = this.getPlanBlueprintValue(plan, fieldOfSemantic.getId());
if (planBlueprintValueModel != null && planBlueprintValueModel.getDateValue() != null) {
deposit.getMetadata().setPublicationDate(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(planBlueprintValueModel.getDateValue()));
} else if (planBlueprintValueModel != null && planBlueprintValueModel.getValue() != null && !planBlueprintValueModel.getValue().isBlank()){
try {
Instant instant = Instant.parse(dmpBlueprintValueModel.getValue());
Instant instant = Instant.parse(planBlueprintValueModel.getValue());
deposit.getMetadata().setPublicationDate(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant));
}catch (Exception e){
logger.error(e.getMessage(), e);
}
}
}
this.applyAccessRight(dmp, deposit);
this.applyIsIdenticalTo(dmp, deposit);
this.applyLicenses(dmp, deposit);
this.applyResearchers(dmp, deposit);
this.applyGrants(dmp, deposit);
this.applyContributors(dmp, deposit);
this.applyCreators(dmp, deposit);
this.applyAccessRight(plan, deposit);
this.applyIsIdenticalTo(plan, deposit);
this.applyLicenses(plan, deposit);
this.applyResearchers(plan, deposit);
this.applyGrants(plan, deposit);
this.applyContributors(plan, deposit);
this.applyCreators(plan, deposit);
return deposit;
}
private DmpBlueprintValueModel getDmpBlueprintValue(DmpModel dmp, UUID id){
if (dmp == null || dmp.getProperties() == null || dmp.getProperties().getDmpBlueprintValues() == null) return null;
return dmp.getProperties().getDmpBlueprintValues().stream().filter(x-> x.getFieldId().equals(id)).findFirst().orElse(null);
private PlanBlueprintValueModel getPlanBlueprintValue(PlanModel plan, UUID id){
if (plan == null || plan.getProperties() == null || plan.getProperties().getPlanBlueprintValues() == null) return null;
return plan.getProperties().getPlanBlueprintValues().stream().filter(x-> x.getFieldId().equals(id)).findFirst().orElse(null);
}
private org.opencdmp.commonmodels.models.dmpblueprint.FieldModel getFieldOfSemantic(DmpModel dmp, String semanticKey){
if (dmp == null || dmp.getDmpBlueprint() == null || dmp.getDmpBlueprint().getDefinition() == null || dmp.getDmpBlueprint().getDefinition().getSections() == null) return null;
for (SectionModel sectionModel : dmp.getDmpBlueprint().getDefinition().getSections()){
private org.opencdmp.commonmodels.models.planblueprint.FieldModel getFieldOfSemantic(PlanModel plan, String semanticKey){
if (plan == null || plan.getPlanBlueprint() == null || plan.getPlanBlueprint().getDefinition() == null || plan.getPlanBlueprint().getDefinition().getSections() == null) return null;
for (SectionModel sectionModel : plan.getPlanBlueprint().getDefinition().getSections()){
if (sectionModel.getFields() != null){
org.opencdmp.commonmodels.models.dmpblueprint.FieldModel fieldModel = sectionModel.getFields().stream().filter(x-> x.getSemantics() != null && x.getSemantics().contains(semanticKey)).findFirst().orElse(null);
org.opencdmp.commonmodels.models.planblueprint.FieldModel fieldModel = sectionModel.getFields().stream().filter(x-> x.getSemantics() != null && x.getSemantics().contains(semanticKey)).findFirst().orElse(null);
if (fieldModel != null) return fieldModel;
}
}
@ -204,7 +202,7 @@ public class ZenodoBuilder {
}
}
}
case INTERNAL_ENTRIES_DESCRIPTIONS, INTERNAL_ENTRIES_DMPS, UPLOAD -> throw new MyApplicationException("Invalid type " + field.getData().getFieldType());
case INTERNAL_ENTRIES_DESCRIPTIONS, INTERNAL_ENTRIES_PlANS, UPLOAD -> throw new MyApplicationException("Invalid type " + field.getData().getFieldType());
default -> throw new MyApplicationException("Invalid type " + field.getData().getFieldType());
}
}
@ -212,23 +210,23 @@ public class ZenodoBuilder {
return values;
}
private List<ReferenceModel> getReferenceModelOfType(DmpModel dmp, String code){
private List<ReferenceModel> getReferenceModelOfType(PlanModel plan, String code){
List<ReferenceModel> response = new ArrayList<>();
if (dmp.getReferences() == null) return response;
for (DmpReferenceModel dmpReferenceModel : dmp.getReferences()){
if (dmpReferenceModel.getReference() != null && dmpReferenceModel.getReference().getType() != null && dmpReferenceModel.getReference().getType().getCode() != null && dmpReferenceModel.getReference().getType().getCode().equals(code)){
response.add(dmpReferenceModel.getReference());
if (plan.getReferences() == null) return response;
for (PlanReferenceModel planReferenceModel : plan.getReferences()){
if (planReferenceModel.getReference() != null && planReferenceModel.getReference().getType() != null && planReferenceModel.getReference().getType().getCode() != null && planReferenceModel.getReference().getType().getCode().equals(code)){
response.add(planReferenceModel.getReference());
}
}
return response;
}
private void applyZenodoRelator(DmpModel dmp, ZenodoDeposit deposit) {
private void applyZenodoRelator(PlanModel plan, ZenodoDeposit deposit) {
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
List<String> acceptedPidTypes = this.pidProperties.getAcceptedTypes();
List<ZenodoRelator> relatedIdentifiers = new ArrayList<>();
for(DescriptionModel descriptionModel: dmp.getDescriptions()){
for(DescriptionModel descriptionModel: plan.getDescriptions()){
for(String relatedId: this.identifierProperties.getRelated()){
List<org.opencdmp.commonmodels.models.descriptiotemplate.FieldModel> fields = this.findSchematicValues(relatedId, descriptionModel.getDescriptionTemplate().getDefinition());
Set<String> values = extractSchematicValues(fields, descriptionModel.getProperties(), acceptedPidTypes);
@ -243,15 +241,15 @@ public class ZenodoBuilder {
deposit.getMetadata().setRelatedIdentifiers(relatedIdentifiers);
}
private void applyAccessRight(DmpModel dmp, ZenodoDeposit deposit){
private void applyAccessRight(PlanModel plan, ZenodoDeposit deposit){
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
if (dmp.getAccessType() == null) {
if (plan.getAccessType() == null) {
deposit.getMetadata().setAccessRight(ZenodoAccessRight.RESTRICTED);
deposit.getMetadata().setAccessConditions("");
} else {
if (dmp.getAccessType().equals(DmpAccessType.Public)) {
Instant publicationDate = dmp.getFinalizedAt();
if (plan.getAccessType().equals(PlanAccessType.Public)) {
Instant publicationDate = plan.getFinalizedAt();
if (publicationDate == null) publicationDate = Instant.now().minusSeconds(1);
if (publicationDate.isBefore(Instant.now())) {
@ -267,39 +265,39 @@ public class ZenodoBuilder {
}
}
private void applyIsIdenticalTo(DmpModel dmp, ZenodoDeposit deposit){
private void applyIsIdenticalTo(PlanModel plan, ZenodoDeposit deposit){
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
if (dmp.getAccessType().equals(DmpAccessType.Public)) {
if (plan.getAccessType().equals(PlanAccessType.Public)) {
ZenodoRelator relator = new ZenodoRelator();
relator.setIdentifier(zenodoServiceProperties.getDomain() + "/external/zenodo/" + dmp.getId().toString());
relator.setIdentifier(zenodoServiceProperties.getDomain() + "/external/zenodo/" + plan.getId().toString());
relator.setRelation(IS_IDENTICAL_TO);
if (deposit.getMetadata().getRelatedIdentifiers() == null)deposit.getMetadata().setRelatedIdentifiers(new ArrayList<>());
deposit.getMetadata().getRelatedIdentifiers().add(relator);
}
}
private void applyLicenses(DmpModel dmp, ZenodoDeposit deposit){
private void applyLicenses(PlanModel plan, ZenodoDeposit deposit){
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
List<ReferenceModel> dmpLicenses = this.getReferenceModelOfType(dmp, zenodoServiceProperties.getLicensesReferenceCode());
if (!dmpLicenses.isEmpty()) {
for (ReferenceModel dmpLicense : dmpLicenses) {
if (dmpLicense != null && dmpLicense.getReference() != null && !dmpLicense.getReference().isBlank()) {
deposit.getMetadata().setLicense(dmpLicense.getReference());
List<ReferenceModel> planLicenses = this.getReferenceModelOfType(plan, zenodoServiceProperties.getLicensesReferenceCode());
if (!planLicenses.isEmpty()) {
for (ReferenceModel planLicense : planLicenses) {
if (planLicense != null && planLicense.getReference() != null && !planLicense.getReference().isBlank()) {
deposit.getMetadata().setLicense(planLicense.getReference());
break;
}
}
}
}
private void applyResearchers(DmpModel dmp, ZenodoDeposit deposit){
private void applyResearchers(PlanModel plan, ZenodoDeposit deposit){
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
List<ZenodoContributor> researchers = new ArrayList<>();
List<ReferenceModel> dmpResearchers = this.getReferenceModelOfType(dmp, zenodoServiceProperties.getResearcherReferenceCode());
if (dmpResearchers != null && !dmpResearchers.isEmpty()) {
for (ReferenceModel researcher : dmpResearchers) {
List<ReferenceModel> planResearchers = this.getReferenceModelOfType(plan, zenodoServiceProperties.getResearcherReferenceCode());
if (planResearchers != null && !planResearchers.isEmpty()) {
for (ReferenceModel researcher : planResearchers) {
ZenodoContributor contributor = new ZenodoContributor();
contributor.setName(researcher.getLabel());
contributor.setType(CONTRIBUTOR_TYPE_RESEARCHER);
@ -316,19 +314,19 @@ public class ZenodoBuilder {
deposit.getMetadata().getContributors().addAll(researchers);
}
private void applyGrants(DmpModel dmp, ZenodoDeposit deposit){
private void applyGrants(PlanModel plan, ZenodoDeposit deposit){
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
List<ReferenceModel> dmpGrants = this.getReferenceModelOfType(dmp, zenodoServiceProperties.getGrantReferenceCode());
List<ReferenceModel> dmpFunders = this.getReferenceModelOfType(dmp, zenodoServiceProperties.getFunderReferenceCode());
List<ReferenceModel> planGrants = this.getReferenceModelOfType(plan, zenodoServiceProperties.getGrantReferenceCode());
List<ReferenceModel> planFunders = this.getReferenceModelOfType(plan, zenodoServiceProperties.getFunderReferenceCode());
if (!dmpGrants.isEmpty()) {
ReferenceModel depositGrant = dmpGrants.stream().filter(x-> x.getSource().equalsIgnoreCase(zenodoServiceProperties.getOpenaireGrantSourceCode())).findFirst().orElse(null);
if (!planGrants.isEmpty()) {
ReferenceModel depositGrant = planGrants.stream().filter(x-> x.getSource().equalsIgnoreCase(zenodoServiceProperties.getOpenaireGrantSourceCode())).findFirst().orElse(null);
if (depositGrant != null) {
String grantReferenceTail = depositGrant.getReference().split(":")[2];
List<FunderProperties.DoiFunder> doiFunders = this.funderProperties.getAvailable();
if (!dmpFunders.isEmpty()) {
ReferenceModel depositFunder = dmpFunders.getFirst();
if (!planFunders.isEmpty()) {
ReferenceModel depositFunder = planFunders.getFirst();
FunderProperties.DoiFunder doiFunder = doiFunders.stream()
.filter(doiFunder1 -> depositFunder.getLabel().contains(doiFunder1.getFunder()) || doiFunder1.getFunder().contains(depositFunder.getLabel()))
.findFirst().orElse(null);
@ -344,21 +342,21 @@ public class ZenodoBuilder {
}
}
private void applyContributors(DmpModel dmp, ZenodoDeposit deposit){
if (dmp.getUsers() == null) return;
private void applyContributors(PlanModel plan, ZenodoDeposit deposit){
if (plan.getUsers() == null) return;
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
List<ReferenceModel> dmpOrganizations = this.getReferenceModelOfType(dmp, zenodoServiceProperties.getOrganizationReferenceCode());
List<ReferenceModel> planOrganizations = this.getReferenceModelOfType(plan, zenodoServiceProperties.getOrganizationReferenceCode());
String zenodoAffiliation = zenodoServiceProperties.getAffiliation();
List<ZenodoContributor> contributors = new ArrayList<>();
for (DmpUserModel userDMP: dmp.getUsers()) {
for (PlanUserModel planUser: plan.getUsers()) {
ZenodoContributor contributor = new ZenodoContributor();
contributor.setName(userDMP.getUser().getName());
contributor.setName(planUser.getUser().getName());
contributor.setType(CONTRIBUTOR_TYPE_PROJECT_MANAGER);
if (dmpOrganizations != null && !dmpOrganizations.isEmpty()) {
contributor.setAffiliation(dmpOrganizations.stream().map(ReferenceModel::getLabel).collect(Collectors.joining(", ")));
if (planOrganizations != null && !planOrganizations.isEmpty()) {
contributor.setAffiliation(planOrganizations.stream().map(ReferenceModel::getLabel).collect(Collectors.joining(", ")));
} else {
if(zenodoAffiliation != null && !zenodoAffiliation.isEmpty()) {
contributor.setAffiliation(zenodoAffiliation);
@ -372,21 +370,21 @@ public class ZenodoBuilder {
}
private void applyCreators(DmpModel dmp, ZenodoDeposit deposit){
if (dmp.getUsers() == null) return;
private void applyCreators(PlanModel plan, ZenodoDeposit deposit){
if (plan.getUsers() == null) return;
if (deposit.getMetadata() == null) deposit.setMetadata(new ZenodoDepositMetadata());
List<ReferenceModel> dmpOrganizations = this.getReferenceModelOfType(dmp, zenodoServiceProperties.getOrganizationReferenceCode());
List<ReferenceModel> planOrganizations = this.getReferenceModelOfType(plan, zenodoServiceProperties.getOrganizationReferenceCode());
String zenodoAffiliation = zenodoServiceProperties.getAffiliation();
ZenodoCreator creator = new ZenodoCreator();
DmpUserModel dmpModel = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(DmpUserRole.Owner)).findFirst().orElse(null);
if (dmpModel == null || dmpModel.getUser() == null) return;
PlanUserModel planModel = plan.getUsers().stream().filter(planUser -> planUser.getRole().equals(PlanUserRole.Owner)).findFirst().orElse(null);
if (planModel == null || planModel.getUser() == null) return;
creator.setName(dmpModel.getUser().getName());
if (dmpOrganizations != null && !dmpOrganizations.isEmpty()) {
creator.setAffiliation(dmpOrganizations.stream().map(ReferenceModel::getLabel).collect(Collectors.joining(", ")));
creator.setName(planModel.getUser().getName());
if (planOrganizations != null && !planOrganizations.isEmpty()) {
creator.setAffiliation(planOrganizations.stream().map(ReferenceModel::getLabel).collect(Collectors.joining(", ")));
} else {
if(zenodoAffiliation != null && !zenodoAffiliation.isEmpty()) {
creator.setAffiliation(zenodoAffiliation);

View File

@ -1,10 +1,10 @@
package org.opencdmp.deposit.zenodorepository.service.zenodo;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.depositbase.repository.DepositConfiguration;
public interface ZenodoDepositService {
String deposit(DmpModel dmpDepositModel, String zenodoToken) throws Exception;
String deposit(PlanModel planDepositModel, String zenodoToken) throws Exception;
DepositConfiguration getConfiguration();

View File

@ -5,7 +5,7 @@ import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.deposit.zenodorepository.model.ZenodoDeposit;
import org.opencdmp.deposit.zenodorepository.model.builder.ZenodoBuilder;
import org.opencdmp.deposit.zenodorepository.service.storage.FileStorageService;
@ -69,7 +69,7 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
}
@Override
public String deposit(DmpModel dmpModel, String zenodoToken) throws Exception {
public String deposit(PlanModel planModel, String zenodoToken) throws Exception {
DepositConfiguration depositConfiguration = this.getConfiguration();
@ -86,10 +86,10 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
DepositConfiguration zenodoConfig = this.zenodoServiceProperties.getDepositConfiguration();
if (zenodoConfig == null) return null;
ZenodoDeposit deposit = zenodoBuilder.build(dmpModel);
ZenodoDeposit deposit = zenodoBuilder.build(planModel);
LinkedHashMap<String, String> links;
String previousDOI = dmpModel.getPreviousDOI();
String previousDOI = planModel.getPreviousDOI();
String unpublishedUrl = null;
String publishUrl;
try {
@ -97,7 +97,7 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
if (previousDOI == null) {
links = deposit(zenodoToken, zenodoUrl, zenodoClient, deposit);
} else {
unpublishedUrl = this.getUnpublishedDOI(zenodoClient, zenodoUrl, previousDOI, zenodoToken, dmpModel.getVersion());
unpublishedUrl = this.getUnpublishedDOI(zenodoClient, zenodoUrl, previousDOI, zenodoToken, planModel.getVersion());
if (unpublishedUrl == null) {
//It requires more than one step to create a new version
//First, get the deposit related to the concept DOI
@ -109,7 +109,7 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
if (unpublishedUrl == null) {
// Second step, add the file to the entry.
FileEnvelopeModel pdfEnvelope = dmpModel.getPdfFile();
FileEnvelopeModel pdfEnvelope = planModel.getPdfFile();
if (links == null || !links.containsKey(ZENODO_LINKS_BUCKET)) throw new MyApplicationException("bucket not found");
String addFileUrl = links.get(ZENODO_LINKS_BUCKET) + "/" + cleanFileName(pdfEnvelope.getFilename()) + "?access_token=" + zenodoToken;
@ -125,7 +125,7 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
.body(BodyInserters
.fromResource(new ByteArrayResource(pdfFileBytes)))
.retrieve().toEntity(Map.class).block();
FileEnvelopeModel rdaJsonEnvelope = dmpModel.getRdaJsonFile();
FileEnvelopeModel rdaJsonEnvelope = planModel.getRdaJsonFile();
String jsonFileName = cleanFileName(rdaJsonEnvelope.getFilename());
addFileUrl = links.get(ZENODO_LINKS_BUCKET) + "/" + jsonFileName + "?access_token=" + zenodoToken;
@ -139,8 +139,8 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
}
zenodoClient.put().uri(addFileUrl).headers(httpHeaders -> httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM)).body(BodyInserters.fromResource(new ByteArrayResource(rdaJsonBytes))).retrieve().toEntity(Map.class).block();
if (dmpModel.getSupportingFilesZip() != null) {
String supportingFilesZipName = cleanFileName(dmpModel.getSupportingFilesZip().getFilename());
if (planModel.getSupportingFilesZip() != null) {
String supportingFilesZipName = cleanFileName(planModel.getSupportingFilesZip().getFilename());
addFileUrl = links.get(ZENODO_LINKS_BUCKET) + "/" + supportingFilesZipName + "?access_token=" + zenodoToken;
zenodoClient.put().uri(addFileUrl).body(BodyInserters.fromResource(new ByteArrayResource(supportingFilesZipName.getBytes()))).retrieve().toEntity(Map.class).block();

View File

@ -31,7 +31,7 @@
<dependency>
<groupId>org.opencdmp</groupId>
<artifactId>repositorydepositbase</artifactId>
<version>2.0.15</version>
<version>2.0.16</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>

View File

@ -3,7 +3,7 @@ package org.opencdmp.deposit.controller;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.commonmodels.models.plan.PlanModel;
import org.opencdmp.deposit.zenodorepository.audit.AuditableAction;
import org.opencdmp.depositbase.repository.DepositConfiguration;
import org.opencdmp.deposit.zenodorepository.service.zenodo.ZenodoDepositService;
@ -29,19 +29,19 @@ public class DepositController implements org.opencdmp.depositbase.repository.De
this.auditService = auditService;
}
public String deposit(@RequestBody DmpModel dmpModel, @RequestParam("authToken")String authToken) throws Exception {
logger.debug(new MapLogEntry("deposit " + DmpModel.class.getSimpleName()).And("dmpModel", dmpModel));
public String deposit(@RequestBody PlanModel planModel, @RequestParam("authToken")String authToken) throws Exception {
logger.debug(new MapLogEntry("deposit " + PlanModel.class.getSimpleName()).And("planModel", planModel));
String doiId = depositClient.deposit(dmpModel, authToken);
String doiId = depositClient.deposit(planModel, authToken);
this.auditService.track(AuditableAction.Deposit_Deposit, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("dmpModel", dmpModel)
new AbstractMap.SimpleEntry<String, Object>("planModel", planModel)
));
return doiId;
}
public String authenticate(@RequestParam("authToken") String code) {
logger.debug(new MapLogEntry("authenticate " + DmpModel.class.getSimpleName()));
logger.debug(new MapLogEntry("authenticate " + PlanModel.class.getSimpleName()));
String token = depositClient.authenticate(code);
@ -51,7 +51,7 @@ public class DepositController implements org.opencdmp.depositbase.repository.De
}
public DepositConfiguration getConfiguration() {
logger.debug(new MapLogEntry("getConfiguration " + DmpModel.class.getSimpleName()));
logger.debug(new MapLogEntry("getConfiguration " + PlanModel.class.getSimpleName()));
DepositConfiguration configuration = depositClient.getConfiguration();
@ -61,7 +61,7 @@ public class DepositController implements org.opencdmp.depositbase.repository.De
}
public String getLogo() {
logger.debug(new MapLogEntry("getLogo " + DmpModel.class.getSimpleName()));
logger.debug(new MapLogEntry("getLogo " + PlanModel.class.getSimpleName()));
String logo = depositClient.getLogo();