An Example Domain

By now you should understand the basics of what Apache Causeway 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:

Diagram

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 Pets for said PetOwner

  • book a Pet in for a Visit

  • enter an outcome and cost of a Visit

  • allow a PetOwner to pay for a Visit

  • find Visits not yet paid and overdue

  • delete a PetOwner and its Pets and Visits, so long as there are no unpaid Visits.

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

    • SimpleModulePetsModule

    • SimpleAppPetClinicApp

Build and run the application (note that the main class has changed) to make sure it still runs fine.