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.Entity;
21  import javax.persistence.GeneratedValue;
22  import javax.persistence.GenerationType;
23  import javax.persistence.Id;
24  import javax.persistence.JoinColumn;
25  import javax.persistence.ManyToOne;
26  import javax.persistence.Table;
27  import java.io.Serializable;
28  
29  /**
30   * A Catalog Attribute Constraint.
31   */
32  @Entity
33  @Table(name = "ATTRIBUTE_CONSTRAINT")
34  public class ConstraintModel implements Serializable {
35  
36      private static final long serialVersionUID = 6836453963830996541L;
37  
38      @Id
39      @GeneratedValue(strategy= GenerationType.IDENTITY)
40      @Column(name = "ID")
41      private Long id;
42      @ManyToOne
43      @JoinColumn(name = "ATTRIBUTE_ID")
44      private AttributeModel attribute;
45      @Column(name = "CONSTRAINT_TYPE")
46      private String constraintType;
47      @Column(name = "VALUE")
48      private String value;
49  
50      public Long getId() {
51          return id;
52      }
53  
54      public void setId(Long id) {
55          this.id = id;
56      }
57  
58      public String getConstraintType() {
59          return constraintType;
60      }
61  
62      public void setConstraintType(String constraintType) {
63          this.constraintType = constraintType;
64      }
65  
66      public String getValue() {
67          return value;
68      }
69  
70      public void setValue(String value) {
71          this.value = value;
72      }
73  
74      public AttributeModel getAttribute() {
75          return attribute;
76      }
77  
78      public void setAttribute(AttributeModel attribute) {
79          this.attribute = attribute;
80          if (attribute.getConstraints() != null && !attribute.getConstraints().contains(this)) {
81              attribute.getConstraints().add(this);
82          }
83  
84      }
85  }