Roberto Sánchez
2014-01-22 79121484b7e6f721f5435a102018152a164ed655
securis/src/main/java/net/curisit/securis/db/Pack.java
....@@ -8,6 +8,7 @@
88 import javax.persistence.Column;
99 import javax.persistence.Entity;
1010 import javax.persistence.FetchType;
11
+import javax.persistence.GeneratedValue;
1112 import javax.persistence.Id;
1213 import javax.persistence.JoinColumn;
1314 import javax.persistence.ManyToOne;
....@@ -31,15 +32,18 @@
3132 @Table(name = "pack")
3233 @NamedQueries(
3334 { @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
34
- @NamedQuery(name = "list-packs-by-org", query = "SELECT pa FROM Pack pa where pa.organization = :organization") })
35
+ @NamedQuery(name = "list-packs-by-orgs", query = "SELECT pa FROM Pack pa where pa.organization.id in :list_ids") })
3536 public class Pack implements Serializable {
3637
3738 private static final long serialVersionUID = 1L;
3839
3940 @Id
41
+ @GeneratedValue
4042 private int id;
4143
4244 private String code;
45
+
46
+ private String comments;
4347
4448 @Column(name = "creation_timestamp")
4549 private Date creationTimestamp;
....@@ -63,7 +67,8 @@
6367 @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "pack")
6468 private Set<License> licenses;
6569
66
- @JoinColumn(name = "num_licenses")
70
+ @Column(name = "num_licenses")
71
+ @JsonProperty("num_licenses")
6772 private int numLicenses;
6873
6974 public int getId() {
....@@ -190,6 +195,16 @@
190195 }
191196
192197 @JsonProperty("license_type_id")
198
+ public void setLicTypeId(Integer idLT) {
199
+ if (idLT == null) {
200
+ licenseType = null;
201
+ } else {
202
+ licenseType = new LicenseType();
203
+ licenseType.setId(idLT);
204
+ }
205
+ }
206
+
207
+ @JsonProperty("license_type_id")
193208 public Integer getLicTypeId() {
194209 return licenseType == null ? null : licenseType.getId();
195210 }
....@@ -205,9 +220,22 @@
205220 createdBy.setUsername(username);
206221 }
207222
223
+ @JsonProperty("created_by_name")
224
+ public String getCreatedByname() {
225
+ return createdBy == null ? null : String.format("%s %s", createdBy.getFirstName(), createdBy.getFirstName());
226
+ }
227
+
208228 @JsonProperty("licensetype_code")
209229 public String getLicenseTypcode() {
210230 return licenseType == null ? null : licenseType.getCode();
211231 }
212232
233
+ public String getComments() {
234
+ return comments;
235
+ }
236
+
237
+ public void setComments(String comments) {
238
+ this.comments = comments;
239
+ }
240
+
213241 }