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.HashSet;
28 import javax.persistence.CascadeType;
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.Id;
32 import javax.persistence.OneToMany;
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 = "allotted_resource")
48 public class AllottedResource implements Serializable {
50 private static final long serialVersionUID = 768026109321305392L;
53 @Column(name = "MODEL_UUID")
54 private String modelUUID;
56 @Column(name = "MODEL_INVARIANT_UUID")
57 private String modelInvariantUUID;
59 @Column(name = "MODEL_VERSION")
60 private String modelVersion;
62 @Column(name = "MODEL_NAME")
63 private String modelName;
65 @Column(name = "TOSCA_NODE_TYPE")
66 private String toscaNodeType;
68 @Column(name = "SUBCATEGORY")
69 private String subcategory;
71 @Column(name = "DESCRIPTION")
72 private String description;
74 @Column(name = "CREATION_TIMESTAMP", updatable = false)
75 @Temporal(TemporalType.TIMESTAMP)
78 @OneToMany(cascade = CascadeType.ALL, mappedBy = "allottedResource")
79 private Set<AllottedResourceCustomization> allotedResourceCustomization;
82 public String toString() {
83 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
84 .append("modelVersion", modelVersion).append("modelName", modelName)
85 .append("toscaNodeType", toscaNodeType).append("subcategory", subcategory)
86 .append("description", description).append("created", created)
87 .append("allotedResourceCustomization", allotedResourceCustomization).toString();
91 public boolean equals(final Object other) {
92 if (!(other instanceof AllottedResource)) {
95 AllottedResource castOther = (AllottedResource) other;
96 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
100 public int hashCode() {
101 return new HashCodeBuilder().append(modelUUID).toHashCode();
105 protected void onCreate() {
106 this.created = new Date();
110 public Set<AllottedResourceCustomization> getAllotedResourceCustomization() {
111 if (allotedResourceCustomization == null)
112 allotedResourceCustomization = new HashSet<>();
113 return allotedResourceCustomization;
116 public void setAllotedResourceCustomization(Set<AllottedResourceCustomization> allotedResourceCustomization) {
117 this.allotedResourceCustomization = allotedResourceCustomization;
120 public String getModelUUID() {
121 return this.modelUUID;
124 public void setModelUUID(String modelUUID) {
125 this.modelUUID = modelUUID;
128 public String getModelInvariantUUID() {
129 return this.modelInvariantUUID;
132 public void setModelInvariantUUID(String modelInvariantUUID) {
133 this.modelInvariantUUID = modelInvariantUUID;
136 public String getModelVersion() {
137 return this.modelVersion;
140 public void setModelVersion(String modelVersion) {
141 this.modelVersion = modelVersion;
144 public String getModelName() {
145 return this.modelName;
148 public void setModelName(String modelName) {
149 this.modelName = modelName;
152 public String getToscaNodeType() {
153 return this.toscaNodeType;
156 public void setToscaNodeType(String toscaNodeType) {
157 this.toscaNodeType = toscaNodeType;
160 public String getSubcategory() {
161 return this.subcategory;
164 public void setSubcategory(String subcategory) {
165 this.subcategory = subcategory;
168 public String getDescription() {
169 return this.description;
172 public void setDescription(String description) {
173 this.description = description;
176 public Date getCreated() {