Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 3.66 KB

04-1-B-UML-Lab.adoc

File metadata and controls

57 lines (39 loc) · 3.66 KB

Domain modeling and code generation

Installing UML Lab

Go to the download page of UML Lab and install it on your machine. To activate it, use the licence key shared in the MyCourses announcement.

Note
By the time of the fourth tutorial, we may not have the license key ready. You should be able to work with a 30-day trial version in this case and activate your license later.

UML Lab project setup

Note
Once you start UML Lab, there are some useful tutorials that help you learn about the features of the modeling tool. Furthermore, there is an introduction on how to use and configure UML Lab among the resources of Rice University.
  1. Create a new UML Lab Java project with the name ca.mcgill.ecse321.eventregistration.model with the default project settings.

  2. Within the project, create a linked folder (Select Project → New Folder → Click Advanced Button → select "Link to alternate location (linked folder)" option) that points to the src/main/java folder of your Eventregistration-Backend project. Name the folder as src-gen. It will be used as the target for generating model code.
    Linking folder

    Caution
    Links to folders will not be versioned, so each team member needs to set this link individually after cloning the project.
  3. Open the ca.mcgill.ecse321.eventregistration.model.umlcd diagram file by double clicking it. It is an empty diagram by default.

  4. Click on the empty diagram editor canvas and open the properties view and configure code generation path.
    Codegen output folder

  5. In the same Properties view, apply the Direct > JPA1 code style.
    Code style

Domain modeling exercise: the Event Registration System

  1. Using the Palette on the left hand side of the class diagram editor, create the following package structure and the Person class, and connect them with the Containment line. Once you save the diagram, the code should be generated to the src-gen folder (left part of the figure below).
    Class Diagram Packages

    Note
    If you disabled the automatic code generation on file save action, then you need to do right click the diagram → generate code manually.
  2. Study the generated Person class in the ca/mcgill/ecse321/eventregistration/model package (folder)!

  3. In the upcoming steps, we will use the java.sql.Time and java.sql.Date data types from the Java Runtime Library, so we need to add them to the model as datatypes.
    Adding data types

  4. Extend the diagram by adding more classes and association and composition relations as shown below. Pay extra attention to the navigability and multiplicity of the references.
    Class Diagram With Classes

  5. Select attributes to be primary keys (Person: id is name, Event: id is name, Registration: id is id)
    Selecting primary keys

    Note
    Verify the generated code:remove any @OneToOne annotations from getters associated with Date and Time from the Event class.
  6. Create an extra int attribute for the RegistrationManager as well and set it as the ID (similarly to the other three classes).

    Caution
    If you forget to supply an ID to any of your entities, Hibernate will throw an exception and you application will fail to start.
  7. Share the modeling project to git. You can use the command line git client or EGit.
    umllab share project