[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / PnfResource.java
1 /*
2  * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
3  * Foundation. ================================================================================ Licensed under the
4  * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
5  * obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
8  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9  * either express or implied. See the License for the specific language governing permissions and limitations under the
10  * License.
11  *
12  * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
13  */
14
15 package org.onap.so.db.catalog.beans;
16
17 import com.openpojo.business.annotation.BusinessKey;
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.Date;
21 import java.util.List;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.FetchType;
25 import javax.persistence.Id;
26 import javax.persistence.OneToMany;
27 import javax.persistence.PrePersist;
28 import javax.persistence.Table;
29 import javax.persistence.Temporal;
30 import javax.persistence.TemporalType;
31 import org.apache.commons.lang3.builder.EqualsBuilder;
32 import org.apache.commons.lang3.builder.HashCodeBuilder;
33 import org.apache.commons.lang3.builder.ToStringBuilder;
34 import uk.co.blackpepper.bowman.annotation.LinkedResource;
35 import uk.co.blackpepper.bowman.annotation.RemoteResource;
36
37 @Entity
38 @RemoteResource("/pnfResource")
39 @Table(name = "pnf_resource")
40 public class PnfResource implements Serializable {
41
42     private static final long serialVersionUID = 7680261093213053483L;
43
44     @BusinessKey
45     @Id
46     @Column(name = "MODEL_UUID")
47     private String modelUUID;
48
49     @Column(name = "MODEL_INVARIANT_UUID")
50     private String modelInvariantUUID;
51
52     @Column(name = "MODEL_NAME")
53     private String modelName;
54
55     @Column(name = "MODEL_VERSION")
56     private String modelVersion;
57
58     @Column(name = "TOSCA_NODE_TYPE")
59     private String toscaNodeType;
60
61     @Column(name = "DESCRIPTION")
62     private String description;
63
64     @Column(name = "ORCHESTRATION_MODE")
65     private String orchestrationMode;
66
67     @Column(name = "RESOURCE_CATEGORY")
68     private String category;
69
70     @Column(name = "RESOURCE_SUB_CATEGORY")
71     private String subCategory;
72
73     @Column(name = "CREATION_TIMESTAMP", updatable = false)
74     @Temporal(TemporalType.TIMESTAMP)
75     private Date created;
76
77     @OneToMany(fetch = FetchType.LAZY, mappedBy = "pnfResources")
78     private List<PnfResourceCustomization> pnfResourceCustomizations;
79
80     @PrePersist
81     protected void onCreate() {
82         this.created = new Date();
83     }
84
85     @Override
86     public String toString() {
87         return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
88                 .append("modelName", modelName).append("modelVersion", modelVersion)
89                 .append("toscaNodeType", toscaNodeType).append("description", description)
90                 .append("orchestrationMode", orchestrationMode).append("created", created)
91                 .append("pnfResourceCustomizations", pnfResourceCustomizations).toString();
92     }
93
94     @Override
95     public boolean equals(final Object other) {
96         if (!(other instanceof PnfResource)) {
97             return false;
98         }
99         PnfResource castOther = (PnfResource) other;
100         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
101     }
102
103     @Override
104     public int hashCode() {
105         return new HashCodeBuilder().append(modelUUID).toHashCode();
106     }
107
108     public String getOrchestrationMode() {
109         return orchestrationMode;
110     }
111
112     public void setOrchestrationMode(String orchestrationMode) {
113         this.orchestrationMode = orchestrationMode;
114     }
115
116     public String getDescription() {
117         return description;
118     }
119
120     public void setDescription(String description) {
121         this.description = description;
122     }
123
124     public Date getCreated() {
125         return created;
126     }
127
128     /**
129      * @return Returns the category.
130      */
131     public String getCategory() {
132         return category;
133     }
134
135     /**
136      * @param category The category to set.
137      */
138     public void setCategory(String category) {
139         this.category = category;
140     }
141
142     /**
143      * @return Returns the subCategory.
144      */
145     public String getSubCategory() {
146         return subCategory;
147     }
148
149     /**
150      * @param subCategory The subCategory to set.
151      */
152     public void setSubCategory(String subCategory) {
153         this.subCategory = subCategory;
154     }
155
156     public String getModelInvariantUUID() {
157         return this.modelInvariantUUID;
158     }
159
160     public void setModelInvariantUUID(String modelInvariantUUID) {
161         this.modelInvariantUUID = modelInvariantUUID;
162     }
163
164     public String getModelName() {
165         return modelName;
166     }
167
168     public void setModelName(String modelName) {
169         this.modelName = modelName;
170     }
171
172     public String getModelUUID() {
173         return modelUUID;
174     }
175
176     public void setModelUUID(String modelUUID) {
177         this.modelUUID = modelUUID;
178     }
179
180     public String getModelInvariantId() {
181         return this.modelInvariantUUID;
182     }
183
184     public String getToscaNodeType() {
185         return toscaNodeType;
186     }
187
188     public void setToscaNodeType(String toscaNodeType) {
189         this.toscaNodeType = toscaNodeType;
190     }
191
192     @LinkedResource
193     public List<PnfResourceCustomization> getPnfResourceCustomizations() {
194         if (pnfResourceCustomizations == null) {
195             pnfResourceCustomizations = new ArrayList<>();
196         }
197         return pnfResourceCustomizations;
198     }
199
200     public void setPnfResourceCustomizations(List<PnfResourceCustomization> pnfResourceCustomizations) {
201         this.pnfResourceCustomizations = pnfResourceCustomizations;
202     }
203
204     public String getModelVersion() {
205         return modelVersion;
206     }
207
208     public void setModelVersion(String modelVersion) {
209         this.modelVersion = modelVersion;
210     }
211 }