Adding rest service for so monitoring
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / InfraRequests.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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.request.beans;
22
23 import java.net.URI;
24 import java.sql.Timestamp;
25 import java.util.Date;
26 import java.util.Objects;
27
28 import javax.persistence.Column;
29 import javax.persistence.Id;
30 import javax.persistence.MappedSuperclass;
31 import javax.persistence.PrePersist;
32 import javax.persistence.PreUpdate;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
36
37 import org.apache.commons.lang3.builder.ToStringBuilder;
38 import org.onap.so.requestsdb.adapter.TimestampXMLAdapter;
39
40 import uk.co.blackpepper.bowman.annotation.ResourceId;
41
42 @MappedSuperclass
43 public abstract class InfraRequests implements java.io.Serializable {
44
45     private static final long serialVersionUID = -5497583682393936143L;
46     private static final String UNKNOWN = "unknown";
47
48
49     @Id
50     @Column(name = "REQUEST_ID", length = 45)
51     private String requestId;
52     @Column(name = "CLIENT_REQUEST_ID", length = 45, unique = true)
53     private String clientRequestId;
54     @Column(name = "ACTION", length = 45)
55     private String action;
56     @Column(name = "REQUEST_STATUS", length = 20)
57     private String requestStatus;
58     @Column(name = "STATUS_MESSAGE", length = 2000)
59     private String statusMessage;
60     @Column(name = "PROGRESS", precision = 11)
61     private Long progress;
62
63     @Column(name = "START_TIME")
64     private Timestamp startTime;
65     @Column(name = "END_TIME")
66     private Timestamp endTime;
67     @Column(name = "SOURCE", length = 45)
68     private String source;
69     @Column(name = "VNF_ID", length = 45)
70     private String vnfId;
71     @Column(name = "VNF_NAME", length = 80)
72     private String vnfName;
73     @Column(name = "VNF_TYPE", length = 200)
74     private String vnfType;
75     @Column(name = "SERVICE_TYPE", length = 45)
76     private String serviceType;
77     @Column(name = "AIC_NODE_CLLI", length = 11)
78     private String aicNodeClli;
79     @Column(name = "TENANT_ID", length = 45)
80     private String tenantId;
81     @Column(name = "PROV_STATUS", length = 20)
82     private String provStatus;
83     @Column(name = "VNF_PARAMS")
84     private String vnfParams;
85     @Column(name = "VNF_OUTPUTS")
86     private String vnfOutputs;
87     @Column(name = "REQUEST_BODY")
88     private String requestBody;
89     @Column(name = "RESPONSE_BODY")
90     private String responseBody;
91     @Column(name = "LAST_MODIFIED_BY", length = 50)
92     private String lastModifiedBy;
93     @Column(name = "MODIFY_TIME")
94     @Temporal(TemporalType.TIMESTAMP)
95     private Date modifyTime;
96     @Column(name = "REQUEST_TYPE", length = 20)
97     private String requestType;
98     @Column(name = "VOLUME_GROUP_ID", length = 45)
99     private String volumeGroupId;
100     @Column(name = "VOLUME_GROUP_NAME", length = 45)
101     private String volumeGroupName;
102     @Column(name = "VF_MODULE_ID", length = 45)
103     private String vfModuleId;
104     @Column(name = "VF_MODULE_NAME", length = 200)
105     private String vfModuleName;
106     @Column(name = "VF_MODULE_MODEL_NAME", length = 200)
107     private String vfModuleModelName;
108     @Column(name = "AAI_SERVICE_ID", length = 50)
109     private String aaiServiceId;
110     @Column(name = "AIC_CLOUD_REGION", length = 11)
111     private String aicCloudRegion;
112     @Column(name = "CALLBACK_URL", length = 200)
113     private String callBackUrl;
114     @Column(name = "CORRELATOR", length = 80)
115     private String correlator;
116     @Column(name = "SERVICE_INSTANCE_ID", length = 45)
117     private String serviceInstanceId;
118     @Column(name = "SERVICE_INSTANCE_NAME", length = 80)
119     private String serviceInstanceName;
120     @Column(name = "REQUEST_SCOPE", length = 45)
121     private String requestScope;
122     @Column(name = "REQUEST_ACTION", length = 45)
123     private String requestAction;
124     @Column(name = "NETWORK_ID", length = 45)
125     private String networkId;
126     @Column(name = "NETWORK_NAME", length = 80)
127     private String networkName;
128     @Column(name = "NETWORK_TYPE", length = 80)
129     private String networkType;
130     @Column(name = "REQUESTOR_ID", length = 80)
131     private String requestorId;
132     @Column(name = "CONFIGURATION_ID", length = 45)
133     private String configurationId;
134     @Column(name = "CONFIGURATION_NAME", length = 200)
135     private String configurationName;
136     @Column(name = "OPERATIONAL_ENV_ID", length = 45)
137     private String operationalEnvId;
138     @Column(name = "OPERATIONAL_ENV_NAME", length = 200)
139     private String operationalEnvName;
140
141     @ResourceId
142     public URI getRequestURI() {
143         return URI.create(this.requestId);
144     }
145
146     public String getRequestId() {
147         return this.requestId;
148     }
149
150     public void setRequestId(String requestId) {
151         this.requestId = requestId;
152     }
153
154     public String getClientRequestId() {
155         return clientRequestId;
156     }
157
158     public void setClientRequestId(String clientRequestId) {
159         this.clientRequestId = clientRequestId;
160     }
161
162     public String getAction() {
163         return this.action;
164     }
165
166     public void setAction(String action) {
167         this.action = action;
168     }
169
170     public String getRequestStatus() {
171         return this.requestStatus;
172     }
173
174     public void setRequestStatus(String requestStatus) {
175         this.requestStatus = requestStatus;
176     }
177
178     public String getStatusMessage() {
179         return this.statusMessage;
180     }
181
182     public void setStatusMessage(String statusMessage) {
183         this.statusMessage = statusMessage;
184     }
185
186     public Long getProgress() {
187         return this.progress;
188     }
189
190     public void setProgress(Long progress) {
191         this.progress = progress;
192     }
193
194     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
195     public Timestamp getStartTime() {
196         return this.startTime;
197     }
198
199     public void setStartTime(Timestamp startTime) {
200         this.startTime = startTime;
201     }
202
203     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
204     public Timestamp getEndTime() {
205         return this.endTime;
206     }
207
208     public void setEndTime(Timestamp endTime) {
209         this.endTime = endTime;
210     }
211
212     public String getSource() {
213         return this.source;
214     }
215
216     public void setSource(String source) {
217         this.source = source;
218     }
219
220     public String getVnfId() {
221         return this.vnfId;
222     }
223
224     public void setVnfId(String vnfId) {
225         this.vnfId = vnfId;
226     }
227
228     public String getVnfName() {
229         return this.vnfName;
230     }
231
232     public void setVnfName(String vnfName) {
233         this.vnfName = vnfName;
234     }
235
236     public String getVnfType() {
237         return this.vnfType;
238     }
239
240     public void setVnfType(String vnfType) {
241         this.vnfType = vnfType;
242     }
243
244     public String getServiceType() {
245         return this.serviceType;
246     }
247
248     public void setServiceType(String serviceType) {
249         this.serviceType = serviceType;
250     }
251
252     public String getAicNodeClli() {
253         return this.aicNodeClli;
254     }
255
256     public void setAicNodeClli(String aicNodeClli) {
257         this.aicNodeClli = aicNodeClli;
258     }
259
260     public String getTenantId() {
261         return this.tenantId;
262     }
263
264     public void setTenantId(String tenantId) {
265         this.tenantId = tenantId;
266     }
267
268     public String getProvStatus() {
269         return this.provStatus;
270     }
271
272     public void setProvStatus(String provStatus) {
273         this.provStatus = provStatus;
274     }
275
276     public String getVnfParams() {
277         return this.vnfParams;
278     }
279
280     public void setVnfParams(String vnfParams) {
281         this.vnfParams = vnfParams;
282     }
283
284     public String getVnfOutputs() {
285         return this.vnfOutputs;
286     }
287
288     public void setVnfOutputs(String vnfOutputs) {
289         this.vnfOutputs = vnfOutputs;
290     }
291
292     public String getRequestBody() {
293         return this.requestBody;
294     }
295
296     public void setRequestBody(String requestBody) {
297         this.requestBody = requestBody;
298     }
299
300     public String getResponseBody() {
301         return this.responseBody;
302     }
303
304     public void setResponseBody(String responseBody) {
305         this.responseBody = responseBody;
306     }
307
308     public String getLastModifiedBy() {
309         return this.lastModifiedBy;
310     }
311
312     public void setLastModifiedBy(String lastModifiedBy) {
313         this.lastModifiedBy = lastModifiedBy;
314     }
315
316     public Date getModifyTime() {
317         return this.modifyTime;
318     }
319
320     public String getRequestType() {
321         return this.requestType;
322     }
323
324     public void setRequestType(String requestType) {
325         this.requestType = requestType;
326     }
327
328     public String getVolumeGroupId() {
329         return this.volumeGroupId;
330     }
331
332     public void setVolumeGroupId(String volumeGroupId) {
333         this.volumeGroupId = volumeGroupId;
334     }
335
336     public String getVolumeGroupName() {
337         return this.volumeGroupName;
338     }
339
340     public void setVolumeGroupName(String volumeGroupName) {
341         this.volumeGroupName = volumeGroupName;
342     }
343
344     public String getVfModuleId() {
345         return this.vfModuleId;
346     }
347
348     public void setVfModuleId(String vfModuleId) {
349         this.vfModuleId = vfModuleId;
350     }
351
352     public String getVfModuleName() {
353         return this.vfModuleName;
354     }
355
356     public void setVfModuleName(String vfModuleName) {
357         this.vfModuleName = vfModuleName;
358     }
359
360     public String getVfModuleModelName() {
361         return this.vfModuleModelName;
362     }
363
364     public void setVfModuleModelName(String vfModuleModelName) {
365         this.vfModuleModelName = vfModuleModelName;
366     }
367
368     public String getAaiServiceId() {
369         return this.aaiServiceId;
370     }
371
372     public void setAaiServiceId(String aaiServiceId) {
373         this.aaiServiceId = aaiServiceId;
374     }
375
376     public String getAicCloudRegion() {
377         return this.aicCloudRegion;
378     }
379
380     public void setAicCloudRegion(String aicCloudRegion) {
381         this.aicCloudRegion = aicCloudRegion;
382     }
383
384     public String getCallBackUrl() {
385         return callBackUrl;
386     }
387
388     public void setCallBackUrl(String callBackUrl) {
389         this.callBackUrl = callBackUrl;
390     }
391
392     public String getCorrelator() {
393         return correlator;
394     }
395
396     public void setCorrelator(String correlator) {
397         this.correlator = correlator;
398     }
399
400     public String getServiceInstanceId() {
401         return serviceInstanceId;
402     }
403
404     public void setServiceInstanceId(String serviceInstanceId) {
405         this.serviceInstanceId = serviceInstanceId;
406     }
407
408     public String getServiceInstanceName() {
409         return serviceInstanceName;
410     }
411
412     public void setServiceInstanceName(String serviceInstanceName) {
413         this.serviceInstanceName = serviceInstanceName;
414     }
415
416     public String getRequestScope() {
417         return requestScope;
418     }
419
420     public void setRequestScope(String requestScope) {
421         this.requestScope = requestScope;
422     }
423
424     public String getRequestAction() {
425         return requestAction;
426     }
427
428     public void setRequestAction(String requestAction) {
429         this.requestAction = requestAction;
430     }
431
432     public String getNetworkId() {
433         return networkId;
434     }
435
436     public void setNetworkId(String networkId) {
437         this.networkId = networkId;
438     }
439
440     public String getNetworkName() {
441         return networkName;
442     }
443
444     public void setNetworkName(String networkName) {
445         this.networkName = networkName;
446     }
447
448     public String getNetworkType() {
449         return networkType;
450     }
451
452     public void setNetworkType(String networkType) {
453         this.networkType = networkType;
454     }
455
456     public String getRequestorId() {
457         return requestorId;
458     }
459
460     public void setRequestorId(String requestorId) {
461         this.requestorId = requestorId;
462     }
463
464     public String getConfigurationId() {
465         return configurationId;
466     }
467
468     public void setConfigurationId(String configurationId) {
469         this.configurationId = configurationId;
470     }
471
472     public String getConfigurationName() {
473         return configurationName;
474     }
475
476     public void setConfigurationName(String configurationName) {
477         this.configurationName = configurationName;
478     }
479
480     public String getOperationalEnvId() {
481         return operationalEnvId;
482     }
483
484     public void setOperationalEnvId(String operationalEnvId) {
485         this.operationalEnvId = operationalEnvId;
486     }
487
488     public String getOperationalEnvName() {
489         return operationalEnvName;
490     }
491
492     public void setOperationalEnvName(String operationalEnvName) {
493         this.operationalEnvName = operationalEnvName;
494     }
495
496     @PrePersist
497     protected void onCreate() {
498         if (requestScope == null)
499             requestScope = UNKNOWN;
500         if (requestAction == null)
501             requestAction = UNKNOWN;
502         this.modifyTime = new Date();
503     }
504
505     @PreUpdate
506     protected void onUpdate() {
507         if (requestScope == null)
508             requestScope = UNKNOWN;
509         if (requestAction == null)
510             requestAction = UNKNOWN;
511         this.modifyTime = new Date();
512     }
513
514     @Override
515     public boolean equals(final Object other) {
516         if (this == other) {
517             return true;
518         }
519         if (!(other instanceof InfraRequests)) {
520             return false;
521         }
522         InfraRequests castOther = (InfraRequests) other;
523         return Objects.equals(getRequestId(), castOther.getRequestId());
524     }
525
526     @Override
527     public int hashCode() {
528         return Objects.hash(getRequestId());
529     }
530
531     @Override
532     public String toString() {
533         return new ToStringBuilder(this).append("requestId", getRequestId())
534                 .append("clientRequestId", getClientRequestId()).append("action", getAction())
535                 .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage())
536                 .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime())
537                 .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName())
538                 .append("vnfType", getVnfType()).append("serviceType", getServiceType())
539                 .append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId())
540                 .append("provStatus", getProvStatus()).append("vnfParams", getVnfParams())
541                 .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody())
542                 .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy())
543                 .append("modifyTime", getModifyTime()).append("requestType", getRequestType())
544                 .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName())
545                 .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName())
546                 .append("vfModuleModelName", getVfModuleModelName()).append("aaiServiceId", getAaiServiceId())
547                 .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl())
548                 .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId())
549                 .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope())
550                 .append("requestAction", getRequestAction()).append("networkId", getNetworkId())
551                 .append("networkName", getNetworkName()).append("networkType", getNetworkType())
552                 .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId())
553                 .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId())
554                 .append("operationalEnvName", getOperationalEnvName()).toString();
555     }
556 }