From 638c1bdd364de0594d3ad9973c9fbac1fcdd272c Mon Sep 17 00:00:00 2001 From: "AAVN\\ntnchuong" Date: Tue, 28 May 2024 15:23:12 +0700 Subject: [PATCH] TE-588: handle to load right workflow or all start process --- .../FlowParallelInOrder.p.json | 28 +++++++++---------- .../analyzer/demo/ProcessAnalyzerBean.java | 23 +++++++++++++-- .../AnalyzerSelection/AnalyzerSelection.xhtml | 4 +-- .../AnalyzerSelectionProcess.p.json | 6 ++-- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/process-analyzer-demo/processes/Analysis Processes/FlowParallelInOrder.p.json b/process-analyzer-demo/processes/Analysis Processes/FlowParallelInOrder.p.json index eff6b97b..3ece21d7 100644 --- a/process-analyzer-demo/processes/Analysis Processes/FlowParallelInOrder.p.json +++ b/process-analyzer-demo/processes/Analysis Processes/FlowParallelInOrder.p.json @@ -1,23 +1,10 @@ { "$schema" : "https://json-schema.axonivy.com/process/11.2.2/process.json", - "id" : "18E3BEFFB97FCA4D", + "id" : "18E3BEFFB97FCA4E", "config" : { "data" : "com.axonivy.utils.process.analyzer.demo.Data" }, "elements" : [ { - "id" : "f39", - "type" : "RequestStart", - "name" : "start", - "config" : { - "signature" : "start" - }, - "visual" : { - "at" : { "x" : 32, "y" : 176 } - }, - "connect" : [ - { "id" : "f41", "to" : "f40", "var" : "in1" } - ] - }, { "id" : "f40", "type" : "TaskSwitchGateway", "name" : "Task 1", @@ -395,6 +382,19 @@ "connect" : [ { "id" : "f1", "to" : "f53", "via" : [ { "x" : 792, "y" : 280 } ], "var" : "in1" } ] + }, { + "id" : "f2", + "type" : "RequestStart", + "name" : "start", + "config" : { + "signature" : "start" + }, + "visual" : { + "at" : { "x" : 32, "y" : 176 } + }, + "connect" : [ + { "id" : "f3", "to" : "f40", "var" : "in1" } + ] } ], "layout" : { "colors" : { diff --git a/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java b/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java index db7ddfb7..f2c2b0f9 100644 --- a/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java +++ b/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java @@ -32,6 +32,7 @@ import ch.ivyteam.ivy.process.model.element.EmbeddedProcessElement; import ch.ivyteam.ivy.process.model.element.ProcessElement; import ch.ivyteam.ivy.process.model.element.SingleTaskCreator; +import ch.ivyteam.ivy.process.model.element.event.start.RequestStart; import ch.ivyteam.ivy.process.model.element.gateway.Alternative; import ch.ivyteam.ivy.process.rdm.IProcess; import ch.ivyteam.ivy.process.rdm.IProcessManager; @@ -161,10 +162,22 @@ public String getDisplayDetectedElement(DetectedElement element) { return String.format("%s (%s)", elementName, shortPid); } - public String getProcessWebLink() { + public String getProcessWebLink(SingleTaskCreator startElement) throws Exception { + IWebStartable webStartable = null; String guid = this.selectedAnalyzer.getProcess().getPid().getProcessGuid(); - IWebStartable webStartable = Ivy.session().getStartables().stream() - .filter(it -> it.getLink().toRelativeUri().getPath().contains(guid)).findFirst().orElse(null); + var listStartElement = getListStartElementsOfProcess(this.selectedAnalyzer.getProcess()); + + for (BaseElement start : listStartElement) { + List listElements = this.processAnalyzer.findAllTasks(start, null); + if (listElements.stream().map(item -> item.getElementName()).toList().contains(startElement.getName()) + || start.getName().equals(startElement.getName())) { + String startName = start.getName(); + webStartable = Ivy.session().getStartables().stream() + .filter(it -> it.getLink().toRelativeUri().getPath().contains(guid + "/" + startName)) + .findFirst().orElse(null); + break; + } + } if (webStartable != null) { return ProcessViewer.of((IProcessWebStartable) webStartable).url().toWebLink().getRelative(); @@ -211,6 +224,10 @@ private static List getElementOfProcess(Process process) { return elements; } + private List getListStartElementsOfProcess(Process process) { + return getElementOfProcess(process).stream().filter(item -> item instanceof RequestStart).toList(); + } + private static List getElementOfProcesses(List processElements) { if (processElements.isEmpty()) { return emptyList(); diff --git a/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelection.xhtml b/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelection.xhtml index 45663a7d..ece7a525 100644 --- a/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelection.xhtml +++ b/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelection.xhtml @@ -27,7 +27,7 @@ @@ -40,7 +40,7 @@ value="#{data.processAnalyzerBean.selectedAnalyzer.elements}" var="element" itemLabel="#{element.name}" itemValue="#{element}" /> diff --git a/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelectionProcess.p.json b/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelectionProcess.p.json index b6544522..686f5f55 100644 --- a/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelectionProcess.p.json +++ b/process-analyzer-demo/src_hd/com/axonivy/utils/process/analyzer/demo/component/AnalyzerSelection/AnalyzerSelectionProcess.p.json @@ -75,7 +75,6 @@ "code" : [ "if(in.processAnalyzerBean.selectedAnalyzer is initialized) {", " in.processAnalyzerBean.selectedAnalyzer.elements = in.processAnalyzerBean.getAllTaskModifier();", - " in.processAnalyzerBean.selectedAnalyzer.processPath = in.processAnalyzerBean.getProcessWebLink();", "}" ] } @@ -192,7 +191,10 @@ "name" : "init alternative", "config" : { "output" : { - "code" : "in.processAnalyzerBean.selectedAnalyzer.alternatives = in.processAnalyzerBean.getALternativeWithMoreThanOneOutgoing();" + "code" : [ + "in.processAnalyzerBean.selectedAnalyzer.alternatives = in.processAnalyzerBean.getALternativeWithMoreThanOneOutgoing();", + "in.processAnalyzerBean.selectedAnalyzer.processPath = in.processAnalyzerBean.getProcessWebLink(in.processAnalyzerBean.selectedAnalyzer.startElement);" + ] } }, "visual" : {