From 146a0fb8b0e90f9196e569152f649baf60d6cc8f Mon Sep 17 00:00:00 2001
From: Joaquín Reñé <jrene@curisit.net>
Date: Tue, 07 Oct 2025 14:52:57 +0000
Subject: [PATCH] #4410 - Comments on classes

---
 securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java |  215 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 150 insertions(+), 65 deletions(-)

diff --git a/securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java b/securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java
index eafd418..5b2c982 100644
--- a/securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java
+++ b/securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java
@@ -1,3 +1,6 @@
+/*
+* Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved.
+*/
 package net.curisit.securis.db;
 
 import java.io.Serializable;
@@ -26,97 +29,179 @@
 import net.curisit.securis.db.common.Metadata;
 
 /**
- * Entity implementation class for Entity: application_metadata
- * 
- */
+* ApplicationMetadata
+* <p>
+* Single metadata entry (key/value/mandatory) attached to an {@link Application}.
+* Uses a composite PK: (application_id, key).
+* <p>
+* Mapping details:
+* - Table: application_metadata
+* - PK: application_id + key (two @Id fields).
+* - application: @ManyToOne with @JsonBackReference to avoid JSON cycles.
+* - creation_timestamp exposed as "creation_timestamp".
+*
+* @author JRA
+* Last reviewed by JRA on Oct 7, 2025.
+*/
 @JsonAutoDetect
 @JsonInclude(Include.NON_NULL)
 @Entity
 @Table(name = "application_metadata")
 @JsonIgnoreProperties(ignoreUnknown = true)
-@NamedQueries({ @NamedQuery(name = "list-application-metadata", query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId") })
+@NamedQueries({
+    @NamedQuery(name = "list-application-metadata",
+                query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId")
+})
 public class ApplicationMetadata implements Serializable, Metadata {
 
-	private static final Logger LOG = LogManager.getLogger(ApplicationMetadata.class);
+    private static final Logger LOG = LogManager.getLogger(ApplicationMetadata.class);
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	@Id
-	@ManyToOne
-	@JoinColumn(name = "application_id")
-	@JsonBackReference
-	private Application application;
+    /** Part of PK: owning application. */
+    @Id
+    @ManyToOne
+    @JoinColumn(name = "application_id")
+    @JsonBackReference
+    private Application application;
 
-	@Id
-	@Column(name = "\"key\"")
-	private String key;
+    /** Part of PK: metadata key (quoted column name). */
+    @Id
+    @Column(name = "\"key\"")
+    private String key;
 
-	private String value;
+    /** Arbitrary metadata value. */
+    private String value;
 
-	private boolean mandatory;
+    /** Whether this key is required for the parent application. */
+    private boolean mandatory;
 
-	@Column(name = "creation_timestamp")
-	@JsonProperty("creation_timestamp")
-	private Date creationTimestamp;
+    /** Server-side creation timestamp. */
+    @Column(name = "creation_timestamp")
+    @JsonProperty("creation_timestamp")
+    private Date creationTimestamp;
 
-	public String getKey() {
-		return key;
-	}
+    // ---------------------------------------------------------------------
+    // Getters & setters
+    // ---------------------------------------------------------------------
 
-	public void setKey(String key) {
-		this.key = key;
-	}
+    /**
+    * getKey<p>
+    * Get the metadata key (PK part).
+    *
+    * @return key
+    */
+    public String getKey() { return key; }
 
-	public Application getApplication() {
-		LOG.info("Getting application from app metadata: {}", application);
-		return application;
-	}
+    /**
+    * setKey<p>
+    * Set the metadata key (PK part).
+    *
+    * @param key
+    */
+    public void setKey(String key) { this.key = key; }
 
-	public void setApplication(Application application) {
-		this.application = application;
-	}
+    /**
+    * getApplication<p>
+    * Get the owning application.
+    *
+    * @return application
+    */
+    public Application getApplication() {
+        LOG.info("Getting application from app metadata: {}", application);
+        return application;
+    }
 
-	public Date getCreationTimestamp() {
-		return creationTimestamp;
-	}
+    /**
+    * setApplication<p>
+    * Set the owning application (PK part).
+    *
+   * @param application
+    */
+    public void setApplication(Application application) { this.application = application; }
 
-	public void setCreationTimestamp(Date creationTimestamp) {
-		this.creationTimestamp = creationTimestamp;
-	}
+    /**
+    * getCreationTimestamp<p>
+    * Get the creation timestamp.
+    *
+    * @return creationTimestamp
+    */
+    public Date getCreationTimestamp() { return creationTimestamp; }
 
-	public String getValue() {
-		return value;
-	}
+    /**
+    * setCreationTimestamp<p>
+    * Set the creation timestamp.
+    *
+    * @param creationTimestamp
+    */
+    public void setCreationTimestamp(Date creationTimestamp) { this.creationTimestamp = creationTimestamp; }
 
-	public void setValue(String value) {
-		this.value = value;
-	}
+    /**
+    * getValue<p>
+    * Get the metadata value.
+    *
+    * @return value
+    */
+    public String getValue() { return value; }
 
-	public boolean isMandatory() {
-		return mandatory;
-	}
+    /**
+    * setValue<p>
+    * Set the metadata value.
+    *
+    * @param value
+    */
+    public void setValue(String value) { this.value = value; }
 
-	public void setMandatory(boolean mandatory) {
-		this.mandatory = mandatory;
-	}
+    /**
+    * isMandatory<p>
+    * Whether this entry is required.
+    *
+    * @return mandatory
+    */
+    public boolean isMandatory() { return mandatory; }
 
-	@Override
-	public String toString() {
+    /**
+    * setMandatory<p>
+    * Mark this entry as required or optional.
+    *
+    * @param mandatory
+    */
+    public void setMandatory(boolean mandatory) { this.mandatory = mandatory; }
 
-		return String.format("AppMd (%s: %s)", this.key, value);
-	}
+    // ---------------------------------------------------------------------
+    // Object methods
+    // ---------------------------------------------------------------------
 
-	@Override
-	public boolean equals(Object obj) {
-		if (!(obj instanceof ApplicationMetadata))
-			return false;
-		ApplicationMetadata other = (ApplicationMetadata) obj;
-		return Objects.equals(key, other.key) && Objects.equals(application, other.application);
-	}
+    /**
+     * toString<p>
+     * Get the string describing the current object
+     * 
+     * @return object string
+     */
+    @Override
+    public String toString() { return String.format("AppMd (%s: %s)", this.key, value); }
 
-	@Override
-	public int hashCode() {
-		return Objects.hash(key, application);
-	}
+    /**
+     * equals<p>
+     * Compare the current object with the given object
+     * 
+     * @param object
+     * @return isEquals
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof ApplicationMetadata)) return false;
+        ApplicationMetadata other = (ApplicationMetadata) obj;
+        return Objects.equals(key, other.key) && Objects.equals(application, other.application);
+    }
 
+    /**
+     * hashCode<p>
+     * Get the object hashCode
+     * 
+     * @return hashCode
+     */
+    @Override
+    public int hashCode() { return Objects.hash(key, application); }
 }
+

--
Gitblit v1.3.2