From 79121484b7e6f721f5435a102018152a164ed655 Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Wed, 22 Jan 2014 18:55:29 +0000
Subject: [PATCH] #395 feature - Implemented pack section

---
 securis/src/main/java/net/curisit/securis/db/Pack.java |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 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 39e99ab..254d6b0 100644
--- a/securis/src/main/java/net/curisit/securis/db/Pack.java
+++ b/securis/src/main/java/net/curisit/securis/db/Pack.java
@@ -8,6 +8,7 @@
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
@@ -31,15 +32,18 @@
 @Table(name = "pack")
 @NamedQueries(
 	{ @NamedQuery(name = "list-packs", query = "SELECT pa FROM Pack pa"),//
-			@NamedQuery(name = "list-packs-by-org", query = "SELECT pa FROM Pack pa where pa.organization = :organization") })
+			@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;
 
 	@Id
+	@GeneratedValue
 	private int id;
 
 	private String code;
+
+	private String comments;
 
 	@Column(name = "creation_timestamp")
 	private Date creationTimestamp;
@@ -63,7 +67,8 @@
 	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "pack")
 	private Set<License> licenses;
 
-	@JoinColumn(name = "num_licenses")
+	@Column(name = "num_licenses")
+	@JsonProperty("num_licenses")
 	private int numLicenses;
 
 	public int getId() {
@@ -190,6 +195,16 @@
 	}
 
 	@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();
 	}
@@ -205,9 +220,22 @@
 		createdBy.setUsername(username);
 	}
 
+	@JsonProperty("created_by_name")
+	public String getCreatedByname() {
+		return createdBy == null ? null : String.format("%s %s", createdBy.getFirstName(), createdBy.getFirstName());
+	}
+
 	@JsonProperty("licensetype_code")
 	public String getLicenseTypcode() {
 		return licenseType == null ? null : licenseType.getCode();
 	}
 
+	public String getComments() {
+		return comments;
+	}
+
+	public void setComments(String comments) {
+		this.comments = comments;
+	}
+
 }

--
Gitblit v1.3.2