Create TimeTracker Model with MagicDraw

This page provides directions to create the TimeTracker Model with MagicDraw. The model is shown below for your reference.

  1. Start MagicDraw.
  2. Select File > Open Project... and traverse to C:\TimeTracker\mda\src\uml\TimeTrackerModel.xml.zip. Click Open to open this model.
  3. If you get a warning message such as "Module andromda-profile-3.2-RC1-SNAPSHOT.xml.zip is not found", just click OK. A file dialog will come up asking you to locate andromda-profile-3.2-RC1-SNAPSHOT.xml.zip. To do this traverse to your Maven repository. The default location for this repository is C:\Documents and Settings\<your username>\.maven\repository. You will find andromda-profile-3.2-RC1-SNAPSHOT.xml.zip under this repository at andromda\xml.zips. Select this file and click Open.
  4. The TimeTracker model will now open showing the only class diagram present in this model. The title of this diagram is "DataTypes[datatype]". This diagram contains platform independent datatypes that should be used in your UML model. Look at the TimeTracker model at the beginning of this section. All data types used in this model are present in the DataTypes diagram. When AndroMDA generates code it will map the platform independent data types to C# data types.
  5. In the Containment Tree on the left, right-click on the root element called Data and select New Element > Package. A new package will be created under the root element with an edit box to its side. Type in TimeTracker as the name of this package. AndroMDA will map the TimeTracker package into a C# namespace called TimeTracker.
  6. Now create a package called Domain under TimeTracker. We will create our entities and supporting classes under this package. Note that AndroMDA does not force this package structure. We are doing it simply to separate our business domain classes from other things such as value objects etc.
  7. In the Containment Tree on the left, right-click on the Domain package and select New Diagram > Class Diagram. A Class Diagram Specification dialog appears. Type in Domain Objects as the name of this diagram and click OK. The diagram is created and opened in a new window.
  8. In the toolbar on the left of the class diagram click on the Class icon (6th icon from the top. 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 "Person". This word will be entered as the name of the class.
  9. Let's add some documentation for the Person 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. Double-click on the Person class to bring up the Class Specification dialog. Add the following sentence in the Documentation field and click OK: "This class represents any person whose time needs to be tracked."
  10. Now let's enter the name attribute of the Person class. Right-click on this class and select Insert New Attribute. A new attribute is inserted with the specification "-unnamed1". Write over this specification with this new one: "+name : String" (be sure to delete the minus sign in front of the name). This new specification indicates that name is an attribute of class Person with a platform independent type of String. Attributes are always generated as private members of the class. However the visibility of the associated property is determined by the visibility of the attribute specification. In this case we have specified public visibility (by using the plus sign) and hence the Name property will be public.
  11. Now we need to add the rate attribute to class Person . However the type of this attribute is Quantity , which is an embedded value representing a value and a unit . So let's first define the class Quantity . Add a new class called Quantity using the class icon in the toolbar. Add two attributes to this class with specifications "+value : double" and "+unit : String". Now we can add the attribute rate to class Person . Add this attribute with the specification "+rate : Quantity"
  12. Add the stereotype Entity to class Person . To do this, right-click on the class and select Stereotype. In the next level menu, check Entity and click Apply. The Person class will now have the Entity stereotype.
  13. Similarly add the EmbeddedValue stereotype to class Quantity .
  14. Now add the class Timecard as shown in the diagram. Remember that before entering the attribute called status you will have to create its type, namely TimecardStatus , which has a stereotype of Enumeration .
  15. Next we must add a one-to-many association between Person and Timecard . To do this, click on the Association icon in the toolbar (13th icon from top). Click on the Person class, drag your mouse to the Timecard class and release the mouse. A new association will be created. Right-click on the Person end of the association and select the multiplicity of 1. Similarly set the multiplicity of the Timecard end to many (*). Again right-click on the Person end of the association and select Edit Name. Type the following specification for this association end: "+owner". Similarly enter the following specification for the Timecard end of the association: "+timecards".
  16. Create the class TimeAllocation as shown in the diagram above.
  17. Create the one-to-many association between Timecard and TimeAllocation . Note that this is a special kind of association called Composition. To select a Composition in the toolbar, you must right-click on the Aggregation icon (14th from the top) and select Composition from the second level of icons.
  18. Now add the class Task and its association relationship with class TimeAllocation .
  19. To complete the class diagram add the convenience methods to the three classes as shown above. To add a method to a class, right-click on it and select Insert New Operation.
  20. Make sure your class diagram matches the one shown above exactly. (It is okay if your classes show empty operation compartments. These can be hidden very easily).
  21. Save your TimeTracker model by selecting File > Save Project.

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