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