From b8f14e957ea3332796b359499382470c1429ff94 Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 12 Mar 2024 14:07:47 +0200 Subject: [PATCH] add remove backend validators, fix public dmp/descriptions --- .../main/java/eu/eudat/model/PublicDmp.java | 33 +++++++++++++++++++ .../eu/eudat/model/PublicDmpReference.java | 13 ++++++++ .../eudat/model/builder/PublicDmpBuilder.java | 6 +++- .../builder/PublicDmpReferenceBuilder.java | 1 + .../query/utils/QueryUtilsServiceImpl.java | 3 +- .../eu/eudat/service/dmp/DmpServiceImpl.java | 1 + dmp-frontend/src/app/core/model/dmp/dmp.ts | 5 +++ .../file-transformer.service.ts | 7 +++- ...description-template-editor.component.html | 8 ++--- .../description-template-editor.component.ts | 20 +++++++++-- ...cription-template-type-editor.component.ts | 1 + .../dmp-blueprint-editor.component.html | 4 +-- .../editor/dmp-blueprint-editor.component.ts | 5 ++- .../editor/language-editor.component.ts | 1 + .../notification-template-editor.component.ts | 8 ++--- .../prefilling-source-editor.component.ts | 13 +++----- .../editor/reference-type-editor.component.ts | 7 ++-- .../tenant/editor/tenant-editor.component.ts | 7 ++-- ...edited-description-activity.component.html | 8 ++--- .../editor/description-editor.resolver.ts | 4 +-- .../description-listing-item.component.html | 2 +- .../description-overview.component.html | 2 +- .../dmp/overview/dmp-overview.component.html | 2 +- .../ui/dmp/overview/dmp-overview.component.ts | 4 ++- dmp-frontend/src/assets/i18n/en.json | 2 ++ 25 files changed, 124 insertions(+), 43 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmp.java b/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmp.java index a0ceb5135..1ad8dbb90 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmp.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmp.java @@ -37,6 +37,15 @@ public class PublicDmp { public static final String _publishedAt = "publishedAt"; + private DmpStatus status; + public static final String _status = "status"; + + private UUID groupId; + public static final String _groupId = "groupId"; + + private DmpAccessType accessType; + public static final String _accessType = "accessType"; + private List dmpUsers; public static final String _dmpUsers = "dmpUsers"; @@ -104,6 +113,30 @@ public class PublicDmp { this.publishedAt = publishedAt; } + public DmpStatus getStatus() { + return status; + } + + public void setStatus(DmpStatus status) { + this.status = status; + } + + public UUID getGroupId() { + return groupId; + } + + public void setGroupId(UUID groupId) { + this.groupId = groupId; + } + + public DmpAccessType getAccessType() { + return accessType; + } + + public void setAccessType(DmpAccessType accessType) { + this.accessType = accessType; + } + public List getDmpUsers() { return dmpUsers; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmpReference.java b/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmpReference.java index a237f3752..707c8e142 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmpReference.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/PublicDmpReference.java @@ -1,5 +1,7 @@ package eu.eudat.model; +import eu.eudat.commons.enums.IsActive; + import java.time.Instant; import java.util.UUID; @@ -14,6 +16,9 @@ public class PublicDmpReference { private PublicReference reference; public static final String _reference = "reference"; + private IsActive isActive; + public static final String _isActive = "isActive"; + public UUID getId() { return id; } @@ -37,4 +42,12 @@ public class PublicDmpReference { public void setReference(PublicReference reference) { this.reference = reference; } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpBuilder.java index 7017394c2..05d146e99 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpBuilder.java @@ -74,6 +74,10 @@ public class PublicDmpBuilder extends BaseBuilder { if (fields.hasField(this.asIndexer(PublicDmp._description))) m.setDescription(d.getDescription()); if (fields.hasField(this.asIndexer(PublicDmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt()); if (fields.hasField(this.asIndexer(PublicDmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType()); + if (fields.hasField(this.asIndexer(PublicDmp._status))) m.setStatus(d.getStatus()); + if (fields.hasField(this.asIndexer(PublicDmp._groupId))) m.setGroupId(d.getGroupId()); + if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType()); if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId())); if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId())); @@ -109,7 +113,7 @@ public class PublicDmpBuilder extends BaseBuilder { this.logger.debug("checking related - {}", PublicDmpUser.class.getSimpleName()); Map> itemMap = null; - FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._user, PublicDmp._id)); + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._dmp, PublicDmp._id)); DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(PublicDmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpReferenceBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpReferenceBuilder.java index a6b31b46e..172adc03e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpReferenceBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/PublicDmpReferenceBuilder.java @@ -66,6 +66,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder cb.or( usePublic ? cb.and( cb.equal(subQueryRoot.get(DescriptionEntity._status), DescriptionStatus.Finalized), - cb.equal(subQueryRoot.get(DescriptionEntity._isActive), IsActive.Active) + cb.equal(subQueryRoot.get(DescriptionEntity._isActive), IsActive.Active), + cb.in(subQueryRoot.get(DescriptionEntity._dmpId)).value(this.buildDmpAuthZSubQuery(query, criteriaBuilder, userId, usePublic)) ): cb.or(), //Creates a false query userId != null ? cb.equal(subQueryRoot.get(DescriptionEntity._createdById), userId) : cb.or() //Creates a false query ) 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 ecde838e0..c20ae6d3e 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 @@ -572,6 +572,7 @@ public class DmpServiceImpl implements DmpService { } data.setLabel(model.getLabel()); + data.setLanguage(model.getLanguage()); data.setProperties(this.jsonHandlingService.toJson(this.buildDmpPropertiesEntity(model.getProperties()))); data.setDescription(model.getDescription()); data.setAccessType(model.getAccessType()); diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 4fdeb4c00..e1ec8da29 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -11,6 +11,7 @@ import { EntityDoi } from '../entity-doi/entity-doi'; import { ReferencePersist } from '../reference/reference'; import { DmpAssociatedUser, User } from "../user/user"; import { DmpReference } from './dmp-reference'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; export interface Dmp extends BaseEntity { label?: string; @@ -157,6 +158,9 @@ export interface PublicDmp extends BaseEntity { description?: string; finalizedAt?: Date; publishedAt?: Date; + status?: DmpStatus; + groupId?: String; + accessType: DmpAccessType; dmpReferences: PublicDmpReference[]; dmpUsers: PublicDmpUser[]; descriptions: PublicDescription[]; @@ -166,6 +170,7 @@ export interface PublicDmpReference { id: Guid; dmp: PublicDmp; reference: PublicReference; + isActive?: IsActive; } export interface PublicReference { diff --git a/dmp-frontend/src/app/core/services/file-transformer/file-transformer.service.ts b/dmp-frontend/src/app/core/services/file-transformer/file-transformer.service.ts index 4248de020..604c4a516 100644 --- a/dmp-frontend/src/app/core/services/file-transformer/file-transformer.service.ts +++ b/dmp-frontend/src/app/core/services/file-transformer/file-transformer.service.ts @@ -7,6 +7,7 @@ import { Guid } from '@common/types/guid'; import * as FileSaver from 'file-saver'; import { MatomoService } from '../matomo/matomo-service'; import { FileUtils } from '../utilities/file-utils.service'; +import { AuthService } from '../auth/auth.service'; @Injectable() export class FileTransformerService extends BaseService { @@ -14,7 +15,8 @@ export class FileTransformerService extends BaseService { constructor( private fileTransformerHttpService: FileTransformerHttpService, private matomoService: MatomoService, - private fileUtils: FileUtils + private fileUtils: FileUtils, + private authentication: AuthService, ) { super(); } private _initialized: boolean = false; @@ -22,6 +24,9 @@ export class FileTransformerService extends BaseService { private _availableFormats: FileFormat[] = []; get availableFormats(): FileFormat[] { + if (!this.authentication.currentAccountIsAuthenticated()){ + return; + } // console.log('availableFormats'); if (!this._initialized && !this._loading) this.init(); return this._availableFormats; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html index 92937132d..45c23c8eb 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html @@ -4,12 +4,12 @@
-

{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE' | translate}}

-

+

{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE' | translate}}

+

{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE-CLONE' | translate}} {{formGroup.get('label').value}}

-

+

{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE-VERSION' | translate}} {{formGroup.get('label').value}}

@@ -119,7 +119,7 @@ {{usersMap.get(user?.get('userId')?.value)?.name}} {{enumUtils.toUserDescriptionTemplateRoleString(user?.get('role')?.value)}} - + diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index f5ec839c6..379ea9de0 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -135,6 +135,22 @@ export class DescriptionTemplateEditorComponent extends BaseEditor void) { @@ -200,7 +216,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor void): void { - if (!this.isClone && !this.isNewVersion){ + if (this.isNewVersion == false){ const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist; this.descriptionTemplateService.persist(formData) @@ -208,7 +224,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), error => this.onCallbackError(error) ); - } else if (this.isNewVersion && !this.isNew && !this.isClone) { + } else if (this.isNewVersion== true && this.isNew == false && this.isClone == false) { const formData = this.formService.getValue(this.formGroup.value) as NewVersionDescriptionTemplatePersist; this.descriptionTemplateService.newVersion(formData) diff --git a/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts index 4a62698d1..bbba7c49f 100644 --- a/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts @@ -135,6 +135,7 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor
-

{{'DMP-BLUEPRINT-EDITOR.TITLE.NEW' | translate}}

-

{{formGroup.get('label').value}}

+

{{'DMP-BLUEPRINT-EDITOR.TITLE.NEW' | translate}}

+

{{formGroup.get('label').value}}

{{'DMP-BLUEPRINT-EDITOR.TITLE.CLONE' | translate}} {{formGroup.get('label').value}} diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts index 53593682f..d5b94b111 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts @@ -153,7 +153,6 @@ export class DmpBlueprintEditorComponent extends BaseEditor void): void { - if (this.isNew && !this.isClone && !this.isNewVersion) { + if ( this.isNewVersion == false) { const formData = this.formService.getValue(this.formGroup.value) as DmpBlueprintPersist; this.dmpBlueprintService.persist(formData) @@ -215,7 +214,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), error => this.onCallbackError(error) ); - } else if (this.isNewVersion && !this.isNew && !this.isClone) { + } else if (this.isNewVersion == true && this.isNew == false && this.isClone == false) { const formData = this.formService.getValue(this.formGroup.value) as NewVersionDmpBlueprintPersist; this.dmpBlueprintService.newVersion(formData) diff --git a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts index 8806ff43c..d6e12f228 100644 --- a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts @@ -155,6 +155,7 @@ export class LanguageEditorComponent extends BaseEditor } formSubmit(): void { + this.formService.removeAllBackEndErrors(this.formGroup); this.formService.touchAllFormFields(this.formGroup); - // if (!this.isFormValid()) { - // return; - // } + if (!this.isFormValid()) { + return; + } this.persistEntity(); } diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.html index 8da972d99..d2a157d3d 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.html @@ -4,10 +4,10 @@ {{'DMP-LISTING.SORT-BY' | translate}}: - {{enumUtils.toRecentActivityOrderString(order.MODIFIED)}} - {{enumUtils.toRecentActivityOrderString(order.DATASETPUBLISHED)}} - {{enumUtils.toRecentActivityOrderString(order.LABEL)}} - {{enumUtils.toRecentActivityOrderString(order.STATUS)}} + {{enumUtils.toRecentActivityOrderString(order.UpdatedAt)}} + + {{enumUtils.toRecentActivityOrderString(order.Label)}} + {{enumUtils.toRecentActivityOrderString(order.Status)}} diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts index a6b23531f..dae06b876 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -155,9 +155,9 @@ export class DescriptionEditorResolver extends BaseEditorResolver { const dmpSectionId = route.paramMap.get('dmpSectionId'); const copyDmpId = route.paramMap.get('copyDmpId'); // const cloneid = route.paramMap.get('cloneid'); - if (id != null) { + if (id != null && copyDmpId == null && dmpSectionId == null) { return this.descriptionService.getSingle(Guid.parse(id), fields) - } else if (dmpId != null && dmpSectionId != null) { + } else if (dmpId != null && dmpSectionId != null && copyDmpId == null) { return this.dmpService.getSingle(Guid.parse(dmpId), DescriptionEditorResolver.dmpLookupFields()).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed), map(dmp => { const description: Description = {}; diff --git a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html index 2bc4c1997..1510a44a0 100644 --- a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html +++ b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.html @@ -24,7 +24,7 @@

- open_in_new{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}} + open_in_new{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}} group_add{{'DESCRIPTION-LISTING.ACTIONS.INVITE-SHORT' | translate}} file_copy{{'DESCRIPTION-LISTING.ACTIONS.COPY-DESCRIPTION' | translate}} delete{{ 'DESCRIPTION-LISTING.ACTIONS.DELETE' | translate }} diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html index af852bb26..cf5aa87b0 100644 --- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html +++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html @@ -91,7 +91,7 @@
-
+
-
+