Do not validate certain BBs
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CollectionResourceInstanceGroupCustomization.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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.IdClass;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.ManyToOne;
34 import javax.persistence.PrePersist;
35 import javax.persistence.Table;
36 import javax.persistence.Temporal;
37 import javax.persistence.TemporalType;
38
39 import org.apache.commons.lang3.builder.EqualsBuilder;
40 import org.apache.commons.lang3.builder.HashCodeBuilder;
41 import org.apache.commons.lang3.builder.ToStringBuilder;
42
43 import com.openpojo.business.annotation.BusinessKey;
44
45 import uk.co.blackpepper.bowman.annotation.LinkedResource;
46
47 @Entity
48 @IdClass(CollectionResourceInstanceGroupCustomizationId.class)
49 @Table(name = "collection_resource_instance_group_customization")
50 public class CollectionResourceInstanceGroupCustomization implements Serializable {
51
52         /**
53          * 
54          */
55         private static final long serialVersionUID = 5169990063225044265L;
56
57         @BusinessKey
58         @Id
59         @Column(name = "COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID")
60         private String modelCustomizationUUID;
61
62         @BusinessKey
63         @Id
64         @Column(name = "INSTANCE_GROUP_MODEL_UUID")
65         private String modelUUID;
66
67         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
68         @JoinColumn(name = "COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID", updatable = false, insertable = false)
69         private CollectionResourceCustomization collectionResourceCust;
70
71         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
72         @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID", updatable = false, insertable = false)
73         private InstanceGroup instanceGroup;
74
75         @Column(name = "FUNCTION")
76         private String function;
77
78         @Column(name = "DESCRIPTION")
79         private String description;
80
81         @Column(name = "CREATION_TIMESTAMP", updatable = false)
82         @Temporal(TemporalType.TIMESTAMP)
83         private Date created;
84
85         @Column(name = "SUBINTERFACE_NETWORK_QUANTITY")
86         private Integer subInterfaceNetworkQuantity;
87
88         @Override
89         public String toString() {
90                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
91                                 .append("modelUUID", modelUUID).append("collectionResourceCust", collectionResourceCust)
92                                 .append("instanceGroup", instanceGroup).append("function", function).append("description", description)
93                                 .append("created", created).append("subInterfaceNetworkQuantity", subInterfaceNetworkQuantity)
94                                 .toString();
95         }
96
97         @Override
98         public boolean equals(final Object other) {
99                 if (!(other instanceof CollectionResourceInstanceGroupCustomization)) {
100                         return false;
101                 }
102                 CollectionResourceInstanceGroupCustomization castOther = (CollectionResourceInstanceGroupCustomization) other;
103                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID)
104                                 .append(modelUUID, castOther.modelUUID).append(collectionResourceCust, castOther.collectionResourceCust)
105                                 .append(instanceGroup, castOther.instanceGroup).isEquals();
106         }
107
108         @Override
109         public int hashCode() {
110                 return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).append(collectionResourceCust)
111                                 .append(instanceGroup).toHashCode();
112         }
113         
114         @PrePersist
115         protected void onCreate() {
116                 this.created = new Date();
117         }
118
119         public String getModelCustomizationUUID() {
120                 return modelCustomizationUUID;
121         }
122
123         public void setModelCustomizationUUID(String modelCustomizationUUID) {
124                 this.modelCustomizationUUID = modelCustomizationUUID;
125         }
126
127         public String getModelUUID() {
128                 return modelUUID;
129         }
130
131         public void setModelUUID(String modelUUID) {
132                 this.modelUUID = modelUUID;
133         }
134
135         public String getFunction() {
136                 return function;
137         }
138
139         public void setFunction(String function) {
140                 this.function = function;
141         }
142
143         public String getDescription() {
144                 return description;
145         }
146
147         public void setDescription(String description) {
148                 this.description = description;
149         }
150
151         public Date getCreated() {
152                 return created;
153         }
154
155         public Integer getSubInterfaceNetworkQuantity() {
156                 return subInterfaceNetworkQuantity;
157         }
158
159         public void setSubInterfaceNetworkQuantity(Integer subInterfaceNetworkQuantity) {
160                 this.subInterfaceNetworkQuantity = subInterfaceNetworkQuantity;
161         }
162
163         @LinkedResource
164         public CollectionResourceCustomization getCollectionResourceCust() {
165                 return collectionResourceCust;
166         }
167
168         public void setCollectionResourceCust(CollectionResourceCustomization collectionResourceCust) {
169                 this.collectionResourceCust = collectionResourceCust;
170         }
171
172         @LinkedResource
173         public InstanceGroup getInstanceGroup() {
174                 return instanceGroup;
175         }
176
177         public void setInstanceGroup(InstanceGroup instanceGroup) {
178                 this.instanceGroup = instanceGroup;
179         }
180 }