Joaquín Reñé
2025-10-07 146a0fb8b0e90f9196e569152f649baf60d6cc8f
securis/src/main/java/net/curisit/securis/db/LicenseType.java
....@@ -1,3 +1,6 @@
1
+/*
2
+* Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved.
3
+*/
14 package net.curisit.securis.db;
25
36 import java.io.Serializable;
....@@ -29,135 +32,236 @@
2932 import com.fasterxml.jackson.annotation.JsonProperty;
3033
3134 /**
32
- * Entity implementation class for Entity: license_type
33
- *
34
- */
35
+* LicenseType
36
+* <p>
37
+* Describes a license category within an application. Owns metadata entries.
38
+*
39
+* Mapping details:
40
+* - Table: license_type
41
+* - Many-to-one to Application (lazy).
42
+* - One-to-many metadata with cascade PERSIST/REMOVE/REFRESH.
43
+* - Named queries for listing and filtering by application(s).
44
+*
45
+* @author JRA
46
+* Last reviewed by JRA on Oct 5, 2025.
47
+*/
3548 @JsonAutoDetect
3649 @JsonInclude(Include.NON_NULL)
3750 @JsonIgnoreProperties(ignoreUnknown = true)
3851 @Entity
3952 @Table(name = "license_type")
40
-@NamedQueries({ @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt"),
41
- @NamedQuery(name = "list-license_types-by_apps-id", query = "SELECT lt FROM LicenseType lt where lt.application.id in :list_ids"),
42
- @NamedQuery(name = "list-application-license_types", query = "SELECT lt FROM LicenseType lt where lt.application.id = :appId") })
53
+@NamedQueries({
54
+ @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt"),
55
+ @NamedQuery(name = "list-license_types-by_apps-id", query = "SELECT lt FROM LicenseType lt where lt.application.id in :list_ids"),
56
+ @NamedQuery(name = "list-application-license_types", query = "SELECT lt FROM LicenseType lt where lt.application.id = :appId")
57
+})
4358 public class LicenseType implements Serializable {
4459
45
- @SuppressWarnings("unused")
46
- private static final Logger LOG = LogManager.getLogger(LicenseType.class);
47
- private static final long serialVersionUID = 1L;
60
+ @SuppressWarnings("unused")
61
+ private static final Logger LOG = LogManager.getLogger(LicenseType.class);
62
+ private static final long serialVersionUID = 1L;
4863
49
- @Id
50
- @GeneratedValue
51
- private Integer id;
64
+ @Id
65
+ @GeneratedValue
66
+ private Integer id;
5267
53
- private String code;
54
- private String name;
55
- private String description;
68
+ private String code;
69
+ private String name;
70
+ private String description;
5671
57
- @Column(name = "creation_timestamp")
58
- @JsonProperty("creation_timestamp")
59
- private Date creationTimestamp;
72
+ @Column(name = "creation_timestamp")
73
+ @JsonProperty("creation_timestamp")
74
+ private Date creationTimestamp;
6075
61
- @JsonIgnore
62
- @ManyToOne(fetch = FetchType.LAZY)
63
- @JoinColumn(name = "application_id")
64
- private Application application;
76
+ @JsonIgnore
77
+ @ManyToOne(fetch = FetchType.LAZY)
78
+ @JoinColumn(name = "application_id")
79
+ private Application application;
6580
66
- @OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.REFRESH }, mappedBy = "licenseType")
67
- @JsonManagedReference
68
- private Set<LicenseTypeMetadata> metadata;
81
+ @OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.REFRESH }, mappedBy = "licenseType")
82
+ @JsonManagedReference
83
+ private Set<LicenseTypeMetadata> metadata;
6984
70
- public Set<LicenseTypeMetadata> getMetadata() {
71
- return metadata;
72
- }
85
+ // ---------------- Getters & setters ----------------
7386
74
- public void setMetadata(Set<LicenseTypeMetadata> metadata) {
75
- this.metadata = metadata;
76
- }
87
+ /**
88
+ * getMetadata<p>
89
+ * Return associated metadata entries.
90
+ *
91
+ * @return metadata
92
+ */
93
+ public Set<LicenseTypeMetadata> getMetadata() { return metadata; }
7794
78
- public Integer getId() {
79
- return id;
80
- }
95
+ /**
96
+ * setMetadata<p>
97
+ * Set associated metadata entries.
98
+ *
99
+ * @param metadata
100
+ */
101
+ public void setMetadata(Set<LicenseTypeMetadata> metadata) { this.metadata = metadata; }
81102
82
- public void setId(Integer id) {
83
- this.id = id;
84
- }
103
+ /**
104
+ * getId<p>
105
+ * Return primary key.
106
+ *
107
+ * @return id
108
+ */
109
+ public Integer getId() { return id; }
85110
86
- public String getName() {
87
- return name;
88
- }
111
+ /**
112
+ * setId<p>
113
+ * Set primary key.
114
+ *
115
+ * @param id
116
+ */
117
+ public void setId(Integer id) { this.id = id; }
89118
90
- public void setName(String name) {
91
- this.name = name;
92
- }
119
+ /**
120
+ * getName<p>
121
+ * Return display name.
122
+ *
123
+ * @return name
124
+ */
125
+ public String getName() { return name; }
93126
94
- public String getDescription() {
95
- return description;
96
- }
127
+ /**
128
+ * setName<p>
129
+ * Set display name.
130
+ *
131
+ * @param name
132
+ */
133
+ public void setName(String name) { this.name = name; }
97134
98
- public void setDescription(String description) {
99
- this.description = description;
100
- }
135
+ /**
136
+ * getDescription<p>
137
+ * Return description.
138
+ *
139
+ * @return description
140
+ */
141
+ public String getDescription() { return description; }
101142
102
- public String getCode() {
103
- return code;
104
- }
143
+ /**
144
+ * setDescription<p>
145
+ * Set description.
146
+ *
147
+ * @param description
148
+ */
149
+ public void setDescription(String description) { this.description = description; }
105150
106
- public void setCode(String code) {
107
- this.code = code;
108
- }
151
+ /**
152
+ * getCode<p>
153
+ * Return short code.
154
+ *
155
+ * @return code
156
+ */
157
+ public String getCode() { return code; }
109158
110
- public Application getApplication() {
111
- return application;
112
- }
159
+ /**
160
+ * setCode<p>
161
+ * Set short code.
162
+ *
163
+ * @param code
164
+ */
165
+ public void setCode(String code) { this.code = code; }
113166
114
- @JsonProperty("application_name")
115
- public String getApplicationName() {
116
- return application == null ? null : application.getName();
117
- }
167
+ /**
168
+ * getApplication<p>
169
+ * Return owning application (entity).
170
+ *
171
+ * @return application
172
+ */
173
+ public Application getApplication() { return application; }
118174
119
- @JsonProperty("application_id")
120
- public Integer getApplicationId() {
121
- return application == null ? null : application.getId();
122
- }
175
+ /**
176
+ * getApplicationName<p>
177
+ * Expose app name for JSON.
178
+ *
179
+ * @return appName
180
+ */
181
+ @JsonProperty("application_name")
182
+ public String getApplicationName() { return application == null ? null : application.getName(); }
123183
124
- @JsonProperty("application_id")
125
- public void setApplicationId(Integer appId) {
126
- if (appId == null) {
127
- application = null;
128
- } else {
129
- application = new Application();
130
- application.setId(appId);
131
- }
132
- }
184
+ /**
185
+ * getApplicationId<p>
186
+ * Expose app id for JSON.
187
+ *
188
+ * @return appId
189
+ */
190
+ @JsonProperty("application_id")
191
+ public Integer getApplicationId() { return application == null ? null : application.getId(); }
133192
134
- public void setApplication(Application application) {
135
- this.application = application;
136
- }
193
+ /**
194
+ * setApplicationId<p>
195
+ * Setter by id for JSON binding (creates shallow Application).
196
+ *
197
+ * @param appId
198
+ */
199
+ @JsonProperty("application_id")
200
+ public void setApplicationId(Integer appId) {
201
+ if (appId == null) {
202
+ application = null;
203
+ } else {
204
+ application = new Application();
205
+ application.setId(appId);
206
+ }
207
+ }
137208
138
- public Date getCreationTimestamp() {
139
- return creationTimestamp;
140
- }
209
+ /**
210
+ * setApplication<p>
211
+ * Set owning application (entity).
212
+ *
213
+ * @param application
214
+ */
215
+ public void setApplication(Application application) { this.application = application; }
141216
142
- public void setCreationTimestamp(Date creationTimestamp) {
143
- this.creationTimestamp = creationTimestamp;
144
- }
217
+ /**
218
+ * getCreationTimestamp<p>
219
+ * Return creation timestamp.
220
+ *
221
+ * @return creationTimestamp
222
+ */
223
+ public Date getCreationTimestamp() { return creationTimestamp; }
145224
146
- @Override
147
- public boolean equals(Object obj) {
148
- if (!(obj instanceof LicenseType))
149
- return false;
150
- LicenseType other = (LicenseType) obj;
151
- return id.equals(other.id);
152
- }
225
+ /**
226
+ * setCreationTimestamp<p>
227
+ * Set creation timestamp.
228
+ *
229
+ * @param creationTimestamp
230
+ */
231
+ public void setCreationTimestamp(Date creationTimestamp) { this.creationTimestamp = creationTimestamp; }
153232
154
- @Override
155
- public int hashCode() {
156
- return (id == null ? 0 : id.hashCode());
157
- }
233
+ // ---------------- Object methods ----------------
158234
159
- @Override
160
- public String toString() {
161
- return String.format("LT: ID: %d, code: %s", id, code);
162
- }
235
+ /**
236
+ * equals<p>
237
+ * Compare the current object with the given object
238
+ *
239
+ * @param object
240
+ * @return isEquals
241
+ */
242
+ @Override
243
+ public boolean equals(Object obj) {
244
+ if (!(obj instanceof LicenseType)) return false;
245
+ LicenseType other = (LicenseType) obj;
246
+ return id != null && id.equals(other.id);
247
+ }
248
+
249
+ /**
250
+ * hashCode<p>
251
+ * Get the object hashCode
252
+ *
253
+ * @return hashCode
254
+ */
255
+ @Override
256
+ public int hashCode() { return (id == null ? 0 : id.hashCode()); }
257
+
258
+ /**
259
+ * toString<p>
260
+ * Get the string describing the current object
261
+ *
262
+ * @return object string
263
+ */
264
+ @Override
265
+ public String toString() { return String.format("LT: ID: %d, code: %s", id, code); }
163266 }
267
+