Tuesday, 11 April 2023

PlantUML: group actors or use cases using a package

We can group actors or use cases using a package.

 

Example 1

package admins {
	actor superAdmin
	actor admin
}

 

Example 2

package passengerUsecases{
	usecase Login
	usecase "Check for availability" as CFA
	usecase "Book tiket" as BT
	usecase Payment
	usecase "Check Flight Status" as CFS
}

groupActorsOrUsecases.txt

@startuml

skinparam actorStyle Hollow

actor passenger
actor bank

package admins {
	actor superAdmin
	actor admin
}

usecase "Validate Card details" as VCD

package passengerUsecases{
	usecase Login
	usecase "Check for availability" as CFA
	usecase "Book tiket" as BT
	usecase Payment
	usecase "Check Flight Status" as CFS
}

package adminUsecases{
	usecase "Update Flight Schedule" as UFS
	usecase "Cancel Ticket" as CT
}

passenger --> Login
passenger --> CFA
passenger --> BT
passenger --> Payment
passenger --> CT
passenger --> CFS

admin --> UFS
admin --> CT

superAdmin --> UFS
superAdmin --> CT

bank --> VCD

Payment --> VCD


@enduml

Above snippet generate below diagram.



We can use the keyword rectangle to keep the package name inside the rectangle.

 

packageDisplayToRectangle.txt

 

@startuml

skinparam actorStyle Hollow

actor passenger
actor bank

rectangle admins {
	actor superAdmin
	actor admin
}

usecase "Validate Card details" as VCD

rectangle passengerUsecases{
	usecase Login
	usecase "Check for availability" as CFA
	usecase "Book tiket" as BT
	usecase Payment
	usecase "Check Flight Status" as CFS
}

rectangle adminUsecases{
	usecase "Update Flight Schedule" as UFS
	usecase "Cancel Ticket" as CT
}

passenger --> Login
passenger --> CFA
passenger --> BT
passenger --> Payment
passenger --> CT
passenger --> CFS

admin --> UFS
admin --> CT

superAdmin --> UFS
superAdmin --> CT

bank --> VCD

Payment --> VCD


@enduml

 

Above snippet generate below diagram.

 


 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment