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;
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.PrePersist;
33 import javax.persistence.Table;
34 import javax.persistence.Temporal;
35 import javax.persistence.TemporalType;
36 import com.fasterxml.jackson.annotation.JsonFormat;
37 import org.apache.commons.lang3.builder.EqualsBuilder;
38 import org.apache.commons.lang3.builder.HashCodeBuilder;
39 import org.apache.commons.lang3.builder.ToStringBuilder;
40 import com.openpojo.business.annotation.BusinessKey;
41 import org.hibernate.annotations.NotFound;
42 import org.hibernate.annotations.NotFoundAction;
43 import uk.co.blackpepper.bowman.annotation.LinkedResource;
44 import uk.co.blackpepper.bowman.annotation.RemoteResource;
47 @RemoteResource("/allottedResource")
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 @NotFound(action = NotFoundAction.IGNORE)
82 private Set<AllottedResourceCustomization> allotedResourceCustomization;
85 public String toString() {
86 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
87 .append("modelVersion", modelVersion).append("modelName", modelName)
88 .append("toscaNodeType", toscaNodeType).append("subcategory", subcategory)
89 .append("description", description).append("created", created)
90 .append("allotedResourceCustomization", allotedResourceCustomization).toString();
94 public boolean equals(final Object other) {
95 if (!(other instanceof AllottedResource)) {
98 AllottedResource castOther = (AllottedResource) other;
99 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
103 public int hashCode() {
104 return new HashCodeBuilder().append(modelUUID).toHashCode();
108 protected void onCreate() {
109 this.created = new Date();
113 public Set<AllottedResourceCustomization> getAllotedResourceCustomization() {
114 if (allotedResourceCustomization == null)
115 allotedResourceCustomization = new HashSet<>();
116 return allotedResourceCustomization;
119 public void setAllotedResourceCustomization(Set<AllottedResourceCustomization> allotedResourceCustomization) {
120 this.allotedResourceCustomization = allotedResourceCustomization;
123 public String getModelUUID() {
124 return this.modelUUID;
127 public void setModelUUID(String modelUUID) {
128 this.modelUUID = modelUUID;
131 public String getModelInvariantUUID() {
132 return this.modelInvariantUUID;
135 public void setModelInvariantUUID(String modelInvariantUUID) {
136 this.modelInvariantUUID = modelInvariantUUID;
139 public String getModelVersion() {
140 return this.modelVersion;
143 public void setModelVersion(String modelVersion) {
144 this.modelVersion = modelVersion;
147 public String getModelName() {
148 return this.modelName;
151 public void setModelName(String modelName) {
152 this.modelName = modelName;
155 public String getToscaNodeType() {
156 return this.toscaNodeType;
159 public void setToscaNodeType(String toscaNodeType) {
160 this.toscaNodeType = toscaNodeType;
163 public String getSubcategory() {
164 return this.subcategory;
167 public void setSubcategory(String subcategory) {
168 this.subcategory = subcategory;
171 public String getDescription() {
172 return this.description;
175 public void setDescription(String description) {
176 this.description = description;
179 public Date getCreated() {