Merge remote-tracking branch 'origin/dublin' into 'origin/master'
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / CloudApiRequests.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017-2019 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
22 package org.onap.so.db.request.beans;
23
24 import java.io.Serializable;
25 import java.util.Date;
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 import org.apache.commons.lang3.builder.EqualsBuilder;
36 import org.apache.commons.lang3.builder.HashCodeBuilder;
37 import org.apache.commons.lang3.builder.ToStringBuilder;
38 import com.fasterxml.jackson.annotation.JsonIgnore;
39 import com.fasterxml.jackson.annotation.JsonInclude;
40 import com.fasterxml.jackson.annotation.JsonInclude.Include;
41 import com.openpojo.business.annotation.BusinessKey;
42
43
44 @Entity
45 @JsonInclude(Include.NON_NULL)
46 @Table(name = "cloud_api_requests")
47 public class CloudApiRequests implements Serializable {
48
49
50     /**
51      * 
52      */
53     private static final long serialVersionUID = 4686890103198488984L;
54
55     @JsonIgnore
56     @Id
57     @BusinessKey
58     @GeneratedValue(strategy = GenerationType.IDENTITY)
59     @Column(name = "ID")
60     private Integer id;
61
62
63     @Column(name = "SO_REQUEST_ID")
64     private String requestId;
65
66     public String getRequestId() {
67         return requestId;
68     }
69
70     public void setRequestId(String requestId) {
71         this.requestId = requestId;
72     }
73
74     @Column(name = "CLOUD_IDENTIFIER")
75     private String cloudIdentifier;
76
77     @Column(name = "REQUEST_BODY", columnDefinition = "LONGTEXT")
78     private String requestBody;
79
80     @Column(name = "CREATE_TIME", insertable = false, updatable = false)
81     @Temporal(TemporalType.TIMESTAMP)
82     private Date created = null;
83
84
85     @Override
86     public boolean equals(final Object other) {
87         if (!(other instanceof CloudApiRequests)) {
88             return false;
89         }
90         CloudApiRequests castOther = (CloudApiRequests) other;
91         return new EqualsBuilder().append(id, castOther.id).isEquals();
92     }
93
94     @Override
95     public int hashCode() {
96         return new HashCodeBuilder().append(id).toHashCode();
97     }
98
99     @Override
100     public String toString() {
101         return new ToStringBuilder(this).append("id", id).append("cloudIdentifier", cloudIdentifier)
102                 .append("requestBody", requestBody).append("created", created).toString();
103     }
104
105     @PrePersist
106     protected void createdAt() {
107         this.created = new Date();
108     }
109
110     public Integer getId() {
111         return id;
112     }
113
114     public void setId(Integer id) {
115         this.id = id;
116     }
117
118     public String getCloudIdentifier() {
119         return cloudIdentifier;
120     }
121
122     public void setCloudIdentifier(String cloudIdentifier) {
123         this.cloudIdentifier = cloudIdentifier;
124     }
125
126
127     public String getRequestBody() {
128         return requestBody;
129     }
130
131     public void setRequestBody(String requestBody) {
132         this.requestBody = requestBody;
133     }
134
135     public Date getCreated() {
136         return created;
137     }
138 }