Merge "Remove references to AIC"
[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 = "REQUEST_STATUS", length = 20)
57     private String requestStatus;
58     @Column(name = "STATUS_MESSAGE", length = 2000)
59     private String statusMessage;
60     @Column(name = "ROLLBACK_STATUS_MESSAGE", length = 2000)
61     private String rollbackStatusMessage;
62     @Column(name = "FLOW_STATUS", length = 2000)
63     private String flowStatus;
64     @Column(name = "RETRY_STATUS_MESSAGE", length = 2000)
65     private String retryStatusMessage;
66     @Column(name = "PROGRESS", precision = 11)
67     private Long progress;
68
69     @Column(name = "START_TIME")
70     private Timestamp startTime;
71     @Column(name = "END_TIME")
72     private Timestamp endTime;
73     @Column(name = "SOURCE", length = 45)
74     private String source;
75     @Column(name = "VNF_ID", length = 45)
76     private String vnfId;
77     @Column(name = "PNF_ID", length = 45)
78     private String pnfId;
79     @Column(name = "VNF_NAME", length = 80)
80     private String vnfName;
81     @Column(name = "VNF_TYPE", length = 200)
82     private String vnfType;
83     @Column(name = "SERVICE_TYPE", length = 45)
84     private String serviceType;
85     @Column(name = "TENANT_ID", length = 45)
86     private String tenantId;
87     @Column(name = "VNF_PARAMS")
88     private String vnfParams;
89     @Column(name = "VNF_OUTPUTS")
90     private String vnfOutputs;
91     @Column(name = "REQUEST_BODY")
92     private String requestBody;
93     @Column(name = "RESPONSE_BODY")
94     private String responseBody;
95     @Column(name = "LAST_MODIFIED_BY", length = 50)
96     private String lastModifiedBy;
97     @Column(name = "MODIFY_TIME")
98     @Temporal(TemporalType.TIMESTAMP)
99     private Date modifyTime;
100     @Column(name = "VOLUME_GROUP_ID", length = 45)
101     private String volumeGroupId;
102     @Column(name = "VOLUME_GROUP_NAME", length = 45)
103     private String volumeGroupName;
104     @Column(name = "VF_MODULE_ID", length = 45)
105     private String vfModuleId;
106     @Column(name = "VF_MODULE_NAME", length = 200)
107     private String vfModuleName;
108     @Column(name = "VF_MODULE_MODEL_NAME", length = 200)
109     private String vfModuleModelName;
110     @Column(name = "CLOUD_REGION", length = 11)
111     private String cloudRegion;
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     @Column(name = "INSTANCE_GROUP_ID", length = 45)
141     private String instanceGroupId;
142     @Column(name = "INSTANCE_GROUP_NAME", length = 200)
143     private String instanceGroupName;
144     @Column(name = "REQUEST_URL", length = 500)
145     private String requestUrl;
146     @Column(name = "ORIGINAL_REQUEST_ID", length = 45)
147     private String originalRequestId;
148     @Column(name = "EXT_SYSTEM_ERROR_SOURCE", length = 80)
149     private String extSystemErrorSource;
150     @Column(name = "ROLLBACK_EXT_SYSTEM_ERROR_SOURCE", length = 80)
151     private String rollbackExtSystemErrorSource;
152
153     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
154     @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID", updatable = false)
155     private List<CloudApiRequests> cloudApiRequests = new ArrayList<>();
156
157     @ResourceId
158     public URI getRequestURI() {
159         return URI.create(this.requestId);
160     }
161
162     public String getRequestId() {
163         return this.requestId;
164     }
165
166     public void setRequestId(String requestId) {
167         this.requestId = requestId;
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 String getRollbackStatusMessage() {
187         return this.rollbackStatusMessage;
188     }
189
190     public void setRollbackStatusMessage(String rollbackStatusMessage) {
191         this.rollbackStatusMessage = rollbackStatusMessage;
192     }
193
194     public String getFlowStatus() {
195         return this.flowStatus;
196     }
197
198     public void setFlowStatus(String flowStatus) {
199         this.flowStatus = flowStatus;
200     }
201
202     public String getRetryStatusMessage() {
203         return this.retryStatusMessage;
204     }
205
206     public void setRetryStatusMessage(String retryStatusMessage) {
207         this.retryStatusMessage = retryStatusMessage;
208     }
209
210     public Long getProgress() {
211         return this.progress;
212     }
213
214     public void setProgress(Long progress) {
215         this.progress = progress;
216     }
217
218     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
219     public Timestamp getStartTime() {
220         return this.startTime;
221     }
222
223     public void setStartTime(Timestamp startTime) {
224         this.startTime = startTime;
225     }
226
227     @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
228     public Timestamp getEndTime() {
229         return this.endTime;
230     }
231
232     public void setEndTime(Timestamp endTime) {
233         this.endTime = endTime;
234     }
235
236     public String getSource() {
237         return this.source;
238     }
239
240     public void setSource(String source) {
241         this.source = source;
242     }
243
244     public String getVnfId() {
245         return this.vnfId;
246     }
247
248     public void setVnfId(String vnfId) {
249         this.vnfId = vnfId;
250     }
251
252     public String getPnfId() {
253         return this.pnfId;
254     }
255
256     public void setPnfId(String pnfId) {
257         this.pnfId = pnfId;
258     }
259
260     public String getVnfName() {
261         return this.vnfName;
262     }
263
264     public void setVnfName(String vnfName) {
265         this.vnfName = vnfName;
266     }
267
268     public String getVnfType() {
269         return this.vnfType;
270     }
271
272     public void setVnfType(String vnfType) {
273         this.vnfType = vnfType;
274     }
275
276     public String getServiceType() {
277         return this.serviceType;
278     }
279
280     public void setServiceType(String serviceType) {
281         this.serviceType = serviceType;
282     }
283
284     public String getTenantId() {
285         return this.tenantId;
286     }
287
288     public void setTenantId(String tenantId) {
289         this.tenantId = tenantId;
290     }
291
292     public String getVnfParams() {
293         return this.vnfParams;
294     }
295
296     public void setVnfParams(String vnfParams) {
297         this.vnfParams = vnfParams;
298     }
299
300     public String getVnfOutputs() {
301         return this.vnfOutputs;
302     }
303
304     public void setVnfOutputs(String vnfOutputs) {
305         this.vnfOutputs = vnfOutputs;
306     }
307
308     public String getRequestBody() {
309         return this.requestBody;
310     }
311
312     public void setRequestBody(String requestBody) {
313         this.requestBody = requestBody;
314     }
315
316     public String getResponseBody() {
317         return this.responseBody;
318     }
319
320     public void setResponseBody(String responseBody) {
321         this.responseBody = responseBody;
322     }
323
324     public String getLastModifiedBy() {
325         return this.lastModifiedBy;
326     }
327
328     public void setLastModifiedBy(String lastModifiedBy) {
329         this.lastModifiedBy = lastModifiedBy;
330     }
331
332     public Date getModifyTime() {
333         return this.modifyTime;
334     }
335
336     public String getVolumeGroupId() {
337         return this.volumeGroupId;
338     }
339
340     public void setVolumeGroupId(String volumeGroupId) {
341         this.volumeGroupId = volumeGroupId;
342     }
343
344     public String getVolumeGroupName() {
345         return this.volumeGroupName;
346     }
347
348     public void setVolumeGroupName(String volumeGroupName) {
349         this.volumeGroupName = volumeGroupName;
350     }
351
352     public String getVfModuleId() {
353         return this.vfModuleId;
354     }
355
356     public void setVfModuleId(String vfModuleId) {
357         this.vfModuleId = vfModuleId;
358     }
359
360     public String getVfModuleName() {
361         return this.vfModuleName;
362     }
363
364     public void setVfModuleName(String vfModuleName) {
365         this.vfModuleName = vfModuleName;
366     }
367
368     public String getVfModuleModelName() {
369         return this.vfModuleModelName;
370     }
371
372     public void setVfModuleModelName(String vfModuleModelName) {
373         this.vfModuleModelName = vfModuleModelName;
374     }
375
376     public String getCloudRegion() {
377         return this.cloudRegion;
378     }
379
380     public void setCloudRegion(String cloudRegion) {
381         this.cloudRegion = cloudRegion;
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     @LinkedResource
429     public List<CloudApiRequests> getCloudApiRequests() {
430         return cloudApiRequests;
431     }
432
433     public void setCloudApiRequests(List<CloudApiRequests> cloudApiRequests) {
434         this.cloudApiRequests = cloudApiRequests;
435     }
436
437     public void setRequestAction(String requestAction) {
438         this.requestAction = requestAction;
439     }
440
441     public String getNetworkId() {
442         return networkId;
443     }
444
445     public void setNetworkId(String networkId) {
446         this.networkId = networkId;
447     }
448
449     public String getNetworkName() {
450         return networkName;
451     }
452
453     public void setNetworkName(String networkName) {
454         this.networkName = networkName;
455     }
456
457     public String getNetworkType() {
458         return networkType;
459     }
460
461     public void setNetworkType(String networkType) {
462         this.networkType = networkType;
463     }
464
465     public String getRequestorId() {
466         return requestorId;
467     }
468
469     public void setRequestorId(String requestorId) {
470         this.requestorId = requestorId;
471     }
472
473     public String getConfigurationId() {
474         return configurationId;
475     }
476
477     public void setConfigurationId(String configurationId) {
478         this.configurationId = configurationId;
479     }
480
481     public String getConfigurationName() {
482         return configurationName;
483     }
484
485     public void setConfigurationName(String configurationName) {
486         this.configurationName = configurationName;
487     }
488
489     public String getOperationalEnvId() {
490         return operationalEnvId;
491     }
492
493     public void setOperationalEnvId(String operationalEnvId) {
494         this.operationalEnvId = operationalEnvId;
495     }
496
497     public String getOperationalEnvName() {
498         return operationalEnvName;
499     }
500
501     public void setOperationalEnvName(String operationalEnvName) {
502         this.operationalEnvName = operationalEnvName;
503     }
504
505     public String getInstanceGroupId() {
506         return instanceGroupId;
507     }
508
509     public void setInstanceGroupId(String instanceGroupId) {
510         this.instanceGroupId = instanceGroupId;
511     }
512
513     public String getInstanceGroupName() {
514         return instanceGroupName;
515     }
516
517     public void setInstanceGroupName(String instanceGroupName) {
518         this.instanceGroupName = instanceGroupName;
519     }
520
521     public String getRequestUrl() {
522         return this.requestUrl;
523     }
524
525     public void setRequestUrl(String requestUrl) {
526         this.requestUrl = requestUrl;
527     }
528
529     public String getOriginalRequestId() {
530         return this.originalRequestId;
531     }
532
533     public void setOriginalRequestId(String originalRequestId) {
534         this.originalRequestId = originalRequestId;
535     }
536
537     public String getExtSystemErrorSource() {
538         return this.extSystemErrorSource;
539     }
540
541     public void setExtSystemErrorSource(String extSystemErrorSource) {
542         this.extSystemErrorSource = extSystemErrorSource;
543     }
544
545     public String getRollbackExtSystemErrorSource() {
546         return this.rollbackExtSystemErrorSource;
547     }
548
549     public void setRollbackExtSystemErrorSource(String rollbackExtSystemErrorSource) {
550         this.rollbackExtSystemErrorSource = rollbackExtSystemErrorSource;
551     }
552
553     @PrePersist
554     protected void onCreate() {
555         if (requestScope == null)
556             requestScope = UNKNOWN;
557         if (requestAction == null)
558             requestAction = UNKNOWN;
559         this.modifyTime = new Date();
560     }
561
562     @PreUpdate
563     protected void onUpdate() {
564         if (requestScope == null)
565             requestScope = UNKNOWN;
566         if (requestAction == null)
567             requestAction = UNKNOWN;
568         this.modifyTime = new Date();
569     }
570
571     @Override
572     public boolean equals(final Object other) {
573         if (this == other) {
574             return true;
575         }
576         if (!(other instanceof InfraRequests)) {
577             return false;
578         }
579         InfraRequests castOther = (InfraRequests) other;
580         return Objects.equals(getRequestId(), castOther.getRequestId());
581     }
582
583     @Override
584     public int hashCode() {
585         return Objects.hash(getRequestId());
586     }
587
588     @Override
589     public String toString() {
590         return new ToStringBuilder(this).append("requestId", getRequestId()).append("requestStatus", getRequestStatus())
591                 .append("statusMessage", getStatusMessage()).append("rollbackStatusMessage", getRollbackStatusMessage())
592                 .append("flowStatus", getFlowStatus()).append("retryStatusMessage", getRetryStatusMessage())
593                 .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime())
594                 .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName())
595                 .append("pnfId", getPnfId()).append("vnfType", getVnfType()).append("serviceType", getServiceType())
596                 .append("tenantId", getTenantId()).append("vnfParams", getVnfParams())
597                 .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody())
598                 .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy())
599                 .append("modifyTime", getModifyTime()).append("volumeGroupId", getVolumeGroupId())
600                 .append("volumeGroupName", getVolumeGroupName()).append("vfModuleId", getVfModuleId())
601                 .append("vfModuleName", getVfModuleName()).append("vfModuleModelName", getVfModuleModelName())
602                 .append("cloudRegion", getCloudRegion()).append("callBackUrl", getCallBackUrl())
603                 .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId())
604                 .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope())
605                 .append("requestAction", getRequestAction()).append("networkId", getNetworkId())
606                 .append("networkName", getNetworkName()).append("networkType", getNetworkType())
607                 .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId())
608                 .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId())
609                 .append("operationalEnvName", getOperationalEnvName()).append("instanceGroupId", getInstanceGroupId())
610                 .append("instanceGroupName", getInstanceGroupName()).append("requestUrl", getRequestUrl())
611                 .append("originalRequestId", originalRequestId).append("extSystemErrorSource", extSystemErrorSource)
612                 .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).toString();
613     }
614 }