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. |
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. |
-
Create a new UML Lab Java project with the name
ca.mcgill.ecse321.eventregistration.model
with the default project settings. -
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.
CautionLinks to folders will not be versioned, so each team member needs to set this link individually after cloning the project. -
Open the ca.mcgill.ecse321.eventregistration.model.umlcd diagram file by double clicking it. It is an empty diagram by default.
-
Click on the empty diagram editor canvas and open the properties view and configure code generation path.
-
In the same Properties view, apply the Direct > JPA1 code style.
-
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).
NoteIf you disabled the automatic code generation on file save action, then you need to do right click the diagram → generate code manually. -
Study the generated
Person
class in theca/mcgill/ecse321/eventregistration/model
package (folder)! -
In the upcoming steps, we will use the
java.sql.Time
andjava.sql.Date
data types from the Java Runtime Library, so we need to add them to the model as datatypes.
-
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.
-
Select attributes to be primary keys (
Person
: id isname
,Event
: id isname
,Registration
: id isid
)
NoteVerify the generated code:remove any @OneToOne
annotations from getters associated withDate
andTime
from theEvent
class. -
Create an extra
int
attribute for theRegistrationManager
as well and set it as the ID (similarly to the other three classes).CautionIf you forget to supply an ID to any of your entities, Hibernate will throw an exception and you application will fail to start. -
Share the modeling project to git. You can use the command line git client or EGit.