From ec7c9d3afee17f5be3855163d4a452e74554a01d Mon Sep 17 00:00:00 2001 From: "Nam.Chu" Date: Thu, 19 Sep 2024 17:58:23 +0700 Subject: [PATCH] IVYPORTAL-17644 Investigate demo engine need to manually restart (null pmv version) - Try remove clean up cronjob --- .../CleanUpObsoletedUserData.p.json | 58 ----------------- ...ByGlobalVariableTriggerStartEventBean.java | 65 ------------------- 2 files changed, 123 deletions(-) delete mode 100644 AxonIvyPortal/portal/processes/SynchronizeDataProcesses/CleanUpObsoletedUserData.p.json delete mode 100644 AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/CronByGlobalVariableTriggerStartEventBean.java diff --git a/AxonIvyPortal/portal/processes/SynchronizeDataProcesses/CleanUpObsoletedUserData.p.json b/AxonIvyPortal/portal/processes/SynchronizeDataProcesses/CleanUpObsoletedUserData.p.json deleted file mode 100644 index 29f7bc55dc2..00000000000 --- a/AxonIvyPortal/portal/processes/SynchronizeDataProcesses/CleanUpObsoletedUserData.p.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "$schema" : "https://json-schema.axonivy.com/process/11.3.0/process.json", - "id" : "1626C02D46BF5153", - "description" : "This is a scheduled process of Portal", - "config" : { - "data" : "ch.ivy.add.portalkit.Data" - }, - "elements" : [ { - "id" : "f6", - "type" : "TaskEnd", - "visual" : { - "at" : { "x" : 120, "y" : 320 } - } - }, { - "id" : "f5", - "type" : "ProgramStart", - "name" : "PortalCleanObsoleteData", - "config" : { - "javaClass" : "ch.ivy.addon.portalkit.util.CronByGlobalVariableTriggerStartEventBean", - "userConfig" : { - "variable" : "PortalStartTimeCleanObsoletedDataExpression" - }, - "link" : "eventLink.ivp" - }, - "visual" : { - "at" : { "x" : 120, "y" : 104 }, - "labelOffset" : { "x" : 104, "y" : 20 }, - "description" : "This is a scheduled process of Portal" - }, - "connect" : [ - { "id" : "f4", "to" : "f2" } - ] - }, { - "id" : "f2", - "type" : "Script", - "name" : [ - "Delete finished hidden", - "system cases" - ], - "config" : { - "output" : { - "code" : [ - "import ch.ivy.addon.portalkit.service.DeleteFinishedHiddenCasesService;", - "DeleteFinishedHiddenCasesService deletFinishedHiddenCasesService = new DeleteFinishedHiddenCasesService();", - "deletFinishedHiddenCasesService.deleteFinishedHiddenCases();" - ] - }, - "sudo" : true - }, - "visual" : { - "at" : { "x" : 120, "y" : 208 }, - "size" : { "width" : 144 } - }, - "connect" : [ - { "id" : "f1", "to" : "f6" } - ] - } ] -} \ No newline at end of file diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/CronByGlobalVariableTriggerStartEventBean.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/CronByGlobalVariableTriggerStartEventBean.java deleted file mode 100644 index c1aa8e91fe6..00000000000 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/util/CronByGlobalVariableTriggerStartEventBean.java +++ /dev/null @@ -1,65 +0,0 @@ -package ch.ivy.addon.portalkit.util; - -import java.util.Optional; - -import org.apache.commons.lang3.StringUtils; - -import ch.ivyteam.ivy.process.eventstart.AbstractProcessStartEventBean; -import ch.ivyteam.ivy.process.eventstart.IProcessStartEventBeanRuntime; -import ch.ivyteam.ivy.process.extension.ProgramConfig; -import ch.ivyteam.ivy.process.extension.ui.ExtensionUiBuilder; -import ch.ivyteam.ivy.process.extension.ui.UiEditorExtension; -import ch.ivyteam.ivy.request.RequestException; -import ch.ivyteam.ivy.vars.Variable; -import ch.ivyteam.ivy.vars.Variables; -import ch.ivyteam.util.IvyRuntimeException; - -public class CronByGlobalVariableTriggerStartEventBean extends AbstractProcessStartEventBean { - - private static final String PORTAL_DELETE_ALL_FINISHED_HIDDEN_CASE = "PortalDeleteAllFinishedHiddenCases"; - private static final String VARIABLE = "variable"; - public CronByGlobalVariableTriggerStartEventBean() { - super("Portal Clean Obsolete Data", "This is a scheduled process of Portal"); - } - - @Override - public void initialize(IProcessStartEventBeanRuntime eventRuntime, ProgramConfig configuration) { - super.initialize(eventRuntime, configuration); - try { - Variable var = - Variables.of(eventRuntime.getProcessModelVersion().getApplication()).variable(configuration.get(VARIABLE)); - Variable deleteAllFinishedHiddenCasesVar = Variables.of(eventRuntime.getProcessModelVersion().getApplication()) - .variable(PORTAL_DELETE_ALL_FINISHED_HIDDEN_CASE); - if (var != null) { - String pattern = var.value(); - Boolean isJobTrigger = Optional.of(deleteAllFinishedHiddenCasesVar).map(Variable::value).map(Boolean::parseBoolean).orElse(false); - if (StringUtils.isNotBlank(pattern) && isJobTrigger) { - eventRuntime.poll().asDefinedByExpression(pattern); - } else { - eventRuntime.poll().disable(); - } - } - } catch (Exception ex) { - throw new IvyRuntimeException("Cannot evaluate the ivyScript configuration ", ex); - } - } - - - @Override - public void poll() { - try { - getEventBeanRuntime().processStarter() - .withReason("Time elapsed or reached cron pattern " + getConfig().get(VARIABLE)).start(); - } catch (RequestException ex) { - throw new IvyRuntimeException("Cannot start process", ex); - } - } - - public static class Editor extends UiEditorExtension { - - @Override - public void initUiFields(ExtensionUiBuilder ui) { - ui.textField(VARIABLE).create(); - } - } -}