Create UserService

This page provides directions to create the UserService using RSM.

We will create UserService in a package named org.andromda.timetracker.service.

  1. In the timetracker model create a package called service under org.andromda.timetracker.
  2. In the model explorer on the left, right-click on the service package and select New Diagram > Class Diagram. The diagram is created and opened in a new window. Type in Services as the name of this diagram and press Enter.
  3. Add a new class to the diagram and name it UserService.
  4. Add the stereotype called Service to UserService.
  5. Let's add id as an attribute of UserVO. Note that attributes are always generated as private members of a class. However the visibilities of the associated getter and setter are determined by the visibility of the attribute specification. In this case we have specified public visibility (by using the plus sign) and hence the getter and setter for the id attribute will be public.
  6. Let's add the getAllUsers() method to UserService. Place your mouse on the UserService class and wait until a 'tooltip' appears above it. Click on the little green circle. A new operation is inserted with the specification <<>>Operation1. Write over this specification with this new one: getAllUsers() and press Enter. Do not specify the return value right now because RSM gets confused with the UserVO[] syntax. After typing the operation press Enter to exit the edit mode.
  7. Select the operation getAllUsers(), and in the Properties tab, click onGeneral. In this sub-panel, click onDefine return type.... A popup dialog will appear, select timtracker::org.andromda.timetracker::vo::UserVO[] and clickOK.
  8. Make sure your class diagram matches the one shown above.
  9. Make sure that the RSM model explorer matches the screen shot shown below.
  10. Save your timetracker model by double-clicking on timetracker.emx and clicking on File > Save (Ctrl + S).
  11. SelectFile > Export.... Choose UML2 Model and then click onNext. As source select /TimeTracker/timetracker.emx and as destination browse to C:\timetracker\mda\src\main\uml.

We are now ready to generate code for the UserService. Please go back to the main tutorial page and continue from where you left off.