Containerization feature of SO
[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         @BusinessKey
63         @Column(name = "SERVICE_TYPE")
64         private String serviceType;
65
66         @BusinessKey
67         @Column(name = "MODEL_NAME")
68         private String modelName;
69
70         @Column(name = "NETWORK_PARAM_XSD")
71         private String paramXsd;
72
73         @Column(name = "CREATION_TIMESTAMP", updatable = false)
74         @Temporal(TemporalType.TIMESTAMP)
75         private Date created;
76
77         @PrePersist
78         protected void onCreate() {
79                 this.created = new Date();
80         }
81
82         @Override
83         public boolean equals(final Object other) {
84                 if (!(other instanceof NetworkRecipe)) {
85                         return false;
86                 }
87                 NetworkRecipe castOther = (NetworkRecipe) other;
88                 return new EqualsBuilder().append(action, castOther.action).append(orchestrationUri, castOther.orchestrationUri)
89                                 .append(serviceType, castOther.serviceType).append(modelName, castOther.modelName).isEquals();
90         }
91
92         @Override
93         public int hashCode() {
94                 return new HashCodeBuilder().append(action).append(orchestrationUri).append(serviceType).append(modelName)
95                                 .toHashCode();
96         }
97
98         public Integer getId() {
99                 return id;
100         }
101
102         public void setId(Integer id) {
103                 this.id = id;
104         }
105
106         public String getAction() {
107                 return action;
108         }
109
110         public void setAction(String action) {
111                 this.action = action;
112         }
113
114         public String getDescription() {
115                 return description;
116         }
117
118         public void setDescription(String description) {
119                 this.description = description;
120         }
121
122         public String getOrchestrationUri() {
123                 return orchestrationUri;
124         }
125
126         public void setOrchestrationUri(String orchestrationUri) {
127                 this.orchestrationUri = orchestrationUri;
128         }
129
130         public Integer getRecipeTimeout() {
131                 return recipeTimeout;
132         }
133
134         public void setRecipeTimeout(Integer recipeTimeout) {
135                 this.recipeTimeout = recipeTimeout;
136         }
137
138         public String getServiceType() {
139                 return serviceType;
140         }
141
142         public void setServiceType(String serviceType) {
143                 this.serviceType = serviceType;
144         }
145
146         public Date getCreated() {
147                 return created;
148         }
149
150         public String getModelName() {
151                 return modelName;
152         }
153
154         public void setModelName(String modelName) {
155                 this.modelName = modelName;
156         }
157
158         public String getParamXsd() {
159                 return paramXsd;
160         }
161
162         public void setParamXsd(String paramXsd) {
163                 this.paramXsd = paramXsd;
164         }
165
166         @Override
167         public String toString() {
168                 StringBuilder sb = new StringBuilder();
169                 sb.append(super.toString());
170                 sb.append(",modelName=" + modelName);
171                 sb.append(",networkParamXSD=" + paramXsd);
172                 return sb.toString();
173         }
174 }