2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.db.catalog.beans;
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;
48 @DiscriminatorColumn(name = "OBJECT_TYPE")
49 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
50 @Table(name = "collection_resource_customization")
51 public class CollectionResourceCustomization implements Serializable {
56 private static final long serialVersionUID = -8328823396870652841L;
60 @Column(name = "MODEL_CUSTOMIZATION_UUID")
61 private String modelCustomizationUUID;
63 @Column(name = "MODEL_INSTANCE_NAME")
64 private String modelInstanceName;
66 @Column(name = "COLLECTION_RESOURCE_TYPE")
69 @Column(name = "ROLE")
72 @Column(name = "FUNCTION")
73 private String function;
75 @Column(name = "CREATION_TIMESTAMP", updatable = false)
76 @Temporal(TemporalType.TIMESTAMP)
79 @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
80 @JoinColumn(name = "CR_MODEL_UUID")
81 private CollectionResource collectionResource;
83 @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResourceCust")
84 private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
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();
96 public boolean equals(final Object other) {
97 if (!(other instanceof CollectionResourceCustomization)) {
100 CollectionResourceCustomization castOther = (CollectionResourceCustomization) other;
101 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
105 public int hashCode() {
106 return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
109 public Date getCreated() {
114 protected void onCreate() {
115 this.created = new Date();
118 public String getModelCustomizationUUID() {
119 return modelCustomizationUUID;
122 public void setModelCustomizationUUID(String modelCustomizationUUID) {
123 this.modelCustomizationUUID = modelCustomizationUUID;
126 public String getModelInstanceName() {
127 return modelInstanceName;
130 public void setModelInstanceName(String modelInstanceName) {
131 this.modelInstanceName = modelInstanceName;
134 public String getType() {
138 public void setType(String type) {
142 public String getRole() {
146 public void setRole(String role) {
150 public String getFunction() {
154 public void setFunction(String function) {
155 this.function = function;
159 public CollectionResource getCollectionResource() {
160 return collectionResource;
163 public void setCollectionResource(CollectionResource collectionResource) {
164 this.collectionResource = collectionResource;
168 public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
169 return collectionInstanceGroupCustomizations;
172 public void setCollectionInstanceGroupCustomizations(
173 List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
174 this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;