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.Date;
25 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;
45 import org.apache.commons.lang3.builder.EqualsBuilder;
46 import org.apache.commons.lang3.builder.HashCodeBuilder;
47 import org.apache.commons.lang3.builder.ToStringBuilder;
49 import com.openpojo.business.annotation.BusinessKey;
51 import uk.co.blackpepper.bowman.annotation.LinkedResource;
54 @DiscriminatorColumn(name = "OBJECT_TYPE")
55 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
56 @Table(name = "instance_group")
57 public class InstanceGroup implements Serializable {
62 private static final long serialVersionUID = -263859017727376578L;
66 @Column(name = "MODEL_UUID")
67 private String modelUUID;
69 @Column(name = "MODEL_NAME")
70 private String modelName;
72 @Column(name = "MODEL_INVARIANT_UUID")
73 private String modelInvariantUUID;
75 @Column(name = "MODEL_VERSION")
76 private String modelVersion;
78 @Column(name = "ROLE")
81 @Column(name = "TOSCA_NODE_TYPE")
82 private String toscaNodeType;
84 @Enumerated(EnumType.STRING)
85 @Column(name = "INSTANCE_GROUP_TYPE")
86 private InstanceGroupType type;
88 @Column(name = "CREATION_TIMESTAMP", updatable = false)
89 @Temporal(TemporalType.TIMESTAMP)
92 @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
93 @JoinColumn(name = "CR_MODEL_UUID")
94 private CollectionResource collectionResource;
96 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
97 private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
99 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
100 private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations;
102 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
103 private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations;
106 public String toString() {
107 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelName", modelName)
108 .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion)
109 .append("role", role).append("toscaNodeType", toscaNodeType).append("type", type)
110 .append("created", created).append("collectionResource", collectionResource)
111 .append("collectionInstanceGroupCustomizations", collectionInstanceGroupCustomizations)
112 .append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString();
116 public boolean equals(final Object other) {
117 if (!(other instanceof InstanceGroup)) {
120 InstanceGroup castOther = (InstanceGroup) other;
121 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
125 public int hashCode() {
126 return new HashCodeBuilder().append(modelUUID).toHashCode();
130 protected void onCreate() {
131 this.created = new Date();
134 public String getModelUUID() {
138 public Date getCreated() {
142 public void setModelUUID(String modelUUID) {
143 this.modelUUID = modelUUID;
146 public String getModelName() {
150 public String getToscaNodeType() {
151 return toscaNodeType;
154 public void setToscaNodeType(String toscaNodeType) {
155 this.toscaNodeType = toscaNodeType;
158 public void setModelName(String modelName) {
159 this.modelName = modelName;
162 public String getModelInvariantUUID() {
163 return modelInvariantUUID;
166 public void setModelInvariantUUID(String modelInvariantUUID) {
167 this.modelInvariantUUID = modelInvariantUUID;
170 public String getModelVersion() {
174 public void setModelVersion(String modelVersion) {
175 this.modelVersion = modelVersion;
178 public String getRole() {
182 public void setRole(String role) {
186 public InstanceGroupType getType() {
190 public void setType(InstanceGroupType type) {
195 public CollectionResource getCollectionResource() {
196 return collectionResource;
199 public void setCollectionResource(CollectionResource collectionResource) {
200 this.collectionResource = collectionResource;
204 public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
205 return collectionInstanceGroupCustomizations;
208 public void setCollectionInstanceGroupCustomizations(
209 List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
210 this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;
214 public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
215 return vnfcInstanceGroupCustomizations;
218 public void setVnfcInstanceGroupCustomizations(
219 List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
220 this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
224 public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomizations() {
225 return collectionNetworkResourceCustomizations;
228 public void setCollectionNetworkResourceCustomizations(
229 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations) {
230 this.collectionNetworkResourceCustomizations = collectionNetworkResourceCustomizations;