Entities
In this section you will create your first entity using AndroMDA. We will create
an entity called
Timecard
that will represent a timecard in the
application. We will associate it with the
User
object, which will
be the person that submitted the timecard. Our finished entity diagram will look
like this:
Note that we have marked the
Timecard
class with a stereotype of
Entity. This tells AndroMDA that
Timecard
is an
Entity as opposed to other type of model elements such as Enumeration or EmbeddedValue.
Stereotypes determine what pattern of code AndroMDA will generate for a model element.
More specifically, they determine which AndroMDA code generation templates will
be triggered.
Also nte that we have marked the attributes to be of type
Date
andString. These are not .NET types, but rather in model driven
architecture the model is kept independent of technology and hence all model elements
are defined in terms of platform independent types. So Date and String in this context
are platform independent types. When we run AndroMDA to generate code, it will translate
platform independent types into platform dependent types such as
System.String
and
System.DateTime
. If we were to use the same model to generate
a Java application, AndroMDA will translate String intojava.lang.String,
which is the Java equivalent ofSystem.String. As you can see,
a key advantage of the model driven approach is that your investment in the business
models is preserved even as technologies come and go.
Now lets add the
Timecard
entity to the model:
- Create a new diagram by right clicking on the
Domain
package and clicking
New Diagram
|Class Diagram. Set the name of the
diagram to
Entity Diagram
and clickOk.
- Click the
Class
tool
in the toolbar and make a new class on the diagram surface. Double click on the
class, name itTimecard, and add the
Entity
stereotype
to it.
- Right click on the
TimecardVO
object and selectInsert
new attribute. Add three public attributes to the class by:
- One called
startDate
of typeDate.
- One called
comments
of typeString.
- We now want to relate the the User entity to the Timecard entity. Drag the
User
class onto the diagram. If it looks very cluttered you can right click
on it and selectSymbol Properties. Uncheck the
Show Tagged
Values
option under
General
and also uncheck
Show
Attributes Properties
in the
Attributes
section.
Finally clickOk, right click on the
User
class
again, and selectAutosize.
- Because each user can submit many timecards, we need to create an association that
defines this relationship. Click the
Association
tool
and draw an association between the
Timecard
class and the
User
class.
- Set the association multiplicity to
*
on the timecard end of the
association by right clicking on the association end near the
Timecard
entity and selecting*.
- Set the name of the timecards association endpoint by right clicking on the association
end near the
Timecard
entity and selectEdit name.
Name the end+timecards.
- Set the association multiplicity to
1
on the user end of the association
by right clicking on the association end near the
User
entity and
selecting1.
- Set the name of the submitter association endpoint by right clicking on the association
end near the
User
entity and selectEdit name.
Name the end+submitter.