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 com.fasterxml.jackson.annotation.JsonFormat;
39 import org.apache.commons.lang3.builder.EqualsBuilder;
40 import org.apache.commons.lang3.builder.HashCodeBuilder;
41 import org.apache.commons.lang3.builder.ToStringBuilder;
43 import com.openpojo.business.annotation.BusinessKey;
45 import uk.co.blackpepper.bowman.annotation.LinkedResource;
48 @Table(name = "allotted_resource")
49 public class AllottedResource implements Serializable {
51 private static final long serialVersionUID = 768026109321305392L;
54 @Column(name = "MODEL_UUID")
55 private String modelUUID;
57 @Column(name = "MODEL_INVARIANT_UUID")
58 private String modelInvariantUUID;
60 @Column(name = "MODEL_VERSION")
61 private String modelVersion;
63 @Column(name = "MODEL_NAME")
64 private String modelName;
66 @Column(name = "TOSCA_NODE_TYPE")
67 private String toscaNodeType;
69 @Column(name = "SUBCATEGORY")
70 private String subcategory;
72 @Column(name = "DESCRIPTION")
73 private String description;
75 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
76 @Column(name = "CREATION_TIMESTAMP", updatable = false)
77 @Temporal(TemporalType.TIMESTAMP)
80 @OneToMany(cascade = CascadeType.ALL, mappedBy = "allottedResource")
81 private Set<AllottedResourceCustomization> allotedResourceCustomization;
84 public String toString() {
85 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
86 .append("modelVersion", modelVersion).append("modelName", modelName)
87 .append("toscaNodeType", toscaNodeType).append("subcategory", subcategory)
88 .append("description", description).append("created", created)
89 .append("allotedResourceCustomization", allotedResourceCustomization).toString();
93 public boolean equals(final Object other) {
94 if (!(other instanceof AllottedResource)) {
97 AllottedResource castOther = (AllottedResource) other;
98 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
102 public int hashCode() {
103 return new HashCodeBuilder().append(modelUUID).toHashCode();
107 protected void onCreate() {
108 this.created = new Date();
112 public Set<AllottedResourceCustomization> getAllotedResourceCustomization() {
113 if (allotedResourceCustomization == null)
114 allotedResourceCustomization = new HashSet<>();
115 return allotedResourceCustomization;
118 public void setAllotedResourceCustomization(Set<AllottedResourceCustomization> allotedResourceCustomization) {
119 this.allotedResourceCustomization = allotedResourceCustomization;
122 public String getModelUUID() {
123 return this.modelUUID;
126 public void setModelUUID(String modelUUID) {
127 this.modelUUID = modelUUID;
130 public String getModelInvariantUUID() {
131 return this.modelInvariantUUID;
134 public void setModelInvariantUUID(String modelInvariantUUID) {
135 this.modelInvariantUUID = modelInvariantUUID;
138 public String getModelVersion() {
139 return this.modelVersion;
142 public void setModelVersion(String modelVersion) {
143 this.modelVersion = modelVersion;
146 public String getModelName() {
147 return this.modelName;
150 public void setModelName(String modelName) {
151 this.modelName = modelName;
154 public String getToscaNodeType() {
155 return this.toscaNodeType;
158 public void setToscaNodeType(String toscaNodeType) {
159 this.toscaNodeType = toscaNodeType;
162 public String getSubcategory() {
163 return this.subcategory;
166 public void setSubcategory(String subcategory) {
167 this.subcategory = subcategory;
170 public String getDescription() {
171 return this.description;
174 public void setDescription(String description) {
175 this.description = description;
178 public Date getCreated() {