Skip to content

Commit

Permalink
TE-588: handle to load right workflow or all start process
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnchuong committed May 28, 2024
1 parent 7d53d5f commit 638c1bd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DetectedElement> 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();
Expand Down Expand Up @@ -211,6 +224,10 @@ private static List<BaseElement> getElementOfProcess(Process process) {
return elements;
}

private List<BaseElement> getListStartElementsOfProcess(Process process) {
return getElementOfProcess(process).stream().filter(item -> item instanceof RequestStart).toList();
}

private static List<BaseElement> getElementOfProcesses(List<ProcessElement> processElements) {
if (processElements.isEmpty()) {
return emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<f:selectItems value="#{data.processAnalyzerBean.processes}"
var="process" itemLabel="#{process.name}" itemValue="#{process}" />
<p:ajax event="change" listener="#{logic.onChooseProcess}"
update="process-analyzer:analyzer-selection:selectOneElement process-analyzer:analyzer-selection:process-viewer-diagram @parent:alternative-selection"
update="process-analyzer:analyzer-selection:selectOneElement @parent:alternative-selection"
process="@this" />
</p:selectOneMenu>

Expand All @@ -40,7 +40,7 @@
value="#{data.processAnalyzerBean.selectedAnalyzer.elements}"
var="element" itemLabel="#{element.name}" itemValue="#{element}" />
<p:ajax event="change" listener="#{logic.onChooseElement}"
update="process-analyzer:analyzer-selection:selectOneElement @parent:alternative-selection"
update="process-analyzer:analyzer-selection:selectOneElement process-analyzer:analyzer-selection:process-viewer-diagram @parent:alternative-selection"
process="@this" />
</p:selectOneMenu>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();",
"}"
]
}
Expand Down Expand Up @@ -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" : {
Expand Down

0 comments on commit 638c1bd

Please sign in to comment.