Step IV¶
Road Test, Issue DL Task¶
- Edit DlProcess.kprocess and change insert the below content to change the DrivingLicense flow
role-ref RTO("RTO"), Applicant("Applicant")
flow DrivingLicense {
document(applicantId:String, firstName:String,lastName:String, age:Int, reviewOkay:Boolean = `false`,
first:Int?, ^second:Int?, result:Int?,
writtenTestPassed:Boolean = `false`,
roadTestPassed:Boolean = `false`,
roadTestCounter:Int = `0`
) display-id("${firstName} ${lastName}")
task ReviewApplication {
input(firstName, lastName, age) display-id("${document.firstName} ${document.lastName}")
output(reviewOkay)
realizer manual(RTO) distribution(system)
}
task SelectQuestion {
output(first!,^second!)
realizer auto
}
task WriteTest {
input(applicantId, first!,^second!) display-id("${document.firstName} ${document.lastName}")
output(result!)
realizer manual(Applicant) distribution(custom)
}
task Evaluate {
input(first!,^second!,result!)
output(writtenTestPassed)
realizer auto
}
task IssueLL {
input(firstName)
realizer auto
}
task RoadTest {
input(roadTestCounter) display-id("${document.firstName} ${document.lastName}")
output(roadTestCounter, roadTestPassed)
realizer manual(RTO) distribution(system)
}
task IssueRegretLetter {
input(firstName)
realizer auto
}
task IssueDL {
input(firstName)
realizer auto
}
net DL {
init-document(applicantId, firstName,lastName, age) having coorelation-id (applicantId)
START out (ReviewApplication)
connector C1 in(ReviewApplication) out select {
case applicationFine => `reviewOkay` => SelectQuestion
case default => IssueRegretLetter
}
connector C2 in(SelectQuestion) out(WriteTest)
connector C3 in(WriteTest) out(Evaluate)
connector C4 in(Evaluate) out select {
case writtenTestPassed => `writtenTestPassed` => IssueLL
case default => IssueRegretLetter
}
connector C5 in(IssueLL) out(RoadTest)
connector C6 in(RoadTest) out select {
case roadTestpass => `roadTestPassed` => IssueDL
case failedLessThanTwice => `roadTestCounter < 2` => RoadTest
case default => IssueRegretLetter
}
END in any(IssueRegretLetter, IssueDL)
}
}
- In this step two new task gets added, RoadTest and IssueDL.
- RoadTest is a manual task and will be done by RTO
- IssueDL is a auto task, so edit IssueDLTaskCode and replace execute method with the following code
def execute(taskId:Id, input:Input): Output = {
println(s"Issue DL to ${input.firstName}")
Output()
}
* $compile
* $run
Execute Flow¶
Now we are ready to create driving licence flow and execute the task
- Go to the browser, and localhost:9000/monitor
- enter username and password rto/rtorto (rto user can create the flow)
- Go to Team tab and click on + button next to the team name
- In Create Flow page select the net DL, application Id as johndoe,and First name as Martha ,Last name as Martin and age as 24.
- Submit will create the flow, and a review Application task (notice the task is allocated to rto)
- Go to localhost:9000/executive to see the task allocated to rto.
- Click on the task display as Martha Martin
- Start the task by clicking on START button, check output Review Okay as true, and COMPLETE
- If you check output Review Okay as false,then as a result of the Connector C1, IssueRegretLetter Task will get executed and End the flow, since the flow ends in any of the task IssueregretLetter or WriteTest.
- Now browse localhost:9000/monitor, notice SelectQuestion auto task got completed automatically, and WriteTest task is assigned to johndoe
- Go to localhost:9000/executive but we need to login as johndoe to complete the task,so logout, and login again in executive as johndoe/johndoe(may use a different browser)
- WriteTest task is listed, start the task. Add the numbers First and Second and enter the Result. Click on Save and Complete.
- Logout and login as rto/rto (If a different browser is used then come back to the previous one)
- Evaluate and IssueLL task will be completed automatically(assuming the addition of first and second is right)
- RoadTest task will get created, and be assigned to rto.
- localhost:9000/executive as rto, and start RoadTest task and click Road Test Passed and increase the counter and save and complete
- If RoadTest Passed as false then it will get created again, since connector C6 indicates two Roadtest are allowed
- Go to http://localhost:9000/report#/flow/search and select Flow Name as DrivingLicence from the dropdown
- Click on search result, and see the details of the flow just got completed along with all the completed tasks.
That concludes the complete driving licence flow.
Exercise¶
- Create a flow, and ReviewApplication task reviewOkay button as false, and see IssueRegretLetter gets fired and flow gets completed.
- Create a flow, and enter the wrong value for WriteTest task and see IssueRegretLetter gets fired and flow gets completed.
- Create a flow, and Fail the RoadTest once and see RoadTest task gets created again, and assign to rto.
- Create a flow, and Fail the RoadTest twice and see IssueRegretLetter gets fired and flow gets completed.