d4de5cbcdf68d695ecbb9fadfb189af4a047bdbd
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CollectionNetworkResourceCustomization.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.catalog.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.PrePersist;
34 import javax.persistence.Table;
35 import javax.persistence.Temporal;
36 import javax.persistence.TemporalType;
37
38 import org.apache.commons.lang3.builder.EqualsBuilder;
39 import org.apache.commons.lang3.builder.HashCodeBuilder;
40 import org.apache.commons.lang3.builder.ToStringBuilder;
41
42 import com.openpojo.business.annotation.BusinessKey;
43
44 import uk.co.blackpepper.bowman.annotation.LinkedResource;
45
46 @Entity
47 @Table(name = "collection_network_resource_customization")
48 public class CollectionNetworkResourceCustomization implements Serializable {
49
50         /**
51          * 
52          */
53         private static final long serialVersionUID = 11115611315801079L;
54
55         @BusinessKey
56         @Id
57         @Column(name = "MODEL_CUSTOMIZATION_UUID")
58         private String modelCustomizationUUID = null;
59
60         @Column(name = "MODEL_INSTANCE_NAME")
61         private String modelInstanceName;
62
63         @Column(name = "CREATION_TIMESTAMP", updatable = false)
64         @Temporal(TemporalType.TIMESTAMP)
65         private Date created;
66
67         @BusinessKey
68         @Column(name = "NETWORK_TECHNOLOGY")
69         private String networkTechnology;
70
71         @BusinessKey
72         @Column(name = "NETWORK_TYPE")
73         private String networkType = null;
74
75         @BusinessKey
76         @Column(name = "NETWORK_SCOPE")
77         private String networkScope;
78
79         @BusinessKey
80         @Column(name = "NETWORK_ROLE")
81         private String networkRole;
82
83         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
84         @JoinColumn(name = "NETWORK_RESOURCE_MODEL_UUID")
85         private NetworkResource networkResource = null;
86
87         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
88         @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID")
89         private InstanceGroup instanceGroup = null;
90
91         @BusinessKey
92         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
93         @JoinColumn(name = "CRC_MODEL_CUSTOMIZATION_UUID")
94         private NetworkCollectionResourceCustomization networkResourceCustomization = null;
95
96         @PrePersist
97         protected void onCreate() {
98                 this.created = new Date();
99         }
100
101         @Override
102         public boolean equals(final Object other) {
103                 if (!(other instanceof CollectionNetworkResourceCustomization)) {
104                         return false;
105                 }
106                 CollectionNetworkResourceCustomization castOther = (CollectionNetworkResourceCustomization) other;
107                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID)
108                                 .append(networkTechnology, castOther.networkTechnology).append(networkType, castOther.networkType)
109                                 .append(networkScope, castOther.networkScope).append(networkRole, castOther.networkRole)
110                                 .append(networkResourceCustomization, castOther.networkResourceCustomization).isEquals();
111         }
112
113         @Override
114         public int hashCode() {
115                 return new HashCodeBuilder().append(modelCustomizationUUID).append(networkTechnology).append(networkType)
116                                 .append(networkScope).append(networkRole).append(networkResourceCustomization).toHashCode();
117         }
118
119         @Override
120         public String toString() {
121                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
122                                 .append("modelInstanceName", modelInstanceName).append("created", created)
123                                 .append("networkTechnology", networkTechnology).append("networkType", networkType)
124                                 .append("networkScope", networkScope).append("networkRole", networkRole)
125                                 .append("networkResource", networkResource).append("collectionResource", networkResourceCustomization)
126                                 .toString();
127         }
128
129         public String getModelCustomizationUUID() {
130                 return this.modelCustomizationUUID;
131         }
132
133         public void setModelCustomizationUUID(String modelCustomizationUUID) {
134                 this.modelCustomizationUUID = modelCustomizationUUID;
135         }
136
137         @LinkedResource
138         public NetworkCollectionResourceCustomization getNetworkResourceCustomization() {
139                 return networkResourceCustomization;
140         }
141
142         public void setNetworkResourceCustomization(NetworkCollectionResourceCustomization networkResourceCustomization) {
143                 this.networkResourceCustomization = networkResourceCustomization;
144         }
145
146         public String getModelInstanceName() {
147                 return this.modelInstanceName;
148         }
149
150         public void setModelInstanceName(String modelInstanceName) {
151                 this.modelInstanceName = modelInstanceName;
152         }
153
154         @LinkedResource
155         public NetworkResource getNetworkResource() {
156                 return this.networkResource;
157         }
158
159         public void setNetworkResource(NetworkResource networkResource) {
160                 this.networkResource = networkResource;
161         }
162
163         public String getNetworkType() {
164                 return this.networkType;
165         }
166
167         public void setNetworkType(String networkType) {
168                 this.networkType = networkType;
169         }
170
171         public Date getCreated() {
172                 return this.created;
173         }
174
175         public String getNetworkTechnology() {
176                 return this.networkTechnology;
177         }
178
179         public void setNetworkTechnology(String networkTechnology) {
180                 this.networkTechnology = networkTechnology;
181         }
182
183         public String getNetworkScope() {
184                 return this.networkScope;
185         }
186
187         public void setNetworkScope(String networkScope) {
188                 this.networkScope = networkScope;
189         }
190
191         public void setNetworkRole(String networkRole) {
192                 this.networkRole = networkRole;
193         }
194
195         public String getNetworkRole() {
196                 return this.networkRole;
197         }
198
199         @LinkedResource
200         public InstanceGroup getInstanceGroup() {
201                 return instanceGroup;
202         }
203
204         public void setInstanceGroup(InstanceGroup instanceGroup) {
205                 this.instanceGroup = instanceGroup;
206         }
207         
208 }