From 0c4cf467d8d263e16477cfbc643e6c81bcdada27 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Fri, 10 Nov 2023 16:13:55 +0200 Subject: [PATCH] Adding description cloning method on service, adding missing functionality on dmp new-version and cloning, dmp persist fix --- .../eu/eudat/authorization/Permission.java | 1 + .../commons/enums/DescriptionStatus.java | 2 +- .../eu/eudat/commons/enums/DmpStatus.java | 2 +- .../eu/eudat/model/persist/DmpPersist.java | 10 ++ .../description/DescriptionService.java | 2 + .../description/DescriptionServiceImpl.java | 73 ++++++++- .../eu/eudat/service/dmp/DmpServiceImpl.java | 147 +++++++++++++++--- .../eudat/controllers/v2/DmpController.java | 10 +- .../managers/DataManagementPlanManager.java | 6 +- .../eudat/logic/managers/DatasetManager.java | 2 +- .../logic/managers/DatasetWizardManager.java | 2 +- .../models/data/dmp/DataManagementPlan.java | 5 +- .../src/main/resources/config/permissions.yml | 7 + 13 files changed, 232 insertions(+), 37 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java index 8d0993ce1..4912b4ade 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java +++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java @@ -75,6 +75,7 @@ public final class Permission { public static String BrowseDescription = "BrowseDescription"; public static String EditDescription = "EditDescription"; public static String DeleteDescription = "DeleteDescription"; + public static String CloneDescription = "CloneDescription"; //DescriptionTag public static String BrowseDescriptionTag = "BrowseDescriptionTag"; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DescriptionStatus.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DescriptionStatus.java index 6a01dcecb..2d3ffa455 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DescriptionStatus.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DescriptionStatus.java @@ -7,7 +7,7 @@ import java.util.Map; public enum DescriptionStatus implements DatabaseEnum { - Saved((short) 0), + Draft((short) 0), Finalized((short) 1), Canceled((short) 2); diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpStatus.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpStatus.java index 229942c9e..2083d6baa 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpStatus.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpStatus.java @@ -7,7 +7,7 @@ import java.util.Map; public enum DmpStatus implements DatabaseEnum { - ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99); + Draft((short) 0), Finalized((short) 1); private final Short value; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DmpPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DmpPersist.java index 337b5f0a5..05c38d8cf 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DmpPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DmpPersist.java @@ -22,6 +22,8 @@ public class DmpPersist { private String language; + private UUID blueprint; + private List references; private List descriptionTemplates; @@ -84,6 +86,14 @@ public class DmpPersist { this.references = references; } + public UUID getBlueprint() { + return blueprint; + } + + public void setBlueprint(UUID blueprint) { + this.blueprint = blueprint; + } + public List getDescriptionTemplates() { return descriptionTemplates; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java index 32c05a2e0..a87f644e9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java @@ -17,4 +17,6 @@ public interface DescriptionService { void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; + void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException; + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index bd6e01b38..7b317b3ae 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -3,9 +3,13 @@ package eu.eudat.service.description; import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.JsonHandlingService; +import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.scope.user.UserScope; import eu.eudat.convention.ConventionService; import eu.eudat.data.DescriptionEntity; +import eu.eudat.data.DescriptionReferenceEntity; +import eu.eudat.data.DescriptionTagEntity; import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.event.DescriptionTouchedEvent; import eu.eudat.event.EventBroker; @@ -13,6 +17,9 @@ import eu.eudat.model.Description; import eu.eudat.model.builder.DescriptionBuilder; import eu.eudat.model.deleter.DescriptionDeleter; import eu.eudat.model.persist.DescriptionPersist; +import eu.eudat.query.DescriptionQuery; +import eu.eudat.query.DescriptionReferenceQuery; +import eu.eudat.query.DescriptionTagQuery; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; @@ -62,6 +69,8 @@ public class DescriptionServiceImpl implements DescriptionService { private final JsonHandlingService jsonHandlingService; + private final UserScope userScope; + @Autowired public DescriptionServiceImpl( EntityManager entityManager, @@ -73,7 +82,7 @@ public class DescriptionServiceImpl implements DescriptionService { MessageSource messageSource, EventBroker eventBroker, QueryFactory queryFactory, - JsonHandlingService jsonHandlingService) { + JsonHandlingService jsonHandlingService, UserScope userScope) { this.entityManager = entityManager; this.authorizationService = authorizationService; this.deleterFactory = deleterFactory; @@ -84,6 +93,7 @@ public class DescriptionServiceImpl implements DescriptionService { this.eventBroker = eventBroker; this.queryFactory = queryFactory; this.jsonHandlingService = jsonHandlingService; + this.userScope = userScope; } @Override @@ -130,4 +140,65 @@ public class DescriptionServiceImpl implements DescriptionService { this.deleterFactory.deleter(DescriptionDeleter.class).deleteAndSaveByIds(List.of(id)); } + + @Override + public void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException { + logger.debug("cloning description: {} with dmp: {}", descriptionId, dmpId); + + this.authorizationService.authorizeForce(Permission.CloneDescription); + + DescriptionEntity existing = this.queryFactory.query(DescriptionQuery.class).ids(descriptionId).isActive(IsActive.Active).first(); + + DescriptionEntity newDescription = new DescriptionEntity(); + newDescription.setId(UUID.randomUUID()); + newDescription.setLabel(existing.getLabel()); + newDescription.setDescription(existing.getDescription()); + newDescription.setStatus(DescriptionStatus.Finalized); + newDescription.setProperties(existing.getProperties()); + newDescription.setDmpId(dmpId); + newDescription.setDmpDescriptionTemplateId(existing.getDmpDescriptionTemplateId()); + newDescription.setCreatedById(userScope.getUserId()); + newDescription.setCreatedAt(Instant.now()); + newDescription.setUpdatedAt(Instant.now()); + newDescription.setIsActive(IsActive.Active); + + this.entityManager.persist(newDescription); + + List descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class) + .descriptionIds(existing.getId()) + .isActive(IsActive.Active) + .collect(); + + List descriptionTags = this.queryFactory.query(DescriptionTagQuery.class) + .descriptionIds(existing.getId()) + .isActive(IsActive.Active) + .collect(); + + for (DescriptionReferenceEntity descriptionReference : descriptionReferences) { + DescriptionReferenceEntity newReference = new DescriptionReferenceEntity(); + newReference.setId(UUID.randomUUID()); + newReference.setDescriptionId(newDescription.getId()); + newReference.setReferenceId(descriptionReference.getReferenceId()); + newReference.setCreatedAt(Instant.now()); + newReference.setUpdatedAt(Instant.now()); + newReference.setIsActive(IsActive.Active); + + this.entityManager.persist(newReference); + } + + for(DescriptionTagEntity descriptionTag : descriptionTags) { + DescriptionTagEntity newTag = new DescriptionTagEntity(); + newTag.setId(UUID.randomUUID()); + newTag.setDescriptionId(newDescription.getId()); + newTag.setTagId(descriptionTag.getTagId()); + newTag.setCreatedAt(Instant.now()); + newTag.setUpdatedAt(Instant.now()); + newTag.setIsActive(IsActive.Active); + + this.entityManager.persist(newTag); + } + + + } + } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java index ea1e031a1..6340f88c7 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java @@ -5,6 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.XmlHandlingService; +import eu.eudat.commons.enums.DmpStatus; import eu.eudat.commons.enums.DmpUserRole; import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.scope.user.UserScope; @@ -16,6 +17,8 @@ import eu.eudat.errorcode.ErrorThesaurusProperties; import eu.eudat.event.DmpTouchedEvent; import eu.eudat.event.EventBroker; import eu.eudat.model.Dmp; +import eu.eudat.model.DmpReference; +import eu.eudat.model.DmpUser; import eu.eudat.model.Reference; import eu.eudat.model.builder.DmpBuilder; import eu.eudat.model.deleter.DmpDeleter; @@ -25,6 +28,7 @@ import eu.eudat.model.persist.*; import eu.eudat.model.persist.referencedefinition.DefinitionPersist; import eu.eudat.model.persist.referencedefinition.FieldPersist; import eu.eudat.query.*; +import eu.eudat.service.description.DescriptionService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.deleter.DeleterFactory; @@ -86,6 +90,8 @@ public class DmpServiceImpl implements DmpService { private final EventBroker eventBroker; + private final DescriptionService descriptionService; + @Autowired public DmpServiceImpl( EntityManager entityManager, @@ -98,7 +104,7 @@ public class DmpServiceImpl implements DmpService { MessageSource messageSource, XmlHandlingService xmlHandlingService, JsonHandlingService jsonHandlingService, - UserScope userScope, EventBroker eventBroker) { + UserScope userScope, EventBroker eventBroker, DescriptionService descriptionService) { this.entityManager = entityManager; this.authorizationService = authorizationService; this.deleterFactory = deleterFactory; @@ -111,6 +117,7 @@ public class DmpServiceImpl implements DmpService { this.jsonHandlingService = jsonHandlingService; this.userScope = userScope; this.eventBroker = eventBroker; + this.descriptionService = descriptionService; } public Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JsonProcessingException { @@ -153,18 +160,19 @@ public class DmpServiceImpl implements DmpService { throw new MyValidationException(this.errors.getDmpNewVersionConflict().getCode(), this.errors.getDmpNewVersionConflict().getMessage()); } - DmpEntity data = new DmpEntity(); - data.setId(UUID.randomUUID()); - data.setIsActive(IsActive.Active); - data.setCreatedAt(Instant.now()); - data.setUpdatedAt(Instant.now()); - data.setGroupId(oldDmpEntity.getGroupId()); - data.setVersion((short)(oldDmpEntity.getVersion() + 1)); - data.setDescription(model.getDescription()); - data.setLabel(model.getLabel()); - data.setLanguage(oldDmpEntity.getLanguage()); - data.setStatus(oldDmpEntity.getStatus()); - data.setProperties(oldDmpEntity.getProperties()); + DmpEntity newDmp = new DmpEntity(); + newDmp.setId(UUID.randomUUID()); + newDmp.setIsActive(IsActive.Active); + newDmp.setCreatedAt(Instant.now()); + newDmp.setUpdatedAt(Instant.now()); + newDmp.setGroupId(oldDmpEntity.getGroupId()); + newDmp.setVersion((short)(oldDmpEntity.getVersion() + 1)); + newDmp.setDescription(model.getDescription()); + newDmp.setLabel(model.getLabel()); + newDmp.setLanguage(oldDmpEntity.getLanguage()); + newDmp.setStatus(DmpStatus.Draft); + newDmp.setProperties(oldDmpEntity.getProperties()); + newDmp.setBlueprint(model.getBlueprintId()); List dmpUsers = this.queryFactory.query(DmpUserQuery.class) .dmpIds(model.getId()) @@ -174,11 +182,15 @@ public class DmpServiceImpl implements DmpService { .dmpIds(model.getId()) .isActives(IsActive.Active) .collect(); + List dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class) + .dmpIds(model.getId()) + .isActive(IsActive.Active) + .collect(); for (DmpUserEntity dmpUser : dmpUsers) { DmpUserEntity newUser = new DmpUserEntity(); newUser.setId(UUID.randomUUID()); - newUser.setDmp(data.getId()); + newUser.setDmp(newDmp.getId()); newUser.setUser(dmpUser.getUser()); newUser.setRole(dmpUser.getRole()); newUser.setCreatedAt(Instant.now()); @@ -191,7 +203,7 @@ public class DmpServiceImpl implements DmpService { for (DmpReferenceEntity dmpReference : dmpReferences) { DmpReferenceEntity newReference = new DmpReferenceEntity(); newReference.setId(UUID.randomUUID()); - newReference.setDmpId(data.getId()); + newReference.setDmpId(newDmp.getId()); newReference.setReferenceId(dmpReference.getReferenceId()); newReference.setData(dmpReference.getData()); newReference.setCreatedAt(Instant.now()); @@ -201,11 +213,28 @@ public class DmpServiceImpl implements DmpService { this.entityManager.persist(newReference); } - this.entityManager.persist(data); + for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) { + DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); + newTemplate.setId(UUID.randomUUID()); + newTemplate.setDmpId(newDmp.getId()); + newTemplate.setDescriptionTemplateId(dmpDescriptionTemplate.getDescriptionTemplateId()); + newTemplate.setSectionId(dmpDescriptionTemplate.getSectionId()); + newTemplate.setCreatedAt(Instant.now()); + newTemplate.setUpdatedAt(Instant.now()); + newTemplate.setIsActive(IsActive.Active); + + this.entityManager.persist(newTemplate); + } + + for (UUID descriptionId : model.getDescriptions()) { + this.descriptionService.clone(newDmp.getId(), descriptionId); + } + + this.entityManager.persist(newDmp); this.entityManager.flush(); - return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).build(BaseFieldSet.build(fields, Dmp._id), data); + return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp); } @Override @@ -214,10 +243,83 @@ public class DmpServiceImpl implements DmpService { this.authorizationService.authorizeForce(Permission.CloneDmp); - return null; + DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrPermissionOrMemberOrPublic).ids(model.getId()).firstAs(fields); + if (!this.conventionService.isValidGuid(model.getId()) || existingDmpEntity == null) + throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); + + DmpEntity newDmp = new DmpEntity(); + newDmp.setId(UUID.randomUUID()); + newDmp.setIsActive(IsActive.Active); + newDmp.setCreatedAt(Instant.now()); + newDmp.setUpdatedAt(Instant.now()); + newDmp.setGroupId(UUID.randomUUID()); + newDmp.setVersion((short) 1); + newDmp.setDescription(model.getDescription()); + newDmp.setLabel(model.getLabel()); + newDmp.setLanguage(existingDmpEntity.getLanguage()); + newDmp.setStatus(DmpStatus.Draft); + newDmp.setProperties(existingDmpEntity.getProperties()); + newDmp.setBlueprint(existingDmpEntity.getBlueprint()); + + List dmpUsers = this.queryFactory.query(DmpUserQuery.class) + .dmpIds(model.getId()) + .isActives(IsActive.Active) + .collect(); + List dmpReferences = this.queryFactory.query(DmpReferenceQuery.class) + .dmpIds(model.getId()) + .isActives(IsActive.Active) + .collect(); + List dmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class) + .dmpIds(model.getId()) + .isActive(IsActive.Active) + .collect(); + + for (DmpUserEntity dmpUser : dmpUsers) { + DmpUserEntity newUser = new DmpUserEntity(); + newUser.setId(UUID.randomUUID()); + newUser.setDmp(newDmp.getId()); + newUser.setUser(dmpUser.getUser()); + newUser.setRole(dmpUser.getRole()); + newUser.setCreatedAt(Instant.now()); + newUser.setUpdatedAt(Instant.now()); + newUser.setIsActive(IsActive.Active); + + this.entityManager.persist(newUser); + } + + for (DmpReferenceEntity dmpReference : dmpReferences) { + DmpReferenceEntity newReference = new DmpReferenceEntity(); + newReference.setId(UUID.randomUUID()); + newReference.setDmpId(newDmp.getId()); + newReference.setReferenceId(dmpReference.getReferenceId()); + newReference.setData(dmpReference.getData()); + newReference.setCreatedAt(Instant.now()); + newReference.setUpdatedAt(Instant.now()); + newReference.setIsActive(IsActive.Active); + + this.entityManager.persist(newReference); + } + + for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) { + DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); + newTemplate.setId(UUID.randomUUID()); + newTemplate.setDmpId(newDmp.getId()); + newTemplate.setDescriptionTemplateId(dmpDescriptionTemplate.getDescriptionTemplateId()); + newTemplate.setSectionId(dmpDescriptionTemplate.getSectionId()); + newTemplate.setCreatedAt(Instant.now()); + newTemplate.setUpdatedAt(Instant.now()); + newTemplate.setIsActive(IsActive.Active); + + this.entityManager.persist(newTemplate); + } + + this.entityManager.flush(); + + DmpEntity resultingDmpEntity = this.queryFactory.query(DmpQuery.class).ids(newDmp.getId()).firstAs(fields); + return this.builderFactory.builder(DmpBuilder.class).build(fields, resultingDmpEntity); } - private DmpEntity patchAndSave(DmpPersist model) throws JsonProcessingException { + private DmpEntity patchAndSave(DmpPersist model) throws JsonProcessingException, InvalidApplicationException { Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); DmpEntity data; @@ -226,17 +328,21 @@ public class DmpServiceImpl implements DmpService { data = this.entityManager.find(DmpEntity.class, model.getId()); if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); + data.setStatus(model.getStatus()); } else { data = new DmpEntity(); data.setId(UUID.randomUUID()); data.setGroupId(UUID.randomUUID()); data.setVersion((short) 1); + data.setStatus(DmpStatus.Draft); + data.setCreator(userScope.getUserId()); + data.setBlueprint(model.getBlueprint()); data.setIsActive(IsActive.Active); data.setCreatedAt(Instant.now()); dmpUserEntity.setId(UUID.randomUUID()); dmpUserEntity.setDmp(data.getId()); - dmpUserEntity.setUser(userScope.getUserIdSafe()); + dmpUserEntity.setUser(userScope.getUserId()); dmpUserEntity.setRole(DmpUserRole.Owner); dmpUserEntity.setCreatedAt(Instant.now()); dmpUserEntity.setUpdatedAt(Instant.now()); @@ -244,7 +350,6 @@ public class DmpServiceImpl implements DmpService { } data.setLabel(model.getLabel()); - data.setStatus(model.getStatus()); data.setProperties(this.jsonHandlingService.toJson(model.getProperties())); data.setDescription(model.getDescription()); data.setUpdatedAt(Instant.now()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java index 7d20c25f2..5e2603ada 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java @@ -131,19 +131,19 @@ public class DmpController { } @PostMapping("clone") - public Dmp buildClone(@MyValidate @RequestBody CloneDmpPersist persist, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException { - logger.debug(new MapLogEntry("clone" + Dmp.class.getSimpleName()).And("model", persist).And("fields", fieldSet)); + public Dmp buildClone(@MyValidate @RequestBody CloneDmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException { + logger.debug(new MapLogEntry("clone" + Dmp.class.getSimpleName()).And("model", model).And("fields", fieldSet)); this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); - Dmp model = this.dmpService.buildClone(persist, fieldSet); + Dmp clone = this.dmpService.buildClone(model, fieldSet); this.auditService.track(AuditableAction.Dmp_Clone, Map.ofEntries( - new AbstractMap.SimpleEntry("model", persist), + new AbstractMap.SimpleEntry("model", model), new AbstractMap.SimpleEntry("fields", fieldSet) )); - return model; + return clone; } @PostMapping("new-version") diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 346a2754f..611051a35 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -1061,7 +1061,7 @@ public class DataManagementPlanManager { .thenApplyAsync(entityDataset -> { DescriptionEntity newDescriptionEntity = new DescriptionEntity(); newDescriptionEntity.update(entityDataset); - newDescriptionEntity.setStatus(DescriptionStatus.Saved); + newDescriptionEntity.setStatus(DescriptionStatus.Draft); //TODO //newDescriptionEntity.setDmpId(newDmp.getId()); @@ -2243,7 +2243,7 @@ public class DataManagementPlanManager { // } // descriptionEntity.setDmpId(dmp.getId()); descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels())); - descriptionEntity.setStatus(DescriptionStatus.Saved); + descriptionEntity.setStatus(DescriptionStatus.Draft); // descriptionEntity.setRegistries(new HashSet<>()); // descriptionEntity.setDatasetDataRepositories(new HashSet<>()); // descriptionEntity.setServices(new HashSet<>()); @@ -2293,7 +2293,7 @@ public class DataManagementPlanManager { this.updateIndex(dmp); } dmp.getDataset().forEach(dataset -> { - dataset.setStatus(DescriptionStatus.Saved); + dataset.setStatus(DescriptionStatus.Draft); dataset.setCreatedAt(Instant.now()); dataset.setUpdatedAt(Instant.now()); //dataset.setDmpId(dmp.getId()); //TODO diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 90cf7f9bc..7dc43516e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -1032,7 +1032,7 @@ public class DatasetManager { DMP dmp = new DMP(); dmp.setId(UUID.fromString(dmpId)); // entity.setDmpId(dmp.getId()); //TODO - entity.setStatus(DescriptionStatus.Saved); + entity.setStatus(DescriptionStatus.Draft); entity.setCreatedAt(Instant.now()); entity.setUpdatedAt(Instant.now()); DescriptionTemplateEntity profile = new DescriptionTemplateEntity(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java index c1c8745b1..3744c1389 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetWizardManager.java @@ -58,7 +58,7 @@ public class DatasetWizardManager { DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid); DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId()); if(dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue()) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation"); - descriptionEntity.setStatus(DescriptionStatus.Saved); + descriptionEntity.setStatus(DescriptionStatus.Draft); apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity); return; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index e9d6f4a4f..c1de6a134 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.IsActive; -import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.old.*; import eu.eudat.model.doi.Doi; @@ -286,11 +285,11 @@ public class DataManagementPlan implements DataModel { if (entity.getDataset() != null) { if (entity.isPublic()) { this.datasets = entity.getDataset().stream() - .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled) && !dataset.getStatus().equals(DescriptionStatus.Saved)) + .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled) && !dataset.getStatus().equals(DescriptionStatus.Draft)) .map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList()); } else { this.datasets = entity.getDataset().stream() - .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Saved)) + .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Draft)) .map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList()); } } diff --git a/dmp-backend/web/src/main/resources/config/permissions.yml b/dmp-backend/web/src/main/resources/config/permissions.yml index 3a2c7d907..b8d0c1ebd 100644 --- a/dmp-backend/web/src/main/resources/config/permissions.yml +++ b/dmp-backend/web/src/main/resources/config/permissions.yml @@ -126,6 +126,13 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + CloneDescription: + roles: + - Admin + claims: [ ] + clients: [ ] + allowAnonymous: false + allowAuthenticated: false # Tag BrowseTag: