[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / ProcessingFlags.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.db.catalog.beans;
22
23 import java.util.Date;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.Lob;
30 import javax.persistence.PrePersist;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.apache.commons.lang3.builder.EqualsBuilder;
35 import org.apache.commons.lang3.builder.HashCodeBuilder;
36 import org.apache.commons.lang3.builder.ToStringBuilder;
37 import org.apache.commons.lang3.builder.ToStringStyle;
38 import org.hibernate.annotations.UpdateTimestamp;
39 import com.fasterxml.jackson.annotation.JsonAutoDetect;
40 import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
41 import com.fasterxml.jackson.annotation.JsonProperty;
42 import com.openpojo.business.annotation.BusinessKey;
43 import uk.co.blackpepper.bowman.annotation.RemoteResource;
44
45
46 /**
47  * EntityBean class for ProcessingFlags. This bean represents a set of flags governing request processing.
48  *
49  */
50 @RemoteResource("/processingFlags")
51 @Entity
52 @Table(name = "processing_flags")
53 @JsonAutoDetect(fieldVisibility = Visibility.ANY)
54 public class ProcessingFlags {
55
56     @Id
57     @Column(name = "ID", nullable = false, updatable = false)
58     @GeneratedValue(strategy = GenerationType.IDENTITY)
59     private Integer id;
60
61     @JsonProperty("flag")
62     @BusinessKey
63     @Column(name = "FLAG")
64     private String flag;
65
66     @JsonProperty("value")
67     @BusinessKey
68     @Column(name = "VALUE")
69     private String value;
70
71     @JsonProperty("endpoint")
72     @BusinessKey
73     @Column(name = "ENDPOINT")
74     private String endpoint;
75
76     @JsonProperty("description")
77     @Lob
78     @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
79     private String description = null;
80
81     @JsonProperty("creation_timestamp")
82     @BusinessKey
83     @Column(name = "CREATION_TIMESTAMP", updatable = false)
84     @Temporal(TemporalType.TIMESTAMP)
85     private Date created;
86
87     @JsonProperty("update_timestamp")
88     @BusinessKey
89     @Column(name = "UPDATE_TIMESTAMP")
90     @Temporal(TemporalType.TIMESTAMP)
91     @UpdateTimestamp
92     private Date updated;
93
94     public ProcessingFlags() {
95
96     }
97
98     @PrePersist
99     protected void onCreate() {
100         this.created = new Date();
101         // this.updated = new Date();
102     }
103
104     public ProcessingFlags(ProcessingFlags flags) {
105         this.flag = flags.getFlag();
106         this.value = flags.getValue();
107         this.endpoint = flags.getEndpoint();
108         this.description = flags.getDescription();
109     }
110
111     public Integer getId() {
112         return this.id;
113     }
114
115     public String getFlag() {
116         return flag;
117     }
118
119     public void setFlag(String flag) {
120         this.flag = flag;
121     }
122
123     public String getValue() {
124         return value;
125     }
126
127     public void setValue(String value) {
128         this.value = value;
129     }
130
131     public String getEndpoint() {
132         return endpoint;
133     }
134
135     public void setEndpoint(String endpoint) {
136         this.endpoint = endpoint;
137     }
138
139     public String getDescription() {
140         return description;
141     }
142
143     public void setDescription(String description) {
144         this.description = description;
145     }
146
147     public Date getCreated() {
148         return created;
149     }
150
151     public void setCreated(Date created) {
152         this.created = created;
153     }
154
155     public Date getUpdated() {
156         return updated;
157     }
158
159     public void setUpdated(Date updated) {
160         this.updated = updated;
161     }
162
163     @Override
164     public String toString() {
165         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("flag", getFlag())
166                 .append("value", getValue()).append("endpoint", getEndpoint()).append("description", getDescription())
167                 .toString();
168     }
169
170     @Override
171     public boolean equals(final Object other) {
172         if (other == null) {
173             return false;
174         }
175         if (!getClass().equals(other.getClass())) {
176             return false;
177         }
178         ProcessingFlags castOther = (ProcessingFlags) other;
179         return new EqualsBuilder().append(getFlag(), castOther.getFlag()).append(getValue(), castOther.getValue())
180                 .isEquals();
181     }
182
183     @Override
184     public int hashCode() {
185         return new HashCodeBuilder(1, 31).append(getFlag()).append(getValue()).append(getEndpoint()).toHashCode();
186     }
187 }