| .. | .. |
|---|
| 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; |
|---|
| .. | .. |
|---|
| 30 | 33 | import com.fasterxml.jackson.annotation.JsonProperty; |
|---|
| 31 | 34 | |
|---|
| 32 | 35 | /** |
|---|
| 33 | | - * Entity implementation class for Entity: application |
|---|
| 34 | | - * |
|---|
| 35 | | - */ |
|---|
| 36 | +* Application |
|---|
| 37 | +* <p> |
|---|
| 38 | +* JPA entity that represents an application registered in the licensing server. |
|---|
| 39 | +* Includes descriptive fields and relationships to <code>LicenseType</code>, |
|---|
| 40 | +* <code>ApplicationMetadata</code> and <code>User</code>. |
|---|
| 41 | +* |
|---|
| 42 | +* Mapping details: |
|---|
| 43 | +* <ul> |
|---|
| 44 | +* <li>Table: <code>application</code></li> |
|---|
| 45 | +* <li>Named queries: <code>list-applications</code>, <code>list-applications-by_ids</code></li> |
|---|
| 46 | +* <li>Relationships: |
|---|
| 47 | +* <ul> |
|---|
| 48 | +* <li><code>@OneToMany</code> <b>licenseTypes</b> (mappedBy="application")</li> |
|---|
| 49 | +* <li><code>@OneToMany</code> <b>metadata</b> with cascade PERSIST/REMOVE/REFRESH</li> |
|---|
| 50 | +* <li><code>@ManyToMany</code> <b>users</b> via join table <code>user_application</code></li> |
|---|
| 51 | +* </ul> |
|---|
| 52 | +* </li> |
|---|
| 53 | +* </ul> |
|---|
| 54 | +*/ |
|---|
| 36 | 55 | @JsonAutoDetect |
|---|
| 37 | 56 | @JsonInclude(Include.NON_NULL) |
|---|
| 38 | 57 | @JsonIgnoreProperties(ignoreUnknown = true) |
|---|
| .. | .. |
|---|
| 46 | 65 | |
|---|
| 47 | 66 | private static final long serialVersionUID = 1L; |
|---|
| 48 | 67 | |
|---|
| 68 | + // ------------------------------------------------------------------ |
|---|
| 69 | + // Columns |
|---|
| 70 | + // ------------------------------------------------------------------ |
|---|
| 71 | + |
|---|
| 72 | + |
|---|
| 73 | + /** Surrogate primary key. */ |
|---|
| 49 | 74 | @Id |
|---|
| 50 | 75 | @GeneratedValue |
|---|
| 51 | 76 | private Integer id; |
|---|
| 52 | 77 | |
|---|
| 78 | + /** Unique short code for the application (business identifier). */ |
|---|
| 53 | 79 | private String code; |
|---|
| 80 | + |
|---|
| 81 | + /** Human-friendly application name. */ |
|---|
| 54 | 82 | private String name; |
|---|
| 83 | + |
|---|
| 84 | + /** Optional description. */ |
|---|
| 55 | 85 | private String description; |
|---|
| 56 | 86 | |
|---|
| 87 | + /** Default license file name suggested for downloads/exports. */ |
|---|
| 57 | 88 | @Column(name = "license_filename") |
|---|
| 58 | 89 | @JsonProperty("license_filename") |
|---|
| 59 | 90 | private String licenseFilename; |
|---|
| 60 | 91 | |
|---|
| 92 | + /** Creation timestamp (server-side). */ |
|---|
| 61 | 93 | @Column(name = "creation_timestamp") |
|---|
| 62 | 94 | @JsonProperty("creation_timestamp") |
|---|
| 63 | 95 | private Date creationTimestamp; |
|---|
| 64 | 96 | |
|---|
| 65 | | - // We don't include the referenced entities to limit the size of each row at |
|---|
| 66 | | - // // the listing |
|---|
| 97 | + // ----------------------- Relationships --------------------------- |
|---|
| 98 | + |
|---|
| 99 | + |
|---|
| 100 | + /** |
|---|
| 101 | + * License types attached to this application (ignored in default JSON to keep listings small). |
|---|
| 102 | + * |
|---|
| 103 | + * We don't include the referenced entities to limit the size of each row at the listing |
|---|
| 104 | + */ |
|---|
| 67 | 105 | @JsonIgnore |
|---|
| 68 | 106 | @OneToMany(fetch = FetchType.LAZY, mappedBy = "application") |
|---|
| 69 | 107 | private Set<LicenseType> licenseTypes; |
|---|
| 70 | 108 | |
|---|
| 109 | + /** |
|---|
| 110 | + * Metadata key/value entries for this application. |
|---|
| 111 | + */ |
|---|
| 71 | 112 | @OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.REFRESH }, mappedBy = "application") |
|---|
| 72 | 113 | @JsonManagedReference |
|---|
| 73 | 114 | private Set<ApplicationMetadata> metadata; |
|---|
| 74 | 115 | |
|---|
| 116 | + /** |
|---|
| 117 | + * Users that have access/relationship with this application (ignored in JSON listings). |
|---|
| 118 | + */ |
|---|
| 75 | 119 | @JsonIgnore |
|---|
| 76 | 120 | // We don't include the users to limit the size of each row a the listing |
|---|
| 77 | 121 | @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) |
|---|
| .. | .. |
|---|
| 80 | 124 | inverseJoinColumns = { @JoinColumn(name = "username", referencedColumnName = "username") }) |
|---|
| 81 | 125 | private Set<User> users; |
|---|
| 82 | 126 | |
|---|
| 127 | + // ------------------------------------------------------------------ |
|---|
| 128 | + // Getters & setters |
|---|
| 129 | + // ------------------------------------------------------------------ |
|---|
| 130 | + |
|---|
| 131 | + /** |
|---|
| 132 | + * getId<p> |
|---|
| 133 | + * Return the primary key. |
|---|
| 134 | + * |
|---|
| 135 | + * @return id |
|---|
| 136 | + */ |
|---|
| 83 | 137 | public Integer getId() { |
|---|
| 84 | 138 | return id; |
|---|
| 85 | 139 | } |
|---|
| 86 | 140 | |
|---|
| 141 | + /** |
|---|
| 142 | + * setId<p> |
|---|
| 143 | + * Set the primary key |
|---|
| 144 | + * |
|---|
| 145 | + * @param id |
|---|
| 146 | + */ |
|---|
| 87 | 147 | public void setId(Integer id) { |
|---|
| 88 | 148 | this.id = id; |
|---|
| 89 | 149 | } |
|---|
| 90 | 150 | |
|---|
| 151 | + /** |
|---|
| 152 | + * getName<p> |
|---|
| 153 | + * Get the name |
|---|
| 154 | + * |
|---|
| 155 | + * @return name |
|---|
| 156 | + */ |
|---|
| 91 | 157 | public String getName() { |
|---|
| 92 | 158 | return name; |
|---|
| 93 | 159 | } |
|---|
| 94 | 160 | |
|---|
| 161 | + /** |
|---|
| 162 | + * setName<p> |
|---|
| 163 | + * Set the name |
|---|
| 164 | + * |
|---|
| 165 | + * @param name |
|---|
| 166 | + */ |
|---|
| 95 | 167 | public void setName(String name) { |
|---|
| 96 | 168 | this.name = name; |
|---|
| 97 | 169 | } |
|---|
| 98 | 170 | |
|---|
| 171 | + /** |
|---|
| 172 | + * getDescription<p> |
|---|
| 173 | + * Get the description |
|---|
| 174 | + * |
|---|
| 175 | + * @return description |
|---|
| 176 | + */ |
|---|
| 99 | 177 | public String getDescription() { |
|---|
| 100 | 178 | return description; |
|---|
| 101 | 179 | } |
|---|
| 102 | 180 | |
|---|
| 181 | + /** |
|---|
| 182 | + * setDescription<p> |
|---|
| 183 | + * Set the description |
|---|
| 184 | + * |
|---|
| 185 | + * @param description |
|---|
| 186 | + */ |
|---|
| 103 | 187 | public void setDescription(String description) { |
|---|
| 104 | 188 | this.description = description; |
|---|
| 105 | 189 | } |
|---|
| 106 | 190 | |
|---|
| 191 | + /** |
|---|
| 192 | + * getCreationTimestamp<p> |
|---|
| 193 | + * Get the creation timestamp |
|---|
| 194 | + * |
|---|
| 195 | + * @return creationTimestamp |
|---|
| 196 | + */ |
|---|
| 107 | 197 | public Date getCreationTimestamp() { |
|---|
| 108 | 198 | return creationTimestamp; |
|---|
| 109 | 199 | } |
|---|
| 110 | 200 | |
|---|
| 201 | + /** |
|---|
| 202 | + * setCreationTimestamp<p> |
|---|
| 203 | + * Set the creation timestamp |
|---|
| 204 | + * |
|---|
| 205 | + * @param creationTimestamp |
|---|
| 206 | + */ |
|---|
| 111 | 207 | public void setCreationTimestamp(Date creationTimestamp) { |
|---|
| 112 | 208 | this.creationTimestamp = creationTimestamp; |
|---|
| 113 | 209 | } |
|---|
| 114 | 210 | |
|---|
| 211 | + /** |
|---|
| 212 | + * getApplicationMetadata<p> |
|---|
| 213 | + * Set the application metadata |
|---|
| 214 | + * |
|---|
| 215 | + * @return appMetadata |
|---|
| 216 | + */ |
|---|
| 115 | 217 | @JsonProperty("metadata") |
|---|
| 116 | 218 | public Set<ApplicationMetadata> getApplicationMetadata() { |
|---|
| 117 | 219 | return metadata; |
|---|
| 118 | 220 | } |
|---|
| 119 | 221 | |
|---|
| 222 | + /** |
|---|
| 223 | + * setApplicationMetadata<p> |
|---|
| 224 | + * Set the application metadata |
|---|
| 225 | + * |
|---|
| 226 | + * @param metadata |
|---|
| 227 | + */ |
|---|
| 120 | 228 | @JsonProperty("metadata") |
|---|
| 121 | 229 | public void setApplicationMetadata(Set<ApplicationMetadata> metadata) { |
|---|
| 122 | 230 | this.metadata = metadata; |
|---|
| 123 | 231 | } |
|---|
| 124 | 232 | |
|---|
| 233 | + /** |
|---|
| 234 | + * getLicenseFilename<p> |
|---|
| 235 | + * Get the license file name |
|---|
| 236 | + * |
|---|
| 237 | + * @return licenseFilename |
|---|
| 238 | + */ |
|---|
| 125 | 239 | public String getLicenseFilename() { |
|---|
| 126 | 240 | return licenseFilename; |
|---|
| 127 | 241 | } |
|---|
| 128 | 242 | |
|---|
| 243 | + /** |
|---|
| 244 | + * setLicenseFilename<p> |
|---|
| 245 | + * Set the license file name |
|---|
| 246 | + * |
|---|
| 247 | + * @param licenseFilename |
|---|
| 248 | + */ |
|---|
| 129 | 249 | public void setLicenseFilename(String licenseFilename) { |
|---|
| 130 | 250 | this.licenseFilename = licenseFilename; |
|---|
| 131 | 251 | } |
|---|
| 132 | 252 | |
|---|
| 253 | + /** |
|---|
| 254 | + * getLicenseTypes<p> |
|---|
| 255 | + * Get the license types |
|---|
| 256 | + * |
|---|
| 257 | + * @return licenseTypes |
|---|
| 258 | + */ |
|---|
| 133 | 259 | public Set<LicenseType> getLicenseTypes() { |
|---|
| 134 | 260 | LOG.info("Getting list license types!!!!"); |
|---|
| 135 | 261 | return licenseTypes; |
|---|
| 136 | 262 | } |
|---|
| 137 | 263 | |
|---|
| 264 | + /** |
|---|
| 265 | + * setLicenseTypes<p> |
|---|
| 266 | + * Set the license types |
|---|
| 267 | + * |
|---|
| 268 | + * @param licenseTypes |
|---|
| 269 | + */ |
|---|
| 138 | 270 | public void setLicenseTypes(Set<LicenseType> licenseTypes) { |
|---|
| 139 | 271 | this.licenseTypes = licenseTypes; |
|---|
| 140 | 272 | } |
|---|
| 141 | 273 | |
|---|
| 274 | + /** |
|---|
| 275 | + * getCode<p> |
|---|
| 276 | + * Get the application code |
|---|
| 277 | + * |
|---|
| 278 | + * @return code |
|---|
| 279 | + */ |
|---|
| 142 | 280 | public String getCode() { |
|---|
| 143 | 281 | return code; |
|---|
| 144 | 282 | } |
|---|
| 145 | 283 | |
|---|
| 284 | + /** |
|---|
| 285 | + * setCode<p> |
|---|
| 286 | + * Set the application code |
|---|
| 287 | + * |
|---|
| 288 | + * @param code |
|---|
| 289 | + */ |
|---|
| 146 | 290 | public void setCode(String code) { |
|---|
| 147 | 291 | this.code = code; |
|---|
| 148 | 292 | } |
|---|
| 149 | 293 | |
|---|
| 294 | + /** |
|---|
| 295 | + * equals<p> |
|---|
| 296 | + * Compares the current object with the given object |
|---|
| 297 | + * |
|---|
| 298 | + * @param object |
|---|
| 299 | + * @return isEquals |
|---|
| 300 | + */ |
|---|
| 150 | 301 | @Override |
|---|
| 151 | 302 | public boolean equals(Object obj) { |
|---|
| 152 | 303 | if (!(obj instanceof Application)) |
|---|
| .. | .. |
|---|
| 155 | 306 | return id.equals(other.id); |
|---|
| 156 | 307 | } |
|---|
| 157 | 308 | |
|---|
| 309 | + /** |
|---|
| 310 | + * hashCode<p> |
|---|
| 311 | + * Get the object hashCode |
|---|
| 312 | + * |
|---|
| 313 | + * @param hashCode |
|---|
| 314 | + */ |
|---|
| 158 | 315 | @Override |
|---|
| 159 | 316 | public int hashCode() { |
|---|
| 160 | 317 | |
|---|