| .. | .. |
|---|
| 32 | 32 | @Entity |
|---|
| 33 | 33 | @Table(name = "pack") |
|---|
| 34 | 34 | @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") }) |
|---|
| 38 | 37 | public class Pack implements Serializable { |
|---|
| 39 | 38 | |
|---|
| 40 | | - private static final long serialVersionUID = 1L; |
|---|
| 39 | + private static final long serialVersionUID = 1L; |
|---|
| 41 | 40 | |
|---|
| 42 | | - @Id |
|---|
| 43 | | - @GeneratedValue |
|---|
| 44 | | - private int id; |
|---|
| 41 | + @Id |
|---|
| 42 | + @GeneratedValue |
|---|
| 43 | + private int id; |
|---|
| 45 | 44 | |
|---|
| 46 | | - private String code; |
|---|
| 45 | + private String code; |
|---|
| 47 | 46 | |
|---|
| 48 | | - private String comments; |
|---|
| 47 | + private String comments; |
|---|
| 49 | 48 | |
|---|
| 50 | | - @Column(name = "creation_timestamp") |
|---|
| 51 | | - private Date creationTimestamp; |
|---|
| 49 | + @Column(name = "creation_timestamp") |
|---|
| 50 | + private Date creationTimestamp; |
|---|
| 52 | 51 | |
|---|
| 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; |
|---|
| 57 | 56 | |
|---|
| 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; |
|---|
| 62 | 61 | |
|---|
| 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; |
|---|
| 67 | 66 | |
|---|
| 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; |
|---|
| 71 | 70 | |
|---|
| 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; |
|---|
| 75 | 74 | |
|---|
| 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; |
|---|
| 79 | 78 | |
|---|
| 80 | | - public int getId() { |
|---|
| 81 | | - return id; |
|---|
| 82 | | - } |
|---|
| 79 | + public int getId() { |
|---|
| 80 | + return id; |
|---|
| 81 | + } |
|---|
| 83 | 82 | |
|---|
| 84 | | - public void setId(int id) { |
|---|
| 85 | | - this.id = id; |
|---|
| 86 | | - } |
|---|
| 83 | + public void setId(int id) { |
|---|
| 84 | + this.id = id; |
|---|
| 85 | + } |
|---|
| 87 | 86 | |
|---|
| 88 | | - public String getCode() { |
|---|
| 89 | | - return code; |
|---|
| 90 | | - } |
|---|
| 87 | + public String getCode() { |
|---|
| 88 | + return code; |
|---|
| 89 | + } |
|---|
| 91 | 90 | |
|---|
| 92 | | - public void setCode(String code) { |
|---|
| 93 | | - this.code = code; |
|---|
| 94 | | - } |
|---|
| 91 | + public void setCode(String code) { |
|---|
| 92 | + this.code = code; |
|---|
| 93 | + } |
|---|
| 95 | 94 | |
|---|
| 96 | | - public Date getCreationTimestamp() { |
|---|
| 97 | | - return creationTimestamp; |
|---|
| 98 | | - } |
|---|
| 95 | + public Date getCreationTimestamp() { |
|---|
| 96 | + return creationTimestamp; |
|---|
| 97 | + } |
|---|
| 99 | 98 | |
|---|
| 100 | | - public void setCreationTimestamp(Date creationTimestamp) { |
|---|
| 101 | | - this.creationTimestamp = creationTimestamp; |
|---|
| 102 | | - } |
|---|
| 99 | + public void setCreationTimestamp(Date creationTimestamp) { |
|---|
| 100 | + this.creationTimestamp = creationTimestamp; |
|---|
| 101 | + } |
|---|
| 103 | 102 | |
|---|
| 104 | | - public Organization getOrganization() { |
|---|
| 105 | | - return organization; |
|---|
| 106 | | - } |
|---|
| 103 | + public Organization getOrganization() { |
|---|
| 104 | + return organization; |
|---|
| 105 | + } |
|---|
| 107 | 106 | |
|---|
| 108 | | - public void setOrganization(Organization organization) { |
|---|
| 109 | | - this.organization = organization; |
|---|
| 110 | | - } |
|---|
| 107 | + public void setOrganization(Organization organization) { |
|---|
| 108 | + this.organization = organization; |
|---|
| 109 | + } |
|---|
| 111 | 110 | |
|---|
| 112 | | - public LicenseType getLicenseType() { |
|---|
| 113 | | - return licenseType; |
|---|
| 114 | | - } |
|---|
| 111 | + public LicenseType getLicenseType() { |
|---|
| 112 | + return licenseType; |
|---|
| 113 | + } |
|---|
| 115 | 114 | |
|---|
| 116 | | - public void setLicenseType(LicenseType licenseType) { |
|---|
| 117 | | - this.licenseType = licenseType; |
|---|
| 118 | | - } |
|---|
| 115 | + public void setLicenseType(LicenseType licenseType) { |
|---|
| 116 | + this.licenseType = licenseType; |
|---|
| 117 | + } |
|---|
| 119 | 118 | |
|---|
| 120 | | - public User getCreatedBy() { |
|---|
| 121 | | - return createdBy; |
|---|
| 122 | | - } |
|---|
| 119 | + public User getCreatedBy() { |
|---|
| 120 | + return createdBy; |
|---|
| 121 | + } |
|---|
| 123 | 122 | |
|---|
| 124 | | - public void setCreatedBy(User createdBy) { |
|---|
| 125 | | - this.createdBy = createdBy; |
|---|
| 126 | | - } |
|---|
| 123 | + public void setCreatedBy(User createdBy) { |
|---|
| 124 | + this.createdBy = createdBy; |
|---|
| 125 | + } |
|---|
| 127 | 126 | |
|---|
| 128 | | - public int getNumLicenses() { |
|---|
| 129 | | - return numLicenses; |
|---|
| 130 | | - } |
|---|
| 127 | + public int getNumLicenses() { |
|---|
| 128 | + return numLicenses; |
|---|
| 129 | + } |
|---|
| 131 | 130 | |
|---|
| 132 | | - public void setNumLicenses(int numLicenses) { |
|---|
| 133 | | - this.numLicenses = numLicenses; |
|---|
| 134 | | - } |
|---|
| 131 | + public void setNumLicenses(int numLicenses) { |
|---|
| 132 | + this.numLicenses = numLicenses; |
|---|
| 133 | + } |
|---|
| 135 | 134 | |
|---|
| 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 | + } |
|---|
| 147 | 148 | |
|---|
| 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 | + } |
|---|
| 164 | 169 | |
|---|
| 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 | + } |
|---|
| 174 | 179 | |
|---|
| 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 | + } |
|---|
| 179 | 184 | |
|---|
| 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 | + } |
|---|
| 187 | 193 | |
|---|
| 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 | + } |
|---|
| 192 | 198 | |
|---|
| 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 | + } |
|---|
| 202 | 208 | |
|---|
| 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 | + } |
|---|
| 212 | 218 | |
|---|
| 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 | + } |
|---|
| 217 | 223 | |
|---|
| 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 | + } |
|---|
| 222 | 228 | |
|---|
| 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 | + } |
|---|
| 228 | 234 | |
|---|
| 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 | + } |
|---|
| 233 | 239 | |
|---|
| 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 | + } |
|---|
| 238 | 244 | |
|---|
| 239 | | - public String getComments() { |
|---|
| 240 | | - return comments; |
|---|
| 241 | | - } |
|---|
| 245 | + public String getComments() { |
|---|
| 246 | + return comments; |
|---|
| 247 | + } |
|---|
| 242 | 248 | |
|---|
| 243 | | - public void setComments(String comments) { |
|---|
| 244 | | - this.comments = comments; |
|---|
| 245 | | - } |
|---|
| 249 | + public void setComments(String comments) { |
|---|
| 250 | + this.comments = comments; |
|---|
| 251 | + } |
|---|
| 246 | 252 | |
|---|
| 247 | | - public boolean isLicensePreactivation() { |
|---|
| 248 | | - return licensePreactivation; |
|---|
| 249 | | - } |
|---|
| 253 | + public boolean isLicensePreactivation() { |
|---|
| 254 | + return licensePreactivation; |
|---|
| 255 | + } |
|---|
| 250 | 256 | |
|---|
| 251 | | - public void setLicensePreactivation(boolean licensePreactivation) { |
|---|
| 252 | | - this.licensePreactivation = licensePreactivation; |
|---|
| 253 | | - } |
|---|
| 257 | + public void setLicensePreactivation(boolean licensePreactivation) { |
|---|
| 258 | + this.licensePreactivation = licensePreactivation; |
|---|
| 259 | + } |
|---|
| 254 | 260 | |
|---|
| 255 | 261 | } |
|---|