Replaced all tabs with spaces in java and pom.xml
[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
36 @Entity
37 @Table(name = "pnf_resource")
38 public class PnfResource implements Serializable {
39
40     private static final long serialVersionUID = 7680261093213053483L;
41
42     @BusinessKey
43     @Id
44     @Column(name = "MODEL_UUID")
45     private String modelUUID;
46
47     @Column(name = "MODEL_INVARIANT_UUID")
48     private String modelInvariantUUID;
49
50     @Column(name = "MODEL_NAME")
51     private String modelName;
52
53     @Column(name = "MODEL_VERSION")
54     private String modelVersion;
55
56     @Column(name = "TOSCA_NODE_TYPE")
57     private String toscaNodeType;
58
59     @Column(name = "DESCRIPTION")
60     private String description;
61
62     @Column(name = "ORCHESTRATION_MODE")
63     private String orchestrationMode;
64
65     @Column(name = "RESOURCE_CATEGORY")
66     private String category;
67
68     @Column(name = "RESOURCE_SUB_CATEGORY")
69     private String subCategory;
70
71     @Column(name = "CREATION_TIMESTAMP", updatable = false)
72     @Temporal(TemporalType.TIMESTAMP)
73     private Date created;
74
75     @OneToMany(fetch = FetchType.LAZY, mappedBy = "pnfResources")
76     private List<PnfResourceCustomization> pnfResourceCustomizations;
77
78     @PrePersist
79     protected void onCreate() {
80         this.created = new Date();
81     }
82
83     @Override
84     public String toString() {
85         return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
86                 .append("modelName", modelName).append("modelVersion", modelVersion)
87                 .append("toscaNodeType", toscaNodeType).append("description", description)
88                 .append("orchestrationMode", orchestrationMode).append("created", created)
89                 .append("pnfResourceCustomizations", pnfResourceCustomizations).toString();
90     }
91
92     @Override
93     public boolean equals(final Object other) {
94         if (!(other instanceof PnfResource)) {
95             return false;
96         }
97         PnfResource castOther = (PnfResource) other;
98         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
99     }
100
101     @Override
102     public int hashCode() {
103         return new HashCodeBuilder().append(modelUUID).toHashCode();
104     }
105
106     public String getOrchestrationMode() {
107         return orchestrationMode;
108     }
109
110     public void setOrchestrationMode(String orchestrationMode) {
111         this.orchestrationMode = orchestrationMode;
112     }
113
114     public String getDescription() {
115         return description;
116     }
117
118     public void setDescription(String description) {
119         this.description = description;
120     }
121
122     public Date getCreated() {
123         return created;
124     }
125
126     /**
127      * @return Returns the category.
128      */
129     public String getCategory() {
130         return category;
131     }
132
133     /**
134      * @param category The category to set.
135      */
136     public void setCategory(String category) {
137         this.category = category;
138     }
139
140     /**
141      * @return Returns the subCategory.
142      */
143     public String getSubCategory() {
144         return subCategory;
145     }
146
147     /**
148      * @param subCategory The subCategory to set.
149      */
150     public void setSubCategory(String subCategory) {
151         this.subCategory = subCategory;
152     }
153
154     public String getModelInvariantUUID() {
155         return this.modelInvariantUUID;
156     }
157
158     public void setModelInvariantUUID(String modelInvariantUUID) {
159         this.modelInvariantUUID = modelInvariantUUID;
160     }
161
162     public String getModelName() {
163         return modelName;
164     }
165
166     public void setModelName(String modelName) {
167         this.modelName = modelName;
168     }
169
170     public String getModelUUID() {
171         return modelUUID;
172     }
173
174     public void setModelUUID(String modelUUID) {
175         this.modelUUID = modelUUID;
176     }
177
178     public String getModelInvariantId() {
179         return this.modelInvariantUUID;
180     }
181
182     public String getToscaNodeType() {
183         return toscaNodeType;
184     }
185
186     public void setToscaNodeType(String toscaNodeType) {
187         this.toscaNodeType = toscaNodeType;
188     }
189
190     @LinkedResource
191     public List<PnfResourceCustomization> getPnfResourceCustomizations() {
192         if (pnfResourceCustomizations == null) {
193             pnfResourceCustomizations = new ArrayList<>();
194         }
195         return pnfResourceCustomizations;
196     }
197
198     public void setPnfResourceCustomizations(List<PnfResourceCustomization> pnfResourceCustomizations) {
199         this.pnfResourceCustomizations = pnfResourceCustomizations;
200     }
201
202     public String getModelVersion() {
203         return modelVersion;
204     }
205
206     public void setModelVersion(String modelVersion) {
207         this.modelVersion = modelVersion;
208     }
209 }