In this section we will create the PersonVO
value object. We will
keep it pretty simple, mapping it one-to-one with the Person
entity.
Later in this tutorial we will model more complex value objects that will map to
more than one entities. The model for the PersonVO
value object
is shown below.
Note that we have added a dependency from Person
to PersonVO
.
This will generate helper code in PersonDao
to support translation between
the Person
entity and the PersonVO
value object. In addition we have
modeled a new type called PersonVO[]
. This type will be used as a return value
from one of our service methods.
Now add PersonVO
and PersonVO[]
to your 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
. The clean
target
ensures that the target directories are cleaned up before the build. Make sure you get a
BUILD SUCCESSFUL
message.
Open the folder C:/timetracker/common/target/src/org/andromda/timetracker/vo in Windows Explorer.
Note that the PersonVO
class is generated here. Open the class and review its contents.
Now open the folder C:/timetracker/core/target/src/org/andromda/timetracker/domain in Windows Explorer.
Do you remember that this folder had six auto-generated files during the last build? This time it has
only five - PersonDaoImpl.java
is missing! What happened? In fact, this class has
now moved from the target folder to the src folder. The reason is that we added a dependency from
Person
to PersonVO
. This triggered AndroMDA to generate some support code
in PersonDaoBase.java
and PersonDaoImpl.java
to allow translation between
Person
and PersonVO
. Most of this code is in the auto-generated
PersonDaoBase
class. However if we need to modify the default translation, AndroMDA provides
override methods in the PersonDaoImpl
class. In addition, the class is moved to the source
tree where it can be safely modified (see C:/timetracker/core/src/java/org/andromda/timetracker/domain).
Review the PersonDaoBase
and PersonDaoImpl
classes to see this conversion support.
Now that we have modeled the PersonVO
value object, it is time to create a service that uses it.
Click
here
to model the PeopleService
.