In this section we will learn how to create associations between entities. We will
start out by modeling a Timecard
entity and then creating two
associations between Timecard
and Person
. The completed
model will be as shown below.
The Timecard
has three attributes:
The Timecard
has two associations with Person
:
The arrows on the two associations indicate that both associations are navigable from
Timecard
to Person
, i.e. the timecard keeps references to its
submitter and approver. Note that two-way navigability is indicated by not having arrows
at either end of the association. The "1" and "*" at each end of the association indicate
their multiplicity. The top association means one person can submit many (indicated by "*")
timecards. Similarly the bottom association means one person can approve many timecards.
We are now ready to add these additional elements to our TimeTracker model. To do this, click the link below for your UML modeling tool.
Follow the steps below to generate code.
C:/timetracker
.maven -o clean install
. Make sure you get a
BUILD SUCCESSFUL
message.
Open the folder C:/timetracker/core/target/src/org/andromda/timetracker/domain in Windows Explorer.
You will see 7 new files in there all related to the timecard entity. Review these files. Note that
the Timecard
class contains two references to the Person
class, but the
Person
class contains no references to the Timecard
class. This is because
both associations between these classes are one-way from Timecard
to Person
.
At this point we have covered most of the important modeling concepts. In the next section we will add the remaining functionality to the TimeTracker model. Click here to get started.