fix catalogdb cvfnc customization
[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.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.IdClass;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.PrePersist;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40
41 import org.apache.commons.lang3.builder.EqualsBuilder;
42 import org.apache.commons.lang3.builder.HashCodeBuilder;
43 import org.apache.commons.lang3.builder.ToStringBuilder;
44
45 import com.openpojo.business.annotation.BusinessKey;
46
47 import uk.co.blackpepper.bowman.annotation.LinkedResource;
48
49 @Entity
50
51 @Table(name = "vnfc_instance_group_customization")
52 public class VnfcInstanceGroupCustomization implements Serializable {
53
54         /**
55          * 
56          */
57         private static final long serialVersionUID = -8288218040186901676L;
58
59         @Id
60         @BusinessKey
61         @Column(name = "ID")
62         @GeneratedValue(strategy = GenerationType.IDENTITY)
63         private Integer id;
64         
65         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
66         @JoinColumn(name = "VNF_RESOURCE_CUSTOMIZATION_ID")
67         private VnfResourceCustomization vnfResourceCust;
68
69         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
70         @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID")
71         private InstanceGroup instanceGroup;
72
73         @Column(name = "FUNCTION")
74         private String function;
75
76         @Column(name = "DESCRIPTION")
77         private String description;
78
79         @Column(name = "CREATION_TIMESTAMP", updatable = false)
80         @Temporal(TemporalType.TIMESTAMP)
81         private Date created;
82
83         @Override
84         public boolean equals(final Object other) {
85                 if (!(other instanceof VnfcInstanceGroupCustomization)) {
86                         return false;
87                 }
88                 VnfcInstanceGroupCustomization castOther = (VnfcInstanceGroupCustomization) other;
89                 return new EqualsBuilder().append(id, castOther.id).isEquals();
90         }
91
92         @Override
93         public int hashCode() {
94                 return new HashCodeBuilder().append(id).toHashCode();
95         }
96
97         @Override
98         public String toString() {
99                 return new ToStringBuilder(this)
100                                 .append("function", function).append("description", description)
101                                 .append("created", created).toString();
102         }
103         
104         public Integer getId() {
105                 return id;
106         }
107
108         public void setId(Integer id) {
109                 this.id = id;
110         }
111
112         @PrePersist
113         protected void onCreate() {
114                 this.created = new Date();
115         }
116         
117         public Date getCreated(){
118                 return created;
119         }
120
121         public String getFunction() {
122                 return function;
123         }
124
125         public void setFunction(String function) {
126                 this.function = function;
127         }
128
129         public String getDescription() {
130                 return description;
131         }
132
133         public void setDescription(String description) {
134                 this.description = description;
135         }
136
137         public void setCreated(Date created) {
138                 this.created = created;
139         }
140
141         @LinkedResource
142         public VnfResourceCustomization getVnfResourceCust() {
143                 return vnfResourceCust;
144         }
145
146         public void setVnfResourceCust(VnfResourceCustomization vnfResourceCust) {
147                 this.vnfResourceCust = vnfResourceCust;
148         }
149
150         @LinkedResource
151         public InstanceGroup getInstanceGroup() {
152                 return instanceGroup;
153         }
154
155         public void setInstanceGroup(InstanceGroup instanceGroup) {
156                 this.instanceGroup = instanceGroup;
157         }
158 }