[SO] Release so 1.13.0 image
[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  * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.so.db.catalog.beans;
23
24 import java.io.Serializable;
25 import java.util.Date;
26 import java.util.List;
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.OneToMany;
37 import javax.persistence.PrePersist;
38 import javax.persistence.Table;
39 import javax.persistence.Temporal;
40 import javax.persistence.TemporalType;
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 import com.openpojo.business.annotation.BusinessKey;
45 import uk.co.blackpepper.bowman.annotation.LinkedResource;
46 import uk.co.blackpepper.bowman.annotation.RemoteResource;
47
48 @Entity
49 @RemoteResource("/vnfcInstanceGroupCustomization")
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     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "vnfcInstanceGroupCustomization")
74     private List<VnfcCustomization> vnfcCustomizations;
75
76     @Column(name = "FUNCTION")
77     private String function;
78
79     @Column(name = "DESCRIPTION")
80     private String description;
81
82     @Column(name = "CREATION_TIMESTAMP", updatable = false)
83     @Temporal(TemporalType.TIMESTAMP)
84     private Date created;
85
86     @Override
87     public boolean equals(final Object other) {
88         if (!(other instanceof VnfcInstanceGroupCustomization)) {
89             return false;
90         }
91         VnfcInstanceGroupCustomization castOther = (VnfcInstanceGroupCustomization) other;
92         return new EqualsBuilder().append(id, castOther.id).isEquals();
93     }
94
95     @Override
96     public int hashCode() {
97         return new HashCodeBuilder().append(id).toHashCode();
98     }
99
100     @Override
101     public String toString() {
102         return new ToStringBuilder(this).append("function", function).append("description", description)
103                 .append("created", created).toString();
104     }
105
106     public Integer getId() {
107         return id;
108     }
109
110     public void setId(Integer id) {
111         this.id = id;
112     }
113
114     @PrePersist
115     protected void onCreate() {
116         this.created = new Date();
117     }
118
119     public Date getCreated() {
120         return created;
121     }
122
123     public String getFunction() {
124         return function;
125     }
126
127     public void setFunction(String function) {
128         this.function = function;
129     }
130
131     public String getDescription() {
132         return description;
133     }
134
135     public void setDescription(String description) {
136         this.description = description;
137     }
138
139     public void setCreated(Date created) {
140         this.created = created;
141     }
142
143     @LinkedResource
144     public VnfResourceCustomization getVnfResourceCust() {
145         return vnfResourceCust;
146     }
147
148     public void setVnfResourceCust(VnfResourceCustomization vnfResourceCust) {
149         this.vnfResourceCust = vnfResourceCust;
150     }
151
152     @LinkedResource
153     public InstanceGroup getInstanceGroup() {
154         return instanceGroup;
155     }
156
157     public void setInstanceGroup(InstanceGroup instanceGroup) {
158         this.instanceGroup = instanceGroup;
159     }
160
161     public List<VnfcCustomization> getVnfcCustomizations() {
162         return vnfcCustomizations;
163     }
164
165     public void setVnfcCustomizations(List<VnfcCustomization> vnfcCustomizations) {
166         this.vnfcCustomizations = vnfcCustomizations;
167     }
168 }