Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / WatchdogServiceModVerIdLookup.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.request.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25 import java.util.Objects;
26 import java.util.Optional;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.Id;
30 import javax.persistence.IdClass;
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.ToStringBuilder;
36
37 @IdClass(WatchdogServiceModVerIdLookupId.class)
38 @Entity
39 @Table(name = "watchdog_service_mod_ver_id_lookup")
40 public class WatchdogServiceModVerIdLookup implements Serializable {
41
42     /**
43      * Serialization id.
44      */
45     private static final long serialVersionUID = 7783869906430250355L;
46
47     @Id
48     @Column(name = "DISTRIBUTION_ID", length = 45)
49     private String distributionId;
50     @Id
51     @Column(name = "SERVICE_MODEL_VERSION_ID", length = 45)
52     private String serviceModelVersionId;
53     @Column(name = "DISTRIBUTION_NOTIFICATION")
54     private String distributionNotification;
55     @Column(name = "CONSUMER_ID", length = 200)
56     private String consumerId;
57     @Column(name = "CREATE_TIME", updatable = false)
58     @Temporal(TemporalType.TIMESTAMP)
59     private Date createTime;
60
61     public WatchdogServiceModVerIdLookup() {
62
63     }
64
65     /**
66      * 
67      * @param distributionId - Distribution ID
68      * @param serviceModelVersionId -- service UUID
69      * @param distributionNotification -- Notification content from ASDC
70      * @param consumerId -- Consumer ID associated with subscription.
71      */
72     public WatchdogServiceModVerIdLookup(String distributionId, String serviceModelVersionId,
73             Optional<String> distributionNotification, String consumerId) {
74         this.distributionId = distributionId;
75         this.serviceModelVersionId = serviceModelVersionId;
76         this.distributionNotification = distributionNotification.orElse(null);
77         this.consumerId = consumerId;
78     }
79
80     public String getDistributionId() {
81         return distributionId;
82     }
83
84     public void setDistributionId(String distributionId) {
85         this.distributionId = distributionId;
86     }
87
88     public String getServiceModelVersionId() {
89         return serviceModelVersionId;
90     }
91
92     public void setServiceModelVersionId(String serviceModelVersionId) {
93         this.serviceModelVersionId = serviceModelVersionId;
94     }
95
96     public Date getCreateTime() {
97         return createTime;
98     }
99
100     @PrePersist
101     protected void onCreate() {
102         this.createTime = new Date();
103     }
104
105     @Override
106     public boolean equals(final Object other) {
107         if (this == other) {
108             return true;
109         }
110         if (!(other instanceof WatchdogServiceModVerIdLookup)) {
111             return false;
112         }
113         WatchdogServiceModVerIdLookup castOther = (WatchdogServiceModVerIdLookup) other;
114         return Objects.equals(getDistributionId(), castOther.getDistributionId())
115                 && Objects.equals(getServiceModelVersionId(), castOther.getServiceModelVersionId());
116     }
117
118     @Override
119     public int hashCode() {
120         return Objects.hash(getDistributionId(), getServiceModelVersionId());
121     }
122
123     @Override
124     public String toString() {
125         return new ToStringBuilder(this).append("distributionId", getDistributionId())
126                 .append("serviceModelVersionId", getServiceModelVersionId()).append("createTime", getCreateTime())
127                 .append("distributionNotification", getDistributionNotification()).append("consumerId", getConsumerId())
128                 .toString();
129     }
130
131     public String getDistributionNotification() {
132         return distributionNotification;
133     }
134
135     public void setDistributionNotification(String distributionNotification) {
136         this.distributionNotification = distributionNotification;
137     }
138
139     public String getConsumerId() {
140         return consumerId;
141     }
142
143     public void setConsumerId(String consumerId) {
144         this.consumerId = consumerId;
145     }
146 }