Roberto Sánchez
2014-09-19 8d5386be38db25a2a41c3bf6c876adee21ca26cc
securis/src/main/java/net/curisit/securis/db/Pack.java
....@@ -32,224 +32,230 @@
3232 @Entity
3333 @Table(name = "pack")
3434 @JsonIgnoreProperties(ignoreUnknown = true)
35
-@NamedQueries(
36
- { @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
37
- @NamedQuery(name = "list-packs-by-orgs", query = "SELECT pa FROM Pack pa where pa.organization.id in :list_ids") })
35
+@NamedQueries({ @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
36
+ @NamedQuery(name = "list-packs-by-orgs", query = "SELECT pa FROM Pack pa where pa.organization.id in :list_ids") })
3837 public class Pack implements Serializable {
3938
40
- private static final long serialVersionUID = 1L;
39
+ private static final long serialVersionUID = 1L;
4140
42
- @Id
43
- @GeneratedValue
44
- private int id;
41
+ @Id
42
+ @GeneratedValue
43
+ private int id;
4544
46
- private String code;
45
+ private String code;
4746
48
- private String comments;
47
+ private String comments;
4948
50
- @Column(name = "creation_timestamp")
51
- private Date creationTimestamp;
49
+ @Column(name = "creation_timestamp")
50
+ private Date creationTimestamp;
5251
53
- @JsonIgnore
54
- @ManyToOne
55
- @JoinColumn(name = "organization_id")
56
- private Organization organization;
52
+ @JsonIgnore
53
+ @ManyToOne
54
+ @JoinColumn(name = "organization_id")
55
+ private Organization organization;
5756
58
- @JsonIgnore
59
- @ManyToOne
60
- @JoinColumn(name = "license_type_id")
61
- private LicenseType licenseType;
57
+ @JsonIgnore
58
+ @ManyToOne
59
+ @JoinColumn(name = "license_type_id")
60
+ private LicenseType licenseType;
6261
63
- @JsonIgnore
64
- @ManyToOne
65
- @JoinColumn(name = "created_by")
66
- private User createdBy;
62
+ @JsonIgnore
63
+ @ManyToOne
64
+ @JoinColumn(name = "created_by")
65
+ private User createdBy;
6766
68
- @JsonIgnore
69
- @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "pack")
70
- private Set<License> licenses;
67
+ @JsonIgnore
68
+ @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "pack")
69
+ private Set<License> licenses;
7170
72
- @Column(name = "num_licenses")
73
- @JsonProperty("num_licenses")
74
- private int numLicenses;
71
+ @Column(name = "num_licenses")
72
+ @JsonProperty("num_licenses")
73
+ private int numLicenses;
7574
76
- @Column(name = "license_preactivation")
77
- @JsonProperty("license_preactivation")
78
- private boolean licensePreactivation;
75
+ @Column(name = "license_preactivation")
76
+ @JsonProperty("license_preactivation")
77
+ private boolean licensePreactivation;
7978
80
- public int getId() {
81
- return id;
82
- }
79
+ public int getId() {
80
+ return id;
81
+ }
8382
84
- public void setId(int id) {
85
- this.id = id;
86
- }
83
+ public void setId(int id) {
84
+ this.id = id;
85
+ }
8786
88
- public String getCode() {
89
- return code;
90
- }
87
+ public String getCode() {
88
+ return code;
89
+ }
9190
92
- public void setCode(String code) {
93
- this.code = code;
94
- }
91
+ public void setCode(String code) {
92
+ this.code = code;
93
+ }
9594
96
- public Date getCreationTimestamp() {
97
- return creationTimestamp;
98
- }
95
+ public Date getCreationTimestamp() {
96
+ return creationTimestamp;
97
+ }
9998
100
- public void setCreationTimestamp(Date creationTimestamp) {
101
- this.creationTimestamp = creationTimestamp;
102
- }
99
+ public void setCreationTimestamp(Date creationTimestamp) {
100
+ this.creationTimestamp = creationTimestamp;
101
+ }
103102
104
- public Organization getOrganization() {
105
- return organization;
106
- }
103
+ public Organization getOrganization() {
104
+ return organization;
105
+ }
107106
108
- public void setOrganization(Organization organization) {
109
- this.organization = organization;
110
- }
107
+ public void setOrganization(Organization organization) {
108
+ this.organization = organization;
109
+ }
111110
112
- public LicenseType getLicenseType() {
113
- return licenseType;
114
- }
111
+ public LicenseType getLicenseType() {
112
+ return licenseType;
113
+ }
115114
116
- public void setLicenseType(LicenseType licenseType) {
117
- this.licenseType = licenseType;
118
- }
115
+ public void setLicenseType(LicenseType licenseType) {
116
+ this.licenseType = licenseType;
117
+ }
119118
120
- public User getCreatedBy() {
121
- return createdBy;
122
- }
119
+ public User getCreatedBy() {
120
+ return createdBy;
121
+ }
123122
124
- public void setCreatedBy(User createdBy) {
125
- this.createdBy = createdBy;
126
- }
123
+ public void setCreatedBy(User createdBy) {
124
+ this.createdBy = createdBy;
125
+ }
127126
128
- public int getNumLicenses() {
129
- return numLicenses;
130
- }
127
+ public int getNumLicenses() {
128
+ return numLicenses;
129
+ }
131130
132
- public void setNumLicenses(int numLicenses) {
133
- this.numLicenses = numLicenses;
134
- }
131
+ public void setNumLicenses(int numLicenses) {
132
+ this.numLicenses = numLicenses;
133
+ }
135134
136
- @JsonProperty("num_activations")
137
- public int getNumActivations() {
138
- if (licenses == null)
139
- return 0;
140
- int num = 0;
141
- for (License lic : licenses) {
142
- if (lic.getStatus() == License.Status.ACTIVE)
143
- num++;
144
- }
145
- return num;
146
- }
135
+ @JsonProperty("num_activations")
136
+ public int getNumActivations() {
137
+ if (licenses == null) {
138
+ return 0;
139
+ }
140
+ int num = 0;
141
+ for (License lic : licenses) {
142
+ if (lic.getStatus() == License.Status.ACTIVE) {
143
+ num++;
144
+ }
145
+ }
146
+ return num;
147
+ }
147148
148
- /**
149
- * Counts all created licenses, It counts active licenses and licenses waiting for activation This number will be used to control the max number of licenses created. Ignore canceled licenses.
150
- *
151
- * @return
152
- */
153
- @JsonProperty("num_creations")
154
- public int getNumCreations() {
155
- if (licenses == null)
156
- return 0;
157
- int num = 0;
158
- for (License lic : licenses) {
159
- if (lic.getStatus() != License.Status.CANCELED)
160
- num++;
161
- }
162
- return num;
163
- }
149
+ /**
150
+ * Counts all created licenses, It counts active licenses and licenses
151
+ * waiting for activation This number will be used to control the max number
152
+ * of licenses created. Ignore canceled licenses.
153
+ *
154
+ * @return
155
+ */
156
+ @JsonProperty("num_creations")
157
+ public int getNumCreations() {
158
+ if (licenses == null) {
159
+ return 0;
160
+ }
161
+ int num = 0;
162
+ for (License lic : licenses) {
163
+ if (lic.getStatus() != License.Status.CANCELED) {
164
+ num++;
165
+ }
166
+ }
167
+ return num;
168
+ }
164169
165
- /**
166
- * Number of available licenses in this pack
167
- *
168
- * @return
169
- */
170
- @JsonProperty("num_available")
171
- public int getNumAvailables() {
172
- return numLicenses - getNumCreations();
173
- }
170
+ /**
171
+ * Number of available licenses in this pack
172
+ *
173
+ * @return
174
+ */
175
+ @JsonProperty("num_available")
176
+ public int getNumAvailables() {
177
+ return numLicenses - getNumCreations();
178
+ }
174179
175
- @JsonProperty("organization_name")
176
- public String getOrgName() {
177
- return organization == null ? null : organization.getName();
178
- }
180
+ @JsonProperty("organization_name")
181
+ public String getOrgName() {
182
+ return organization == null ? null : organization.getName();
183
+ }
179184
180
- @JsonProperty("application_name")
181
- public String getAppName() {
182
- if (licenseType == null)
183
- return null;
184
- Application app = licenseType.getApplication();
185
- return app == null ? null : app.getName();
186
- }
185
+ @JsonProperty("application_name")
186
+ public String getAppName() {
187
+ if (licenseType == null) {
188
+ return null;
189
+ }
190
+ Application app = licenseType.getApplication();
191
+ return app == null ? null : app.getName();
192
+ }
187193
188
- @JsonProperty("organization_id")
189
- public Integer getOrgId() {
190
- return organization == null ? null : organization.getId();
191
- }
194
+ @JsonProperty("organization_id")
195
+ public Integer getOrgId() {
196
+ return organization == null ? null : organization.getId();
197
+ }
192198
193
- @JsonProperty("organization_id")
194
- public void setOrgId(Integer idOrg) {
195
- if (idOrg == null) {
196
- organization = null;
197
- } else {
198
- organization = new Organization();
199
- organization.setId(idOrg);
200
- }
201
- }
199
+ @JsonProperty("organization_id")
200
+ public void setOrgId(Integer idOrg) {
201
+ if (idOrg == null) {
202
+ organization = null;
203
+ } else {
204
+ organization = new Organization();
205
+ organization.setId(idOrg);
206
+ }
207
+ }
202208
203
- @JsonProperty("license_type_id")
204
- public void setLicTypeId(Integer idLT) {
205
- if (idLT == null) {
206
- licenseType = null;
207
- } else {
208
- licenseType = new LicenseType();
209
- licenseType.setId(idLT);
210
- }
211
- }
209
+ @JsonProperty("license_type_id")
210
+ public void setLicTypeId(Integer idLT) {
211
+ if (idLT == null) {
212
+ licenseType = null;
213
+ } else {
214
+ licenseType = new LicenseType();
215
+ licenseType.setId(idLT);
216
+ }
217
+ }
212218
213
- @JsonProperty("license_type_id")
214
- public Integer getLicTypeId() {
215
- return licenseType == null ? null : licenseType.getId();
216
- }
219
+ @JsonProperty("license_type_id")
220
+ public Integer getLicTypeId() {
221
+ return licenseType == null ? null : licenseType.getId();
222
+ }
217223
218
- @JsonProperty("created_by_id")
219
- public String getCreatedById() {
220
- return createdBy == null ? null : createdBy.getUsername();
221
- }
224
+ @JsonProperty("created_by_id")
225
+ public String getCreatedById() {
226
+ return createdBy == null ? null : createdBy.getUsername();
227
+ }
222228
223
- @JsonProperty("created_by_id")
224
- public void setCreatedById(String username) {
225
- createdBy = new User();
226
- createdBy.setUsername(username);
227
- }
229
+ @JsonProperty("created_by_id")
230
+ public void setCreatedById(String username) {
231
+ createdBy = new User();
232
+ createdBy.setUsername(username);
233
+ }
228234
229
- @JsonProperty("created_by_name")
230
- public String getCreatedByname() {
231
- return createdBy == null ? null : String.format("%s %s (%s)", createdBy.getFirstName(), createdBy.getLastName(), createdBy.getUsername());
232
- }
235
+ @JsonProperty("created_by_name")
236
+ public String getCreatedByname() {
237
+ return createdBy == null ? null : String.format("%s %s (%s)", createdBy.getFirstName(), createdBy.getLastName(), createdBy.getUsername());
238
+ }
233239
234
- @JsonProperty("licensetype_code")
235
- public String getLicenseTypcode() {
236
- return licenseType == null ? null : licenseType.getCode();
237
- }
240
+ @JsonProperty("licensetype_code")
241
+ public String getLicenseTypcode() {
242
+ return licenseType == null ? null : licenseType.getCode();
243
+ }
238244
239
- public String getComments() {
240
- return comments;
241
- }
245
+ public String getComments() {
246
+ return comments;
247
+ }
242248
243
- public void setComments(String comments) {
244
- this.comments = comments;
245
- }
249
+ public void setComments(String comments) {
250
+ this.comments = comments;
251
+ }
246252
247
- public boolean isLicensePreactivation() {
248
- return licensePreactivation;
249
- }
253
+ public boolean isLicensePreactivation() {
254
+ return licensePreactivation;
255
+ }
250256
251
- public void setLicensePreactivation(boolean licensePreactivation) {
252
- this.licensePreactivation = licensePreactivation;
253
- }
257
+ public void setLicensePreactivation(boolean licensePreactivation) {
258
+ this.licensePreactivation = licensePreactivation;
259
+ }
254260
255261 }