This page provides directions to create the PeopleService using ArgoUML. The model is shown below for your reference.
service
under
org.andromda.timetracker
. We will create our services in this package.service
package in the Explorer pane on the left and click
on the Class Diagram tool. In the Name: field of the property panel type
Services
as the name of this diagram.PeopleService
.PeopleService
.PeopleService
as shown above. You don't need to
type the {sequential>
as part of the specification -- it is
the default. As with the attributes, you can also create and specify methods
from the property panel if you prefer.Person
class on to the diagram.PeopleService
to Person
.
We are now ready to generate code for the PeopleService
. Please go back to the main
tutorial page and continue from where you left off.
protectedjava.lang.Long handleCreatePerson(org.andromda.timetracker.vo.PersonVO personVO)throwsjava.lang.Exception { Person person = Person.Factory.newInstance();// The following line differs for AndroMDA 3.1 vs 3.2//getPersonDao().personVOToEntity(personVO, person, true); // AndroMDA 3.2getPersonDao().personVOToEntity(personVO);// AndroMDA 3.1getPersonDao().create(person);returnperson.getId(); }
You will also need to provide implementations for the methods in the
class domain.PersonDaoImpl
which marshall and unmarshal
data for the value object PersonVO.
/** * @see org.andromda.timetracker.domain.PersonDao#toPersonVO(org.andromda.timetracker.domain.Person) */publicorg.andromda.timetracker.vo.PersonVO toPersonVO(finalorg.andromda.timetracker.domain.Person entity) { org.andromda.timetracker.vo.PersonVO pvo =neworg.andromda.timetracker.vo.PersonVO(); pvo.setId(entity.getId()); pvo.setUsername(entity.getUsername()); pvo.setFirstName(entity.getFirstName()); pvo.setLastName(entity.getLastName());returnpvo; }/** * @see org.andromda.timetracker.domain.PersonDao#personVOToEntity(org.andromda.timetracker.vo.PersonVO) */publicorg.andromda.timetracker.domain.Person personVOToEntity(org.andromda.timetracker.vo.PersonVO personVO) { org.andromda.timetracker.domain.Person person =neworg.andromda.timetracker.domain.Person.Factory().newInstance(); person.setId(personVO.getId()); person.setUsername(personVO.getUsername()); person.setFirstName(personVO.getFirstName()); person.setLastName(personVO.getLastName());returnperson; }