Merge remote-tracking branch 'origin/dublin' into 'origin/master'
[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
161     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
162     @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID")
163     private List<CloudApiRequests> cloudApiRequests = new ArrayList<>();
164
165     @ResourceId
166     public URI getRequestURI() {
167         return URI.create(this.requestId);
168     }
169
170     public String getRequestId() {
171         return this.requestId;
172     }
173
174     public void setRequestId(String requestId) {
175         this.requestId = requestId;
176     }
177
178     public String getClientRequestId() {
179         return clientRequestId;
180     }
181
182     public void setClientRequestId(String clientRequestId) {
183         this.clientRequestId = clientRequestId;
184     }
185
186     public String getAction() {
187         return this.action;
188     }
189
190     public void setAction(String action) {
191         this.action = action;
192     }
193
194     public String getRequestStatus() {
195         return this.requestStatus;
196     }
197
198     public void setRequestStatus(String requestStatus) {
199         this.requestStatus = requestStatus;
200     }
201
202     public String getStatusMessage() {
203         return this.statusMessage;
204     }
205
206     public void setStatusMessage(String statusMessage) {
207         this.statusMessage = statusMessage;
208     }
209
210     public String getRollbackStatusMessage() {
211         return this.rollbackStatusMessage;
212     }
213
214     public void setRollbackStatusMessage(String rollbackStatusMessage) {
215         this.rollbackStatusMessage = rollbackStatusMessage;
216     }
217
218     public String getFlowStatus() {
219         return this.flowStatus;
220     }
221
222     public void setFlowStatus(String flowStatus) {
223         this.flowStatus = flowStatus;
224     }
225
226     public String getRetryStatusMessage() {
227         return this.retryStatusMessage;
228     }
229
230     public void setRetryStatusMessage(String retryStatusMessage) {
231         this.retryStatusMessage = retryStatusMessage;
232     }
233
234     public Long getProgress() {
235         return this.progress;
236     }
237
238     public void setProgress(Long progress) {
239         this.progress = progress;
240     }
241
242     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
243     public Timestamp getStartTime() {
244         return this.startTime;
245     }
246
247     public void setStartTime(Timestamp startTime) {
248         this.startTime = startTime;
249     }
250
251     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
252     public Timestamp getEndTime() {
253         return this.endTime;
254     }
255
256     public void setEndTime(Timestamp endTime) {
257         this.endTime = endTime;
258     }
259
260     public String getSource() {
261         return this.source;
262     }
263
264     public void setSource(String source) {
265         this.source = source;
266     }
267
268     public String getVnfId() {
269         return this.vnfId;
270     }
271
272     public void setVnfId(String vnfId) {
273         this.vnfId = vnfId;
274     }
275
276     public String getVnfName() {
277         return this.vnfName;
278     }
279
280     public void setVnfName(String vnfName) {
281         this.vnfName = vnfName;
282     }
283
284     public String getVnfType() {
285         return this.vnfType;
286     }
287
288     public void setVnfType(String vnfType) {
289         this.vnfType = vnfType;
290     }
291
292     public String getServiceType() {
293         return this.serviceType;
294     }
295
296     public void setServiceType(String serviceType) {
297         this.serviceType = serviceType;
298     }
299
300     public String getAicNodeClli() {
301         return this.aicNodeClli;
302     }
303
304     public void setAicNodeClli(String aicNodeClli) {
305         this.aicNodeClli = aicNodeClli;
306     }
307
308     public String getTenantId() {
309         return this.tenantId;
310     }
311
312     public void setTenantId(String tenantId) {
313         this.tenantId = tenantId;
314     }
315
316     public String getProvStatus() {
317         return this.provStatus;
318     }
319
320     public void setProvStatus(String provStatus) {
321         this.provStatus = provStatus;
322     }
323
324     public String getVnfParams() {
325         return this.vnfParams;
326     }
327
328     public void setVnfParams(String vnfParams) {
329         this.vnfParams = vnfParams;
330     }
331
332     public String getVnfOutputs() {
333         return this.vnfOutputs;
334     }
335
336     public void setVnfOutputs(String vnfOutputs) {
337         this.vnfOutputs = vnfOutputs;
338     }
339
340     public String getRequestBody() {
341         return this.requestBody;
342     }
343
344     public void setRequestBody(String requestBody) {
345         this.requestBody = requestBody;
346     }
347
348     public String getResponseBody() {
349         return this.responseBody;
350     }
351
352     public void setResponseBody(String responseBody) {
353         this.responseBody = responseBody;
354     }
355
356     public String getLastModifiedBy() {
357         return this.lastModifiedBy;
358     }
359
360     public void setLastModifiedBy(String lastModifiedBy) {
361         this.lastModifiedBy = lastModifiedBy;
362     }
363
364     public Date getModifyTime() {
365         return this.modifyTime;
366     }
367
368     public String getRequestType() {
369         return this.requestType;
370     }
371
372     public void setRequestType(String requestType) {
373         this.requestType = requestType;
374     }
375
376     public String getVolumeGroupId() {
377         return this.volumeGroupId;
378     }
379
380     public void setVolumeGroupId(String volumeGroupId) {
381         this.volumeGroupId = volumeGroupId;
382     }
383
384     public String getVolumeGroupName() {
385         return this.volumeGroupName;
386     }
387
388     public void setVolumeGroupName(String volumeGroupName) {
389         this.volumeGroupName = volumeGroupName;
390     }
391
392     public String getVfModuleId() {
393         return this.vfModuleId;
394     }
395
396     public void setVfModuleId(String vfModuleId) {
397         this.vfModuleId = vfModuleId;
398     }
399
400     public String getVfModuleName() {
401         return this.vfModuleName;
402     }
403
404     public void setVfModuleName(String vfModuleName) {
405         this.vfModuleName = vfModuleName;
406     }
407
408     public String getVfModuleModelName() {
409         return this.vfModuleModelName;
410     }
411
412     public void setVfModuleModelName(String vfModuleModelName) {
413         this.vfModuleModelName = vfModuleModelName;
414     }
415
416     public String getAaiServiceId() {
417         return this.aaiServiceId;
418     }
419
420     public void setAaiServiceId(String aaiServiceId) {
421         this.aaiServiceId = aaiServiceId;
422     }
423
424     public String getAicCloudRegion() {
425         return this.aicCloudRegion;
426     }
427
428     public void setAicCloudRegion(String aicCloudRegion) {
429         this.aicCloudRegion = aicCloudRegion;
430     }
431
432     public String getCallBackUrl() {
433         return callBackUrl;
434     }
435
436     public void setCallBackUrl(String callBackUrl) {
437         this.callBackUrl = callBackUrl;
438     }
439
440     public String getCorrelator() {
441         return correlator;
442     }
443
444     public void setCorrelator(String correlator) {
445         this.correlator = correlator;
446     }
447
448     public String getServiceInstanceId() {
449         return serviceInstanceId;
450     }
451
452     public void setServiceInstanceId(String serviceInstanceId) {
453         this.serviceInstanceId = serviceInstanceId;
454     }
455
456     public String getServiceInstanceName() {
457         return serviceInstanceName;
458     }
459
460     public void setServiceInstanceName(String serviceInstanceName) {
461         this.serviceInstanceName = serviceInstanceName;
462     }
463
464     public String getRequestScope() {
465         return requestScope;
466     }
467
468     public void setRequestScope(String requestScope) {
469         this.requestScope = requestScope;
470     }
471
472     public String getRequestAction() {
473         return requestAction;
474     }
475
476     @LinkedResource
477     public List<CloudApiRequests> getCloudApiRequests() {
478         return cloudApiRequests;
479     }
480
481     public void setCloudApiRequests(List<CloudApiRequests> cloudApiRequests) {
482         this.cloudApiRequests = cloudApiRequests;
483     }
484
485     public void setRequestAction(String requestAction) {
486         this.requestAction = requestAction;
487     }
488
489     public String getNetworkId() {
490         return networkId;
491     }
492
493     public void setNetworkId(String networkId) {
494         this.networkId = networkId;
495     }
496
497     public String getNetworkName() {
498         return networkName;
499     }
500
501     public void setNetworkName(String networkName) {
502         this.networkName = networkName;
503     }
504
505     public String getNetworkType() {
506         return networkType;
507     }
508
509     public void setNetworkType(String networkType) {
510         this.networkType = networkType;
511     }
512
513     public String getRequestorId() {
514         return requestorId;
515     }
516
517     public void setRequestorId(String requestorId) {
518         this.requestorId = requestorId;
519     }
520
521     public String getConfigurationId() {
522         return configurationId;
523     }
524
525     public void setConfigurationId(String configurationId) {
526         this.configurationId = configurationId;
527     }
528
529     public String getConfigurationName() {
530         return configurationName;
531     }
532
533     public void setConfigurationName(String configurationName) {
534         this.configurationName = configurationName;
535     }
536
537     public String getOperationalEnvId() {
538         return operationalEnvId;
539     }
540
541     public void setOperationalEnvId(String operationalEnvId) {
542         this.operationalEnvId = operationalEnvId;
543     }
544
545     public String getOperationalEnvName() {
546         return operationalEnvName;
547     }
548
549     public void setOperationalEnvName(String operationalEnvName) {
550         this.operationalEnvName = operationalEnvName;
551     }
552
553     public String getInstanceGroupId() {
554         return instanceGroupId;
555     }
556
557     public void setInstanceGroupId(String instanceGroupId) {
558         this.instanceGroupId = instanceGroupId;
559     }
560
561     public String getInstanceGroupName() {
562         return instanceGroupName;
563     }
564
565     public void setInstanceGroupName(String instanceGroupName) {
566         this.instanceGroupName = instanceGroupName;
567     }
568
569     public String getRequestUrl() {
570         return this.requestUrl;
571     }
572
573     public void setRequestUrl(String requestUrl) {
574         this.requestUrl = requestUrl;
575     }
576
577     public String getOriginalRequestId() {
578         return this.originalRequestId;
579     }
580
581     public void setOriginalRequestId(String originalRequestId) {
582         this.originalRequestId = originalRequestId;
583     }
584
585     public String getExtSystemErrorSource() {
586         return this.extSystemErrorSource;
587     }
588
589     public void setExtSystemErrorSource(String extSystemErrorSource) {
590         this.extSystemErrorSource = extSystemErrorSource;
591     }
592
593     @PrePersist
594     protected void onCreate() {
595         if (requestScope == null)
596             requestScope = UNKNOWN;
597         if (requestAction == null)
598             requestAction = UNKNOWN;
599         this.modifyTime = new Date();
600     }
601
602     @PreUpdate
603     protected void onUpdate() {
604         if (requestScope == null)
605             requestScope = UNKNOWN;
606         if (requestAction == null)
607             requestAction = UNKNOWN;
608         this.modifyTime = new Date();
609     }
610
611     @Override
612     public boolean equals(final Object other) {
613         if (this == other) {
614             return true;
615         }
616         if (!(other instanceof InfraRequests)) {
617             return false;
618         }
619         InfraRequests castOther = (InfraRequests) other;
620         return Objects.equals(getRequestId(), castOther.getRequestId());
621     }
622
623     @Override
624     public int hashCode() {
625         return Objects.hash(getRequestId());
626     }
627
628     @Override
629     public String toString() {
630         return new ToStringBuilder(this).append("requestId", getRequestId())
631                 .append("clientRequestId", getClientRequestId()).append("action", getAction())
632                 .append("requestStatus", getRequestStatus()).append("statusMessage", getStatusMessage())
633                 .append("rollbackStatusMessage", getRollbackStatusMessage()).append("flowStatus", getFlowStatus())
634                 .append("retryStatusMessage", getRetryStatusMessage()).append("progress", getProgress())
635                 .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource())
636                 .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType())
637                 .append("serviceType", getServiceType()).append("aicNodeClli", getAicNodeClli())
638                 .append("tenantId", getTenantId()).append("provStatus", getProvStatus())
639                 .append("vnfParams", getVnfParams()).append("vnfOutputs", getVnfOutputs())
640                 .append("requestBody", getRequestBody()).append("responseBody", getResponseBody())
641                 .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime())
642                 .append("requestType", getRequestType()).append("volumeGroupId", getVolumeGroupId())
643                 .append("volumeGroupName", getVolumeGroupName()).append("vfModuleId", getVfModuleId())
644                 .append("vfModuleName", getVfModuleName()).append("vfModuleModelName", getVfModuleModelName())
645                 .append("aaiServiceId", getAaiServiceId()).append("aicCloudRegion", getAicCloudRegion())
646                 .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator())
647                 .append("serviceInstanceId", getServiceInstanceId())
648                 .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope())
649                 .append("requestAction", getRequestAction()).append("networkId", getNetworkId())
650                 .append("networkName", getNetworkName()).append("networkType", getNetworkType())
651                 .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId())
652                 .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId())
653                 .append("operationalEnvName", getOperationalEnvName()).append("instanceGroupId", getInstanceGroupId())
654                 .append("instanceGroupName", getInstanceGroupName()).append("requestUrl", getRequestUrl())
655                 .append("originalRequestId", originalRequestId).append("extSystemErrorSource", extSystemErrorSource)
656                 .toString();
657     }
658 }