diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/DatabaseEnumConverter.java b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/DatabaseEnumConverter.java index 158ddce6f..2811ea71c 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/DatabaseEnumConverter.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/DatabaseEnumConverter.java @@ -10,7 +10,7 @@ public abstract class DatabaseEnumConverter, T> @Override public T convertToDatabaseColumn(EnumType value) { - if (value == null) throw new IllegalArgumentException("value"); + if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName()); return value.getValue(); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java index 257909821..1e9f8df1f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java @@ -29,7 +29,7 @@ public interface DmpService { Dmp createNewVersion(NewVersionDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, TransformerException; - Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException; + Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException; List assignUsers(UUID dmp, List model, FieldSet fields) throws InvalidApplicationException, IOException; Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException; 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 d276a45cd..63a9f01bc 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 @@ -291,6 +291,9 @@ public class DmpServiceImpl implements DmpService { newDmp.setStatus(DmpStatus.Draft); newDmp.setProperties(oldDmpEntity.getProperties()); newDmp.setBlueprintId(model.getBlueprintId()); + newDmp.setCreatorId(this.userScope.getUserId()); + + this.entityManager.persist(newDmp); List dmpUsers = this.queryFactory.query(DmpUserQuery.class) .dmpIds(model.getId()) @@ -348,8 +351,6 @@ public class DmpServiceImpl implements DmpService { this.descriptionService.clone(newDmp.getId(), descriptionId); } - this.entityManager.persist(newDmp); - oldDmpEntity.setVersionStatus(DmpVersionStatus.Previous); this.entityManager.merge(oldDmpEntity); @@ -364,7 +365,7 @@ public class DmpServiceImpl implements DmpService { } @Override - public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException { + public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException { this.authorizationService.authorizeForce(Permission.CloneDmp); DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(model.getId()).firstAs(fields); @@ -378,12 +379,17 @@ public class DmpServiceImpl implements DmpService { newDmp.setUpdatedAt(Instant.now()); newDmp.setGroupId(UUID.randomUUID()); newDmp.setVersion((short) 1); + newDmp.setVersionStatus(DmpVersionStatus.Current); newDmp.setDescription(model.getDescription()); newDmp.setLabel(model.getLabel()); newDmp.setLanguage(existingDmpEntity.getLanguage()); newDmp.setStatus(DmpStatus.Draft); newDmp.setProperties(existingDmpEntity.getProperties()); newDmp.setBlueprintId(existingDmpEntity.getBlueprintId()); + newDmp.setAccessType(existingDmpEntity.getAccessType()); + newDmp.setCreatorId(this.userScope.getUserId()); + + this.entityManager.persist(newDmp); List dmpUsers = this.queryFactory.query(DmpUserQuery.class) .dmpIds(model.getId()) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DmpController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DmpController.java index a18db9127..c3e2ad149 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DmpController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DmpController.java @@ -152,7 +152,7 @@ public class DmpController { @PostMapping("clone") @Transactional @ValidationFilterAnnotation(validator = CloneDmpPersist.CloneDmpPersistValidator.ValidatorName, argumentName = "model") - public Dmp buildClone(@RequestBody CloneDmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException { + public Dmp buildClone(@RequestBody CloneDmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException, InvalidApplicationException { logger.debug(new MapLogEntry("clone" + Dmp.class.getSimpleName()).And("model", model).And("fields", fieldSet)); this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); diff --git a/dmp-backend/web/src/main/resources/config/permissions.yml b/dmp-backend/web/src/main/resources/config/permissions.yml index 0623855fa..553e0823f 100644 --- a/dmp-backend/web/src/main/resources/config/permissions.yml +++ b/dmp-backend/web/src/main/resources/config/permissions.yml @@ -385,7 +385,7 @@ permissions: allowAuthenticated: false InviteDmpUsers: roles: - - User + - Admin claims: [ ] clients: [ ] allowAnonymous: false diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index bf2de858c..f59d0ef25 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -127,6 +127,7 @@ export interface NewVersionDmpPersist { description: String; blueprintId: Guid; descriptions: Guid[]; + hash?: string; } export interface DmpUserPersist { diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts index 54da65bf9..93d2d227e 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts @@ -36,6 +36,7 @@ export class DmpEditorResolver extends BaseEditorResolver { nameof(x => x.version), nameof(x => x.updatedAt), nameof(x => x.publicAfter), + nameof(x => x.hash), [nameof(x => x.properties), nameof(x => x.dmpBlueprintValues), nameof(x => x.fieldId)].join('.'), [nameof(x => x.properties), nameof(x => x.dmpBlueprintValues), nameof(x => x.fieldValue)].join('.'), diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index 3b64d6340..6b9fe0e84 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -167,6 +167,8 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr nameof(x => x.version), nameof(x => x.groupId), nameof(x => x.updatedAt), + nameof(x => x.hash), + [nameof(x => x.descriptions), nameof(x => x.id)].join('.'), [nameof(x => x.descriptions), nameof(x => x.label)].join('.'), diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index af98b8983..91b74d6d8 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -28,7 +28,7 @@ {{'GENERAL.ACTIONS.SHOW-MORE' | translate}}
- open_in_new{{'DMP-LISTING.ACTIONS.EXPORT' | translate}} + open_in_new{{'DMP-LISTING.ACTIONS.EXPORT' | translate}} add{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}} group_add{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}} filter_none{{'DMP-LISTING.ACTIONS.CLONE' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.editor.model.ts b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.editor.model.ts index 6ca660cd1..5b0e98d98 100644 --- a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.editor.model.ts @@ -11,6 +11,7 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist { description: String; blueprintId: Guid; descriptions: Guid[] = []; + hash?: string; public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); @@ -24,6 +25,7 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist { this.description = item.description; this.blueprintId = item.blueprint.id; if (item.descriptions) { this.descriptions = item.descriptions.map(x => x.id); } + this.hash= item.hash; } return this; } @@ -37,6 +39,7 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist { description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], blueprintId: [{ value: this.blueprintId, disabled: disabled }, context.getValidation('blueprintId').validators], descriptions: [{ value: this.descriptions, disabled: disabled }, context.getValidation('descriptions').validators], + hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators] }); } @@ -48,6 +51,8 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist { baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); baseValidationArray.push({ key: 'blueprintId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'blueprintId')] }); baseValidationArray.push({ key: 'descriptions', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptions')] }); + baseValidationArray.push({ key: 'hash', validators: [] }); + baseContext.validation = baseValidationArray; return baseContext; } 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 3eaf404a6..93d8371d9 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 @@ -151,7 +151,7 @@

{{ 'DMP-OVERVIEW.ACTIONS.REVERSE' | translate }}

-
+
@@ -193,7 +193,7 @@
-
+