1d4cef158fa8bdd181f9fd88db99067b453af044
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / VnfcInstanceGroupCustomization.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(VnfcInstanceGroupCustomizationId.class)
49 @Table(name = "vnfc_instance_group_customization")
50 public class VnfcInstanceGroupCustomization implements Serializable {
51
52         /**
53          * 
54          */
55         private static final long serialVersionUID = -8288218040186901676L;
56
57         @BusinessKey
58         @Id
59         @Column(name = "VNF_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 = "VNF_RESOURCE_CUSTOMIZATION_MODEL_UUID", updatable = false, insertable = false)
69         private VnfResourceCustomization vnfResourceCust;
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         @Override
86         public boolean equals(final Object other) {
87                 if (!(other instanceof VnfcInstanceGroupCustomization)) {
88                         return false;
89                 }
90                 VnfcInstanceGroupCustomization castOther = (VnfcInstanceGroupCustomization) other;
91                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID)
92                                 .append(modelUUID, castOther.modelUUID).isEquals();
93         }
94
95         @Override
96         public int hashCode() {
97                 return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).toHashCode();
98         }
99
100         @Override
101         public String toString() {
102                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
103                                 .append("modelUUID", modelUUID).append("function", function).append("description", description)
104                                 .append("created", created).toString();
105         }
106         
107         @PrePersist
108         protected void onCreate() {
109                 this.created = new Date();
110         }
111         
112         public Date getCreated() {
113                 return created;
114         }
115
116         public String getModelCustomizationUUID() {
117                 return modelCustomizationUUID;
118         }
119
120         public void setModelCustomizationUUID(String modelCustomizationUUID) {
121                 this.modelCustomizationUUID = modelCustomizationUUID;
122         }
123
124         public String getModelUUID() {
125                 return modelUUID;
126         }
127
128         public void setModelUUID(String modelUUID) {
129                 this.modelUUID = modelUUID;
130         }
131
132         public String getFunction() {
133                 return function;
134         }
135
136         public void setFunction(String function) {
137                 this.function = function;
138         }
139
140         public String getDescription() {
141                 return description;
142         }
143
144         public void setDescription(String description) {
145                 this.description = description;
146         }
147
148         public void setCreated(Date created) {
149                 this.created = created;
150         }
151
152         @LinkedResource
153         public VnfResourceCustomization getVnfResourceCust() {
154                 return vnfResourceCust;
155         }
156
157         public void setVnfResourceCust(VnfResourceCustomization vnfResourceCust) {
158                 this.vnfResourceCust = vnfResourceCust;
159         }
160
161         @LinkedResource
162         public InstanceGroup getInstanceGroup() {
163                 return instanceGroup;
164         }
165
166         public void setInstanceGroup(InstanceGroup instanceGroup) {
167                 this.instanceGroup = instanceGroup;
168         }
169 }