1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
58
59
60 public Long getId() {
61 return id;
62 }
63
64
65
66
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 }