Skip to content

Commit

Permalink
TE-584: Handle task from sub process
Browse files Browse the repository at this point in the history
  • Loading branch information
trungmaihova committed May 27, 2024
1 parent a4ccbea commit a7b8474
Show file tree
Hide file tree
Showing 13 changed files with 617 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.primefaces.component.selectoneradio.SelectOneRadio;

import com.axonivy.portal.components.util.CaseUtils;
import com.axonivy.utils.process.analyzer.AdvancedProcessAnalyzer;
import com.axonivy.utils.process.analyzer.demo.constant.FindType;
import com.axonivy.utils.process.analyzer.demo.constant.UseCase;
Expand All @@ -36,6 +37,7 @@
import ch.ivyteam.ivy.process.rdm.IProcess;
import ch.ivyteam.ivy.process.rdm.IProcessManager;
import ch.ivyteam.ivy.process.viewer.api.ProcessViewer;
import ch.ivyteam.ivy.workflow.ICase;
import ch.ivyteam.ivy.workflow.start.IProcessWebStartable;
import ch.ivyteam.ivy.workflow.start.IWebStartable;

Expand Down Expand Up @@ -119,15 +121,18 @@ public void onSelectSequenceFlow(AjaxBehaviorEvent event) {
public List<DetectedElement> getDetectedTask() throws Exception {
UseCase useCase = selectedAnalyzer.getUseCase();
String flowName = selectedAnalyzer.getFlowName();

ICase icase = CaseUtils.findCase("c2e70381-d72c-49a2-b73d-91bbb212df83");

SingleTaskCreator startElement = selectedAnalyzer.getStartElement();
processAnalyzer = updateProcessAnalyzer(selectedAnalyzer);

long startTime = System.currentTimeMillis();
List<?> detectedElements = null;
if (FindType.ALL_TASK.equals(selectedAnalyzer.getFindType())) {
detectedElements = processAnalyzer.findAllTasks(startElement, useCase);
detectedElements = processAnalyzer.findAllTasks(icase, useCase);
} else {
detectedElements = processAnalyzer.findTasksOnPath(startElement, useCase, flowName);
detectedElements = processAnalyzer.findTasksOnPath(icase, useCase, flowName);
}

long executionTime = System.currentTimeMillis() - startTime;
Expand All @@ -140,12 +145,13 @@ public Duration getDetectedTaskCalculate() throws Exception {
UseCase useCase = selectedAnalyzer.getUseCase();
String flowName = selectedAnalyzer.getFlowName();
SingleTaskCreator startElement = selectedAnalyzer.getStartElement();
ICase icase = CaseUtils.findCase("c2e70381-d72c-49a2-b73d-91bbb212df83");
processAnalyzer = updateProcessAnalyzer(selectedAnalyzer);
Duration total = Duration.ZERO;
if (FindType.ALL_TASK.equals(selectedAnalyzer.getFindType())) {
total = processAnalyzer.calculateWorstCaseDuration(startElement, useCase);
total = processAnalyzer.calculateWorstCaseDuration(icase, useCase);
} else {
total = processAnalyzer.calculateDurationOfPath(startElement, useCase, flowName);
total = processAnalyzer.calculateDurationOfPath(icase, useCase, flowName);
}

return total;
Expand Down
125 changes: 122 additions & 3 deletions process-analyzer-test/processes/FlowSubprocess.p.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "Task A"
"name" : "Task A",
"code" : [
"import java.util.concurrent.TimeUnit;",
"import com.axonivy.utils.process.analyzer.APAConfig;",
"import com.axonivy.utils.process.analyzer.test.UseCase;",
"",
"APAConfig.setEstimate(5,TimeUnit.HOURS,UseCase.BIGPROJECT);"
]
}
},
"visual" : {
Expand Down Expand Up @@ -122,7 +129,14 @@
"name" : "Task B",
"config" : {
"task" : {
"name" : "Task B"
"name" : "Task B",
"code" : [
"import java.util.concurrent.TimeUnit;",
"import com.axonivy.utils.process.analyzer.APAConfig;",
"import com.axonivy.utils.process.analyzer.test.UseCase;",
"",
"APAConfig.setEstimate(4,TimeUnit.HOURS,UseCase.BIGPROJECT);"
]
}
},
"visual" : {
Expand All @@ -149,7 +163,7 @@
"findTasksOnPath( start.ivp ) => TaskA, TaskB"
],
"visual" : {
"at" : { "x" : 376, "y" : 343 },
"at" : { "x" : 824, "y" : 167 },
"size" : { "width" : 476, "height" : 97 }
}
}, {
Expand Down Expand Up @@ -198,5 +212,110 @@
"visual" : {
"at" : { "x" : 488, "y" : 192 }
}
}, {
"id" : "f10",
"type" : "RequestStart",
"name" : "start3",
"config" : {
"signature" : "start3"
},
"visual" : {
"at" : { "x" : 96, "y" : 312 }
},
"connect" : [
{ "id" : "f11", "to" : "S30" }
]
}, {
"id" : "S30",
"type" : "EmbeddedProcess",
"name" : "Sub Process A",
"elements" : [ {
"id" : "S30-g0",
"type" : "EmbeddedStart",
"visual" : {
"at" : { "x" : 64, "y" : 256 }
},
"parentConnector" : "f11",
"connect" : [
{ "id" : "S30-f0", "to" : "S30-f1" }
]
}, {
"id" : "S30-g1",
"type" : "EmbeddedEnd",
"visual" : {
"at" : { "x" : 496, "y" : 256 }
},
"parentConnector" : "f13"
}, {
"id" : "S30-f1",
"type" : "SubProcessCall",
"name" : "CallSubProcess A",
"config" : {
"processCall" : "FlowSubProcessCall:call()",
"call" : {
"map" : { },
"code" : [
"import com.axonivy.utils.process.analyzer.test.UseCase;",
"import java.util.concurrent.TimeUnit;",
"import com.axonivy.utils.process.analyzer.APAConfig;",
"",
"APAConfig.handleAsTask();",
"APAConfig.setTaskName(\"CallSubProcess A\");",
"APAConfig.setEstimate(10,TimeUnit.DAYS,UseCase.BIGPROJECT);",
"APAConfig.setEstimate(5,TimeUnit.DAYS,UseCase.SMALLPROJECT);"
]
}
},
"visual" : {
"at" : { "x" : 208, "y" : 256 }
},
"connect" : [
{ "id" : "S30-f2", "to" : "S30-f3" }
]
}, {
"id" : "S30-f3",
"type" : "UserTask",
"name" : "TaskC",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskC"
}
},
"visual" : {
"at" : { "x" : 368, "y" : 256 }
},
"connect" : [
{ "id" : "S30-f4", "to" : "S30-g1" }
]
} ],
"visual" : {
"at" : { "x" : 288, "y" : 312 }
},
"connect" : [
{ "id" : "f13", "to" : "f12" }
]
}, {
"id" : "f12",
"type" : "UserTask",
"name" : "TaskB",
"config" : {
"dialog" : "com.axonivy.utils.process.analyzer.test.Dummy:start()",
"task" : {
"name" : "TaskB"
}
},
"visual" : {
"at" : { "x" : 480, "y" : 312 }
},
"connect" : [
{ "id" : "f15", "to" : "f14" }
]
}, {
"id" : "f14",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 672, "y" : 312 }
}
} ]
}
Loading

0 comments on commit a7b8474

Please sign in to comment.