Skip to content

Commit

Permalink
Merge pull request #14 from axonivy-market/TE-588-Handle-to-load-righ…
Browse files Browse the repository at this point in the history
…t-workflow-or-all-start-process

TE-588: handle to load right workflow or all start process
  • Loading branch information
ntnchuong authored May 28, 2024
2 parents 10293a1 + da59e63 commit 02d6d3f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$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"
},
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,28 @@ 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);
List<BaseElement> listStartElement = getStartElementsOfProcess(this.selectedAnalyzer.getProcess());

List<String> startElementNames = listStartElement.stream().map(BaseElement::getName).toList();
String elementName = startElementNames.stream().filter(name -> name.equals(startElement.getName())).findFirst()
.orElse(null);

for (BaseElement startNode : listStartElement) {
List<DetectedElement> listElements = this.processAnalyzer.findAllTasks(startNode, null);
boolean isExist = listElements.stream().anyMatch(it -> it.getElementName().equals(startElement.getName()));
if (isExist) {
elementName = startNode.getName();
break;
}
}

final String startName = elementName;
webStartable = Ivy.session().getStartables().stream()
.filter(it -> it.getLink().toRelativeUri().getPath().contains(guid + "/" + startName)).findFirst()
.orElse(null);

if (webStartable != null) {
return ProcessViewer.of((IProcessWebStartable) webStartable).url().toWebLink().getRelative();
Expand Down Expand Up @@ -211,6 +230,10 @@ private static List<BaseElement> getElementOfProcess(Process process) {
return elements;
}

private List<BaseElement> getStartElementsOfProcess(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 02d6d3f

Please sign in to comment.