-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathJDL.ftl
More file actions
134 lines (126 loc) · 3.89 KB
/
JDL.ftl
File metadata and controls
134 lines (126 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<#--
This template generates a JHipster JDL file.
Please consult our online tutorial https://contextmapper.org/docs/jhipster-microservice-generation/ to learn how to use it.
-->
<#--
variables to collect entity names and references:
-->
<#assign allEntityNames = [] />
<#assign oneToManyRefs = [] />
<#assign oneToOneRefs = [] />
<#--
counter to give microservices different ports: (8081, 8082, 8083, ...)
-->
<#assign portCounter = 8080 />
<#--
loop to collect entity data per Bounded Context (BC) and create application plus microservice for each BC
-->
<#list filterStructuralBoundedContexts(boundedContexts) as bc>
<#assign entities = [] />
<#assign entityNames = [] />
<#list bc.aggregates as agg>
<#assign entities = entities + agg.domainObjects?filter(dob -> instanceOf(dob, Entity) || instanceOf(dob, ValueObject))>
</#list>
<#assign entityNames = entities?map(e -> e.name)>
<#assign allEntityNames = allEntityNames + entityNames>
<#if entities?has_content>
/* Bounded Context ${bc.name} */<#lt>
<#list entities as entity>
entity ${entity.name} {
<#list entity.attributes as attribute>
${attribute.name} ${mapAttributeType(attribute.type)}
</#list>
}
<#list entity.references as reference>
<#if reference.domainObjectType?has_content && (instanceOf(reference.domainObjectType, Entity) || instanceOf(reference.domainObjectType, ValueObject)) && entityNames?seq_contains(reference.domainObjectType.name)>
<#if reference.collectionType?has_content && reference.collectionType.name() != "NONE">
<#assign oneToManyRefs = oneToManyRefs + [ entity.name + "{" + reference.name + "} to " + reference.domainObjectType.name ]>
<#else>
<#assign oneToOneRefs = oneToOneRefs + [ entity.name + "{"+ reference.name + "} to " + reference.domainObjectType.name ]>
</#if>
</#if>
</#list>
</#list>
microservice ${entityNames?join(", ")} with ${bc.name}<#lt>
</#if>
<#assign portCounter++ />
application {
config {
baseName ${bc.name},
packageName org.contextmapper.generated.${bc.name?lower_case},
applicationType microservice
serverPort ${portCounter?int?c}
enableSwaggerCodegen true
}
<#if entityNames?has_content>
entities ${entityNames?join(", ")}
</#if>
}
</#list>
<#--
here we print the collected references as relationships:
-->
/* relationships */
<#if oneToManyRefs?has_content>
relationship OneToMany {<#lt>
<#list oneToManyRefs as reference>
${reference}
</#list>
}<#lt>
</#if>
<#if oneToOneRefs?has_content>
relationship OneToOne {<#lt>
<#list oneToOneRefs as reference>
${reference}
</#list>
}<#lt>
</#if>
<#--
create a microservice gateway (user interface)
-->
/* microservice gateway app */
application {
config {
baseName gateway,
packageName org.contextmapper.generated.gateway,
applicationType gateway
serverPort 8080
}
<#if allEntityNames?has_content>
entities ${allEntityNames?join(", ")}
</#if>
}
<#--
additional configurations for the JHipster generator:
-->
/* additional options */
dto * with mapstruct
service * with serviceImpl
<#-- Data type mapping: -->
<#function mapAttributeType inputType>
<#if inputType == "String">
<#return "String">
<#elseif inputType == "int" || inputType == "Integer">
<#return "Integer">
<#elseif inputType == "long" || inputType == "Long">
<#return "Long">
<#elseif inputType == "boolean" || inputType == "Boolean">
<#return "Boolean">
<#elseif inputType == "Date" || inputType == "DateTime" || inputType == "Timestamp">
<#return "LocalDate">
<#elseif inputType == "BigDecimal" || inputType == "BigInteger">
<#return "BigDecimal">
<#elseif inputType == "double" || inputType == "Double">
<#return "Double">
<#elseif inputType == "float" || inputType == "Float">
<#return "Float">
<#elseif inputType == "Key">
<#return "UUID">
<#elseif inputType == "Blob" || inputType =="Object[]">
<#return "Blob">
<#elseif inputType == "Clob">
<#return "TextBlob">
<#else>
<#return "Blob">
</#if>
</#function>