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=========================================================
20 package org.onap.so.db.catalog.beans;
23 import java.io.Serializable;
24 import java.util.Date;
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.MapKey;
35 import javax.persistence.OneToMany;
36 import javax.persistence.Table;
37 import javax.persistence.Temporal;
38 import javax.persistence.TemporalType;
40 import org.apache.commons.lang3.builder.EqualsBuilder;
41 import org.apache.commons.lang3.builder.HashCodeBuilder;
42 import org.apache.commons.lang3.builder.ToStringBuilder;
44 import com.openpojo.business.annotation.BusinessKey;
46 @Table(name = "model")
47 public class Model implements Serializable {
49 private static final long serialVersionUID = 768026109321305392L;
52 @Column(name = "ID", nullable = false, updatable = false)
53 @GeneratedValue(strategy = GenerationType.IDENTITY)
55 @Column(name = "MODEL_CUSTOMIZATION_ID", length = 40)
56 private String modelCustomizationId = null;
57 @Column(name = "MODEL_CUSTOMIZATION_NAME", length = 40)
58 private String modelCustomizationName = null;
59 @Column(name = "MODEL_INVARIANT_ID", length = 40)
60 private String modelInvariantId = null;
61 @Column(name = "MODEL_NAME", length = 40)
62 private String modelName = null;
64 @Column(name = "MODEL_TYPE", length = 20)
65 private String modelType = null;
66 @Column(name = "MODEL_VERSION", length = 20)
67 private String modelVersion = null;
69 @Column(name = "MODEL_VERSION_ID", length = 40)
70 private String modelVersionId = null;
71 @Column(name = "CREATION_TIMESTAMP", nullable = false, updatable = false)
72 @Temporal(TemporalType.TIMESTAMP)
73 private Date created = null;
74 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy="modelId")
75 @MapKey(name = "action")
76 private Map<String,ModelRecipe> recipes;
81 public Integer getId() {
86 * @return the modelCustomizationId
88 public String getModelCustomizationId() {
89 return modelCustomizationId;
93 * @param modelCustomizationId the modelCustomizationId to set
95 public void setModelCustomizationId(String modelCustomizationId) {
96 this.modelCustomizationId = modelCustomizationId;
100 * @return the modelCustomizationName
102 public String getModelCustomizationName() {
103 return modelCustomizationName;
107 * @param modelCustomizationName the modelCustomizationName to set
109 public void setModelCustomizationName(String modelCustomizationName) {
110 this.modelCustomizationName = modelCustomizationName;
114 * @return the modelInvariantId
116 public String getModelInvariantId() {
117 return modelInvariantId;
121 * @param modelInvariantId the modelInvariantId to set
123 public void setModelInvariantId(String modelInvariantId) {
124 this.modelInvariantId = modelInvariantId;
128 * @return the modelName
130 public String getModelName() {
135 * @param modelName the modelName to set
137 public void setModelName(String modelName) {
138 this.modelName = modelName;
142 * @return the modelType
144 public String getModelType() {
149 * @param modelType the modelType to set
151 public void setModelType(String modelType) {
152 this.modelType = modelType;
156 * @return the modelVersion
158 public String getModelVersion() {
163 * @param modelVersion the modelVersion to set
165 public void setModelVersion(String modelVersion) {
166 this.modelVersion = modelVersion;
170 * @return the modelVersionId
172 public String getModelVersionId() {
173 return modelVersionId;
177 * @param modelVersionId the modelVersionId to set
179 public void setModelVersionId(String modelVersionId) {
180 this.modelVersionId = modelVersionId;
184 * @return the created
186 public Date getCreated() {
191 * @return the recipes
193 public Map<String, ModelRecipe> getRecipes() {
198 * @param recipes the recipes to set
200 public void setRecipes(Map<String, ModelRecipe> recipes) {
201 this.recipes = recipes;
205 public boolean equals(final Object other) {
206 if (!(other instanceof Model)) {
209 Model castOther = (Model) other;
210 return new EqualsBuilder().append(getModelType(), castOther.getModelType())
211 .append(getModelVersionId(), castOther.getModelVersionId()).isEquals();
215 public int hashCode() {
216 return new HashCodeBuilder().append(getModelType()).append(getModelVersionId()).toHashCode();
220 public String toString() {
221 return new ToStringBuilder(this).append("id", getId()).append("modelCustomizationId", getModelCustomizationId())
222 .append("modelCustomizationName", getModelCustomizationName())
223 .append("modelInvariantId", getModelInvariantId()).append("modelName", getModelName())
224 .append("modelType", getModelType()).append("modelVersion", getModelVersion())
225 .append("modelVersionId", getModelVersionId()).append("created", getCreated())
226 .append("recipes", getRecipes()).toString();