2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.db.catalog.beans;
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.Date;
26 import java.util.List;
28 import javax.persistence.CascadeType;
29 import javax.persistence.Column;
30 import javax.persistence.DiscriminatorColumn;
31 import javax.persistence.Entity;
32 import javax.persistence.EnumType;
33 import javax.persistence.Enumerated;
34 import javax.persistence.FetchType;
35 import javax.persistence.Id;
36 import javax.persistence.Inheritance;
37 import javax.persistence.InheritanceType;
38 import javax.persistence.JoinColumn;
39 import javax.persistence.ManyToOne;
40 import javax.persistence.OneToMany;
41 import javax.persistence.PrePersist;
42 import javax.persistence.Table;
43 import javax.persistence.Temporal;
44 import javax.persistence.TemporalType;
46 import org.apache.commons.lang3.builder.EqualsBuilder;
47 import org.apache.commons.lang3.builder.HashCodeBuilder;
48 import org.apache.commons.lang3.builder.ToStringBuilder;
50 import com.openpojo.business.annotation.BusinessKey;
52 import uk.co.blackpepper.bowman.annotation.LinkedResource;
55 @DiscriminatorColumn(name = "OBJECT_TYPE")
56 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
57 @Table(name = "instance_group")
58 public class InstanceGroup implements Serializable {
63 private static final long serialVersionUID = -263859017727376578L;
67 @Column(name = "MODEL_UUID")
68 private String modelUUID;
70 @Column(name = "MODEL_NAME")
71 private String modelName;
73 @Column(name = "MODEL_INVARIANT_UUID")
74 private String modelInvariantUUID;
76 @Column(name = "MODEL_VERSION")
77 private String modelVersion;
79 @Column(name = "ROLE")
82 @Column(name = "TOSCA_NODE_TYPE")
83 private String toscaNodeType;
85 @Enumerated(EnumType.STRING)
86 @Column(name = "INSTANCE_GROUP_TYPE")
87 private InstanceGroupType type;
89 @Column(name = "CREATION_TIMESTAMP", updatable = false)
90 @Temporal(TemporalType.TIMESTAMP)
93 @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
94 @JoinColumn(name = "CR_MODEL_UUID")
95 private CollectionResource collectionResource;
97 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
98 private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
100 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
101 private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>();
103 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
104 private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations;
107 public String toString() {
108 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelName", modelName)
109 .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion)
110 .append("role", role).append("toscaNodeType", toscaNodeType).append("type", type)
111 .append("created", created).append("collectionResource", collectionResource)
112 .append("collectionInstanceGroupCustomizations", collectionInstanceGroupCustomizations)
113 .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString();
117 public boolean equals(final Object other) {
118 if (!(other instanceof InstanceGroup)) {
121 InstanceGroup castOther = (InstanceGroup) other;
122 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
126 public int hashCode() {
127 return new HashCodeBuilder().append(modelUUID).toHashCode();
131 protected void onCreate() {
132 this.created = new Date();
135 public String getModelUUID() {
139 public Date getCreated() {
143 public void setModelUUID(String modelUUID) {
144 this.modelUUID = modelUUID;
147 public String getModelName() {
151 public String getToscaNodeType() {
152 return toscaNodeType;
155 public void setToscaNodeType(String toscaNodeType) {
156 this.toscaNodeType = toscaNodeType;
159 public void setModelName(String modelName) {
160 this.modelName = modelName;
163 public String getModelInvariantUUID() {
164 return modelInvariantUUID;
167 public void setModelInvariantUUID(String modelInvariantUUID) {
168 this.modelInvariantUUID = modelInvariantUUID;
171 public String getModelVersion() {
175 public void setModelVersion(String modelVersion) {
176 this.modelVersion = modelVersion;
179 public String getRole() {
183 public void setRole(String role) {
187 public InstanceGroupType getType() {
191 public void setType(InstanceGroupType type) {
196 public CollectionResource getCollectionResource() {
197 return collectionResource;
200 public void setCollectionResource(CollectionResource collectionResource) {
201 this.collectionResource = collectionResource;
205 public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
206 return collectionInstanceGroupCustomizations;
209 public void setCollectionInstanceGroupCustomizations(
210 List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
211 this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;
215 public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
216 return vnfcInstanceGroupCustomizations;
219 public void setVnfcInstanceGroupCustomizations(
220 List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
221 this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
225 public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomizations() {
226 return collectionNetworkResourceCustomizations;
229 public void setCollectionNetworkResourceCustomizations(
230 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations) {
231 this.collectionNetworkResourceCustomizations = collectionNetworkResourceCustomizations;