From 0ded82e5cb2bb055a11418ab8b73f3150bf62871 Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 5 Apr 2024 09:44:26 +0300 Subject: [PATCH 1/2] description multiplicity ui changes --- .../editor/description-editor.component.ts | 2 +- .../dmp-editor.component.html | 12 +++------- .../dmp-editor.component.ts | 22 ++++++++++++++----- .../dmp-editor.resolver.ts | 1 + 4 files changed, 21 insertions(+), 16 deletions(-) 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 3d1a0ac14..8272d2be9 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 @@ -594,7 +594,7 @@ export class DescriptionEditorComponent extends BaseEditor x.dmpDescriptionTemplate.descriptionTemplateGroupId == sectionDescriptionTemplate.descriptionTemplateGroupId); if (commonDescriptions && commonDescriptions.length >= sectionDescriptionTemplate.maxMultiplicity) { - rejectedDmpDescriptionTemplates = commonDescriptions.map(x => x.dmpDescriptionTemplate); + rejectedDmpDescriptionTemplates.push.apply(rejectedDmpDescriptionTemplates, commonDescriptions.map(x => x.dmpDescriptionTemplate)); } } }) 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 9ae489a4a..698244d6b 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 @@ -96,17 +96,11 @@ 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 04db52f5c..4f93b3b14 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 @@ -172,12 +172,18 @@ export class DmpEditorComponent extends BaseEditor implemen prepareForm(data: Dmp) { try { this.editorModel = data ? new DmpEditorModel().fromModel(data) : new DmpEditorModel(); - if (data && data.descriptions) { - if (data.status == DmpStatus.Finalized) { - data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized); - } else { - data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled); + if (data) { + if(data.descriptions){ + if (data.status == DmpStatus.Finalized) { + data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized); + } else { + data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled); + } } + if(data.dmpDescriptionTemplates){ + data.dmpDescriptionTemplates = data.dmpDescriptionTemplates.filter(x => x.isActive === IsActive.Active); + } + } this.item = data; @@ -416,7 +422,7 @@ export class DmpEditorComponent extends BaseEditor implemen // // public descriptionsInSection(sectionId: Guid) { - return this.item?.descriptions?.filter(x => x?.dmpDescriptionTemplate?.sectionId === sectionId) || []; + return this.item?.descriptions?.filter(x => x.isActive == IsActive.Active && x?.dmpDescriptionTemplate?.sectionId === sectionId && x.dmpDescriptionTemplate.isActive == IsActive.Active) || []; } editDescription(id: string, isNew: boolean) { @@ -459,6 +465,10 @@ export class DmpEditorComponent extends BaseEditor implemen if (section.descriptionTemplates?.length > 0){ const descriptions = this.descriptionsInSection(section.id) + if (this.item.dmpDescriptionTemplates.filter(x => x.sectionId == section.id).length > descriptions.map(x => x.dmpDescriptionTemplate).length){ + return true; + } + let multiplicityValidResults :boolean[] = []; section.descriptionTemplates.forEach(sectionDescriptionTemplate => { if (sectionDescriptionTemplate.maxMultiplicity != null){ 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 aa718bc02..ea63a9e38 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 @@ -62,6 +62,7 @@ export class DmpEditorResolver extends BaseEditorResolver { [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.sectionId)].join('.'), [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.descriptionTemplateGroupId)].join('.'), + [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.isActive)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), From 76a355891fa62e4047334de3b7e724bba7d75b2a Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Fri, 5 Apr 2024 10:07:38 +0300 Subject: [PATCH 2/2] added tenantcode to dashboard statistics cacahe key --- .../dashborad/DashboardServiceImpl.java | 12 ++++++--- .../DashboardStatisticsCacheService.java | 25 +++++++++++++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardServiceImpl.java index dd699b754..2239d0ca8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardServiceImpl.java @@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.OwnedResource; import eu.eudat.authorization.Permission; import eu.eudat.commons.enums.*; +import eu.eudat.commons.scope.tenant.TenantScope; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.types.dashborad.RecentActivityItemEntity; import eu.eudat.convention.ConventionService; @@ -41,7 +42,8 @@ public class DashboardServiceImpl implements DashboardService { private final BuilderFactory builderFactory; private final QueryFactory queryFactory; private final UserScope userScope; - private final DashboardServiceProperties config; + private final TenantScope tenantScope; + private final DashboardServiceProperties config; private final ElasticQueryHelperService elasticQueryHelperService; private final DashboardStatisticsCacheService dashboardStatisticsCacheService; @Autowired @@ -49,13 +51,15 @@ public class DashboardServiceImpl implements DashboardService { ConventionService conventionService, AuthorizationService authorizationService, BuilderFactory builderFactory, QueryFactory queryFactory, - UserScope userScope, + UserScope userScope, + TenantScope tenantScope, DashboardServiceProperties config, ElasticQueryHelperService elasticQueryHelperService, DashboardStatisticsCacheService dashboardStatisticsCacheService) { this.conventionService = conventionService; this.authorizationService = authorizationService; this.builderFactory = builderFactory; this.queryFactory = queryFactory; this.userScope = userScope; + this.tenantScope = tenantScope; this.config = config; this.elasticQueryHelperService = elasticQueryHelperService; this.dashboardStatisticsCacheService = dashboardStatisticsCacheService; @@ -138,7 +142,7 @@ public class DashboardServiceImpl implements DashboardService { public DashboardStatistics getMyDashboardStatistics() throws InvalidApplicationException { this.authorizationService.authorizeAtLeastOneForce(this.userScope.getUserIdSafe() != null ? List.of(new OwnedResource(this.userScope.getUserIdSafe())) : null); - DashboardStatisticsCacheService.DashboardStatisticsCacheValue cacheValue = this.dashboardStatisticsCacheService.lookup(this.dashboardStatisticsCacheService.buildKey(this.userScope.getUserId().toString().toLowerCase(Locale.ROOT))); + DashboardStatisticsCacheService.DashboardStatisticsCacheValue cacheValue = this.dashboardStatisticsCacheService.lookup(this.dashboardStatisticsCacheService.buildKey(this.dashboardStatisticsCacheService.generateUserTenantCacheKey(this.userScope.getUserId(), this.tenantScope.getTenantCode()))); if (cacheValue == null || cacheValue.getDashboardStatistics() == null) { DmpUserQuery dmpUserLookup = this.queryFactory.query(DmpUserQuery.class); dmpUserLookup.userIds(this.userScope.getUserId()); @@ -161,7 +165,7 @@ public class DashboardServiceImpl implements DashboardService { statistics.getReferenceTypeStatistics().add(referenceTypeStatistics); } } - cacheValue = new DashboardStatisticsCacheService.DashboardStatisticsCacheValue(this.userScope.getUserId()); + cacheValue = new DashboardStatisticsCacheService.DashboardStatisticsCacheValue(this.userScope.getUserId(), this.tenantScope.getTenantCode()); cacheValue.setPublic(false); cacheValue.setDashboardStatistics(statistics); this.dashboardStatisticsCacheService.put(cacheValue); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardStatisticsCacheService.java b/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardStatisticsCacheService.java index d700fb979..5dd739dd3 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardStatisticsCacheService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dashborad/DashboardStatisticsCacheService.java @@ -1,5 +1,6 @@ package eu.eudat.service.dashborad; +import eu.eudat.commons.scope.user.UserScope; import eu.eudat.model.DashboardStatistics; import gr.cite.tools.cache.CacheService; import org.springframework.beans.factory.annotation.Autowired; @@ -19,12 +20,14 @@ public class DashboardStatisticsCacheService extends CacheService