An Example Domain
By now you should understand the basics of what Apache Isis does, but there’s only so much we can learn from a single domain class. Let’s therefore evolve the app into a slightly more interesting domain and explore other features of the framework.
The domain we’re going to work on is a version of the venerable "Pet Clinic" app. Here’s a sketch of (our version of) its domain:
The colours used are from "Java: Modeling in Color" book by Coad et al. |
Some of the use cases we might want to support include:
-
create a
PetOwner
-
add and remove
Pet
s for saidPetOwner
-
book a
Pet
in for aVisit
-
enter an
outcome
andcost
of aVisit
-
allow a
PetOwner
to pay for aVisit
-
find
Visit
s not yet paid and overdue -
delete a
PetOwner
and itsPet
s andVisit
s, so long as there are no unpaidVisit
s.
This tutorial has worked solutions for all of these.
Ex 2.1: Refactor SimpleObject
to PetOwner
To start with, let’s rename the SimpleObject
entity to PetOwner
Solution
git checkout tags/02-01-renames-SimpleObject-to-PetOwner
mvn clean install
mvn -pl spring-boot:run
Tasks
Just checkout the solution above and review the git history to see the changes that have already been made. These include:
-
Domain classes renamed (along with corresponding tests)
-
SimpleObject
entity →PetOwner
-
SimpleObjects
domain service →PetOwners
-
SimpleObjectRepository
repository service →PetOwnerRepository
-
Infrastructure classes renamed
-
SimpleModule
→PetsModule
-
SimpleApp
→PetClinicApp
-
Build and run the application (note that the main class has changed) to make sure it still runs fine.