Joaquín Reñé
2025-10-07 146a0fb8b0e90f9196e569152f649baf60d6cc8f
securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.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;
....@@ -26,97 +29,179 @@
2629 import net.curisit.securis.db.common.Metadata;
2730
2831 /**
29
- * Entity implementation class for Entity: application_metadata
30
- *
31
- */
32
+* ApplicationMetadata
33
+* <p>
34
+* Single metadata entry (key/value/mandatory) attached to an {@link Application}.
35
+* Uses a composite PK: (application_id, key).
36
+* <p>
37
+* Mapping details:
38
+* - Table: application_metadata
39
+* - PK: application_id + key (two @Id fields).
40
+* - application: @ManyToOne with @JsonBackReference to avoid JSON cycles.
41
+* - creation_timestamp exposed as "creation_timestamp".
42
+*
43
+* @author JRA
44
+* Last reviewed by JRA on Oct 7, 2025.
45
+*/
3246 @JsonAutoDetect
3347 @JsonInclude(Include.NON_NULL)
3448 @Entity
3549 @Table(name = "application_metadata")
3650 @JsonIgnoreProperties(ignoreUnknown = true)
37
-@NamedQueries({ @NamedQuery(name = "list-application-metadata", query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId") })
51
+@NamedQueries({
52
+ @NamedQuery(name = "list-application-metadata",
53
+ query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId")
54
+})
3855 public class ApplicationMetadata implements Serializable, Metadata {
3956
40
- private static final Logger LOG = LogManager.getLogger(ApplicationMetadata.class);
57
+ private static final Logger LOG = LogManager.getLogger(ApplicationMetadata.class);
4158
42
- private static final long serialVersionUID = 1L;
59
+ private static final long serialVersionUID = 1L;
4360
44
- @Id
45
- @ManyToOne
46
- @JoinColumn(name = "application_id")
47
- @JsonBackReference
48
- private Application application;
61
+ /** Part of PK: owning application. */
62
+ @Id
63
+ @ManyToOne
64
+ @JoinColumn(name = "application_id")
65
+ @JsonBackReference
66
+ private Application application;
4967
50
- @Id
51
- @Column(name = "\"key\"")
52
- private String key;
68
+ /** Part of PK: metadata key (quoted column name). */
69
+ @Id
70
+ @Column(name = "\"key\"")
71
+ private String key;
5372
54
- private String value;
73
+ /** Arbitrary metadata value. */
74
+ private String value;
5575
56
- private boolean mandatory;
76
+ /** Whether this key is required for the parent application. */
77
+ private boolean mandatory;
5778
58
- @Column(name = "creation_timestamp")
59
- @JsonProperty("creation_timestamp")
60
- private Date creationTimestamp;
79
+ /** Server-side creation timestamp. */
80
+ @Column(name = "creation_timestamp")
81
+ @JsonProperty("creation_timestamp")
82
+ private Date creationTimestamp;
6183
62
- public String getKey() {
63
- return key;
64
- }
84
+ // ---------------------------------------------------------------------
85
+ // Getters & setters
86
+ // ---------------------------------------------------------------------
6587
66
- public void setKey(String key) {
67
- this.key = key;
68
- }
88
+ /**
89
+ * getKey<p>
90
+ * Get the metadata key (PK part).
91
+ *
92
+ * @return key
93
+ */
94
+ public String getKey() { return key; }
6995
70
- public Application getApplication() {
71
- LOG.info("Getting application from app metadata: {}", application);
72
- return application;
73
- }
96
+ /**
97
+ * setKey<p>
98
+ * Set the metadata key (PK part).
99
+ *
100
+ * @param key
101
+ */
102
+ public void setKey(String key) { this.key = key; }
74103
75
- public void setApplication(Application application) {
76
- this.application = application;
77
- }
104
+ /**
105
+ * getApplication<p>
106
+ * Get the owning application.
107
+ *
108
+ * @return application
109
+ */
110
+ public Application getApplication() {
111
+ LOG.info("Getting application from app metadata: {}", application);
112
+ return application;
113
+ }
78114
79
- public Date getCreationTimestamp() {
80
- return creationTimestamp;
81
- }
115
+ /**
116
+ * setApplication<p>
117
+ * Set the owning application (PK part).
118
+ *
119
+ * @param application
120
+ */
121
+ public void setApplication(Application application) { this.application = application; }
82122
83
- public void setCreationTimestamp(Date creationTimestamp) {
84
- this.creationTimestamp = creationTimestamp;
85
- }
123
+ /**
124
+ * getCreationTimestamp<p>
125
+ * Get the creation timestamp.
126
+ *
127
+ * @return creationTimestamp
128
+ */
129
+ public Date getCreationTimestamp() { return creationTimestamp; }
86130
87
- public String getValue() {
88
- return value;
89
- }
131
+ /**
132
+ * setCreationTimestamp<p>
133
+ * Set the creation timestamp.
134
+ *
135
+ * @param creationTimestamp
136
+ */
137
+ public void setCreationTimestamp(Date creationTimestamp) { this.creationTimestamp = creationTimestamp; }
90138
91
- public void setValue(String value) {
92
- this.value = value;
93
- }
139
+ /**
140
+ * getValue<p>
141
+ * Get the metadata value.
142
+ *
143
+ * @return value
144
+ */
145
+ public String getValue() { return value; }
94146
95
- public boolean isMandatory() {
96
- return mandatory;
97
- }
147
+ /**
148
+ * setValue<p>
149
+ * Set the metadata value.
150
+ *
151
+ * @param value
152
+ */
153
+ public void setValue(String value) { this.value = value; }
98154
99
- public void setMandatory(boolean mandatory) {
100
- this.mandatory = mandatory;
101
- }
155
+ /**
156
+ * isMandatory<p>
157
+ * Whether this entry is required.
158
+ *
159
+ * @return mandatory
160
+ */
161
+ public boolean isMandatory() { return mandatory; }
102162
103
- @Override
104
- public String toString() {
163
+ /**
164
+ * setMandatory<p>
165
+ * Mark this entry as required or optional.
166
+ *
167
+ * @param mandatory
168
+ */
169
+ public void setMandatory(boolean mandatory) { this.mandatory = mandatory; }
105170
106
- return String.format("AppMd (%s: %s)", this.key, value);
107
- }
171
+ // ---------------------------------------------------------------------
172
+ // Object methods
173
+ // ---------------------------------------------------------------------
108174
109
- @Override
110
- public boolean equals(Object obj) {
111
- if (!(obj instanceof ApplicationMetadata))
112
- return false;
113
- ApplicationMetadata other = (ApplicationMetadata) obj;
114
- return Objects.equals(key, other.key) && Objects.equals(application, other.application);
115
- }
175
+ /**
176
+ * toString<p>
177
+ * Get the string describing the current object
178
+ *
179
+ * @return object string
180
+ */
181
+ @Override
182
+ public String toString() { return String.format("AppMd (%s: %s)", this.key, value); }
116183
117
- @Override
118
- public int hashCode() {
119
- return Objects.hash(key, application);
120
- }
184
+ /**
185
+ * equals<p>
186
+ * Compare the current object with the given object
187
+ *
188
+ * @param object
189
+ * @return isEquals
190
+ */
191
+ @Override
192
+ public boolean equals(Object obj) {
193
+ if (!(obj instanceof ApplicationMetadata)) return false;
194
+ ApplicationMetadata other = (ApplicationMetadata) obj;
195
+ return Objects.equals(key, other.key) && Objects.equals(application, other.application);
196
+ }
121197
198
+ /**
199
+ * hashCode<p>
200
+ * Get the object hashCode
201
+ *
202
+ * @return hashCode
203
+ */
204
+ @Override
205
+ public int hashCode() { return Objects.hash(key, application); }
122206 }
207
+