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;
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.Id;
31 import javax.persistence.OneToMany;
32 import javax.persistence.OneToOne;
33 import javax.persistence.PrePersist;
34 import javax.persistence.Table;
35 import javax.persistence.Temporal;
36 import javax.persistence.TemporalType;
38 import org.apache.commons.lang3.builder.EqualsBuilder;
39 import org.apache.commons.lang3.builder.HashCodeBuilder;
40 import org.apache.commons.lang3.builder.ToStringBuilder;
42 import com.openpojo.business.annotation.BusinessKey;
44 import uk.co.blackpepper.bowman.annotation.LinkedResource;
47 @Table(name = "collection_resource")
48 public class CollectionResource implements Serializable {
53 private static final long serialVersionUID = -8612818857960992110L;
57 @Column(name = "MODEL_UUID")
58 private String modelUUID;
60 @Column(name = "MODEL_NAME")
61 private String modelName;
63 @Column(name = "MODEL_INVARIANT_UUID")
64 private String modelInvariantUUID;
66 @Column(name = "MODEL_VERSION")
67 private String modelVersion;
69 @Column(name = "TOSCA_NODE_TYPE")
70 private String toscaNodeType;
72 @Column(name = "DESCRIPTION")
73 private String description;
75 @Column(name = "CREATION_TIMESTAMP", updatable = false)
76 @Temporal(TemporalType.TIMESTAMP)
79 @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResource")
80 private Set<CollectionResourceCustomization> collectionResourceCustomization;
82 @OneToOne(cascade = CascadeType.ALL, mappedBy = "collectionResource")
83 private InstanceGroup instanceGroup;
86 public boolean equals(final Object other) {
87 if (!(other instanceof CollectionResource)) {
90 CollectionResource castOther = (CollectionResource) other;
91 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
95 public int hashCode() {
96 return new HashCodeBuilder().append(modelUUID).toHashCode();
99 public Set<CollectionResourceCustomization> getCollectionResourceCustomization() {
100 return collectionResourceCustomization;
103 public void setCollectionResourceCustomization(
104 Set<CollectionResourceCustomization> collectionResourceCustomization) {
105 this.collectionResourceCustomization = collectionResourceCustomization;
108 public String getModelUUID() {
112 public Date getCreated() {
117 protected void onCreate() {
118 this.created = new Date();
121 public void setModelUUID(String modelUUID) {
122 this.modelUUID = modelUUID;
125 public String getModelName() {
129 public void setModelName(String modelName) {
130 this.modelName = modelName;
133 public String getModelInvariantUUID() {
134 return modelInvariantUUID;
137 public void setModelInvariantUUID(String modelInvariantUUID) {
138 this.modelInvariantUUID = modelInvariantUUID;
141 public String getModelVersion() {
145 public void setModelVersion(String modelVersion) {
146 this.modelVersion = modelVersion;
149 public String getToscaNodeType() {
150 return toscaNodeType;
153 public void setToscaNodeType(String toscaNodeType) {
154 this.toscaNodeType = toscaNodeType;
157 public String getDescription() {
161 public void setDescription(String description) {
162 this.description = description;
166 public InstanceGroup getInstanceGroup() {
167 return instanceGroup;
170 public void setInstanceGroup(InstanceGroup instanceGroup) {
171 this.instanceGroup = instanceGroup;
175 public String toString() {
176 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelName", modelName)
177 .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion)
178 .append("toscaNodeType", toscaNodeType).append("description", description).append("created", created)