From 8d5386be38db25a2a41c3bf6c876adee21ca26cc Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Fri, 19 Sep 2014 08:26:02 +0000
Subject: [PATCH] #396 fix - Fixed more SonarQube issues
---
securis/src/main/java/net/curisit/securis/db/Pack.java | 358 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 182 insertions(+), 176 deletions(-)
diff --git a/securis/src/main/java/net/curisit/securis/db/Pack.java b/securis/src/main/java/net/curisit/securis/db/Pack.java
index 7812fbc..1e5ab59 100644
--- a/securis/src/main/java/net/curisit/securis/db/Pack.java
+++ b/securis/src/main/java/net/curisit/securis/db/Pack.java
@@ -32,224 +32,230 @@
@Entity
@Table(name = "pack")
@JsonIgnoreProperties(ignoreUnknown = true)
-@NamedQueries(
- { @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
- @NamedQuery(name = "list-packs-by-orgs", query = "SELECT pa FROM Pack pa where pa.organization.id in :list_ids") })
+@NamedQueries({ @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
+ @NamedQuery(name = "list-packs-by-orgs", query = "SELECT pa FROM Pack pa where pa.organization.id in :list_ids") })
public class Pack implements Serializable {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue
- private int id;
+ @Id
+ @GeneratedValue
+ private int id;
- private String code;
+ private String code;
- private String comments;
+ private String comments;
- @Column(name = "creation_timestamp")
- private Date creationTimestamp;
+ @Column(name = "creation_timestamp")
+ private Date creationTimestamp;
- @JsonIgnore
- @ManyToOne
- @JoinColumn(name = "organization_id")
- private Organization organization;
+ @JsonIgnore
+ @ManyToOne
+ @JoinColumn(name = "organization_id")
+ private Organization organization;
- @JsonIgnore
- @ManyToOne
- @JoinColumn(name = "license_type_id")
- private LicenseType licenseType;
+ @JsonIgnore
+ @ManyToOne
+ @JoinColumn(name = "license_type_id")
+ private LicenseType licenseType;
- @JsonIgnore
- @ManyToOne
- @JoinColumn(name = "created_by")
- private User createdBy;
+ @JsonIgnore
+ @ManyToOne
+ @JoinColumn(name = "created_by")
+ private User createdBy;
- @JsonIgnore
- @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "pack")
- private Set<License> licenses;
+ @JsonIgnore
+ @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "pack")
+ private Set<License> licenses;
- @Column(name = "num_licenses")
- @JsonProperty("num_licenses")
- private int numLicenses;
+ @Column(name = "num_licenses")
+ @JsonProperty("num_licenses")
+ private int numLicenses;
- @Column(name = "license_preactivation")
- @JsonProperty("license_preactivation")
- private boolean licensePreactivation;
+ @Column(name = "license_preactivation")
+ @JsonProperty("license_preactivation")
+ private boolean licensePreactivation;
- public int getId() {
- return id;
- }
+ public int getId() {
+ return id;
+ }
- public void setId(int id) {
- this.id = id;
- }
+ public void setId(int id) {
+ this.id = id;
+ }
- public String getCode() {
- return code;
- }
+ public String getCode() {
+ return code;
+ }
- public void setCode(String code) {
- this.code = code;
- }
+ public void setCode(String code) {
+ this.code = code;
+ }
- public Date getCreationTimestamp() {
- return creationTimestamp;
- }
+ public Date getCreationTimestamp() {
+ return creationTimestamp;
+ }
- public void setCreationTimestamp(Date creationTimestamp) {
- this.creationTimestamp = creationTimestamp;
- }
+ public void setCreationTimestamp(Date creationTimestamp) {
+ this.creationTimestamp = creationTimestamp;
+ }
- public Organization getOrganization() {
- return organization;
- }
+ public Organization getOrganization() {
+ return organization;
+ }
- public void setOrganization(Organization organization) {
- this.organization = organization;
- }
+ public void setOrganization(Organization organization) {
+ this.organization = organization;
+ }
- public LicenseType getLicenseType() {
- return licenseType;
- }
+ public LicenseType getLicenseType() {
+ return licenseType;
+ }
- public void setLicenseType(LicenseType licenseType) {
- this.licenseType = licenseType;
- }
+ public void setLicenseType(LicenseType licenseType) {
+ this.licenseType = licenseType;
+ }
- public User getCreatedBy() {
- return createdBy;
- }
+ public User getCreatedBy() {
+ return createdBy;
+ }
- public void setCreatedBy(User createdBy) {
- this.createdBy = createdBy;
- }
+ public void setCreatedBy(User createdBy) {
+ this.createdBy = createdBy;
+ }
- public int getNumLicenses() {
- return numLicenses;
- }
+ public int getNumLicenses() {
+ return numLicenses;
+ }
- public void setNumLicenses(int numLicenses) {
- this.numLicenses = numLicenses;
- }
+ public void setNumLicenses(int numLicenses) {
+ this.numLicenses = numLicenses;
+ }
- @JsonProperty("num_activations")
- public int getNumActivations() {
- if (licenses == null)
- return 0;
- int num = 0;
- for (License lic : licenses) {
- if (lic.getStatus() == License.Status.ACTIVE)
- num++;
- }
- return num;
- }
+ @JsonProperty("num_activations")
+ public int getNumActivations() {
+ if (licenses == null) {
+ return 0;
+ }
+ int num = 0;
+ for (License lic : licenses) {
+ if (lic.getStatus() == License.Status.ACTIVE) {
+ num++;
+ }
+ }
+ return num;
+ }
- /**
- * 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.
- *
- * @return
- */
- @JsonProperty("num_creations")
- public int getNumCreations() {
- if (licenses == null)
- return 0;
- int num = 0;
- for (License lic : licenses) {
- if (lic.getStatus() != License.Status.CANCELED)
- num++;
- }
- return num;
- }
+ /**
+ * 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.
+ *
+ * @return
+ */
+ @JsonProperty("num_creations")
+ public int getNumCreations() {
+ if (licenses == null) {
+ return 0;
+ }
+ int num = 0;
+ for (License lic : licenses) {
+ if (lic.getStatus() != License.Status.CANCELED) {
+ num++;
+ }
+ }
+ return num;
+ }
- /**
- * Number of available licenses in this pack
- *
- * @return
- */
- @JsonProperty("num_available")
- public int getNumAvailables() {
- return numLicenses - getNumCreations();
- }
+ /**
+ * Number of available licenses in this pack
+ *
+ * @return
+ */
+ @JsonProperty("num_available")
+ public int getNumAvailables() {
+ return numLicenses - getNumCreations();
+ }
- @JsonProperty("organization_name")
- public String getOrgName() {
- return organization == null ? null : organization.getName();
- }
+ @JsonProperty("organization_name")
+ public String getOrgName() {
+ return organization == null ? null : organization.getName();
+ }
- @JsonProperty("application_name")
- public String getAppName() {
- if (licenseType == null)
- return null;
- Application app = licenseType.getApplication();
- return app == null ? null : app.getName();
- }
+ @JsonProperty("application_name")
+ public String getAppName() {
+ if (licenseType == null) {
+ return null;
+ }
+ Application app = licenseType.getApplication();
+ return app == null ? null : app.getName();
+ }
- @JsonProperty("organization_id")
- public Integer getOrgId() {
- return organization == null ? null : organization.getId();
- }
+ @JsonProperty("organization_id")
+ public Integer getOrgId() {
+ return organization == null ? null : organization.getId();
+ }
- @JsonProperty("organization_id")
- public void setOrgId(Integer idOrg) {
- if (idOrg == null) {
- organization = null;
- } else {
- organization = new Organization();
- organization.setId(idOrg);
- }
- }
+ @JsonProperty("organization_id")
+ public void setOrgId(Integer idOrg) {
+ if (idOrg == null) {
+ organization = null;
+ } else {
+ organization = new Organization();
+ organization.setId(idOrg);
+ }
+ }
- @JsonProperty("license_type_id")
- public void setLicTypeId(Integer idLT) {
- if (idLT == null) {
- licenseType = null;
- } else {
- licenseType = new LicenseType();
- licenseType.setId(idLT);
- }
- }
+ @JsonProperty("license_type_id")
+ public void setLicTypeId(Integer idLT) {
+ if (idLT == null) {
+ licenseType = null;
+ } else {
+ licenseType = new LicenseType();
+ licenseType.setId(idLT);
+ }
+ }
- @JsonProperty("license_type_id")
- public Integer getLicTypeId() {
- return licenseType == null ? null : licenseType.getId();
- }
+ @JsonProperty("license_type_id")
+ public Integer getLicTypeId() {
+ return licenseType == null ? null : licenseType.getId();
+ }
- @JsonProperty("created_by_id")
- public String getCreatedById() {
- return createdBy == null ? null : createdBy.getUsername();
- }
+ @JsonProperty("created_by_id")
+ public String getCreatedById() {
+ return createdBy == null ? null : createdBy.getUsername();
+ }
- @JsonProperty("created_by_id")
- public void setCreatedById(String username) {
- createdBy = new User();
- createdBy.setUsername(username);
- }
+ @JsonProperty("created_by_id")
+ public void setCreatedById(String username) {
+ createdBy = new User();
+ createdBy.setUsername(username);
+ }
- @JsonProperty("created_by_name")
- public String getCreatedByname() {
- return createdBy == null ? null : String.format("%s %s (%s)", createdBy.getFirstName(), createdBy.getLastName(), createdBy.getUsername());
- }
+ @JsonProperty("created_by_name")
+ public String getCreatedByname() {
+ return createdBy == null ? null : String.format("%s %s (%s)", createdBy.getFirstName(), createdBy.getLastName(), createdBy.getUsername());
+ }
- @JsonProperty("licensetype_code")
- public String getLicenseTypcode() {
- return licenseType == null ? null : licenseType.getCode();
- }
+ @JsonProperty("licensetype_code")
+ public String getLicenseTypcode() {
+ return licenseType == null ? null : licenseType.getCode();
+ }
- public String getComments() {
- return comments;
- }
+ public String getComments() {
+ return comments;
+ }
- public void setComments(String comments) {
- this.comments = comments;
- }
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
- public boolean isLicensePreactivation() {
- return licensePreactivation;
- }
+ public boolean isLicensePreactivation() {
+ return licensePreactivation;
+ }
- public void setLicensePreactivation(boolean licensePreactivation) {
- this.licensePreactivation = licensePreactivation;
- }
+ public void setLicensePreactivation(boolean licensePreactivation) {
+ this.licensePreactivation = licensePreactivation;
+ }
}
--
Gitblit v1.3.2