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  /**
35   * A Catalog CategoryDto.
36   */
37  @Entity
38  @Table(name = "CATALOG_CATEGORY",
39          uniqueConstraints = { @UniqueConstraint(columnNames = { "NAME" })})
40  public class CategoryModel implements Serializable {
41      private static final long serialVersionUID = 5776108323599073407L;
42  
43      @Id
44      @GeneratedValue(strategy= GenerationType.IDENTITY)
45      @Column(name = "ID")
46      private Long id;
47      @Column(name = "NAME")
48      private String name;
49      @Column(name = "DISPLAY_NAME")
50      private String displayName;
51      @Column(name = "DESCRIPTION")
52      private String description;
53      @Column(name = "CATALOG_ID")
54      private String catalogId;
55      @ManyToMany(fetch = FetchType.EAGER)
56      @JoinTable(name = "category_events", joinColumns = { @JoinColumn(name = "category_id")},
57              inverseJoinColumns = { @JoinColumn(name = "event_id")})
58      private List<EventModel> events;
59  
60      public CategoryModel() {
61          catalogId = "DEFAULT";
62      }
63  
64      /**
65       * Returns the id of the AttributeDto.
66       * @return
67       */
68      public Long getId() {
69          return id;
70      }
71  
72      /**
73       * Set the id of the AttributeDto.
74       * @param id
75       */
76      public void setId(Long id) {
77          this.id = id;
78      }
79  
80      /**
81       * Gets the value of the name property.
82       *
83       * @return possible object is
84       * {@link String }
85       */
86      public String getName() {
87          return name;
88      }
89  
90      /**
91       * Sets the value of the name property.
92       *
93       * @param value allowed object is
94       *              {@link String }
95       */
96      public void setName(String value) {
97          this.name = value;
98      }
99  
100     /**
101      * The value used when displaying the category name.
102      * @return the display name.
103      */
104     public String getDisplayName() {
105         return displayName;
106     }
107 
108     /**
109      * Sets the value to be used when displaying the name.
110      * @param dislpayName The display name.
111      */
112     public void setDisplayName(String dislpayName) {
113         this.displayName = dislpayName;
114     }
115 
116     /**
117      * Gets the value of the description property.
118      *
119      * @return possible object is
120      * {@link String }
121      */
122     public String getDescription() {
123         return description;
124     }
125 
126     /**
127      * Sets the value of the description property.
128      *
129      * @param value allowed object is
130      *              {@link String }
131      */
132     public void setDescription(String value) {
133         this.description = value;
134     }
135 
136     /**
137      * Get the Catalog Id this Category is associated with.
138      * @return the catalog id or null.
139      */
140     public String getCatalogId() {
141         return catalogId;
142     }
143 
144     /**
145      * Set the catalog id this Category is associated with.
146      * @param catalogId The catalog id or null.
147      */
148     public void setCatalogId(String catalogId) {
149         this.catalogId = catalogId;
150     }
151 
152     /**
153      * Return the List of EventDto objects.
154      * @return the List of Events or null.
155      */
156     public List<EventModel> getEvents() {
157         return events;
158     }
159 
160     /**
161      * Sets the List of EventDto objects.
162      * @param events the List of Events.
163      */
164     public void setEvents(List<EventModel> events) {
165         this.events = events;
166     }
167 
168 }