[SO] Release so 1.13.0 image
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / Model.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 package org.onap.so.db.catalog.beans;
21
22
23 import java.io.Serializable;
24 import java.util.Date;
25 import java.util.Map;
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.MapKey;
34 import javax.persistence.OneToMany;
35 import javax.persistence.Table;
36 import javax.persistence.Temporal;
37 import javax.persistence.TemporalType;
38 import org.apache.commons.lang3.builder.EqualsBuilder;
39 import org.apache.commons.lang3.builder.HashCodeBuilder;
40 import org.apache.commons.lang3.builder.ToStringBuilder;
41 import com.openpojo.business.annotation.BusinessKey;
42 import uk.co.blackpepper.bowman.annotation.RemoteResource;
43
44 @Entity
45 @RemoteResource("/model")
46 @Table(name = "model")
47 public class Model implements Serializable {
48
49     private static final long serialVersionUID = 768026109321305392L;
50
51     @Id
52     @Column(name = "ID", nullable = false, updatable = false)
53     @GeneratedValue(strategy = GenerationType.IDENTITY)
54     private Integer id;
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;
63     @BusinessKey
64     @Column(name = "MODEL_TYPE", length = 20)
65     private String modelType = null;
66     @Column(name = "MODEL_VERSION", length = 20)
67     private String modelVersion = null;
68     @BusinessKey
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;
77
78     /**
79      * @return the id
80      */
81     public Integer getId() {
82         return id;
83     }
84
85     /**
86      * @return the modelCustomizationId
87      */
88     public String getModelCustomizationId() {
89         return modelCustomizationId;
90     }
91
92     /**
93      * @param modelCustomizationId the modelCustomizationId to set
94      */
95     public void setModelCustomizationId(String modelCustomizationId) {
96         this.modelCustomizationId = modelCustomizationId;
97     }
98
99     /**
100      * @return the modelCustomizationName
101      */
102     public String getModelCustomizationName() {
103         return modelCustomizationName;
104     }
105
106     /**
107      * @param modelCustomizationName the modelCustomizationName to set
108      */
109     public void setModelCustomizationName(String modelCustomizationName) {
110         this.modelCustomizationName = modelCustomizationName;
111     }
112
113     /**
114      * @return the modelInvariantId
115      */
116     public String getModelInvariantId() {
117         return modelInvariantId;
118     }
119
120     /**
121      * @param modelInvariantId the modelInvariantId to set
122      */
123     public void setModelInvariantId(String modelInvariantId) {
124         this.modelInvariantId = modelInvariantId;
125     }
126
127     /**
128      * @return the modelName
129      */
130     public String getModelName() {
131         return modelName;
132     }
133
134     /**
135      * @param modelName the modelName to set
136      */
137     public void setModelName(String modelName) {
138         this.modelName = modelName;
139     }
140
141     /**
142      * @return the modelType
143      */
144     public String getModelType() {
145         return modelType;
146     }
147
148     /**
149      * @param modelType the modelType to set
150      */
151     public void setModelType(String modelType) {
152         this.modelType = modelType;
153     }
154
155     /**
156      * @return the modelVersion
157      */
158     public String getModelVersion() {
159         return modelVersion;
160     }
161
162     /**
163      * @param modelVersion the modelVersion to set
164      */
165     public void setModelVersion(String modelVersion) {
166         this.modelVersion = modelVersion;
167     }
168
169     /**
170      * @return the modelVersionId
171      */
172     public String getModelVersionId() {
173         return modelVersionId;
174     }
175
176     /**
177      * @param modelVersionId the modelVersionId to set
178      */
179     public void setModelVersionId(String modelVersionId) {
180         this.modelVersionId = modelVersionId;
181     }
182
183     /**
184      * @return the created
185      */
186     public Date getCreated() {
187         return created;
188     }
189
190     /**
191      * @return the recipes
192      */
193     public Map<String, ModelRecipe> getRecipes() {
194         return recipes;
195     }
196
197     /**
198      * @param recipes the recipes to set
199      */
200     public void setRecipes(Map<String, ModelRecipe> recipes) {
201         this.recipes = recipes;
202     }
203
204     @Override
205     public boolean equals(final Object other) {
206         if (!(other instanceof Model)) {
207             return false;
208         }
209         Model castOther = (Model) other;
210         return new EqualsBuilder().append(getModelType(), castOther.getModelType())
211                 .append(getModelVersionId(), castOther.getModelVersionId()).isEquals();
212     }
213
214     @Override
215     public int hashCode() {
216         return new HashCodeBuilder().append(getModelType()).append(getModelVersionId()).toHashCode();
217     }
218
219     @Override
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();
227     }
228
229 }