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/PackMetadata.java |  246 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 172 insertions(+), 74 deletions(-)

diff --git a/securis/src/main/java/net/curisit/securis/db/PackMetadata.java b/securis/src/main/java/net/curisit/securis/db/PackMetadata.java
index d35b22c..e690db5 100644
--- a/securis/src/main/java/net/curisit/securis/db/PackMetadata.java
+++ b/securis/src/main/java/net/curisit/securis/db/PackMetadata.java
@@ -1,3 +1,6 @@
+/*
+* Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved.
+*/
 package net.curisit.securis.db;
 
 import java.io.Serializable;
@@ -22,106 +25,201 @@
 import net.curisit.securis.db.common.Metadata;
 
 /**
- * Entity implementation class for Entity: pack_metadata
- * 
- */
+* PackMetadata
+* <p>
+* Single metadata entry (key/value/flags) attached to a {@link Pack}.
+* Uses composite PK: (pack_id, key).
+*
+* Mapping details:
+* - Table: pack_metadata
+* - PK: pack_id + key (two @Id fields)
+* - 'pack' is @JsonIgnore to reduce payload size in list views
+* - NamedQuery: list-pack-metadata by pack id
+*
+* Flags:
+* - readonly: UI hint to prevent edits
+* - mandatory: requires value on pack creation/updates
+* 
+* @author JRA
+* Last reviewed by JRA on Oct 5, 2025.
+*/
 @JsonAutoDetect
 @JsonInclude(Include.NON_NULL)
 @Entity
 @Table(name = "pack_metadata")
 @JsonIgnoreProperties(ignoreUnknown = true)
