Adding description cloning method on service, adding missing functionality on dmp new-version and cloning, dmp persist fix
This commit is contained in:
parent
c2c1d834cc
commit
0c4cf467d8
|
@ -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";
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
|||
|
||||
public enum DescriptionStatus implements DatabaseEnum<Short> {
|
||||
|
||||
Saved((short) 0),
|
||||
Draft((short) 0),
|
||||
Finalized((short) 1),
|
||||
Canceled((short) 2);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
|||
|
||||
public enum DmpStatus implements DatabaseEnum<Short> {
|
||||
|
||||
ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99);
|
||||
Draft((short) 0), Finalized((short) 1);
|
||||
|
||||
private final Short value;
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ public class DmpPersist {
|
|||
|
||||
private String language;
|
||||
|
||||
private UUID blueprint;
|
||||
|
||||
private List<DmpReferencePersist> references;
|
||||
|
||||
private List<DmpDescriptionTemplatePersist> 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<DmpDescriptionTemplatePersist> getDescriptionTemplates() {
|
||||
return descriptionTemplates;
|
||||
}
|
||||
|
|
|
@ -17,4 +17,6 @@ public interface DescriptionService {
|
|||
|
||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||
|
||||
void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<DescriptionReferenceEntity> descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class)
|
||||
.descriptionIds(existing.getId())
|
||||
.isActive(IsActive.Active)
|
||||
.collect();
|
||||
|
||||
List<DescriptionTagEntity> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<DmpUserEntity> 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<DmpDescriptionTemplateEntity> 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<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class)
|
||||
.dmpIds(model.getId())
|
||||
.isActives(IsActive.Active)
|
||||
.collect();
|
||||
List<DmpReferenceEntity> dmpReferences = this.queryFactory.query(DmpReferenceQuery.class)
|
||||
.dmpIds(model.getId())
|
||||
.isActives(IsActive.Active)
|
||||
.collect();
|
||||
List<DmpDescriptionTemplateEntity> 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());
|
||||
|
|
|
@ -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<String, Object>("model", persist),
|
||||
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
));
|
||||
|
||||
return model;
|
||||
return clone;
|
||||
}
|
||||
|
||||
@PostMapping("new-version")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<DMP, DataManagementPlan> {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,13 @@ permissions:
|
|||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
CloneDescription:
|
||||
roles:
|
||||
- Admin
|
||||
claims: [ ]
|
||||
clients: [ ]
|
||||
allowAnonymous: false
|
||||
allowAuthenticated: false
|
||||
|
||||
# Tag
|
||||
BrowseTag:
|
||||
|
|
Loading…
Reference in New Issue