| .. | .. |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | import java.io.Serializable; |
|---|
| 4 | 4 | import java.util.Date; |
|---|
| 5 | +import java.util.Set; |
|---|
| 5 | 6 | |
|---|
| 6 | 7 | import javax.persistence.Column; |
|---|
| 7 | 8 | import javax.persistence.Entity; |
|---|
| 9 | +import javax.persistence.FetchType; |
|---|
| 8 | 10 | import javax.persistence.GeneratedValue; |
|---|
| 9 | 11 | import javax.persistence.Id; |
|---|
| 10 | 12 | import javax.persistence.JoinColumn; |
|---|
| 11 | 13 | import javax.persistence.ManyToOne; |
|---|
| 12 | 14 | import javax.persistence.NamedQueries; |
|---|
| 13 | 15 | import javax.persistence.NamedQuery; |
|---|
| 16 | +import javax.persistence.OneToMany; |
|---|
| 14 | 17 | import javax.persistence.Table; |
|---|
| 15 | 18 | |
|---|
| 16 | 19 | import org.apache.logging.log4j.LogManager; |
|---|
| .. | .. |
|---|
| 31 | 34 | @Entity |
|---|
| 32 | 35 | @Table(name = "license_type") |
|---|
| 33 | 36 | @NamedQueries({ |
|---|
| 34 | | - @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt") |
|---|
| 37 | + @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt"), |
|---|
| 38 | + @NamedQuery(name = "list-application-license_types", query = "SELECT lt FROM LicenseType lt where lt.application.id = :appId") |
|---|
| 35 | 39 | }) |
|---|
| 36 | 40 | public class LicenseType implements Serializable { |
|---|
| 37 | 41 | |
|---|
| 42 | + @SuppressWarnings("unused") |
|---|
| 38 | 43 | private static final Logger LOG = LogManager.getLogger(LicenseType.class); |
|---|
| 39 | 44 | private static final long serialVersionUID = 1L; |
|---|
| 40 | 45 | |
|---|
| .. | .. |
|---|
| 53 | 58 | @ManyToOne |
|---|
| 54 | 59 | @JoinColumn(name = "application_id") |
|---|
| 55 | 60 | private Application application; |
|---|
| 61 | + |
|---|
| 62 | + @JsonIgnore |
|---|
| 63 | + // We don't include the referenced entities to limit the size of each row at |
|---|
| 64 | + // the listing |
|---|
| 65 | + @OneToMany(fetch = FetchType.LAZY, mappedBy = "license_type") |
|---|
| 66 | + private Set<LicenseTypeMetadata> metadata; |
|---|
| 67 | + |
|---|
| 68 | + public Set<LicenseTypeMetadata> getMetadata() { |
|---|
| 69 | + return metadata; |
|---|
| 70 | + } |
|---|
| 71 | + |
|---|
| 72 | + public void setMetadata(Set<LicenseTypeMetadata> metadata) { |
|---|
| 73 | + this.metadata = metadata; |
|---|
| 74 | + } |
|---|
| 56 | 75 | |
|---|
| 57 | 76 | public int getId() { |
|---|
| 58 | 77 | return id; |
|---|
| .. | .. |
|---|
| 91 | 110 | } |
|---|
| 92 | 111 | |
|---|
| 93 | 112 | @JsonProperty("application_name") |
|---|
| 94 | | - public String getParentOrgName() { |
|---|
| 113 | + public String getApplicationName() { |
|---|
| 95 | 114 | return application == null ? null : application.getName(); |
|---|
| 96 | 115 | } |
|---|
| 97 | 116 | |
|---|
| 98 | 117 | @JsonProperty("application_id") |
|---|
| 99 | 118 | public Integer getApplicationId() { |
|---|
| 100 | | - LOG.info("application " + application); |
|---|
| 101 | 119 | return application == null ? null : application.getId(); |
|---|
| 102 | 120 | } |
|---|
| 103 | 121 | |
|---|
| 104 | 122 | @JsonProperty("application_id") |
|---|
| 105 | 123 | public void setApplicationId(Integer appId) { |
|---|
| 106 | | - LOG.info("setApplicationId(Integer appId) " + appId); |
|---|
| 107 | | - application = new Application(); |
|---|
| 108 | | - application.setId(appId); |
|---|
| 124 | + if (appId == null) { |
|---|
| 125 | + application = null; |
|---|
| 126 | + } else { |
|---|
| 127 | + application = new Application(); |
|---|
| 128 | + application.setId(appId); |
|---|
| 129 | + } |
|---|
| 109 | 130 | } |
|---|
| 110 | 131 | |
|---|
| 111 | 132 | public void setApplication(Application application) { |
|---|