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