From 3cbbc38370b754e8ace809a136a0ebef53e1485b Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 15 May 2024 10:46:50 +0300 Subject: [PATCH 1/7] plan overview show user roles with section --- .../app/ui/dmp/overview/dmp-overview.component.html | 12 ++++++++---- .../app/ui/dmp/overview/dmp-overview.component.ts | 9 +++++++++ dmp-frontend/src/assets/i18n/en.json | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) 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 4d8cfc31b..481c0d4a4 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 @@ -239,15 +239,15 @@
-
+

{{ 'DMP-OVERVIEW.DMP-AUTHORS' | translate }}

-
-
@@ -257,7 +257,11 @@ ({{ 'DMP-OVERVIEW.YOU' | translate }})

-

{{ enumUtils.toDmpUserRoleString(dmpUser.role) }}

+

+ {{ enumUtils.toDmpUserRoleString(dmpUser.role) }} - + {{ 'DMP-OVERVIEW.ROLES.ALL-SECTIONS' | translate}} + {{ getSectionNameById(dmpUser.sectionId) }} +

- - + - +
diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts index 41f2a5056..2d073f85b 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts @@ -63,6 +63,7 @@ export class DescriptionEditorComponent extends BaseEditor { - const canedit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription); + this.canEdit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription); this.canReview = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.ReviewDescription); - this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !canedit); + this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.canEdit); if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties')); if (this.item.descriptionTemplate?.definition) this.pageToFieldSetMap = this.mapPageToFieldSet(this.item.descriptionTemplate);; // this.selectedSystemFields = this.selectedSystemFieldDisabled(); this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel); - if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted || !canedit) { + if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted || !this.canEdit) { this.viewOnly = true; this.isFinalized = true; this.formGroup.disable(); From e5abbe9aaec1a53cccafd6cd21d84d9d0d515e54 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 15 May 2024 12:55:47 +0300 Subject: [PATCH 3/7] disable add description in dmp editor when description templates is not selected --- .../dmp-editor.component.html | 10 ++++++++-- .../dmp-editor-blueprint/dmp-editor.component.ts | 15 +++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html index 480826958..a65ff6ef6 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html @@ -104,8 +104,14 @@ diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts index 21bc35e57..1b00babfc 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts @@ -298,9 +298,11 @@ export class DmpEditorComponent extends BaseEditor implemen //Transform descriptionTemplates formData.descriptionTemplates = []; for (const sectionId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) { - formData.descriptionTemplates.push( - ...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } }) - ); + if (this.formGroup.get('descriptionTemplates').get(sectionId).value != undefined){ + formData.descriptionTemplates.push( + ...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } }) + ); + } } this.dmpService.persist(formData) @@ -572,7 +574,12 @@ export class DmpEditorComponent extends BaseEditor implemen }); } - canAddDescription(section: DmpBlueprintDefinitionSection): boolean { + hasDescriptionTemplates(section: DmpBlueprintDefinitionSection): boolean { + if (this.item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id).length > 0) return true; + return false; + } + + hasValidMultiplicity(section: DmpBlueprintDefinitionSection): boolean { if (section.hasTemplates) { if (section.descriptionTemplates?.length > 0) { const descriptions = this.descriptionsInSection(section.id) From bd867472780676bdc12fa4c290b8ac7e4660a1f8 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 15 May 2024 12:56:18 +0300 Subject: [PATCH 4/7] disable add description in dmp editor when description templates is not selected --- dmp-frontend/src/assets/i18n/en.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 39b15fbc1..6a2f45b5a 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1506,7 +1506,10 @@ "LOCKED": "Locked", "DESCRIPTION": "Description", "NO-TEMPLATE-MESSAGE": "If you can't find a template or if you want to create a personalized template for your institution, research community or training needs, please contact us.", - "DESCRIPTION-TEMPLATES-MAX-MULTIPLICITY": "Description Templates has reached the maximun multiplicity", + "DESCRIPTION-TEMPLATES": { + "EMPTY": "Descriptiont templates not found", + "MAX-MULTIPLICITY": "Description Templates has reached the maximun multiplicity" + }, "UNSUCCESSFUL-REMOVE-TEMPLATE": "Cannot remove template, because it's already being used by one or more Descriptions.", "FIELDS": { "TITLE": "Title of Plan", From 87d6158647bf415c4fab0af0c55b14318ea27404 Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 15 May 2024 13:22:17 +0300 Subject: [PATCH 5/7] user profile reload page after save --- .../src/app/ui/user-profile/user-profile.component.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index f67df945d..5179089e0 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -249,21 +249,20 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes return; } const formData = this.formService.getValue(this.formGroup.value) as UserPersist; - formData.additionalInfo.organization.typeId = Guid.parse(this.referenceTypeService.getOrganizationReferenceType()); + if (formData.additionalInfo.organization) formData.additionalInfo.organization.typeId = Guid.parse(this.referenceTypeService.getOrganizationReferenceType()); this.userService.persist(formData) .pipe(takeUntil(this._destroyed)) .subscribe( x => { this.editMode = false; this.languageService.changeLanguage(this.formGroup.get('additionalInfo').get('language').value); - this.getOrRefreshData(); this.authService.refresh() .pipe(takeUntil(this._destroyed)) .subscribe(result => { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/profile']); + // this.router.navigate(['/profile']); + window.location.reload(); }); - // .subscribe(result => window.location.reload()); }, error => this.onCallbackError(error)); } From 1ea7f03afd603a5e462cf7f90ac080a8f1c7894b Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Wed, 15 May 2024 13:26:07 +0300 Subject: [PATCH 6/7] Adding short descriptions displaying on doc card links, small fixes --- docs/docs/documentation/application/blueprints.md | 1 + .../application/descriptions/collaborations.md | 1 + .../application/descriptions/create-a-description.md | 1 + .../application/descriptions/description-lifecycle.md | 1 + .../application/descriptions/edit-a-description.md | 1 + .../documentation/application/descriptions/exports.md | 1 + .../documentation/application/descriptions/imports.md | 1 + .../application/descriptions/prefill-a-description.md | 1 + .../documentation/application/descriptions/reviewing.md | 1 + docs/docs/documentation/application/introduction.md | 1 + .../docs/documentation/application/plans/create-a-plan.md | 1 + .../documentation/application/plans/doi-assignment.md | 1 + docs/docs/documentation/application/plans/edit-a-plan.md | 1 + docs/docs/documentation/application/plans/exports.md | 1 + docs/docs/documentation/application/plans/imports.md | 1 + .../application/plans/invite-collaborators.md | 1 + .../documentation/application/plans/plan-lifecycle.md | 1 + docs/docs/documentation/application/plans/reviewing.md | 1 + docs/docs/documentation/application/plans/versions.md | 1 + docs/docs/documentation/application/references.md | 1 + docs/docs/documentation/application/templates.md | 1 + docs/docs/documentation/for-devs/apis/swagger.md | 1 + .../documentation/for-devs/authentication/keycloak.md | 1 + docs/docs/documentation/getting-started/architecture.md | 1 + docs/docs/documentation/getting-started/installation.md | 1 + docs/docs/documentation/getting-started/introduction.md | 1 + .../supplementary-services/notifications/email.md | 8 +++++++- 27 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/docs/documentation/application/blueprints.md b/docs/docs/documentation/application/blueprints.md index 2371fccce..e05f90710 100644 --- a/docs/docs/documentation/application/blueprints.md +++ b/docs/docs/documentation/application/blueprints.md @@ -1,5 +1,6 @@ --- sidebar_position: 3 +description: What do we call 'blueprints' --- # Blueprints \ No newline at end of file diff --git a/docs/docs/documentation/application/descriptions/collaborations.md b/docs/docs/documentation/application/descriptions/collaborations.md index 2ffae5e8d..1791f36d7 100644 --- a/docs/docs/documentation/application/descriptions/collaborations.md +++ b/docs/docs/documentation/application/descriptions/collaborations.md @@ -1,5 +1,6 @@ --- sidebar_position: 5 +description: Discover how collaboration works on descriptions --- # Collaborations \ No newline at end of file diff --git a/docs/docs/documentation/application/descriptions/create-a-description.md b/docs/docs/documentation/application/descriptions/create-a-description.md index 858b5192d..16a24a9b3 100644 --- a/docs/docs/documentation/application/descriptions/create-a-description.md +++ b/docs/docs/documentation/application/descriptions/create-a-description.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: Discover how to create a new description --- # Create a Description diff --git a/docs/docs/documentation/application/descriptions/description-lifecycle.md b/docs/docs/documentation/application/descriptions/description-lifecycle.md index df8838717..8d7fd59fe 100644 --- a/docs/docs/documentation/application/descriptions/description-lifecycle.md +++ b/docs/docs/documentation/application/descriptions/description-lifecycle.md @@ -1,5 +1,6 @@ --- sidebar_position: 4 +description: Discover the lifecycle of a description --- # Description Lifecycle \ No newline at end of file diff --git a/docs/docs/documentation/application/descriptions/edit-a-description.md b/docs/docs/documentation/application/descriptions/edit-a-description.md index 419f079e6..09cc5f8aa 100644 --- a/docs/docs/documentation/application/descriptions/edit-a-description.md +++ b/docs/docs/documentation/application/descriptions/edit-a-description.md @@ -1,5 +1,6 @@ --- sidebar_position: 2 +description: Discover how to edit a description --- # Edit a Description diff --git a/docs/docs/documentation/application/descriptions/exports.md b/docs/docs/documentation/application/descriptions/exports.md index 83d8afe16..15c9bfb6b 100644 --- a/docs/docs/documentation/application/descriptions/exports.md +++ b/docs/docs/documentation/application/descriptions/exports.md @@ -1,5 +1,6 @@ --- sidebar_position: 8 +description: Discover export options for a description --- # Exports diff --git a/docs/docs/documentation/application/descriptions/imports.md b/docs/docs/documentation/application/descriptions/imports.md index 83c89dcbb..3df360d48 100644 --- a/docs/docs/documentation/application/descriptions/imports.md +++ b/docs/docs/documentation/application/descriptions/imports.md @@ -1,5 +1,6 @@ --- sidebar_position: 7 +description: Discover import options for a description --- # Imports \ No newline at end of file diff --git a/docs/docs/documentation/application/descriptions/prefill-a-description.md b/docs/docs/documentation/application/descriptions/prefill-a-description.md index a9593ff80..cf668e9ce 100644 --- a/docs/docs/documentation/application/descriptions/prefill-a-description.md +++ b/docs/docs/documentation/application/descriptions/prefill-a-description.md @@ -1,5 +1,6 @@ --- sidebar_position: 3 +description: Discover how to prefill a description to save time --- # Prefill a Description \ No newline at end of file diff --git a/docs/docs/documentation/application/descriptions/reviewing.md b/docs/docs/documentation/application/descriptions/reviewing.md index 632286a5c..ef264de8c 100644 --- a/docs/docs/documentation/application/descriptions/reviewing.md +++ b/docs/docs/documentation/application/descriptions/reviewing.md @@ -1,5 +1,6 @@ --- sidebar_position: 6 +description: Discover how to review a description --- # Reviewing \ No newline at end of file diff --git a/docs/docs/documentation/application/introduction.md b/docs/docs/documentation/application/introduction.md index 4fd6418bb..33034f2ad 100644 --- a/docs/docs/documentation/application/introduction.md +++ b/docs/docs/documentation/application/introduction.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: A brief introduction to the core entities of the platform --- # Introduction \ No newline at end of file diff --git a/docs/docs/documentation/application/plans/create-a-plan.md b/docs/docs/documentation/application/plans/create-a-plan.md index b1bc1c22c..f4ece939b 100644 --- a/docs/docs/documentation/application/plans/create-a-plan.md +++ b/docs/docs/documentation/application/plans/create-a-plan.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: Discover how to create a new plan --- # Create a Plan diff --git a/docs/docs/documentation/application/plans/doi-assignment.md b/docs/docs/documentation/application/plans/doi-assignment.md index ec347f1a4..af5c1c8ed 100644 --- a/docs/docs/documentation/application/plans/doi-assignment.md +++ b/docs/docs/documentation/application/plans/doi-assignment.md @@ -1,5 +1,6 @@ --- sidebar_position: 9 +description: Discover how to publich a plan and aquire a DOI --- # DOI Assignment \ No newline at end of file diff --git a/docs/docs/documentation/application/plans/edit-a-plan.md b/docs/docs/documentation/application/plans/edit-a-plan.md index 96d575dce..0a48b949d 100644 --- a/docs/docs/documentation/application/plans/edit-a-plan.md +++ b/docs/docs/documentation/application/plans/edit-a-plan.md @@ -1,5 +1,6 @@ --- sidebar_position: 2 +description: Discover how to edit a plan --- # Edit a Plan diff --git a/docs/docs/documentation/application/plans/exports.md b/docs/docs/documentation/application/plans/exports.md index c22d73e51..d006ba741 100644 --- a/docs/docs/documentation/application/plans/exports.md +++ b/docs/docs/documentation/application/plans/exports.md @@ -1,5 +1,6 @@ --- sidebar_position: 8 +description: Discover export options for a plan --- # Exports diff --git a/docs/docs/documentation/application/plans/imports.md b/docs/docs/documentation/application/plans/imports.md index ba072d752..d415ddc0e 100644 --- a/docs/docs/documentation/application/plans/imports.md +++ b/docs/docs/documentation/application/plans/imports.md @@ -1,5 +1,6 @@ --- sidebar_position: 7 +description: Discover import options for a plan --- # Imports diff --git a/docs/docs/documentation/application/plans/invite-collaborators.md b/docs/docs/documentation/application/plans/invite-collaborators.md index a45eacb06..b880b11be 100644 --- a/docs/docs/documentation/application/plans/invite-collaborators.md +++ b/docs/docs/documentation/application/plans/invite-collaborators.md @@ -1,5 +1,6 @@ --- sidebar_position: 4 +description: Discover how you invite people to a plan --- # Invite collaborators diff --git a/docs/docs/documentation/application/plans/plan-lifecycle.md b/docs/docs/documentation/application/plans/plan-lifecycle.md index 8e1ad4124..2b3d69393 100644 --- a/docs/docs/documentation/application/plans/plan-lifecycle.md +++ b/docs/docs/documentation/application/plans/plan-lifecycle.md @@ -1,5 +1,6 @@ --- sidebar_position: 3 +description: Discover the lifecycle of a plan --- # Plan lifecycle diff --git a/docs/docs/documentation/application/plans/reviewing.md b/docs/docs/documentation/application/plans/reviewing.md index 632286a5c..bd449322a 100644 --- a/docs/docs/documentation/application/plans/reviewing.md +++ b/docs/docs/documentation/application/plans/reviewing.md @@ -1,5 +1,6 @@ --- sidebar_position: 6 +description: Discover how to review a plan --- # Reviewing \ No newline at end of file diff --git a/docs/docs/documentation/application/plans/versions.md b/docs/docs/documentation/application/plans/versions.md index 5a8f88b77..5ddee2d40 100644 --- a/docs/docs/documentation/application/plans/versions.md +++ b/docs/docs/documentation/application/plans/versions.md @@ -1,5 +1,6 @@ --- sidebar_position: 5 +description: Discover plan versioning options --- # Versions diff --git a/docs/docs/documentation/application/references.md b/docs/docs/documentation/application/references.md index 7e37155ee..4cdabe330 100644 --- a/docs/docs/documentation/application/references.md +++ b/docs/docs/documentation/application/references.md @@ -1,5 +1,6 @@ --- sidebar_position: 2 +description: What do we call 'references' --- # References \ No newline at end of file diff --git a/docs/docs/documentation/application/templates.md b/docs/docs/documentation/application/templates.md index d4af0d40c..ad0d7b771 100644 --- a/docs/docs/documentation/application/templates.md +++ b/docs/docs/documentation/application/templates.md @@ -1,5 +1,6 @@ --- sidebar_position: 4 +description: What do we call 'templates' --- # Templates \ No newline at end of file diff --git a/docs/docs/documentation/for-devs/apis/swagger.md b/docs/docs/documentation/for-devs/apis/swagger.md index 71bb1113b..0f448e3f2 100644 --- a/docs/docs/documentation/for-devs/apis/swagger.md +++ b/docs/docs/documentation/for-devs/apis/swagger.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: A brief guide on the API documentation tool this platform uses --- # Swagger \ No newline at end of file diff --git a/docs/docs/documentation/for-devs/authentication/keycloak.md b/docs/docs/documentation/for-devs/authentication/keycloak.md index f3129a212..a8a89aa69 100644 --- a/docs/docs/documentation/for-devs/authentication/keycloak.md +++ b/docs/docs/documentation/for-devs/authentication/keycloak.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: A guide on how Keycloak is configured as an auth provider for the platform --- # Keycloak \ No newline at end of file diff --git a/docs/docs/documentation/getting-started/architecture.md b/docs/docs/documentation/getting-started/architecture.md index d12ff1dfc..cd0908294 100644 --- a/docs/docs/documentation/getting-started/architecture.md +++ b/docs/docs/documentation/getting-started/architecture.md @@ -1,5 +1,6 @@ --- sidebar_position: 3 +description: A guide for the platform architecture --- # Architecture diff --git a/docs/docs/documentation/getting-started/installation.md b/docs/docs/documentation/getting-started/installation.md index 68f67b3f7..ae9e0e606 100644 --- a/docs/docs/documentation/getting-started/installation.md +++ b/docs/docs/documentation/getting-started/installation.md @@ -1,5 +1,6 @@ --- sidebar_position: 2 +description: A guide for the platform installation process --- # Installation diff --git a/docs/docs/documentation/getting-started/introduction.md b/docs/docs/documentation/getting-started/introduction.md index 76a25123e..4ed2e23c7 100644 --- a/docs/docs/documentation/getting-started/introduction.md +++ b/docs/docs/documentation/getting-started/introduction.md @@ -1,5 +1,6 @@ --- sidebar_position: 1 +description: A brief introduction to the platform features --- # Introduction diff --git a/docs/docs/documentation/supplementary-services/notifications/email.md b/docs/docs/documentation/supplementary-services/notifications/email.md index 39c55d458..43abce221 100644 --- a/docs/docs/documentation/supplementary-services/notifications/email.md +++ b/docs/docs/documentation/supplementary-services/notifications/email.md @@ -5,4 +5,10 @@ description: Learn about the email notifications. # Email -These notifications are received by email, using the mail server configured during the platform installation. \ No newline at end of file +These notifications are received by email. + +:::info + +The mail server is configured during the notification service installation. + +::: \ No newline at end of file From f2ad93603cbd745aca30aa8374296161202703d4 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 15 May 2024 13:49:59 +0300 Subject: [PATCH 7/7] dmp clone fix --- .../model/persist/NewVersionDmpPersist.java | 34 ++++---- .../description/DescriptionService.java | 14 ++-- .../description/DescriptionServiceImpl.java | 67 ---------------- .../opencdmp/service/dmp/DmpServiceImpl.java | 78 ++++++++++++++++++- .../main/resources/config/storage-devel.yml | 10 --- .../web/src/main/resources/config/storage.yml | 10 +++ .../model/builder/UserBuilder.java | 14 +--- 7 files changed, 113 insertions(+), 114 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpPersist.java index ffd301e6d..a311046fe 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/NewVersionDmpPersist.java @@ -1,7 +1,7 @@ package org.opencdmp.model.persist; -import org.opencdmp.commons.validation.BaseValidator; import gr.cite.tools.validation.specification.Specification; +import org.opencdmp.commons.validation.BaseValidator; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.DmpEntity; import org.opencdmp.errorcode.ErrorThesaurusProperties; @@ -18,18 +18,18 @@ import java.util.UUID; public class NewVersionDmpPersist { - private UUID id = null; + private UUID id; public static final String _id = "id"; - private String label = null; + private String label; public static final String _label = "label"; - private String description = null; + private String description; public static final String _description = "description"; - private UUID blueprintId = null; + private UUID blueprintId; public static final String _blueprintId = "blueprintId"; @@ -42,7 +42,7 @@ public class NewVersionDmpPersist { public static final String _hash = "hash"; public UUID getId() { - return id; + return this.id; } public void setId(UUID id) { @@ -50,7 +50,7 @@ public class NewVersionDmpPersist { } public String getLabel() { - return label; + return this.label; } public void setLabel(String label) { @@ -58,7 +58,7 @@ public class NewVersionDmpPersist { } public String getDescription() { - return description; + return this.description; } public void setDescription(String description) { @@ -66,7 +66,7 @@ public class NewVersionDmpPersist { } public UUID getBlueprintId() { - return blueprintId; + return this.blueprintId; } public void setBlueprintId(UUID blueprintId) { @@ -74,7 +74,7 @@ public class NewVersionDmpPersist { } public List getDescriptions() { - return descriptions; + return this.descriptions; } public void setDescriptions(List descriptions) { @@ -82,7 +82,7 @@ public class NewVersionDmpPersist { } public String getHash() { - return hash; + return this.hash; } public void setHash(String hash) { @@ -113,23 +113,23 @@ public class NewVersionDmpPersist { this.spec() .iff(() -> this.isValidGuid(item.getId())) .must(() -> this.isValidHash(item.getHash())) - .failOn(NewVersionDmpPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._hash}, LocaleContextHolder.getLocale())), + .failOn(NewVersionDmpPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._hash}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getLabel())) - .failOn(NewVersionDmpPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), + .failOn(NewVersionDmpPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getLabel())) .must(() -> this.lessEqualLength(item.getLabel(), DmpEntity._labelLength)) - .failOn(NewVersionDmpPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), + .failOn(NewVersionDmpPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getDescription())) - .failOn(NewVersionDmpPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._description}, LocaleContextHolder.getLocale())), + .failOn(NewVersionDmpPersist._description).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._description}, LocaleContextHolder.getLocale())), this.spec() .must(() -> this.isValidGuid(item.getBlueprintId())) - .failOn(NewVersionDmpPersist._blueprintId).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._blueprintId}, LocaleContextHolder.getLocale())), + .failOn(NewVersionDmpPersist._blueprintId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._blueprintId}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getDescriptions())) - .failOn(NewVersionDmpPersist._descriptions).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._descriptions}, LocaleContextHolder.getLocale())) + .failOn(NewVersionDmpPersist._descriptions).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._descriptions}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java index f5d5d308c..23e5e027b 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionService.java @@ -1,17 +1,17 @@ package org.opencdmp.service.description; -import org.opencdmp.commons.types.description.importexport.DescriptionImportExport; -import org.opencdmp.data.StorageFileEntity; -import org.opencdmp.model.description.Description; -import org.opencdmp.model.DescriptionValidationResult; -import org.opencdmp.model.StorageFile; -import org.opencdmp.model.persist.*; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyValidationException; import gr.cite.tools.fieldset.FieldSet; import jakarta.xml.bind.JAXBException; +import org.opencdmp.commons.types.description.importexport.DescriptionImportExport; +import org.opencdmp.data.StorageFileEntity; +import org.opencdmp.model.DescriptionValidationResult; +import org.opencdmp.model.StorageFile; +import org.opencdmp.model.description.Description; +import org.opencdmp.model.persist.*; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; import org.xml.sax.SAXException; @@ -40,8 +40,6 @@ public interface DescriptionService { List validate(List descriptionIds) throws InvalidApplicationException; - void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException, IOException; - ResponseEntity export(UUID id, String exportType) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException; StorageFile uploadFieldFile(DescriptionFieldFilePersist model, MultipartFile file, FieldSet fields) throws IOException; diff --git a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java index cd79e1b22..742bec78b 100644 --- a/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/description/DescriptionServiceImpl.java @@ -817,73 +817,6 @@ public class DescriptionServiceImpl implements DescriptionService { //region clone - @Override - public void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException, IOException { - logger.debug("cloning description: {} with description: {}", descriptionId, dmpId); - - this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(descriptionId)), Permission.CloneDescription); - - DescriptionEntity existing = this.queryFactory.query(DescriptionQuery.class).disableTracking().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.Draft); - newDescription.setProperties(existing.getProperties()); - newDescription.setDmpId(dmpId); - newDescription.setDmpDescriptionTemplateId(existing.getDmpDescriptionTemplateId()); - newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId()); - newDescription.setCreatedById(this.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).disableTracking() - .descriptionIds(existing.getId()) - .isActive(IsActive.Active) - .collect(); - - List descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).disableTracking() - .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.setData(descriptionReference.getData()); - 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); - } - - this.entityManager.flush(); - - this.elasticService.persistDescription(newDescription); - - this.annotationEntityTouchedIntegrationEventHandler.handleDescription(newDescription.getId()); - this.annotationEntityTouchedIntegrationEventHandler.handleDescription(existing.getId()); - } - //endregion //region file export diff --git a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java index 1c302e8df..9d8f89acb 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java @@ -444,6 +444,7 @@ public class DmpServiceImpl implements DmpService { this.entityManager.persist(newReference); } + Map dmpDescriptionTemplateRemap = new HashMap<>(); for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) { DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); newTemplate.setId(UUID.randomUUID()); @@ -453,12 +454,15 @@ public class DmpServiceImpl implements DmpService { newTemplate.setCreatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now()); newTemplate.setIsActive(IsActive.Active); + dmpDescriptionTemplateRemap.put(dmpDescriptionTemplate.getId(), newTemplate.getId()); this.entityManager.persist(newTemplate); } + this.entityManager.flush(); + for (UUID descriptionId : model.getDescriptions()) { - this.descriptionService.clone(newDmp.getId(), descriptionId); + this.cloneDescription(newDmp.getId(), dmpDescriptionTemplateRemap, descriptionId); } this.entityManager.flush(); @@ -476,6 +480,74 @@ public class DmpServiceImpl implements DmpService { return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp); } + public void cloneDescription(UUID dmpId, Map dmpDescriptionTemplateRemap, UUID descriptionId) throws InvalidApplicationException, IOException { + logger.debug("cloning description: {} with description: {}", descriptionId, dmpId); + + this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(descriptionId)), Permission.CloneDescription); + + DescriptionEntity existing = this.queryFactory.query(DescriptionQuery.class).disableTracking().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.Draft); + newDescription.setProperties(existing.getProperties()); + newDescription.setDmpId(dmpId); + newDescription.setDmpDescriptionTemplateId(dmpDescriptionTemplateRemap.get(existing.getDmpDescriptionTemplateId())); + newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId()); + newDescription.setCreatedById(this.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).disableTracking() + .descriptionIds(existing.getId()) + .isActive(IsActive.Active) + .collect(); + + List descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).disableTracking() + .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.setData(descriptionReference.getData()); + 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); + } + + this.entityManager.flush(); + + this.elasticService.persistDescription(newDescription); + + this.annotationEntityTouchedIntegrationEventHandler.handleDescription(newDescription.getId()); + this.annotationEntityTouchedIntegrationEventHandler.handleDescription(existing.getId()); + } + + + private void updateVersionStatusAndSave(DmpEntity data, DmpStatus previousStatus, DmpStatus newStatus) throws InvalidApplicationException { if (previousStatus.equals(newStatus)) return; @@ -578,6 +650,7 @@ public class DmpServiceImpl implements DmpService { this.entityManager.persist(newReference); } + Map dmpDescriptionTemplateRemap = new HashMap<>(); for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) { DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); newTemplate.setId(UUID.randomUUID()); @@ -587,6 +660,7 @@ public class DmpServiceImpl implements DmpService { newTemplate.setCreatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now()); newTemplate.setIsActive(IsActive.Active); + dmpDescriptionTemplateRemap.put(dmpDescriptionTemplate.getId(), newTemplate.getId()); this.entityManager.persist(newTemplate); } @@ -600,7 +674,7 @@ public class DmpServiceImpl implements DmpService { DmpEntity resultingDmpEntity = this.queryFactory.query(DmpQuery.class).disableTracking().ids(newDmp.getId()).firstAs(fields); if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){ for (UUID description: model.getDescriptions()) { - this.descriptionService.clone(newDmp.getId(), description); + this.cloneDescription(newDmp.getId(), dmpDescriptionTemplateRemap, description); } } return this.builderFactory.builder(DmpBuilder.class).build(fields, resultingDmpEntity); diff --git a/backend/web/src/main/resources/config/storage-devel.yml b/backend/web/src/main/resources/config/storage-devel.yml index 8e3edbd48..0b0d2f9da 100644 --- a/backend/web/src/main/resources/config/storage-devel.yml +++ b/backend/web/src/main/resources/config/storage-devel.yml @@ -1,15 +1,5 @@ storage: service: - defaultLanguage: en - storages: - - type: Temp - basePath: ${FILE_STORAGE}/temp - - type: Main - basePath: ${FILE_STORAGE}/main - - type: Transformer - basePath: ${FILE_STORAGE}/transformer - - type: Deposit - basePath: ${FILE_STORAGE}/deposit static-files: semantics: backend/web/src/main/resources/Semantics.json material-files: diff --git a/backend/web/src/main/resources/config/storage.yml b/backend/web/src/main/resources/config/storage.yml index eece13a50..444fb7d5c 100644 --- a/backend/web/src/main/resources/config/storage.yml +++ b/backend/web/src/main/resources/config/storage.yml @@ -3,6 +3,16 @@ storage: enable: true intervalSeconds: 600 service: + defaultLanguage: en + storages: + - type: Temp + basePath: ${FILE_STORAGE}/temp + - type: Main + basePath: ${FILE_STORAGE}/main + - type: Transformer + basePath: ${FILE_STORAGE}/transformer + - type: Deposit + basePath: ${FILE_STORAGE}/deposit tempStoreLifetimeSeconds: 7200 material-files: localizedNameLanguageKey: "{lang}" diff --git a/notification-service/notification/src/main/java/gr/cite/notification/model/builder/UserBuilder.java b/notification-service/notification/src/main/java/gr/cite/notification/model/builder/UserBuilder.java index 403e0e694..6519c9f63 100644 --- a/notification-service/notification/src/main/java/gr/cite/notification/model/builder/UserBuilder.java +++ b/notification-service/notification/src/main/java/gr/cite/notification/model/builder/UserBuilder.java @@ -23,19 +23,13 @@ import java.util.stream.Collectors; @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserBuilder extends BaseBuilder { - private final BuilderFactory builderFactory; - private final QueryFactory queryFactory; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired public UserBuilder( - ConventionService conventionService, - BuilderFactory builderFactory, - QueryFactory queryFactory + ConventionService conventionService ) { super(conventionService, new LoggerService(LoggerFactory.getLogger(UserBuilder.class))); - this.builderFactory = builderFactory; - this.queryFactory = queryFactory; } public UserBuilder authorize(EnumSet values) { @@ -45,9 +39,9 @@ public class UserBuilder extends BaseBuilder { @Override public List build(FieldSet fields, List datas) throws MyApplicationException { - this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(datas).map(e -> e.size()).orElse(0), Optional.ofNullable(fields).map(e -> e.getFields()).map(e -> e.size()).orElse(0)); + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(datas).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); - if (fields == null || fields.isEmpty()) return new ArrayList<>(); + if (fields == null || fields.isEmpty() || datas == null) return new ArrayList<>(); List models = new ArrayList<>(); @@ -61,7 +55,7 @@ public class UserBuilder extends BaseBuilder { if (fields.hasField(this.asIndexer(User._isActive))) m.setIsActive(d.getIsActive()); models.add(m); } - this.logger.debug("build {} items", Optional.ofNullable(models).map(e -> e.size()).orElse(0)); + this.logger.debug("build {} items", models.size()); return models; } }