| .. | .. |
|---|
| 1 | +/* |
|---|
| 2 | +* Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved. |
|---|
| 3 | +*/ |
|---|
| 1 | 4 | package net.curisit.securis.db; |
|---|
| 2 | 5 | |
|---|
| 3 | 6 | import java.io.Serializable; |
|---|
| .. | .. |
|---|
| 20 | 23 | import com.fasterxml.jackson.annotation.JsonProperty; |
|---|
| 21 | 24 | |
|---|
| 22 | 25 | /** |
|---|
| 23 | | - * Entity implementation class for Entity: settings settings is a table that has |
|---|
| 24 | | - * rows with 3 columns: "key", "value", "timestamp" |
|---|
| 25 | | - * |
|---|
| 26 | | - */ |
|---|
| 27 | | -@Entity() |
|---|
| 28 | | -@EntityListeners({ |
|---|
| 29 | | - ModificationTimestampListener.class |
|---|
| 30 | | -}) |
|---|
| 26 | +* Settings |
|---|
| 27 | +* <p> |
|---|
| 28 | +* Simple key/value store with last modification timestamp. |
|---|
| 29 | +* Table rows have columns: "key", "value", "modification_timestamp". |
|---|
| 30 | +* |
|---|
| 31 | +* Mapping details: |
|---|
| 32 | +* - Table: settings |
|---|
| 33 | +* - Listeners: {@link ModificationTimestampListener} |
|---|
| 34 | +* - NamedQuery: get-param by key |
|---|
| 35 | +* |
|---|
| 36 | +* @author JRA |
|---|
| 37 | +* Last reviewed by JRA on Oct 5, 2025. |
|---|
| 38 | +*/ |
|---|
| 39 | +@Entity |
|---|
| 40 | +@EntityListeners({ ModificationTimestampListener.class }) |
|---|
| 31 | 41 | @Table(name = "settings") |
|---|
| 32 | 42 | @NamedQueries({ |
|---|
| 33 | 43 | @NamedQuery(name = "get-param", query = "SELECT p FROM Settings p where p.key = :key") |
|---|
| 34 | 44 | }) |
|---|
| 35 | 45 | public class Settings implements ModificationTimestampEntity, Serializable { |
|---|
| 46 | + |
|---|
| 36 | 47 | @SuppressWarnings("unused") |
|---|
| 37 | 48 | private static final Logger LOG = LogManager.getLogger(Settings.class); |
|---|
| 38 | 49 | |
|---|
| 39 | 50 | private static final long serialVersionUID = 1L; |
|---|
| 40 | 51 | |
|---|
| 52 | + /** Primary key: setting key. */ |
|---|
| 41 | 53 | @Id |
|---|
| 42 | 54 | String key; |
|---|
| 43 | 55 | |
|---|
| 56 | + /** Setting value as string. */ |
|---|
| 44 | 57 | String value; |
|---|
| 45 | 58 | |
|---|
| 59 | + /** Last modification timestamp. */ |
|---|
| 46 | 60 | @Column(name = "modification_timestamp") |
|---|
| 47 | 61 | @JsonProperty("modification_timestamp") |
|---|
| 48 | 62 | private Date modificationTimestamp; |
|---|
| 49 | 63 | |
|---|
| 50 | | - public String getKey() { |
|---|
| 51 | | - return key; |
|---|
| 52 | | - } |
|---|
| 64 | + // -------- Getters/setters -------- |
|---|
| 53 | 65 | |
|---|
| 54 | | - public void setKey(String key) { |
|---|
| 55 | | - this.key = key; |
|---|
| 56 | | - } |
|---|
| 66 | + /** |
|---|
| 67 | + * getKey<p> |
|---|
| 68 | + * Return setting key. |
|---|
| 69 | + * |
|---|
| 70 | + * @return key |
|---|
| 71 | + */ |
|---|
| 72 | + public String getKey() { return key; } |
|---|
| 57 | 73 | |
|---|
| 58 | | - public String getValue() { |
|---|
| 59 | | - return value; |
|---|
| 60 | | - } |
|---|
| 74 | + /** |
|---|
| 75 | + * setKey<p> |
|---|
| 76 | + * Set setting key. |
|---|
| 77 | + * |
|---|
| 78 | + * @param key |
|---|
| 79 | + */ |
|---|
| 80 | + public void setKey(String key) { this.key = key; } |
|---|
| 61 | 81 | |
|---|
| 62 | | - public void setValue(String value) { |
|---|
| 63 | | - this.value = value; |
|---|
| 64 | | - } |
|---|
| 82 | + /** |
|---|
| 83 | + * getValue<p> |
|---|
| 84 | + * Return value. |
|---|
| 85 | + * |
|---|
| 86 | + * @return value |
|---|
| 87 | + */ |
|---|
| 88 | + public String getValue() { return value; } |
|---|
| 65 | 89 | |
|---|
| 90 | + /** |
|---|
| 91 | + * setValue<p> |
|---|
| 92 | + * Set value. |
|---|
| 93 | + * |
|---|
| 94 | + * @param value |
|---|
| 95 | + */ |
|---|
| 96 | + public void setValue(String value) { this.value = value; } |
|---|
| 97 | + |
|---|
| 98 | + /** |
|---|
| 99 | + * getModificationTimestamp<p> |
|---|
| 100 | + * Required by ModificationTimestampEntity. |
|---|
| 101 | + * |
|---|
| 102 | + * @return modificationTimestamp |
|---|
| 103 | + */ |
|---|
| 66 | 104 | @Override |
|---|
| 67 | | - public Date getModificationTimestamp() { |
|---|
| 68 | | - return modificationTimestamp; |
|---|
| 69 | | - } |
|---|
| 105 | + public Date getModificationTimestamp() { return modificationTimestamp; } |
|---|
| 70 | 106 | |
|---|
| 107 | + /** |
|---|
| 108 | + * setModificationTimestamp<p> |
|---|
| 109 | + * Required by ModificationTimestampEntity. |
|---|
| 110 | + * |
|---|
| 111 | + * @param modificationTimestamp |
|---|
| 112 | + */ |
|---|
| 71 | 113 | @Override |
|---|
| 72 | | - public void setModificationTimestamp(Date modificationTimestamp) { |
|---|
| 73 | | - this.modificationTimestamp = modificationTimestamp; |
|---|
| 74 | | - } |
|---|
| 114 | + public void setModificationTimestamp(Date modificationTimestamp) { this.modificationTimestamp = modificationTimestamp; } |
|---|
| 75 | 115 | |
|---|
| 116 | + /** |
|---|
| 117 | + * toString<p> |
|---|
| 118 | + * Get the string describing the current object |
|---|
| 119 | + * |
|---|
| 120 | + * @return object string |
|---|
| 121 | + */ |
|---|
| 76 | 122 | @Override |
|---|
| 77 | | - public String toString() { |
|---|
| 78 | | - |
|---|
| 79 | | - return String.format("{key: %s, value: %s, ts: %s}", key, value, modificationTimestamp); |
|---|
| 80 | | - } |
|---|
| 81 | | - |
|---|
| 123 | + public String toString() { return String.format("{key: %s, value: %s, ts: %s}", key, value, modificationTimestamp); } |
|---|
| 82 | 124 | } |
|---|
| 125 | + |
|---|