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;
49 import uk.co.blackpepper.bowman.annotation.RemoteResource;
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 {
61 private static final long serialVersionUID = -263859017727376578L;
65 @Column(name = "MODEL_UUID")
66 private String modelUUID;
68 @Column(name = "MODEL_NAME")
69 private String modelName;
71 @Column(name = "MODEL_INVARIANT_UUID")
72 private String modelInvariantUUID;
74 @Column(name = "MODEL_VERSION")
75 private String modelVersion;
77 @Column(name = "ROLE")
80 @Column(name = "TOSCA_NODE_TYPE")
81 private String toscaNodeType;
83 @Enumerated(EnumType.STRING)
84 @Column(name = "INSTANCE_GROUP_TYPE")
85 private InstanceGroupType type;
87 @Column(name = "CREATION_TIMESTAMP", updatable = false)
88 @Temporal(TemporalType.TIMESTAMP)
91 @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
92 @JoinColumn(name = "CR_MODEL_UUID")
93 private CollectionResource collectionResource;
95 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
96 private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
98 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
99 private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations = new ArrayList<>();
101 @OneToMany(cascade = CascadeType.ALL, mappedBy = "instanceGroup")
102 private List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations;
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();
115 public boolean equals(final Object other) {
116 if (!(other instanceof InstanceGroup)) {
119 InstanceGroup castOther = (InstanceGroup) other;
120 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
124 public int hashCode() {
125 return new HashCodeBuilder().append(modelUUID).toHashCode();
129 protected void onCreate() {
130 this.created = new Date();
133 public String getModelUUID() {
137 public Date getCreated() {
141 public void setModelUUID(String modelUUID) {
142 this.modelUUID = modelUUID;
145 public String getModelName() {
149 public String getToscaNodeType() {
150 return toscaNodeType;
153 public void setToscaNodeType(String toscaNodeType) {
154 this.toscaNodeType = toscaNodeType;
157 public void setModelName(String modelName) {
158 this.modelName = modelName;
161 public String getModelInvariantUUID() {
162 return modelInvariantUUID;
165 public void setModelInvariantUUID(String modelInvariantUUID) {
166 this.modelInvariantUUID = modelInvariantUUID;
169 public String getModelVersion() {
173 public void setModelVersion(String modelVersion) {
174 this.modelVersion = modelVersion;
177 public String getRole() {
181 public void setRole(String role) {
185 public InstanceGroupType getType() {
189 public void setType(InstanceGroupType type) {
194 public CollectionResource getCollectionResource() {
195 return collectionResource;
198 public void setCollectionResource(CollectionResource collectionResource) {
199 this.collectionResource = collectionResource;
203 public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
204 return collectionInstanceGroupCustomizations;
207 public void setCollectionInstanceGroupCustomizations(
208 List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
209 this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;
213 public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupCustomizations() {
214 return vnfcInstanceGroupCustomizations;
217 public void setVnfcInstanceGroupCustomizations(
218 List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
219 this.vnfcInstanceGroupCustomizations = vnfcInstanceGroupCustomizations;
223 public List<CollectionNetworkResourceCustomization> getCollectionNetworkResourceCustomizations() {
224 return collectionNetworkResourceCustomizations;
227 public void setCollectionNetworkResourceCustomizations(
228 List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizations) {
229 this.collectionNetworkResourceCustomizations = collectionNetworkResourceCustomizations;