51bcd54ae119dd7a44ee4975184670c885ebe1bf
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / NetworkRecipe.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
21 package org.onap.so.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.Id;
29 import javax.persistence.PrePersist;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33
34 import org.apache.commons.lang3.builder.EqualsBuilder;
35 import org.apache.commons.lang3.builder.HashCodeBuilder;
36
37 import com.openpojo.business.annotation.BusinessKey;
38
39 @Entity
40 @Table(name = "network_recipe")
41 public class NetworkRecipe implements Serializable, Recipe {
42         private static final long serialVersionUID = 768026109321305392L;
43
44         @Id
45         @Column(name = "id")
46         private Integer id;
47
48         @BusinessKey
49         @Column(name = "ACTION")
50         protected String action;
51
52         @Column(name = "DESCRIPTION")
53         private String description;
54
55         @BusinessKey
56         @Column(name = "ORCHESTRATION_URI")
57         protected String orchestrationUri;
58
59         @Column(name = "RECIPE_TIMEOUT")
60         private Integer recipeTimeout;
61
62         @Column(name = "VERSION_STR")
63         private String versionStr;
64
65         @BusinessKey
66         @Column(name = "SERVICE_TYPE")
67         private String serviceType;
68
69         @BusinessKey
70         @Column(name = "MODEL_NAME")
71         private String modelName;
72
73         @Column(name = "NETWORK_PARAM_XSD")
74         private String paramXsd;
75
76         @Column(name = "CREATION_TIMESTAMP", updatable = false)
77         @Temporal(TemporalType.TIMESTAMP)
78         private Date created;
79
80         @PrePersist
81         protected void onCreate() {
82                 this.created = new Date();
83         }
84
85         @Override
86         public boolean equals(final Object other) {
87                 if (!(other instanceof NetworkRecipe)) {
88                         return false;
89                 }
90                 NetworkRecipe castOther = (NetworkRecipe) other;
91                 return new EqualsBuilder().append(action, castOther.action).append(orchestrationUri, castOther.orchestrationUri)
92                                 .append(serviceType, castOther.serviceType).append(modelName, castOther.modelName).isEquals();
93         }
94
95         @Override
96         public int hashCode() {
97                 return new HashCodeBuilder().append(action).append(orchestrationUri).append(serviceType).append(modelName)
98                                 .toHashCode();
99         }
100
101         public Integer getId() {
102                 return id;
103         }
104
105         public void setId(Integer id) {
106                 this.id = id;
107         }
108
109         public String getAction() {
110                 return action;
111         }
112
113         public void setAction(String action) {
114                 this.action = action;
115         }
116
117         public String getDescription() {
118                 return description;
119         }
120
121         public void setDescription(String description) {
122                 this.description = description;
123         }
124
125         public String getOrchestrationUri() {
126                 return orchestrationUri;
127         }
128
129         public void setOrchestrationUri(String orchestrationUri) {
130                 this.orchestrationUri = orchestrationUri;
131         }
132
133         public Integer getRecipeTimeout() {
134                 return recipeTimeout;
135         }
136
137         public void setRecipeTimeout(Integer recipeTimeout) {
138                 this.recipeTimeout = recipeTimeout;
139         }
140
141         public String getServiceType() {
142                 return serviceType;
143         }
144
145         public void setServiceType(String serviceType) {
146                 this.serviceType = serviceType;
147         }
148
149         public Date getCreated() {
150                 return created;
151         }
152
153         public String getModelName() {
154                 return modelName;
155         }
156
157         public void setModelName(String modelName) {
158                 this.modelName = modelName;
159         }
160
161         public String getParamXsd() {
162                 return paramXsd;
163         }
164
165         public void setParamXsd(String paramXsd) {
166                 this.paramXsd = paramXsd;
167         }
168
169         @Override
170         public String toString() {
171                 StringBuilder sb = new StringBuilder();
172                 sb.append(super.toString());
173                 sb.append(",modelName=" + modelName);
174                 sb.append(",networkParamXSD=" + paramXsd);
175                 return sb.toString();
176         }
177
178         public String getVersionStr() {
179                 return versionStr;
180         }
181
182         public void setVersionStr(String versionStr) {
183                 this.versionStr = versionStr;
184         }
185 }