Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CollectionResource.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.Set;
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.Id;
30 import javax.persistence.OneToMany;
31 import javax.persistence.OneToOne;
32 import javax.persistence.PrePersist;
33 import javax.persistence.Table;
34 import javax.persistence.Temporal;
35 import javax.persistence.TemporalType;
36 import org.apache.commons.lang3.builder.EqualsBuilder;
37 import org.apache.commons.lang3.builder.HashCodeBuilder;
38 import org.apache.commons.lang3.builder.ToStringBuilder;
39 import com.openpojo.business.annotation.BusinessKey;
40 import uk.co.blackpepper.bowman.annotation.LinkedResource;
41
42 @Entity
43 @Table(name = "collection_resource")
44 public class CollectionResource implements Serializable {
45
46     /**
47      * 
48      */
49     private static final long serialVersionUID = -8612818857960992110L;
50
51     @BusinessKey
52     @Id
53     @Column(name = "MODEL_UUID")
54     private String modelUUID;
55
56     @Column(name = "MODEL_NAME")
57     private String modelName;
58
59     @Column(name = "MODEL_INVARIANT_UUID")
60     private String modelInvariantUUID;
61
62     @Column(name = "MODEL_VERSION")
63     private String modelVersion;
64
65     @Column(name = "TOSCA_NODE_TYPE")
66     private String toscaNodeType;
67
68     @Column(name = "DESCRIPTION")
69     private String description;
70
71     @Column(name = "CREATION_TIMESTAMP", updatable = false)
72     @Temporal(TemporalType.TIMESTAMP)
73     private Date created;
74
75     @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResource")
76     private Set<CollectionResourceCustomization> collectionResourceCustomization;
77
78     @OneToOne(cascade = CascadeType.ALL, mappedBy = "collectionResource")
79     private InstanceGroup instanceGroup;
80
81     @Override
82     public boolean equals(final Object other) {
83         if (!(other instanceof CollectionResource)) {
84             return false;
85         }
86         CollectionResource castOther = (CollectionResource) other;
87         return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
88     }
89
90     @Override
91     public int hashCode() {
92         return new HashCodeBuilder().append(modelUUID).toHashCode();
93     }
94
95     public Set<CollectionResourceCustomization> getCollectionResourceCustomization() {
96         return collectionResourceCustomization;
97     }
98
99     public void setCollectionResourceCustomization(
100             Set<CollectionResourceCustomization> collectionResourceCustomization) {
101         this.collectionResourceCustomization = collectionResourceCustomization;
102     }
103
104     public String getModelUUID() {
105         return modelUUID;
106     }
107
108     public Date getCreated() {
109         return this.created;
110     }
111
112     @PrePersist
113     protected void onCreate() {
114         this.created = new Date();
115     }
116
117     public void setModelUUID(String modelUUID) {
118         this.modelUUID = modelUUID;
119     }
120
121     public String getModelName() {
122         return modelName;
123     }
124
125     public void setModelName(String modelName) {
126         this.modelName = modelName;
127     }
128
129     public String getModelInvariantUUID() {
130         return modelInvariantUUID;
131     }
132
133     public void setModelInvariantUUID(String modelInvariantUUID) {
134         this.modelInvariantUUID = modelInvariantUUID;
135     }
136
137     public String getModelVersion() {
138         return modelVersion;
139     }
140
141     public void setModelVersion(String modelVersion) {
142         this.modelVersion = modelVersion;
143     }
144
145     public String getToscaNodeType() {
146         return toscaNodeType;
147     }
148
149     public void setToscaNodeType(String toscaNodeType) {
150         this.toscaNodeType = toscaNodeType;
151     }
152
153     public String getDescription() {
154         return description;
155     }
156
157     public void setDescription(String description) {
158         this.description = description;
159     }
160
161     @LinkedResource
162     public InstanceGroup getInstanceGroup() {
163         return instanceGroup;
164     }
165
166     public void setInstanceGroup(InstanceGroup instanceGroup) {
167         this.instanceGroup = instanceGroup;
168     }
169
170     @Override
171     public String toString() {
172         return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelName", modelName)
173                 .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion)
174                 .append("toscaNodeType", toscaNodeType).append("description", description).append("created", created)
175                 .toString();
176     }
177 }