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;
46 import uk.co.blackpepper.bowman.annotation.RemoteResource;
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 {
58 private static final long serialVersionUID = -8328823396870652841L;
62 @Column(name = "MODEL_CUSTOMIZATION_UUID")
63 private String modelCustomizationUUID;
65 @Column(name = "MODEL_INSTANCE_NAME")
66 private String modelInstanceName;
68 @Column(name = "COLLECTION_RESOURCE_TYPE")
71 @Column(name = "ROLE")
74 @Column(name = "FUNCTION")
75 private String function;
77 @Column(name = "CREATION_TIMESTAMP", updatable = false)
78 @Temporal(TemporalType.TIMESTAMP)
81 @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
82 @JoinColumn(name = "CR_MODEL_UUID")
83 private CollectionResource collectionResource;
85 @OneToMany(cascade = CascadeType.ALL, mappedBy = "collectionResourceCust")
86 private List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations;
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();
98 public boolean equals(final Object other) {
99 if (!(other instanceof CollectionResourceCustomization)) {
102 CollectionResourceCustomization castOther = (CollectionResourceCustomization) other;
103 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
107 public int hashCode() {
108 return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
111 public Date getCreated() {
116 protected void onCreate() {
117 this.created = new Date();
120 public String getModelCustomizationUUID() {
121 return modelCustomizationUUID;
124 public void setModelCustomizationUUID(String modelCustomizationUUID) {
125 this.modelCustomizationUUID = modelCustomizationUUID;
128 public String getModelInstanceName() {
129 return modelInstanceName;
132 public void setModelInstanceName(String modelInstanceName) {
133 this.modelInstanceName = modelInstanceName;
136 public String getType() {
140 public void setType(String type) {
144 public String getRole() {
148 public void setRole(String role) {
152 public String getFunction() {
156 public void setFunction(String function) {
157 this.function = function;
161 public CollectionResource getCollectionResource() {
162 return collectionResource;
165 public void setCollectionResource(CollectionResource collectionResource) {
166 this.collectionResource = collectionResource;
170 public List<CollectionResourceInstanceGroupCustomization> getCollectionInstanceGroupCustomizations() {
171 return collectionInstanceGroupCustomizations;
174 public void setCollectionInstanceGroupCustomizations(
175 List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations) {
176 this.collectionInstanceGroupCustomizations = collectionInstanceGroupCustomizations;