From 6c13d3b68fedbe338d64750871bd128a9f605194 Mon Sep 17 00:00:00 2001 From: Aldo Mihasi Date: Mon, 14 Nov 2022 09:34:49 +0200 Subject: [PATCH] when new version is deposited, create dataset in existing dataverse --- .../interfaces/DataverseDeposit.java | 27 +++++++++-------- .../dmp/overview/dmp-overview.component.html | 6 ++-- .../ui/dmp/overview/dmp-overview.component.ts | 30 +++++++++++++++---- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java b/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java index 52f0f1802..9a63460c5 100644 --- a/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java +++ b/dmp-backend/dataverseRepository/src/main/java/eu/eudat/depositinterface/dataverserepository/interfaces/DataverseDeposit.java @@ -3,10 +3,7 @@ package eu.eudat.depositinterface.dataverserepository.interfaces; import com.fasterxml.jackson.databind.ObjectMapper; import com.researchspace.dataverse.api.v1.DataverseAPI; import com.researchspace.dataverse.api.v1.DataverseConfig; -import com.researchspace.dataverse.entities.DataverseContacts; -import com.researchspace.dataverse.entities.DataversePost; -import com.researchspace.dataverse.entities.DataverseResponse; -import com.researchspace.dataverse.entities.Identifier; +import com.researchspace.dataverse.entities.*; import com.researchspace.dataverse.entities.facade.DatasetAuthor; import com.researchspace.dataverse.entities.facade.DatasetContact; import com.researchspace.dataverse.entities.facade.DatasetDescription; @@ -76,13 +73,17 @@ public class DataverseDeposit implements RepositoryDeposit { if(!this.isApiSet) this.setDataverseApi(); - DataversePost entity = new DataversePost(); - entity.setName(dmpDepositModel.getLabel()); - entity.setAlias(dmpDepositModel.getLabel().replace(" ", "_")); - entity.setDescription(dmpDepositModel.getDescription()); - entity.setCreationDate(new Date()); - entity.setDataverseContacts(Collections.singletonList(new DataverseContacts(SYSTEM_EMAIL))); - DataverseResponse response = this.api.getDataverseOperations().createNewDataverse(SYSTEM_PARENT_DATAVERSE_ALIAS, entity); + String alias = dmpDepositModel.getLabel().replace(" ", "_"); + DataverseGet dataverse = this.api.getDataverseOperations().getDataverseById(alias); + if(dataverse == null) { + DataversePost entity = new DataversePost(); + entity.setName(dmpDepositModel.getLabel()); + entity.setAlias(alias); + entity.setDescription(dmpDepositModel.getDescription()); + entity.setCreationDate(new Date()); + entity.setDataverseContacts(Collections.singletonList(new DataverseContacts(SYSTEM_EMAIL))); + DataverseResponse response = this.api.getDataverseOperations().createNewDataverse(SYSTEM_PARENT_DATAVERSE_ALIAS, entity); + } DatasetFacade dataset = DatasetFacade.builder() .title(dmpDepositModel.getLabel()) @@ -93,7 +94,7 @@ public class DataverseDeposit implements RepositoryDeposit { .languages(new ArrayList<>()) .depositor("") .build(); - Identifier id = this.api.getDataverseOperations().createDataset(dataset, entity.getAlias()); + Identifier id = this.api.getDataverseOperations().createDataset(dataset, alias); String doi = this.api.getDatasetOperations().getDataset(id).getDoiId().orElse(null); @@ -148,7 +149,7 @@ public class DataverseDeposit implements RepositoryDeposit { conf.setDepositAccountStatus(SystemDeposit.getValue()); conf.setAccessToken(API_TOKEN); conf.setRepositoryUrl(SERVER + "/api/"); - conf.setRepositoryRecordUrl(SERVER + "/dataverse/"); + conf.setRepositoryRecordUrl(SERVER + "/dataset.xhtml?persistentId=doi:"); return conf; } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index 602935ded..bec9d1720 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -114,13 +114,13 @@

{{'DMP-EDITOR.TITLE.SUBTITLE' | translate}}

- - + + {{doi.repositoryId}}
-