View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  package org.apache.logging.log4j.catalog.jpa.model;
18  
19  import javax.persistence.CascadeType;
20  import javax.persistence.Column;
21  import javax.persistence.Entity;
22  import javax.persistence.FetchType;
23  import javax.persistence.GeneratedValue;
24  import javax.persistence.GenerationType;
25  import javax.persistence.Id;
26  import javax.persistence.JoinColumn;
27  import javax.persistence.JoinTable;
28  import javax.persistence.ManyToMany;
29  import javax.persistence.Table;
30  import javax.persistence.UniqueConstraint;
31  import java.io.Serializable;
32  import java.util.List;
33  
34  import org.apache.logging.log4j.catalog.api.Product;
35  
36  /**
37   * Definition of a ProductDto.
38   */
39  @Entity
40  @Table(name = "CATALOG_PRODUCT",
41          uniqueConstraints = { @UniqueConstraint(columnNames = { "NAME" })})
42  public class ProductModel implements Serializable {
43      private static final long serialVersionUID = -736368842796386523L;
44      @Id
45      @GeneratedValue(strategy= GenerationType.IDENTITY)
46      @Column(name = "ID")
47      private Long id;
48      @Column(name = "NAME")
49      private String name;
50      @Column(name = "DISPLAY_NAME")
51      private String displayName;
52      @Column(name = "DESCRIPTION")
53      private String description;
54      @Column(name = "CATALOG_ID")
55      private String catalogId;
56      @ManyToMany(fetch = FetchType.EAGER)
57      @JoinTable(name = "PRODUCT_EVENTS", joinColumns = { @JoinColumn(name = "PRODUCT_ID")},
58              inverseJoinColumns = { @JoinColumn(name = "EVENT_ID")})
59      private List<EventModel> events;
60  
61      public ProductModel() {
62          catalogId = "DEFAULT";
63      }
64  
65      public Long getId() {
66          return id;
67      }
68  
69      public void setId(Long id) {
70          this.id = id;
71      }
72  
73      /**
74       * Returns the name of the product.
75       * @return the name of the product.
76       */
77      public String getName() {
78          return name;
79      }
80  
81      /**
82       * Set the name of the product.
83       * @param name the name of the product.
84       */
85      public void setName(String name) {
86          this.name = name;
87      }
88  
89      /**
90       * The value used when displaying the category name.
91       * @return the display name.
92       */
93      public String getDisplayName() {
94          return displayName;
95      }
96  
97      /**
98       * Sets the value to be used when displaying the name.
99       * @param dislpayName The display name.
100      */
101     public void setDisplayName(String dislpayName) {
102         this.displayName = dislpayName;
103     }
104     /**
105      * Return the product description.
106      * @return the description of the product.
107      */
108     public String getDescription() {
109         return description;
110     }
111 
112     /**
113      * Set the description of the product.
114      * @param description the description of the product.
115      */
116     public void setDescription(String description) {
117         this.description = description;
118     }
119 
120     /**
121      * Get the Catalog Id this Product is associated with.
122      * @return the catalog id or null.
123      */
124     public String getCatalogId() {
125         return catalogId;
126     }
127 
128     /**
129      * Set the catalog id this Product is associated with.
130      * @param catalogId The catalog id or null.
131      */
132     public void setCatalogId(String catalogId) {
133         this.catalogId = catalogId;
134     }
135 
136     /**
137      * Returns the List of EventDto objects associated with this product.
138      * @return the List of Events.
139      */
140     public List<EventModel> getEvents() {
141         return events;
142     }
143 
144     /**
145      * Sets the List of EventDto objects.
146      * @param events the List of Events.
147      */
148     public void setEvents(List<EventModel> events) {
149         this.events = events;
150     }
151 
152 }