[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / AllottedResource.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25 import java.util.HashSet;
26 import java.util.Set;
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;
45
46 @Entity
47 @RemoteResource("/allottedResource")
48 @Table(name = "allotted_resource")
49 public class AllottedResource implements Serializable {
50
51     private static final long serialVersionUID = 768026109321305392L;
52     @BusinessKey
53     @Id
54     @Column(name = "MODEL_UUID")
55     private String modelUUID;
56
57     @Column(name = "MODEL_INVARIANT_UUID")
58     private String modelInvariantUUID;
59
60     @Column(name = "MODEL_VERSION")
61     private String modelVersion;
62
63     @Column(name = "MODEL_NAME")
64     private String modelName;
65
66     @Column(name = "TOSCA_NODE_TYPE")
67     private String toscaNodeType;
68
69     @Column(name = "SUBCATEGORY")
70     private String subcategory;
71
72     @Column(name = "DESCRIPTION")
73     private String description;
74
75     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
76     @Column(name = "CREATION_TIMESTAMP", updatable = false)
77     @Temporal(TemporalType.TIMESTAMP)
78     private Date created;
79
80     @OneToMany(cascade = CascadeType.ALL, mappedBy = "allottedResource")
81     @NotFound(action = NotFoundAction.IGNORE)
82     private Set<AllottedResourceCustomization> allotedResourceCustomization;
83
84     @Override
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();
91     }
92
93     @Override
94     public boolean equals(final Object other) {
95         if (!(other instanceof AllottedResource)) {
96             return false;
97         }
98         AllottedResource castOther = (AllottedResource) other;
99         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
100     }
101
102     @Override
103     public int hashCode() {
104         return new HashCodeBuilder().append(modelUUID).toHashCode();
105     }
106
107     @PrePersist
108     protected void onCreate() {
109         this.created = new Date();
110     }
111
112     @LinkedResource
113     public Set<AllottedResourceCustomization> getAllotedResourceCustomization() {
114         if (allotedResourceCustomization == null)
115             allotedResourceCustomization = new HashSet<>();
116         return allotedResourceCustomization;
117     }
118
119     public void setAllotedResourceCustomization(Set<AllottedResourceCustomization> allotedResourceCustomization) {
120         this.allotedResourceCustomization = allotedResourceCustomization;
121     }
122
123     public String getModelUUID() {
124         return this.modelUUID;
125     }
126
127     public void setModelUUID(String modelUUID) {
128         this.modelUUID = modelUUID;
129     }
130
131     public String getModelInvariantUUID() {
132         return this.modelInvariantUUID;
133     }
134
135     public void setModelInvariantUUID(String modelInvariantUUID) {
136         this.modelInvariantUUID = modelInvariantUUID;
137     }
138
139     public String getModelVersion() {
140         return this.modelVersion;
141     }
142
143     public void setModelVersion(String modelVersion) {
144         this.modelVersion = modelVersion;
145     }
146
147     public String getModelName() {
148         return this.modelName;
149     }
150
151     public void setModelName(String modelName) {
152         this.modelName = modelName;
153     }
154
155     public String getToscaNodeType() {
156         return this.toscaNodeType;
157     }
158
159     public void setToscaNodeType(String toscaNodeType) {
160         this.toscaNodeType = toscaNodeType;
161     }
162
163     public String getSubcategory() {
164         return this.subcategory;
165     }
166
167     public void setSubcategory(String subcategory) {
168         this.subcategory = subcategory;
169     }
170
171     public String getDescription() {
172         return this.description;
173     }
174
175     public void setDescription(String description) {
176         this.description = description;
177     }
178
179     public Date getCreated() {
180         return created;
181     }
182 }