add rollback ext system error source
[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.ArrayList;
26 import java.util.Date;
27 import java.util.List;
28 import java.util.Objects;
29 import javax.persistence.CascadeType;
30 import javax.persistence.Column;
31 import javax.persistence.FetchType;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.MappedSuperclass;
35 import javax.persistence.OneToMany;
36 import javax.persistence.PrePersist;
37 import javax.persistence.PreUpdate;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
41 import org.apache.commons.lang3.builder.ToStringBuilder;
42 import org.onap.so.requestsdb.TimestampXMLAdapter;
43 import uk.co.blackpepper.bowman.annotation.LinkedResource;
44 import uk.co.blackpepper.bowman.annotation.ResourceId;
45
46 @MappedSuperclass
47 public abstract class InfraRequests implements java.io.Serializable {
48
49     private static final long serialVersionUID = -5497583682393936143L;
50     private static final String UNKNOWN = "unknown";
51
52
53     @Id
54     @Column(name = "REQUEST_ID", length = 45)
55     private String requestId;
56     @Column(name = "CLIENT_REQUEST_ID", length = 45, unique = true)
57     private String clientRequestId;
58     @Column(name = "ACTION", length = 45)
59     private String action;
60     @Column(name = "REQUEST_STATUS", length = 20)
61     private String requestStatus;
62     @Column(name = "STATUS_MESSAGE", length = 2000)
63     private String statusMessage;
64     @Column(name = "ROLLBACK_STATUS_MESSAGE", length = 2000)
65     private String rollbackStatusMessage;
66     @Column(name = "FLOW_STATUS", length = 2000)
67     private String flowStatus;
68     @Column(name = "RETRY_STATUS_MESSAGE", length = 2000)
69     private String retryStatusMessage;
70     @Column(name = "PROGRESS", precision = 11)
71     private Long progress;
72
73     @Column(name = "START_TIME")
74     private Timestamp startTime;
75     @Column(name = "END_TIME")
76     private Timestamp endTime;
77     @Column(name = "SOURCE", length = 45)
78     private String source;
79     @Column(name = "VNF_ID", length = 45)
80     private String vnfId;
81     @Column(name = "VNF_NAME", length = 80)
82     private String vnfName;
83     @Column(name = "VNF_TYPE", length = 200)
84     private String vnfType;
85     @Column(name = "SERVICE_TYPE", length = 45)
86     private String serviceType;
87     @Column(name = "AIC_NODE_CLLI", length = 11)
88     private String aicNodeClli;
89     @Column(name = "TENANT_ID", length = 45)
90     private String tenantId;
91     @Column(name = "PROV_STATUS", length = 20)
92     private String provStatus;
93     @Column(name = "VNF_PARAMS")
94     private String vnfParams;
95     @Column(name = "VNF_OUTPUTS")
96     private String vnfOutputs;
97     @Column(name = "REQUEST_BODY")
98     private String requestBody;
99     @Column(name = "RESPONSE_BODY")
100     private String responseBody;
101     @Column(name = "LAST_MODIFIED_BY", length = 50)
102     private String lastModifiedBy;
103     @Column(name = "MODIFY_TIME")
104     @Temporal(TemporalType.TIMESTAMP)
105     private Date modifyTime;
106     @Column(name = "REQUEST_TYPE", length = 20)
107     private String requestType;
108     @Column(name = "VOLUME_GROUP_ID", length = 45)
109     private String volumeGroupId;
110     @Column(name = "VOLUME_GROUP_NAME", length = 45)
111     private String volumeGroupName;
112     @Column(name = "VF_MODULE_ID", length = 45)
113     private String vfModuleId;
114     @Column(name = "VF_MODULE_NAME", length = 200)
115     private String vfModuleName;
116     @Column(name = "VF_MODULE_MODEL_NAME", length = 200)
117     private String vfModuleModelName;
118     @Column(name = "AAI_SERVICE_ID", length = 50)
119     private String aaiServiceId;
120     @Column(name = "AIC_CLOUD_REGION", length = 11)
121     private String aicCloudRegion;
122     @Column(name = "CALLBACK_URL", length = 200)
123     private String callBackUrl;
124     @Column(name = "CORRELATOR", length = 80)
125     private String correlator;
126     @Column(name = "SERVICE_INSTANCE_ID", length = 45)
127     private String serviceInstanceId;
128     @Column(name = "SERVICE_INSTANCE_NAME", length = 80)
129     private String serviceInstanceName;
130     @Column(name = "REQUEST_SCOPE", length = 45)
131     private String requestScope;
132     @Column(name = "REQUEST_ACTION", length = 45)
133     private String requestAction;
134     @Column(name = "NETWORK_ID", length = 45)
135     private String networkId;
136     @Column(name = "NETWORK_NAME", length = 80)
137     private String networkName;
138     @Column(name = "NETWORK_TYPE", length = 80)
139     private String networkType;
140     @Column(name = "REQUESTOR_ID", length = 80)
141     private String requestorId;
142     @Column(name = "CONFIGURATION_ID", length = 45)
143     private String configurationId;
144     @Column(name = "CONFIGURATION_NAME", length = 200)
145     private String configurationName;
146     @Column(name = "OPERATIONAL_ENV_ID", length = 45)
147     private String operationalEnvId;
148     @Column(name = "OPERATIONAL_ENV_NAME", length = 200)
149     private String operationalEnvName;
150     @Column(name = "INSTANCE_GROUP_ID", length = 45)
151     private String instanceGroupId;
152     @Column(name = "INSTANCE_GROUP_NAME", length = 200)
153     private String instanceGroupName;
154     @Column(name = "REQUEST_URL", length = 500)
155     private String requestUrl;
156     @Column(name = "ORIGINAL_REQUEST_ID", length = 45)
157     private String originalRequestId;
158     @Column(name = "EXT_SYSTEM_ERROR_SOURCE", length = 80)
159     private String extSystemErrorSource;
160     @Column(name = "ROLLBACK_EXT_SYSTEM_ERROR_SOURCE", length = 80)
161     private String rollbackExtSystemErrorSource;
162
163     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
164     @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID")
165     private List<CloudApiRequests> cloudApiRequests = new ArrayList<>();
166
167     @ResourceId
168     public URI getRequestURI() {
169         return URI.create(this.requestId);
170     }
171
172     public String getRequestId() {
173         return this.requestId;
174     }
175
176     public void setRequestId(String requestId) {
177         this.requestId = requestId;
178     }
179
180     public String getClientRequestId() {
181         return clientRequestId;
182     }
183
184     public void setClientRequestId(String clientRequestId) {
185         this.clientRequestId = clientRequestId;
186     }
187
188     public String getAction() {
189         return this.action;
190     }
191
192     public void setAction(String action) {
193         this.action = action;
194     }
195
196     public String getRequestStatus() {
197         return this.requestStatus;
198     }
199
200     public void setRequestStatus(String requestStatus) {
201         this.requestStatus = requestStatus;
202     }
203
204     public String getStatusMessage() {
205         return this.statusMessage;
206     }
207
208     public void setStatusMessage(String statusMessage) {
209         this.statusMessage = statusMessage;
210     }
211
212     public String getRollbackStatusMessage() {
213         return this.rollbackStatusMessage;
214     }
215
216     public void setRollbackStatusMessage(String rollbackStatusMessage) {
217         this.rollbackStatusMessage = rollbackStatusMessage;
218     }
219
220     public String getFlowStatus() {
221         return this.flowStatus;
222     }
223
224     public void setFlowStatus(String flowStatus) {
225         this.flowStatus = flowStatus;
226     }
227
228     public String getRetryStatusMessage() {
229         return this.retryStatusMessage;
230     }
231
232     public void setRetryStatusMessage(String retryStatusMessage) {
233         this.retryStatusMessage = retryStatusMessage;
234     }
235
236     public Long getProgress() {
237         return this.progress;
238     }
239
240     public void setProgress(Long progress) {
241         this.progress = progress;
242     }
243
244     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
245     public Timestamp getStartTime() {
246         return this.startTime;
247     }
248
249     public void setStartTime(Timestamp startTime) {
250         this.startTime = startTime;
251     }
252
253     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
254     public Timestamp getEndTime() {
255         return this.endTime;
256     }
257
258     public void setEndTime(Timestamp endTime) {
259         this.endTime = endTime;
260     }
261
262     public String getSource() {
263         return this.source;
264     }
265
266     public void setSource(String source) {
267         this.source = source;
268     }
269
270     public String getVnfId() {
271         return this.vnfId;
272     }
273
274     public void setVnfId(String vnfId) {
275         this.vnfId = vnfId;
276     }
277
278     public String getVnfName() {
279         return this.vnfName;
280     }
281
282     public void setVnfName(String vnfName) {
283         this.vnfName = vnfName;
284     }
285
286     public String getVnfType() {
287         return this.vnfType;
288     }
289
290     public void setVnfType(String vnfType) {
291         this.vnfType = vnfType;
292     }
293
294     public String getServiceType() {
295         return this.serviceType;
296     }
297
298     public void setServiceType(String serviceType) {
299         this.serviceType = serviceType;
300     }
301
302     public String getAicNodeClli() {
303         return this.aicNodeClli;
304     }
305
306     public void setAicNodeClli(String aicNodeClli) {
307         this.aicNodeClli = aicNodeClli;
308     }
309
310     public String getTenantId() {
311         return this.tenantId;
312     }
313
314     public void setTenantId(String tenantId) {
315         this.tenantId = tenantId;
316     }
317
318     public String getProvStatus() {
319         return this.provStatus;
320     }
321
322     public void setProvStatus(String provStatus) {
323         this.provStatus = provStatus;
324     }
325
326     public String getVnfParams() {
327         return this.vnfParams;
328     }
329
330     public void setVnfParams(String vnfParams) {
331         this.vnfParams = vnfParams;
332     }
333
334     public String getVnfOutputs() {
335         return this.vnfOutputs;
336     }
337
338     public void setVnfOutputs(String vnfOutputs) {
339         this.vnfOutputs = vnfOutputs;
340     }
341
342     public String getRequestBody() {
343         return this.requestBody;
344     }
345
346     public void setRequestBody(String requestBody) {
347         this.requestBody = requestBody;
348     }
349
350     public String getResponseBody() {
351         return this.responseBody;
352     }
353
354     public void setResponseBody(String responseBody) {
355         this.responseBody = responseBody;
356     }
357
358     public String getLastModifiedBy() {
359         return this.lastModifiedBy;
360     }
361
362     public void setLastModifiedBy(String lastModifiedBy) {
363         this.lastModifiedBy = lastModifiedBy;
364     }
365
366     public Date getModifyTime() {
367         return this.modifyTime;
368     }
369
370     public String getRequestType() {
371         return this.requestType;
372     }
373
374     public void setRequestType(String requestType) {
375         this.requestType = requestType;
376     }
377
378     public String getVolumeGroupId() {
379         return this.volumeGroupId;
380     }
381
382     public void setVolumeGroupId(String volumeGroupId) {
383         this.volumeGroupId = volumeGroupId;
384     }
385
386     public String getVolumeGroupName() {
387         return this.volumeGroupName;
388     }
389
390     public void setVolumeGroupName(String volumeGroupName) {
391         this.volumeGroupName = volumeGroupName;
392     }
393
394     public String getVfModuleId() {
395         return this.vfModuleId;
396     }
397
398     public void setVfModuleId(String vfModuleId) {
399         this.vfModuleId = vfModuleId;
400     }
401
402     public String getVfModuleName() {
403         return this.vfModuleName;
404     }
405
406     public void setVfModuleName(String vfModuleName) {
407         this.vfModuleName = vfModuleName;
408     }
409
410     public String getVfModuleModelName() {
411         return this.vfModuleModelName;
412     }
413
414     public void setVfModuleModelName(String vfModuleModelName) {
415         this.vfModuleModelName = vfModuleModelName;
416     }
417
418     public String getAaiServiceId() {
419         return this.aaiServiceId;
420     }
421
422     public void setAaiServiceId(String aaiServiceId) {
423         this.aaiServiceId = aaiServiceId;
424     }
425
426     public String getAicCloudRegion() {
427         return this.aicCloudRegion;
428     }
429
430     public void setAicCloudRegion(String aicCloudRegion) {
431         this.aicCloudRegion = aicCloudRegion;
432     }
433
434     public String getCallBackUrl() {
435         return callBackUrl;
436     }
437
438     public void setCallBackUrl(String callBackUrl) {
439         this.callBackUrl = callBackUrl;
440     }
441
442     public String getCorrelator() {
443         return correlator;
444     }
445
446     public void setCorrelator(String correlator) {
447         this.correlator = correlator;
448     }
449
450     public String getServiceInstanceId() {
451         return serviceInstanceId;
452     }
453
454     public void setServiceInstanceId(String serviceInstanceId) {
455         this.serviceInstanceId = serviceInstanceId;
456     }
457
458     public String getServiceInstanceName() {
459         return serviceInstanceName;
460     }
461
462     public void setServiceInstanceName(String serviceInstanceName) {
463         this.serviceInstanceName = serviceInstanceName;
464     }
465
466     public String getRequestScope() {
467         return requestScope;
468     }
469
470     public void setRequestScope(String requestScope) {
471         this.requestScope = requestScope;
472     }
473
474     public String getRequestAction() {
475         return requestAction;
476     }
477
478     @LinkedResource
479     public List<CloudApiRequests> getCloudApiRequests() {
480         return cloudApiRequests;
481     }
482
483     public void setCloudApiRequests(List<CloudApiRequests> cloudApiRequests) {
484         this.cloudApiRequests = cloudApiRequests;
485     }
486
487     public void setRequestAction(String requestAction) {
488         this.requestAction = requestAction;
489     }
490
491     public String getNetworkId() {
492         return networkId;
493     }
494
495     public void setNetworkId(String networkId) {
496         this.networkId = networkId;
497     }
498
499     public String getNetworkName() {
500         return networkName;
501     }
502
503     public void setNetworkName(String networkName) {
504         this.networkName = networkName;
505     }
506
507     public String getNetworkType() {
508         return networkType;
509     }
510
511     public void setNetworkType(String networkType) {
512         this.networkType = networkType;
513     }
514
515     public String getRequestorId() {
516         return requestorId;
517     }
518
519     public void setRequestorId(String requestorId) {
520         this.requestorId = requestorId;
521     }
522
523     public String getConfigurationId() {
524         return configurationId;
525     }
526
527     public void setConfigurationId(String configurationId) {
528         this.configurationId = configurationId;
529     }
530
531     public String getConfigurationName() {
532         return configurationName;
533     }
534
535     public void setConfigurationName(String configurationName) {
536         this.configurationName = configurationName;
537     }
538
539     public String getOperationalEnvId() {
540         return operationalEnvId;
541     }
542
543     public void setOperationalEnvId(String operationalEnvId) {
544         this.operationalEnvId = operationalEnvId;
545     }
546
547     public String getOperationalEnvName() {
548         return operationalEnvName;
549     }
550
551     public void setOperationalEnvName(String operationalEnvName) {
552         this.operationalEnvName = operationalEnvName;
553     }
554
555     public String getInstanceGroupId() {
556         return instanceGroupId;
557     }
558
559     public void setInstanceGroupId(String instanceGroupId) {
560         this.instanceGroupId = instanceGroupId;
561     }
562
563     public String getInstanceGroupName() {
564         return instanceGroupName;
565     }
566
567     public void setInstanceGroupName(String instanceGroupName) {
568         this.instanceGroupName = instanceGroupName;
569     }
570
571     public String getRequestUrl() {
572         return this.requestUrl;
573     }
574
575     public void setRequestUrl(String requestUrl) {
576         this.requestUrl = requestUrl;
577     }
578
579     public String getOriginalRequestId() {
580         return this.originalRequestId;
581     }
582
583     public void setOriginalRequestId(String originalRequestId) {
584         this.originalRequestId = originalRequestId;
585     }
586
587     public String getExtSystemErrorSource() {
588         return this.extSystemErrorSource;
589     }
590
591     public void setExtSystemErrorSource(String extSystemErrorSource) {
592         this.extSystemErrorSource = extSystemErrorSource;
593     }
594
595     public String getRollbackExtSystemErrorSource() {
596         return this.rollbackExtSystemErrorSource;
597     }
598
599     public void setRollbackExtSystemErrorSource(String rollbackExtSystemErrorSource) {
600         this.rollbackExtSystemErrorSource = rollbackExtSystemErrorSource;
601     }
602
603     @PrePersist
604     protected void onCreate() {
605         if (requestScope == null)
606             requestScope = UNKNOWN;
607         if (requestAction == null)
608             requestAction = UNKNOWN;
609         this.modifyTime = new Date();
610     }
611
612     @PreUpdate
613     protected void onUpdate() {
614         if (requestScope == null)
615             requestScope = UNKNOWN;
616         if (requestAction == null)
617             requestAction = UNKNOWN;
618         this.modifyTime = new Date();
619     }
620
621     @Override
622     public boolean equals(final Object other) {
623         if (this == other) {
624             return true;
625         }
626         if (!(other instanceof InfraRequests)) {
627             return false;
628         }
629         InfraRequests castOther = (InfraRequests) other;
630         return Objects.equals(getRequestId(), castOther.getRequestId());
631     }
632
633     @Override
634     public int hashCode() {
635         return Objects.hash(getRequestId());
636     }
637
638     @Override
639     public String toString() {
640         return new ToStringBuilder(this).append("requestId", getRequestId())
641                 .append("clientRequestId", getClientRequestId()).append("action", getAction())
642                 .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage())
643                 .append("rollbackStatusMessage", getRollbackStatusMessage()).append("flowStatus", getFlowStatus())
644                 .append("retryStatusMessage", getRetryStatusMessage()).append("progress", getProgress())
645                 .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource())
646                 .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType())
647                 .append("serviceType", getServiceType()).append("aicNodeClli", getAicNodeClli())
648                 .append("tenantId", getTenantId()).append("provStatus", getProvStatus())
649                 .append("vnfParams", getVnfParams()).append("vnfOutputs", getVnfOutputs())
650                 .append("requestBody", getRequestBody()).append("responseBody", getResponseBody())
651                 .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime())
652                 .append("requestType", getRequestType()).append("volumeGroupId", getVolumeGroupId())
653                 .append("volumeGroupName", getVolumeGroupName()).append("vfModuleId", getVfModuleId())
654                 .append("vfModuleName", getVfModuleName()).append("vfModuleModelName", getVfModuleModelName())
655                 .append("aaiServiceId", getAaiServiceId()).append("aicCloudRegion", getAicCloudRegion())
656                 .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator())
657                 .append("serviceInstanceId", getServiceInstanceId())
658                 .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope())
659                 .append("requestAction", getRequestAction()).append("networkId", getNetworkId())
660                 .append("networkName", getNetworkName()).append("networkType", getNetworkType())
661                 .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId())
662                 .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId())
663                 .append("operationalEnvName", getOperationalEnvName()).append("instanceGroupId", getInstanceGroupId())
664                 .append("instanceGroupName", getInstanceGroupName()).append("requestUrl", getRequestUrl())
665                 .append("originalRequestId", originalRequestId).append("extSystemErrorSource", extSystemErrorSource)
666                 .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).toString();
667     }
668 }