Defining a Data Model
The data model defines the structure for the scenarios to import into the application. For more details, please refer to Section Managing the Application Data.
In a .jdl
file, names should be declared without any whitespace. This includes the:
-
entity
names; -
attribute
names; -
relationship
names; and -
collectorClass
name.
JDL declarations can be annotated using DOM
tags to provide information to the Platform generator. For more details, please refer to Section Generating the Application Structure.
Note that, while the data model is described using a JDL file, the Platform does not rely on JHipster to generate the application.
The following examples show how DOM tags are inserted in JDL:
entity ResourceUsagePerDay { // DOM [primary.keys] : [day] day Integer, numberOfHours Integer, } relationship ManyToOne { // DOM [affects.primary.key] : [true] Requirement{activity} to Activity{requirements}, ... }
The following JDL text provides you with an example of a simple data model:
application { // DOM [java.collectorClass] : [<%=collectorClass%>] } entity Country { // DOM [primary.keys] : [id] id String required, name String } entity Plant { // DOM [primary.keys] : [plantId] plantId String required, } entity Resource { // DOM [primary.keys] : [id] id String required, name String } entity ResourceCapacity { quantity Integer } entity Activity { // DOM [primary.keys] : [id] id String required, name String, durationInHours Double } entity Precedence { } entity Requirement { quantity Integer } entity Schedule { start Instant, end Instant } entity SolutionSummary { // DOM [single.row] : [true] start Instant, end Instant, timespan Integer } entity ResourceUsagePerDay { // DOM [primary.keys] : [day] day Integer, numberOfHours Integer, } relationship ManyToOne { // DOM [affects.primary.key] : [true] Requirement{activity} to Activity{requirements}, // DOM [affects.primary.key] : [true] Requirement{resource} to Resource{requirements}, // DOM [affects.primary.key] : [true] Precedence{first} to Activity{successors}, // DOM [affects.primary.key] : [true] Precedence{second} to Activity{predecessors}, // DOM [affects.primary.key] : [true] Schedule{resource} to Resource{schedules} // DOM [affects.primary.key] : [true] Schedule{activity} to Activity{schedules} // DOM [affects.primary.key] : [true] ResourceUsagePerDay{resource} to Resource{usagePerDay} // DOM [affects.primary.key] : [true] Plant{country} to Country{plants} // DOM [affects.primary.key] : [true] Activity{plant} to Plant{activities} } relationship OneToOne { // DOM [affects.primary.key] : [true] ResourceCapacity{resource} to Resource{capacity} }