[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / InstanceGroup.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.ArrayList;
25 import java.util.Date;
26 import java.util.List;
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.DiscriminatorColumn;
30 import javax.persistence.Entity;
31 import javax.persistence.EnumType;
32 import javax.persistence.Enumerated;
33 import javax.persistence.FetchType;
34 import javax.persistence.Id;
35 import javax.persistence.Inheritance;
36 import javax.persistence.InheritanceType;
37 import javax.persistence.JoinColumn;
38 import javax.persistence.ManyToOne;
39 import javax.persistence.OneToMany;
40 import javax.persistence.PrePersist;
41 import javax.persistence.Table;
42 import javax.persistence.Temporal;
43 import javax.persistence.TemporalType;
44 import org.apache.commons.lang3.builder.EqualsBuilder;
45 import org.apache.commons.lang3.builder.HashCodeBuilder;
46 import org.apache.commons.lang3.builder.ToStringBuilder;
47 import com.openpojo.business.annotation.BusinessKey;
48 import uk.co.blackpepper.bowman.annotation.LinkedResource;
49 import uk.co.blackpepper.bowman.annotation.RemoteResource;
50
51 @Entity
52 @RemoteResource("/instanceGroup")
53 @DiscriminatorColumn(name = "OBJECT_TYPE")
54 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
55 @Table(name = "instance_group")
56 public class InstanceGroup implements Serializable {
57
58     /**
59      * 
60      */
61     private static final long serialVersionUID = -263859017727376578L;
62
63     @BusinessKey
64     @Id
65     @Column(name = "MODEL_UUID")
66     private String modelUUID;
67
68     @Column(name = "MODEL_NAME")
69     private String modelName;
70
71     @Column(name = "MODEL_INVARIANT_UUID")
72     private String modelInvariantUUID;
73
74     @Column(name = "MODEL_VERSION")
75     private String modelVersion;
76
77     @Column(name = "ROLE")
78     private String role;
79
80     @Column(name = "TOSCA_NODE_TYPE")
81     private String toscaNodeType;
82
83     @Enumerated(EnumType.STRING)
84     @Column(name = "INSTANCE_GROUP_TYPE")
85     private InstanceGroupType type;
86
87     @Column(name = "CREATION_TIMESTAMP", updatable = false)
88     @Temporal(TemporalType.TIMESTAMP)
89     private Date created;
90
91     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
92     @JoinColumn(name = "CR_MODEL_UUID")
93     private CollectionResource collectionResource;
94
95     @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
96     private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
97
98     @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
99     private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>();
100
101     @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
102     private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations;
103
104     @Override
105     public String toString() {
106         return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelName", modelName)
107                 .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion)
108                 .append("role", role).append("toscaNodeType", toscaNodeType).append("type", type)
109                 .append("created", created).append("collectionResource", collectionResource)
110                 .append("collectionInstanceGroupCustomizations", collectionInstanceGroupCustomizations)
111                 .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString();
112     }
113
114     @Override
115     public boolean equals(final Object other) {
116         if (!(other instanceof InstanceGroup)) {
117             return false;
118         }
119         InstanceGroup castOther = (InstanceGroup) other;
120         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
121     }
122
123     @Override
124     public int hashCode() {
125         return new HashCodeBuilder().append(modelUUID).toHashCode();
126     }
127
128     @PrePersist
129     protected void onCreate() {
130         this.created = new Date();
131     }
132
133     public String getModelUUID() {
134         return modelUUID;
135     }
136
137     public Date getCreated() {
138         return created;
139     }
140
141     public void setModelUUID(String modelUUID) {
142         this.modelUUID = modelUUID;
143     }
144
145     public String getModelName() {
146         return modelName;
147     }
148
149     public String getToscaNodeType() {
150         return toscaNodeType;
151     }
152
153     public void setToscaNodeType(String toscaNodeType) {
154         this.toscaNodeType = toscaNodeType;
155     }
156
157     public void setModelName(String modelName) {
158         this.modelName = modelName;
159     }
160
161     public String getModelInvariantUUID() {
162         return modelInvariantUUID;
163     }
164
165     public void setModelInvariantUUID(String modelInvariantUUID) {
166         this.modelInvariantUUID = modelInvariantUUID;
167     }
168
169     public String getModelVersion() {
170         return modelVersion;
171     }
172
173     public void setModelVersion(String modelVersion) {
174         this.modelVersion = modelVersion;
175     }
176
177     public String getRole() {
178         return role;
179     }
180
181     public void setRole(String role) {
182         this.role = role;
183     }
184
185     public InstanceGroupType getType() {
186         return type;
187     }
188
189     public void setType(InstanceGroupType type) {
190         this.type = type;
191     }
192
193     @LinkedResource
194     public CollectionResource getCollectionResource() {
195         return collectionResource;
196     }
197
198     public void setCollectionResource(CollectionResource collectionResource) {
199         this.collectionResource = collectionResource;
200     }
201
202     @LinkedResource
203     public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
204         return collectionInstanceGroupCustomizations;
205     }
206
207     public void setCollectionInstanceGroupCustomizations(
208             List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
209         this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;
210     }
211
212     @LinkedResource
213     public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
214         return vnfcInstanceGroupCustomizations;
215     }
216
217     public void setVnfcInstanceGroupCustomizations(
218             List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
219         this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
220     }
221
222     @LinkedResource
223     public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomizations() {
224         return collectionNetworkResourceCustomizations;
225     }
226
227     public void setCollectionNetworkResourceCustomizations(
228             List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations) {
229         this.collectionNetworkResourceCustomizations = collectionNetworkResourceCustomizations;
230     }
231 }