[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CollectionResourceInstanceGroupCustomization.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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 javax.persistence.CascadeType;
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.FetchType;
29 import javax.persistence.Id;
30 import javax.persistence.IdClass;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.PrePersist;
34 import javax.persistence.Table;
35 import javax.persistence.Temporal;
36 import javax.persistence.TemporalType;
37 import org.apache.commons.lang3.builder.EqualsBuilder;
38 import org.apache.commons.lang3.builder.HashCodeBuilder;
39 import org.apache.commons.lang3.builder.ToStringBuilder;
40 import com.openpojo.business.annotation.BusinessKey;
41 import uk.co.blackpepper.bowman.annotation.LinkedResource;
42 import uk.co.blackpepper.bowman.annotation.RemoteResource;
43
44 @Entity
45 @RemoteResource("/collectionResourceInstanceGroupCustomization")
46 @IdClass(CollectionResourceInstanceGroupCustomizationId.class)
47 @Table(name = "collection_resource_instance_group_customization")
48 public class CollectionResourceInstanceGroupCustomization implements Serializable {
49
50     /**
51      * 
52      */
53     private static final long serialVersionUID = 5169990063225044265L;
54
55     @BusinessKey
56     @Id
57     @Column(name = "COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID")
58     private String modelCustomizationUUID;
59
60     @BusinessKey
61     @Id
62     @Column(name = "INSTANCE_GROUP_MODEL_UUID")
63     private String modelUUID;
64
65     @BusinessKey
66     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
67     @JoinColumn(name = "COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID", updatable = false, insertable = false)
68     private CollectionResourceCustomization collectionResourceCust;
69
70     @BusinessKey
71     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
72     @JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID", updatable = false, insertable = false)
73     private InstanceGroup instanceGroup;
74
75     @Column(name = "FUNCTION")
76     private String function;
77
78     @Column(name = "DESCRIPTION")
79     private String description;
80
81     @Column(name = "CREATION_TIMESTAMP", updatable = false)
82     @Temporal(TemporalType.TIMESTAMP)
83     private Date created;
84
85     @Column(name = "SUBINTERFACE_NETWORK_QUANTITY")
86     private Integer subInterfaceNetworkQuantity;
87
88     @Override
89     public String toString() {
90         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
91                 .append("modelUUID", modelUUID).append("collectionResourceCust", collectionResourceCust)
92                 .append("instanceGroup", instanceGroup).append("function", function).append("description", description)
93                 .append("created", created).append("subInterfaceNetworkQuantity", subInterfaceNetworkQuantity)
94                 .toString();
95     }
96
97     @Override
98     public boolean equals(final Object other) {
99         if (!(other instanceof CollectionResourceInstanceGroupCustomization)) {
100             return false;
101         }
102         CollectionResourceInstanceGroupCustomization castOther = (CollectionResourceInstanceGroupCustomization) other;
103         return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID)
104                 .append(modelUUID, castOther.modelUUID).append(collectionResourceCust, castOther.collectionResourceCust)
105                 .append(instanceGroup, castOther.instanceGroup).isEquals();
106     }
107
108     @Override
109     public int hashCode() {
110         return new HashCodeBuilder().append(modelCustomizationUUID).append(modelUUID).append(collectionResourceCust)
111                 .append(instanceGroup).toHashCode();
112     }
113
114     @PrePersist
115     protected void onCreate() {
116         this.created = new Date();
117     }
118
119     public String getModelCustomizationUUID() {
120         return modelCustomizationUUID;
121     }
122
123     public void setModelCustomizationUUID(String modelCustomizationUUID) {
124         this.modelCustomizationUUID = modelCustomizationUUID;
125     }
126
127     public String getModelUUID() {
128         return modelUUID;
129     }
130
131     public void setModelUUID(String modelUUID) {
132         this.modelUUID = modelUUID;
133     }
134
135     public String getFunction() {
136         return function;
137     }
138
139     public void setFunction(String function) {
140         this.function = function;
141     }
142
143     public String getDescription() {
144         return description;
145     }
146
147     public void setDescription(String description) {
148         this.description = description;
149     }
150
151     public Date getCreated() {
152         return created;
153     }
154
155     public Integer getSubInterfaceNetworkQuantity() {
156         return subInterfaceNetworkQuantity;
157     }
158
159     public void setSubInterfaceNetworkQuantity(Integer subInterfaceNetworkQuantity) {
160         this.subInterfaceNetworkQuantity = subInterfaceNetworkQuantity;
161     }
162
163     @LinkedResource
164     public CollectionResourceCustomization getCollectionResourceCust() {
165         return collectionResourceCust;
166     }
167
168     public void setCollectionResourceCust(CollectionResourceCustomization collectionResourceCust) {
169         this.collectionResourceCust = collectionResourceCust;
170     }
171
172     @LinkedResource
173     public InstanceGroup getInstanceGroup() {
174         return instanceGroup;
175     }
176
177     public void setInstanceGroup(InstanceGroup instanceGroup) {
178         this.instanceGroup = instanceGroup;
179     }
180 }