-@NamedQueries({ @NamedQuery(name = "list-pack-metadata", query = "SELECT a FROM PackMetadata a where a.pack.id = :packId") })
+@NamedQueries({
+    @NamedQuery(name = "list-pack-metadata",
+                query = "SELECT a FROM PackMetadata a where a.pack.id = :packId")
+})
 public class PackMetadata implements Serializable, Metadata {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	@Id
-	@JsonIgnore
-	@ManyToOne
-	@JoinColumn(name = "pack_id")
-	private Pack pack;
+    /** PK part: owning pack (ignored in JSON). */
+    @Id
+    @JsonIgnore
+    @ManyToOne
+    @JoinColumn(name = "pack_id")
+    private Pack pack;
 
-	@Id
-	@Column(name = "\"key\"")
-	private String key;
+    /** PK part: metadata key (quoted column name). */
+    @Id
+    @Column(name = "\"key\"")
+    private String key;
 
-	private String value;
+    /** Metadata value. */
+    private String value;
 
-	private boolean readonly;
+    /** Whether this field can be edited by clients. */
+    private boolean readonly;
 
-	private boolean mandatory;
+    /** Whether this field is required. */
+    private boolean mandatory;
 
-	@JsonProperty("pack_id")
-	public Integer getPackId() {
-		return pack == null ? null : pack.getId();
-	}
+    // -------- JSON helpers to expose pack id --------
 
-	@JsonProperty("pack_id")
-	public void setLicenseTypeId(Integer idPack) {
-		if (idPack == null) {
-			pack = null;
-		} else {
-			pack = new Pack();
-			pack.setId(idPack);
-		}
-	}
+    /** 
+     * getPackId<p>
+     * Expose pack id as JSON scalar. 
+     * 
+     * @return packId
+     */
+    @JsonProperty("pack_id")
+    public Integer getPackId() {
+        return pack == null ? null : pack.getId();
+    }
 
-	public Pack getPack() {
-		return pack;
-	}
+    /** 
+     * setLicenseTypeId<p>
+     * Setter by id (creates shallow Pack).
+     * 
+     * @param packId
+     */
+    @JsonProperty("pack_id")
+    public void setLicenseTypeId(Integer idPack) {
+        if (idPack == null) {
+            pack = null;
+        } else {
+            pack = new Pack();
+            pack.setId(idPack);
+        }
+    }
 
-	public void setPack(Pack pack) {
-		this.pack = pack;
-	}
+    // -------- Getters & setters --------
 
-	public String getValue() {
-		return value;
-	}
+    /** 
+     * getPack<p>
+     * Return owning pack (entity). 
+     * 
+     * @return pack
+     */
+    public Pack getPack() { return pack; }
 
-	public void setValue(String value) {
-		this.value = value;
-	}
+    /** 
+     * setPack<p>
+     * Set owning pack (entity). 
+     * 
+     * @param pack
+     */
+    public void setPack(Pack pack) { this.pack = pack; }
 
-	public String getKey() {
-		return key;
-	}
+    /** 
+     * getValue<p>
+     * Return metadata value. 
+     * 
+     * @return metadataValue
+     */
+    public String getValue() { return value; }
 
-	public void setKey(String key) {
-		this.key = key;
-	}
+    /** 
+     * setValue<p>
+     * Set the metadata value. 
+     * 
+     * @param metadataValue
+     */
+    public void setValue(String value) { this.value = value; }
 
-	public boolean isReadonly() {
-		return readonly;
-	}
+    /** 
+     * getKey<p>
+     * Return metadata key (PK part). 
+     * 
+     * @return key
+     */
+    public String getKey() { return key; }
 
-	public void setReadonly(boolean readonly) {
-		this.readonly = readonly;
-	}
+    /** 
+     * setKey<p>
+     * Set metadata key (PK part). 
+     * 
+     * @param key
+     */
+    public void setKey(String key) { this.key = key; }
 
-	public boolean isMandatory() {
-		return mandatory;
-	}
+    /** 
+     * isReadonly<p>
+     * Return read-only flag. 
+     * 
+     * @return isReadonly
+     */
+    public boolean isReadonly() { return readonly; }
 
-	public void setMandatory(boolean mandatory) {
-		this.mandatory = mandatory;
-	}
+    /** 
+     * setReadonly<p>
+     * Set read-only flag.
+     * 
+     * @param readonly
+     */
+    public void setReadonly(boolean readonly) { this.readonly = readonly; }
 
-	@Override
-	public String toString() {
-		return String.format("PackMD (%s: %s)", key, value);
-	}
+    /** 
+     * isMandatory<p>
+     * Return mandatory flag. 
+     * 
+     * @return isMandatory
+     */
+    public boolean isMandatory() { return mandatory; }
 
-	@Override
-	public boolean equals(Object obj) {
-		if (!(obj instanceof PackMetadata))
-			return false;
-		PackMetadata other = (PackMetadata) obj;
-		return Objects.equals(key, other.key) && Objects.equals(pack, other.pack);
-	}
+    /** 
+     * setMandatory<p>
+     * Set mandatory flag.
+     * 
+     * @param mandatory
+     */
+    public void setMandatory(boolean mandatory) { this.mandatory = mandatory; }
 
-	@Override
-	public int hashCode() {
-		return Objects.hash(key, pack);
-	}
+    // -------- Object methods --------
 
+    /**
+     * toString<p>
+     * Get the string describing the current object
+     * 
+     * @return object string
+     */
+    @Override
+    public String toString() { return String.format("PackMD (%s: %s)", key, value); }
+
+    /**
+     * equals<p>
+     * Compare the current object with the given object
+     * 
+     * @param object
+     * @return isEquals
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof PackMetadata)) return false;
+        PackMetadata other = (PackMetadata) obj;
+        return Objects.equals(key, other.key) && Objects.equals(pack, other.pack);
+    }
+
+    /**
+     * hashCode<p>
+     * Get the object hashCode
+     * 
+     * @return hashCode
+     */
+    @Override
+    public int hashCode() { return Objects.hash(key, pack); }
 }
+

--
Gitblit v1.3.2