Create UserVO

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

UserVO

Containment Tree

We will create UserVO and UserVO[] in a package named org.andromda.timetracker.vo. When finished, the containment tree in ArgoUML will look like the screen shot on the right.

  1. Start ArgoUML.
  2. Select FileOpen Project... and traverse to the location that you where you saved the AndroMDA profile. (If you didn't save the profile locally yet, get it now from this link.) Click Open to open this model and then choose FileSave As... and save in the newly created AndroMDA project at C:/timetracker/mda/src/main/uml/timetracker.zargo
  3. It is critical to also update the root pom.xml to reference the proper model, more specifically you will need to make the model.uri element point to jar:file:${project.basedir}/src/main/uml/timetracker.zargo!/timetracker.xmi; you will need to do this because the default value points to a plain XMI file instead of the XMI file contained in a ZIP archive (the .zargo file saved by ArgoUML)
  4. The TimeTracker model will now open showing the only class diagram present in this model. The title of this diagram is "DataTypes". This diagram contains platform independent datatypes that should be used in your UML model.
  5. In the Containment Tree on the left, click on the root element called Data to select it and change its name to "TimeTracker" in the property panel at the bottom of the screen. .
  6. Now right-click on the TimeTracker model and select Add Package. A new package will be created under the TimeTracker model element with no name so it is displayed as (unnamed Package). Select this new package and name it org.andromda.timetracker using the name field of the property panel. AndroMDA will map this package to a Java package with the same name. Note: Make sure the package name is exactly org.andromda.timetracker, with no leading or trailing spaces. We have found that some browsers introduce a leading space in the package name if you copy it from this page!
  7. Now create a package called vo under org.andromda.timetracker. We will create our value objects in this package. Note that AndroMDA does not require this package structure. We are doing it simply to separate our value objects from other type of objects such as business entities, services etc.
  8. In the Containment Tree on the left, right-click on the vo package and select Create DiagramNew Class Diagram. Select the newly created diagram (you may need to expand the vo package in the explorer tree to see it) and name it Value Objects. You should now have a blank diagram in the main editing pane.
  9. In the toolbar above the class diagram click on the Class tool . Class Tool Now click anywhere inside the diagram. A new class will be created. The class will be automatically selected as indicated by the 4 knobs around it. (If you somehow deselected the class, then select it again by clicking on it.) Now type the word "UserVO". This word will be entered as the name of the class.
  10. Let's add some documentation for the UserVO class. It is always a good idea to document your model. Documentation added to model elements such as classes, attributes and methods is carried over to the code as comments. In the property panel at the bottom of the screen, click on the Documentation tab. Add the following sentence in the Documentation field: "This class represents a value object that carries information about a TimeTracker user."
  11. Now add the stereotype ValueObject to class UserVO. To do this, right-click on the class and select Apply Stereotype. In the next level menu, check ValueObject. You can also do this by selecting the Stereotype tab on the property panel, selecting the ValueObject stereotype in the Available Stereotypes column and click the >> button to move it to the Applied Stereotypes column. Use whichever tool is most comfortable for your style of work. The UserVO class will now have the ValueObject stereotype. Apply Stereotype
  12. Let's add id as an attribute of UserVO. Right-click on the UserVO class and select Insert New Attribute. A new attribute is inserted with the specification "+newAttr : int". Write over this specification with this new one: "+id : Long" (be sure to delete the minus sign in front of the name). 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.
  13. Attributes can also be added from the property panel by using the New Attribute tool. New Attribute Tool
  14. Now add three more public attributes called username, firstName and lastName to the UserVO class. Make them String type.
  15. Add a new class to the diagram and name it UserVO[].
  16. Make sure your class diagram matches the one shown above exactly. (It is okay if your class shows an empty operation compartment. This can be hidden very easily).
  17. Make sure that the ArgoUML explorer pane matches the screen shot shown above.
  18. Save your TimeTracker model by selecting File > Save Project.

Congratulations! You have now specified the UserVO value object of the TimeTracker application. We are now ready to generate some code. Please go back to the main tutorial page and continue from where you left off.