-
Notifications
You must be signed in to change notification settings - Fork 0
/
domain_entity_java.vm
112 lines (96 loc) · 4.58 KB
/
domain_entity_java.vm
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
/*
* Java domain class for entity "${entity.name}"
* Created on $today.date ( Date ISO $today.date("yyyy-MM-dd") - Time $today.time )
* Generated by $generator.name ( version $generator.version )
*/
package ${target.javaPackageFromFolder(${SRC})};
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonProperty;
#foreach( $import in $java.imports($entity) )
import $import;
#end
##--------------------------------------------------------------------------------------------------------
## Data fields = fields not in Primary Key and not in selected Links
#set( $dataFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.NOT_IN_SELECTED_LINKS ) )
##--------------------------------------------------------------------------------------------------------
## Link fields = fields not in Primary Key and used as FK in selected Links
#set( $linkFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.IN_SELECTED_LINKS ) )
##--------------------------------------------------------------------------------------------------------
/**
* Domain class for entity "${entity.name}"
*
* @author Telosys Tools Generator
*
*/
public class ${entity.name} implements Serializable {
private static final long serialVersionUID = 1L;
//----------------------------------------------------------------------
// ENTITY PRIMARY KEY
//----------------------------------------------------------------------
#foreach( $field in $entity.keyAttributes )
@JsonProperty("$field.databaseName.toLowerCase()")
private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} #end;
#end
//----------------------------------------------------------------------
// ENTITY DATA FIELDS
//----------------------------------------------------------------------
#foreach( $field in $dataFields )
@JsonProperty("$field.databaseName.toLowerCase()")
private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} \r\n #end;
#end
#foreach( $field in $linkFields )
// Attribute "$field.name" is a link
@JsonProperty("$field.databaseName.toLowerCase()")
private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} \r\n #end;
#end
//----------------------------------------------------------------------
// ENTITY LINKS ( RELATIONSHIP )
//----------------------------------------------------------------------
#foreach( $link in $entity.selectedLinks )
private ${link.formattedFieldType(10)} $link.formattedFieldName(12) ;
#end
//----------------------------------------------------------------------
// CONSTRUCTOR(S)
//----------------------------------------------------------------------
public ${entity.name}() {
super();
}
//----------------------------------------------------------------------
// GETTER & SETTER FOR "KEY FIELD(S)"
//----------------------------------------------------------------------
#foreach( $attribute in $entity.keyAttributes )
public void ${attribute.setter}( $attribute.type $attribute.name ) {
this.$attribute.name = $attribute.name ;
}
public $attribute.type ${attribute.getter}() {
return this.$attribute.name;
}
#end
//----------------------------------------------------------------------
// GETTERS & SETTERS FOR "DATA FIELDS"
//----------------------------------------------------------------------
#foreach( $attribute in $dataFields )
public void ${attribute.setter}( $attribute.type $attribute.name ) {
this.$attribute.name = $attribute.name ;
}
public $attribute.type ${attribute.getter}() {
return this.$attribute.name;
}
#end
//----------------------------------------------------------------------
// GETTERS & SETTERS FOR LINKS
//----------------------------------------------------------------------
#foreach( $link in $entity.selectedLinks )
public void ${link.setter}( ${link.formattedFieldType(0)} ${link.formattedFieldName(0)} ) {
this.${link.formattedFieldName(0)} = ${link.formattedFieldName(0)};
}
public ${link.formattedFieldType(0)} ${link.getter}() {
return this.${link.formattedFieldName(0)};
}
#end
//----------------------------------------------------------------------
// toString METHOD
//----------------------------------------------------------------------
## This function generates a 'toString' method with 4 blanks before each line
$java.toStringMethod($fn.concatLists($entity.keyAttributes, $dataFields), 4)
}