From a8574904b3d3c663a2053add3553497db1e27e57 Mon Sep 17 00:00:00 2001 From: nhthinh-axonivy Date: Wed, 11 Dec 2024 18:48:26 +0700 Subject: [PATCH] feature/IVYPORTAL-18050-Create-cache-mechanism-for-dashboard-converter-to-enhance-performance --- .../generic/bean/DashboardModificationBean.java | 4 ++-- .../ivy/addon/portalkit/dto/dashboard/Dashboard.java | 2 +- .../ch/ivy/addon/portalkit/util/DashboardUtils.java | 12 +----------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java index 0fd4f824cf..58c9a2ec3d 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portal/generic/bean/DashboardModificationBean.java @@ -395,8 +395,8 @@ public void savePublicArrangement() { } } newDashboards.addAll(idToDashboard.values()); - String dashboardsAsSJSON = BusinessEntityConverter.entityToJsonValue(newDashboards); - Ivy.var().set(PortalVariable.DASHBOARD.key, dashboardsAsSJSON); + + saveDashboards(newDashboards); } public void savePrivateArrangement() { diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java index 3134cd3d51..0896ec2dc6 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/dto/dashboard/Dashboard.java @@ -139,7 +139,7 @@ public void setTemplateId(String templateId) { } public Boolean getIsTopMenu() { - return isTopMenu != null ? isTopMenu : false; + return isTopMenu; } public void setIsTopMenu(Boolean isTopMenu) { diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java index 61f1a53baa..08e87c7028 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/DashboardUtils.java @@ -73,7 +73,6 @@ public static List getPublicDashboards() { try { String dashboardJson = Ivy.var().get(PortalVariable.DASHBOARD.key); dashboards = jsonToDashboards(dashboardJson); - ensureDefaultIsTopMenu(dashboards); addDefaultTaskCaseListDashboardsIfMissing(dashboards); setDashboardAsPublic(dashboards); } catch (Exception e) { @@ -167,6 +166,7 @@ private static List jsonToDashboards(String dashboardJson) { JsonDashboardMigrator migrator = new JsonDashboardMigrator(mapper.readTree(dashboardJson)); List dashboards = BusinessEntityConverter.convertJsonNodeToList(migrator.migrate(), Dashboard.class); dashboards.forEach(initDefaultPermission()); + return dashboards; } catch (JsonProcessingException e) { Ivy.log().error("Failed to parse dashboards from JSON: {0}", e); @@ -317,16 +317,6 @@ public static void updatePropertiesToNullIfCurrentValueIsDefaultValue(List dashboards) { - if (dashboards != null) { - dashboards.forEach(dashboard -> { - if (dashboard.getIsTopMenu() == null) { - dashboard.setIsTopMenu(false); - } - }); - } - } - private record PortalPrivateDashboardWrapper(Locale loadedLocale, List dashboards) { } private record PortalPublicDashboardWrapper(Locale loadedLocale, List dashboards) {