Create PeopleService using ArgoUML

This page provides directions to create the PeopleService using ArgoUML. The model is shown below for your reference.

  1. In the TimeTracker model create a package called service under org.andromda.timetracker. We will create our services in this package.
  2. Select the 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.
  3. Add a new class to the diagram and name it PeopleService.
  4. Add the stereotype called Service to PeopleService.
  5. Add three methods to 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.
  6. From the Explorer pane on the left, drag the Person class on to the diagram.
  7. Create a dependency from PeopleService to Person.
  8. Make sure your class diagram matches the one shown above.
  9. Save the model by selecting File > Save Project.

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.

NOTE:If you are using AndroMDA 3.1 you will need to adjust the code that is given on the main tutorial page.

protected
java.lang.Long handleCreatePerson(org.andromda.timetracker.vo.PersonVO personVO)
throws
java.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.2
getPersonDao().personVOToEntity(personVO);
// AndroMDA 3.1
getPersonDao().create(person);
return
person.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) */
public
org.andromda.timetracker.vo.PersonVO toPersonVO(
final
org.andromda.timetracker.domain.Person entity) { org.andromda.timetracker.vo.PersonVO pvo =
new
org.andromda.timetracker.vo.PersonVO(); pvo.setId(entity.getId()); pvo.setUsername(entity.getUsername()); pvo.setFirstName(entity.getFirstName()); pvo.setLastName(entity.getLastName());
return
pvo; }
/** * @see org.andromda.timetracker.domain.PersonDao#personVOToEntity(org.andromda.timetracker.vo.PersonVO) */
public
org.andromda.timetracker.domain.Person personVOToEntity(org.andromda.timetracker.vo.PersonVO personVO) { org.andromda.timetracker.domain.Person person =
new
org.andromda.timetracker.domain.Person.Factory().newInstance(); person.setId(personVO.getId()); person.setUsername(personVO.getUsername()); person.setFirstName(personVO.getFirstName()); person.setLastName(personVO.getLastName());
return
person; }