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.Column;
20  import javax.persistence.Convert;
21  import javax.persistence.Entity;
22  import javax.persistence.GeneratedValue;
23  import javax.persistence.GenerationType;
24  import javax.persistence.Id;
25  import javax.persistence.JoinColumn;
26  import javax.persistence.ManyToOne;
27  import javax.persistence.Table;
28  import java.io.Serializable;
29  
30  import org.apache.logging.log4j.catalog.jpa.converter.BooleanToStringConverter;
31  
32  /**
33   *
34   */
35  @Entity
36  @Table(name = "event_attributes")
37  public class EventAttributeModel implements Serializable {
38  
39      @Id
40      @GeneratedValue(strategy= GenerationType.IDENTITY)
41      @Column(name = "ID", updatable = false, nullable = false)
42      private Long id;
43  
44      @ManyToOne
45      @JoinColumn(name = "event_id", referencedColumnName = "id")
46      private EventModel event;
47  
48      @ManyToOne
49      @JoinColumn(name = "attribute_id", referencedColumnName = "id")
50      private AttributeModel attribute;
51  
52      @Column(name = "is_required")
53      @Convert(converter=BooleanToStringConverter.class)
54      private Boolean isRequired;
55  
56      /**
57       * Return the identifier for this event.
58       * @return the identifier for this event.
59       */
60      public Long getId() {
61          return id;
62      }
63  
64      /**
65       * Set the identifier for this event.
66       * @param id the identifier for this event.
67       */
68      public void setId(Long id) {
69          this.id = id;
70      }
71  
72      public EventModel getEvent() {
73          return event;
74      }
75  
76      public void setEvent(EventModel event) {
77          this.event = event;
78      }
79  
80      public AttributeModel getAttribute() {
81          return attribute;
82      }
83  
84      public void setAttribute(AttributeModel attribute) {
85          this.attribute = attribute;
86      }
87  
88      public Boolean isRequired() {
89          return isRequired;
90      }
91  
92      public void setRequired(Boolean required) {
93          isRequired = required;
94      }
95  
96      @Override
97      public boolean equals(Object o) {
98          if (this == o) {
99              return true;
100         }
101         if (o == null || getClass() != o.getClass()) {
102             return false;
103         }
104 
105         EventAttributeModel that = (EventAttributeModel) o;
106 
107         if (!event.equals(that.event)) {
108             return false;
109         }
110         return attribute.equals(that.attribute);
111     }
112 
113     @Override
114     public int hashCode() {
115         int result = event == null ? 0 : event.hashCode();
116         result = 31 * result + attribute.hashCode();
117         return result;
118     }
119 }