[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CollectionResourceCustomization.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.List;
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.DiscriminatorColumn;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.Id;
32 import javax.persistence.Inheritance;
33 import javax.persistence.InheritanceType;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.OneToMany;
37 import javax.persistence.PrePersist;
38 import javax.persistence.Table;
39 import javax.persistence.Temporal;
40 import javax.persistence.TemporalType;
41 import org.apache.commons.lang3.builder.EqualsBuilder;
42 import org.apache.commons.lang3.builder.HashCodeBuilder;
43 import org.apache.commons.lang3.builder.ToStringBuilder;
44 import com.openpojo.business.annotation.BusinessKey;
45 import uk.co.blackpepper.bowman.annotation.LinkedResource;
46 import uk.co.blackpepper.bowman.annotation.RemoteResource;
47
48 @Entity
49 @RemoteResource("/collectionResourceCustomization")
50 @DiscriminatorColumn(name = "OBJECT_TYPE")
51 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
52 @Table(name = "collection_resource_customization")
53 public class CollectionResourceCustomization implements Serializable {
54
55     /**
56      * 
57      */
58     private static final long serialVersionUID = -8328823396870652841L;
59
60     @BusinessKey
61     @Id
62     @Column(name = "MODEL_CUSTOMIZATION_UUID")
63     private String modelCustomizationUUID;
64
65     @Column(name = "MODEL_INSTANCE_NAME")
66     private String modelInstanceName;
67
68     @Column(name = "COLLECTION_RESOURCE_TYPE")
69     private String type;
70
71     @Column(name = "ROLE")
72     private String role;
73
74     @Column(name = "FUNCTION")
75     private String function;
76
77     @Column(name = "CREATION_TIMESTAMP", updatable = false)
78     @Temporal(TemporalType.TIMESTAMP)
79     private Date created;
80
81     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
82     @JoinColumn(name = "CR_MODEL_UUID")
83     private CollectionResource collectionResource;
84
85     @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResourceCust")
86     private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
87
88     @Override
89     public String toString() {
90         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
91                 .append("modelInstanceName", modelInstanceName).append("type", type).append("role", role)
92                 .append("function", function).append("created", created)
93                 .append("collectionResource", collectionResource)
94                 .append("collectionInstanceGroupCustomizations", collectionInstanceGroupCustomizations).toString();
95     }
96
97     @Override
98     public boolean equals(final Object other) {
99         if (!(other instanceof CollectionResourceCustomization)) {
100             return false;
101         }
102         CollectionResourceCustomization castOther = (CollectionResourceCustomization) other;
103         return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
104     }
105
106     @Override
107     public int hashCode() {
108         return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
109     }
110
111     public Date getCreated() {
112         return this.created;
113     }
114
115     @PrePersist
116     protected void onCreate() {
117         this.created = new Date();
118     }
119
120     public String getModelCustomizationUUID() {
121         return modelCustomizationUUID;
122     }
123
124     public void setModelCustomizationUUID(String modelCustomizationUUID) {
125         this.modelCustomizationUUID = modelCustomizationUUID;
126     }
127
128     public String getModelInstanceName() {
129         return modelInstanceName;
130     }
131
132     public void setModelInstanceName(String modelInstanceName) {
133         this.modelInstanceName = modelInstanceName;
134     }
135
136     public String getType() {
137         return type;
138     }
139
140     public void setType(String type) {
141         this.type = type;
142     }
143
144     public String getRole() {
145         return role;
146     }
147
148     public void setRole(String role) {
149         this.role = role;
150     }
151
152     public String getFunction() {
153         return function;
154     }
155
156     public void setFunction(String function) {
157         this.function = function;
158     }
159
160     @LinkedResource
161     public CollectionResource getCollectionResource() {
162         return collectionResource;
163     }
164
165     public void setCollectionResource(CollectionResource collectionResource) {
166         this.collectionResource = collectionResource;
167     }
168
169     @LinkedResource
170     public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
171         return collectionInstanceGroupCustomizations;
172     }
173
174     public void setCollectionInstanceGroupCustomizations(
175             List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
176         this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;
177     }
178 }