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