Replaced all tabs with spaces in java and pom.xml
[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
47 @Entity
48 @DiscriminatorColumn(name = "OBJECT_TYPE")
49 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
50 @Table(name = "collection_resource_customization")
51 public class CollectionResourceCustomization implements Serializable {
52
53     /**
54      * 
55      */
56     private static final long serialVersionUID = -8328823396870652841L;
57
58     @BusinessKey
59     @Id
60     @Column(name = "MODEL_CUSTOMIZATION_UUID")
61     private String modelCustomizationUUID;
62
63     @Column(name = "MODEL_INSTANCE_NAME")
64     private String modelInstanceName;
65
66     @Column(name = "COLLECTION_RESOURCE_TYPE")
67     private String type;
68
69     @Column(name = "ROLE")
70     private String role;
71
72     @Column(name = "FUNCTION")
73     private String function;
74
75     @Column(name = "CREATION_TIMESTAMP", updatable = false)
76     @Temporal(TemporalType.TIMESTAMP)
77     private Date created;
78
79     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
80     @JoinColumn(name = "CR_MODEL_UUID")
81     private CollectionResource collectionResource;
82
83     @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResourceCust")
84     private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
85
86     @Override
87     public String toString() {
88         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
89                 .append("modelInstanceName", modelInstanceName).append("type", type).append("role", role)
90                 .append("function", function).append("created", created)
91                 .append("collectionResource", collectionResource)
92                 .append("collectionInstanceGroupCustomizations", collectionInstanceGroupCustomizations).toString();
93     }
94
95     @Override
96     public boolean equals(final Object other) {
97         if (!(other instanceof CollectionResourceCustomization)) {
98             return false;
99         }
100         CollectionResourceCustomization castOther = (CollectionResourceCustomization) other;
101         return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
102     }
103
104     @Override
105     public int hashCode() {
106         return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
107     }
108
109     public Date getCreated() {
110         return this.created;
111     }
112
113     @PrePersist
114     protected void onCreate() {
115         this.created = new Date();
116     }
117
118     public String getModelCustomizationUUID() {
119         return modelCustomizationUUID;
120     }
121
122     public void setModelCustomizationUUID(String modelCustomizationUUID) {
123         this.modelCustomizationUUID = modelCustomizationUUID;
124     }
125
126     public String getModelInstanceName() {
127         return modelInstanceName;
128     }
129
130     public void setModelInstanceName(String modelInstanceName) {
131         this.modelInstanceName = modelInstanceName;
132     }
133
134     public String getType() {
135         return type;
136     }
137
138     public void setType(String type) {
139         this.type = type;
140     }
141
142     public String getRole() {
143         return role;
144     }
145
146     public void setRole(String role) {
147         this.role = role;
148     }
149
150     public String getFunction() {
151         return function;
152     }
153
154     public void setFunction(String function) {
155         this.function = function;
156     }
157
158     @LinkedResource
159     public CollectionResource getCollectionResource() {
160         return collectionResource;
161     }
162
163     public void setCollectionResource(CollectionResource collectionResource) {
164         this.collectionResource = collectionResource;
165     }
166
167     @LinkedResource
168     public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
169         return collectionInstanceGroupCustomizations;
170     }
171
172     public void setCollectionInstanceGroupCustomizations(
173             List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
174         this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;
175     }
176 }