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