0a74c1d7becf062f1fdf467de576a9654385c473
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / RequestProcessingData.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.request.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.PrePersist;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35
36 import org.apache.commons.lang3.builder.EqualsBuilder;
37 import org.apache.commons.lang3.builder.HashCodeBuilder;
38 import org.apache.commons.lang3.builder.ToStringBuilder;
39
40 import com.fasterxml.jackson.annotation.JsonInclude;
41 import com.fasterxml.jackson.annotation.JsonInclude.Include;
42 import com.openpojo.business.annotation.BusinessKey;
43
44 /**
45  * persist the request identifiers created when MSO POSTs a request to PINC 
46  * <br>
47  * <p>
48  * </p>
49  * 
50  * @author
51  * @version 
52  */
53
54 @Entity
55
56 @JsonInclude(Include.NON_NULL)
57 @Table(name = "request_processing_data")
58 public class RequestProcessingData implements Serializable{
59
60         /**
61      * 
62      */
63         private static final long serialVersionUID = -3497593687393936143L;
64
65         @Id
66         @GeneratedValue(strategy = GenerationType.IDENTITY)
67         @Column(name = "ID")
68         private Integer id;
69         
70         @BusinessKey
71         @Column(name = "SO_REQUEST_ID", length=50, unique=true)
72         private String soRequestId;
73         
74         @BusinessKey
75         @Column(name = "GROUPING_ID", length=100, unique=true)
76         private String groupingId;
77         
78         @BusinessKey
79         @Column(name = "NAME", length=200)
80         private String name;
81         
82         @Column(name = "VALUE", columnDefinition = "LONGTEXT")
83         private String value;
84         
85         @BusinessKey
86         @Column(name = "TAG", length=200)
87         private String tag;
88         
89         @Column(name = "CREATE_TIME", insertable = false, updatable = false)
90         @Temporal(TemporalType.TIMESTAMP)
91         private Date created = null;
92
93         @Override
94         public boolean equals(final Object other) {
95                 if (!(other instanceof RequestProcessingData)) {
96                         return false;
97                 }
98                 RequestProcessingData castOther = (RequestProcessingData) other;
99                 return new EqualsBuilder().append(soRequestId, castOther.soRequestId).append(groupingId, castOther.groupingId)
100                                 .append(name, castOther.name).append(tag, castOther.tag).isEquals();
101         }
102
103         @Override
104         public int hashCode() {
105                 return new HashCodeBuilder().append(soRequestId).append(groupingId).append(name).append(tag).toHashCode();
106         }
107
108         @Override
109         public String toString() {
110                 return new ToStringBuilder(this).append("id", id).append("soRequestId", soRequestId)
111                                 .append("groupingId", groupingId).append("name", name).append("value", value).append("tag", tag)
112                                 .toString();
113         }
114
115         @PrePersist
116         protected void createdAt() {
117                 this.created = new Date();
118         }
119         
120         public Integer getId() {
121                 return id;
122         }
123
124         public void setId(Integer id) {
125                 this.id = id;
126         }
127
128         public String getSoRequestId() {
129                 return soRequestId;
130         }
131
132         public void setSoRequestId(String soRequestId) {
133                 this.soRequestId = soRequestId;
134         }
135
136         public String getGroupingId() {
137                 return groupingId;
138         }
139
140         public void setGroupingId(String groupingId) {
141                 this.groupingId = groupingId;
142         }
143
144         public String getName() {
145                 return name;
146         }
147
148         public void setName(String name) {
149                 this.name = name;
150         }
151
152         public String getValue() {
153                 return value;
154         }
155
156         public void setValue(String value) {
157                 this.value = value;
158         }
159
160         public String getTag() {
161                 return tag;
162         }
163
164         public void setTag(String tag) {
165                 this.tag = tag;
166         }
167         
168     public Date getCreated() {
169                 return created;
170         }
171 }