From 27126d1c9f7f12c671389aaf80c367dd646510a6 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 22 Mar 2024 17:04:33 +0100 Subject: [PATCH] starting mapping to catalogue --- .../manage/ManageDoActionNotification.java | 7 ---- .../manage/mapping/MappingToCatalogue.java | 41 +++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/mapping/MappingToCatalogue.java diff --git a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java index ece1d24..59c7485 100644 --- a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java +++ b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/ManageDoActionNotification.java @@ -23,7 +23,6 @@ import org.gcube.application.geoportal.common.model.document.lifecycle.Lifecycle import org.gcube.common.authorization.utils.manager.SecretManager; import org.gcube.common.authorization.utils.manager.SecretManagerProvider; import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS; -import org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEventType; import lombok.extern.slf4j.Slf4j; @@ -168,12 +167,6 @@ public class ManageDoActionNotification { NotificationWhen.class.getSimpleName()); return filteredList; } - - - public static CatalogueEventType toCatalogueEventType(String itemPhase, String lastInvokedStep) { - - return null; - } /** * Gets the list user compliant to roles. diff --git a/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/mapping/MappingToCatalogue.java b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/mapping/MappingToCatalogue.java new file mode 100644 index 0000000..f9210d9 --- /dev/null +++ b/notifications-plugins/src/main/java/org/gcube/application/cms/notifications/manage/mapping/MappingToCatalogue.java @@ -0,0 +1,41 @@ +package org.gcube.application.cms.notifications.manage.mapping; + +import org.gcube.application.cms.plugins.implementations.Default3PhaseManager; +import org.gcube.application.cms.plugins.implementations.SimpleLifeCycleManager; +import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; +import org.gcube.social_networking.socialnetworking.model.beans.catalogue.CatalogueEventType; + +public class MappingToCatalogue { + + public static CatalogueEventType toCatalogueEventType(String itemPhase, String lastInvokedStep) { + + // SimpleLifeCycleManager + if (itemPhase.equals(SimpleLifeCycleManager.Phases.PUBLISHED) + && lastInvokedStep.equals(SimpleLifeCycleManager.Steps.PUBLISH.getId())) { + return CatalogueEventType.ITEM_SUBMITTED; + } else if (itemPhase.equals(SimpleLifeCycleManager.Phases.UNPUBLISHED) + && lastInvokedStep.equals(SimpleLifeCycleManager.Steps.UNPUBLISH.getId())) { + // TODO + // Missing ITEM UNPUBLISHED; + + } + + // Default3PhaseManager + if (itemPhase.equals(Default3PhaseManager.Phases.PENDING_APPROVAL) + && lastInvokedStep.equals(Default3PhaseManager.STEPS.SUBMIT.getId())) { + return CatalogueEventType.ITEM_SUBMITTED; + } else if (itemPhase.equals(Default3PhaseManager.Phases.PUBLISHED) + && lastInvokedStep.equals(Default3PhaseManager.STEPS.APPROVE.getId())) { + return CatalogueEventType.ITEM_PUBLISHED; + } else if (itemPhase.equals(LifecycleInformation.CommonPhases.DRAFT_PHASE) + && lastInvokedStep.equals(Default3PhaseManager.STEPS.REJECT.getId())) { + return CatalogueEventType.ITEM_REJECTED; + } else if (itemPhase.equals(LifecycleInformation.CommonPhases.DRAFT_PHASE) + && lastInvokedStep.equals(Default3PhaseManager.STEPS.UNPUBLISH.getId())) { + // TODO + // Missing ITEM UNPUBLISHED; + } + + return null; + } +}