[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / HomingInstance.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2018. Intel Corp. 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 package org.onap.so.db.catalog.beans;
21
22 import com.fasterxml.jackson.annotation.JsonProperty;
23 import com.openpojo.business.annotation.BusinessKey;
24 import org.apache.commons.lang3.builder.EqualsBuilder;
25 import org.apache.commons.lang3.builder.HashCodeBuilder;
26 import org.apache.commons.lang3.builder.ToStringBuilder;
27 import uk.co.blackpepper.bowman.annotation.RemoteResource;
28 import uk.co.blackpepper.bowman.annotation.ResourceId;
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.Id;
32 import javax.persistence.Table;
33 import javax.persistence.Transient;
34 import java.net.URI;
35
36 /**
37  * EntityBean class for a HomingInstance. This bean represents a homing instance of a service, populated on successful
38  * homing
39  *
40  */
41 @Entity
42 @RemoteResource("/homingInstance")
43 @Table(name = "homing_instances")
44 public class HomingInstance {
45     @JsonProperty
46     @BusinessKey
47     @Id
48     @Column(name = "SERVICE_INSTANCE_ID")
49     private String serviceInstanceId;
50
51     @JsonProperty("cloud_region_id")
52     @BusinessKey
53     @Column(name = "CLOUD_REGION_ID")
54     private String cloudRegionId;
55
56     @JsonProperty("cloud_owner")
57     @BusinessKey
58     @Column(name = "CLOUD_OWNER")
59     private String cloudOwner;
60
61
62
63     @JsonProperty("oof_directives")
64     @BusinessKey
65     @Column(name = "OOF_DIRECTIVES", columnDefinition = "LONGTEXT")
66     private String oofDirectives;
67
68     @Transient
69     private URI uri;
70
71     public HomingInstance() {
72
73     }
74
75     public HomingInstance(HomingInstance homingInstance) {
76         this.serviceInstanceId = homingInstance.getServiceInstanceId();
77         this.cloudRegionId = homingInstance.getCloudRegionId();
78         this.cloudOwner = homingInstance.getCloudOwner();
79         this.oofDirectives = homingInstance.getOofDirectives();
80     }
81
82
83     public String getServiceInstanceId() {
84         return this.serviceInstanceId;
85     }
86
87     public void setServiceInstanceId(String serviceInstanceId) {
88
89         this.serviceInstanceId = serviceInstanceId;
90     }
91
92     public String getCloudRegionId() {
93
94         return this.cloudRegionId;
95     }
96
97     public void setCloudRegionId(String cloudRegionId) {
98
99         this.cloudRegionId = cloudRegionId;
100     }
101
102     public String getCloudOwner() {
103
104         return this.cloudOwner;
105     }
106
107     public void setCloudOwner(String cloudOwner) {
108
109         this.cloudOwner = cloudOwner;
110     }
111
112     public String getOofDirectives() {
113         return oofDirectives;
114     }
115
116     public void setOofDirectives(String oofDirectives) {
117         this.oofDirectives = oofDirectives;
118     }
119
120     @ResourceId
121     public URI getUri() {
122         return this.uri;
123     }
124
125     public void setUri(URI uri) {
126
127         this.uri = uri;
128     }
129
130     @Override
131     public String toString() {
132         return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId)
133                 .append("cloudRegionId", cloudRegionId).append("cloudOwner", cloudOwner)
134                 .append("oofDirectives", oofDirectives).toString();
135     }
136
137     @Override
138     public boolean equals(final Object other) {
139         if (!(other instanceof HomingInstance)) {
140             return false;
141         }
142         HomingInstance castOther = (HomingInstance) other;
143         return new EqualsBuilder().append(serviceInstanceId, castOther.serviceInstanceId).isEquals();
144     }
145
146     @Override
147     public int hashCode() {
148         return new HashCodeBuilder().append(serviceInstanceId).toHashCode();
149     }
150 }