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;
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;
51 @DiscriminatorColumn(name = "OBJECT_TYPE")
52 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
53 @Table(name = "instance_group")
54 public class InstanceGroup implements Serializable {
59 private static final long serialVersionUID = -263859017727376578L;
63 @Column(name = "MODEL_UUID")
64 private String modelUUID;
66 @Column(name = "MODEL_NAME")
67 private String modelName;
69 @Column(name = "MODEL_INVARIANT_UUID")
70 private String modelInvariantUUID;
72 @Column(name = "MODEL_VERSION")
73 private String modelVersion;
75 @Column(name = "ROLE")
78 @Column(name = "TOSCA_NODE_TYPE")
79 private String toscaNodeType;
81 @Enumerated(EnumType.STRING)
82 @Column(name = "INSTANCE_GROUP_TYPE")
83 private InstanceGroupType type;
85 @Column(name = "CREATION_TIMESTAMP", updatable = false)
86 @Temporal(TemporalType.TIMESTAMP)
89 @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
90 @JoinColumn(name = "CR_MODEL_UUID")
91 private CollectionResource collectionResource;
93 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
94 private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
96 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
97 private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>();
99 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
100 private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations;
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();
113 public boolean equals(final Object other) {
114 if (!(other instanceof InstanceGroup)) {
117 InstanceGroup castOther = (InstanceGroup) other;
118 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
122 public int hashCode() {
123 return new HashCodeBuilder().append(modelUUID).toHashCode();
127 protected void onCreate() {
128 this.created = new Date();
131 public String getModelUUID() {
135 public Date getCreated() {
139 public void setModelUUID(String modelUUID) {
140 this.modelUUID = modelUUID;
143 public String getModelName() {
147 public String getToscaNodeType() {
148 return toscaNodeType;
151 public void setToscaNodeType(String toscaNodeType) {
152 this.toscaNodeType = toscaNodeType;
155 public void setModelName(String modelName) {
156 this.modelName = modelName;
159 public String getModelInvariantUUID() {
160 return modelInvariantUUID;
163 public void setModelInvariantUUID(String modelInvariantUUID) {
164 this.modelInvariantUUID = modelInvariantUUID;
167 public String getModelVersion() {
171 public void setModelVersion(String modelVersion) {
172 this.modelVersion = modelVersion;
175 public String getRole() {
179 public void setRole(String role) {
183 public InstanceGroupType getType() {
187 public void setType(InstanceGroupType type) {
192 public CollectionResource getCollectionResource() {
193 return collectionResource;
196 public void setCollectionResource(CollectionResource collectionResource) {
197 this.collectionResource = collectionResource;
201 public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
202 return collectionInstanceGroupCustomizations;
205 public void setCollectionInstanceGroupCustomizations(
206 List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
207 this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;
211 public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
212 return vnfcInstanceGroupCustomizations;
215 public void setVnfcInstanceGroupCustomizations(
216 List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
217 this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
221 public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomizations() {
222 return collectionNetworkResourceCustomizations;
225 public void setCollectionNetworkResourceCustomizations(
226 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations) {
227 this.collectionNetworkResourceCustomizations = collectionNetworkResourceCustomizations;