2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.db.request.beans;
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;
47 public abstract class InfraRequests implements java.io.Serializable {
49 private static final long serialVersionUID = -5497583682393936143L;
50 private static final String UNKNOWN = "unknown";
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;
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)
77 @Column(name = "PNF_ID", length = 45)
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;
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<>();
158 public URI getRequestURI() {
159 return URI.create(this.requestId);
162 public String getRequestId() {
163 return this.requestId;
166 public void setRequestId(String requestId) {
167 this.requestId = requestId;
170 public String getRequestStatus() {
171 return this.requestStatus;
174 public void setRequestStatus(String requestStatus) {
175 this.requestStatus = requestStatus;
178 public String getStatusMessage() {
179 return this.statusMessage;
182 public void setStatusMessage(String statusMessage) {
183 this.statusMessage = statusMessage;
186 public String getRollbackStatusMessage() {
187 return this.rollbackStatusMessage;
190 public void setRollbackStatusMessage(String rollbackStatusMessage) {
191 this.rollbackStatusMessage = rollbackStatusMessage;
194 public String getFlowStatus() {
195 return this.flowStatus;
198 public void setFlowStatus(String flowStatus) {
199 this.flowStatus = flowStatus;
202 public String getRetryStatusMessage() {
203 return this.retryStatusMessage;
206 public void setRetryStatusMessage(String retryStatusMessage) {
207 this.retryStatusMessage = retryStatusMessage;
210 public Long getProgress() {
211 return this.progress;
214 public void setProgress(Long progress) {
215 this.progress = progress;
218 @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
219 public Timestamp getStartTime() {
220 return this.startTime;
223 public void setStartTime(Timestamp startTime) {
224 this.startTime = startTime;
227 @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
228 public Timestamp getEndTime() {
232 public void setEndTime(Timestamp endTime) {
233 this.endTime = endTime;
236 public String getSource() {
240 public void setSource(String source) {
241 this.source = source;
244 public String getVnfId() {
248 public void setVnfId(String vnfId) {
252 public String getPnfId() {
256 public void setPnfId(String pnfId) {
260 public String getVnfName() {
264 public void setVnfName(String vnfName) {
265 this.vnfName = vnfName;
268 public String getVnfType() {
272 public void setVnfType(String vnfType) {
273 this.vnfType = vnfType;
276 public String getServiceType() {
277 return this.serviceType;
280 public void setServiceType(String serviceType) {
281 this.serviceType = serviceType;
284 public String getTenantId() {
285 return this.tenantId;
288 public void setTenantId(String tenantId) {
289 this.tenantId = tenantId;
292 public String getVnfParams() {
293 return this.vnfParams;
296 public void setVnfParams(String vnfParams) {
297 this.vnfParams = vnfParams;
300 public String getVnfOutputs() {
301 return this.vnfOutputs;
304 public void setVnfOutputs(String vnfOutputs) {
305 this.vnfOutputs = vnfOutputs;
308 public String getRequestBody() {
309 return this.requestBody;
312 public void setRequestBody(String requestBody) {
313 this.requestBody = requestBody;
316 public String getResponseBody() {
317 return this.responseBody;
320 public void setResponseBody(String responseBody) {
321 this.responseBody = responseBody;
324 public String getLastModifiedBy() {
325 return this.lastModifiedBy;
328 public void setLastModifiedBy(String lastModifiedBy) {
329 this.lastModifiedBy = lastModifiedBy;
332 public Date getModifyTime() {
333 return this.modifyTime;
336 public String getVolumeGroupId() {
337 return this.volumeGroupId;
340 public void setVolumeGroupId(String volumeGroupId) {
341 this.volumeGroupId = volumeGroupId;
344 public String getVolumeGroupName() {
345 return this.volumeGroupName;
348 public void setVolumeGroupName(String volumeGroupName) {
349 this.volumeGroupName = volumeGroupName;
352 public String getVfModuleId() {
353 return this.vfModuleId;
356 public void setVfModuleId(String vfModuleId) {
357 this.vfModuleId = vfModuleId;
360 public String getVfModuleName() {
361 return this.vfModuleName;
364 public void setVfModuleName(String vfModuleName) {
365 this.vfModuleName = vfModuleName;
368 public String getVfModuleModelName() {
369 return this.vfModuleModelName;
372 public void setVfModuleModelName(String vfModuleModelName) {
373 this.vfModuleModelName = vfModuleModelName;
376 public String getCloudRegion() {
377 return this.cloudRegion;
380 public void setCloudRegion(String cloudRegion) {
381 this.cloudRegion = cloudRegion;
384 public String getCallBackUrl() {
388 public void setCallBackUrl(String callBackUrl) {
389 this.callBackUrl = callBackUrl;
392 public String getCorrelator() {
396 public void setCorrelator(String correlator) {
397 this.correlator = correlator;
400 public String getServiceInstanceId() {
401 return serviceInstanceId;
404 public void setServiceInstanceId(String serviceInstanceId) {
405 this.serviceInstanceId = serviceInstanceId;
408 public String getServiceInstanceName() {
409 return serviceInstanceName;
412 public void setServiceInstanceName(String serviceInstanceName) {
413 this.serviceInstanceName = serviceInstanceName;
416 public String getRequestScope() {
420 public void setRequestScope(String requestScope) {
421 this.requestScope = requestScope;
424 public String getRequestAction() {
425 return requestAction;
429 public List<CloudApiRequests> getCloudApiRequests() {
430 return cloudApiRequests;
433 public void setCloudApiRequests(List<CloudApiRequests> cloudApiRequests) {
434 this.cloudApiRequests = cloudApiRequests;
437 public void setRequestAction(String requestAction) {
438 this.requestAction = requestAction;
441 public String getNetworkId() {
445 public void setNetworkId(String networkId) {
446 this.networkId = networkId;
449 public String getNetworkName() {
453 public void setNetworkName(String networkName) {
454 this.networkName = networkName;
457 public String getNetworkType() {
461 public void setNetworkType(String networkType) {
462 this.networkType = networkType;
465 public String getRequestorId() {
469 public void setRequestorId(String requestorId) {
470 this.requestorId = requestorId;
473 public String getConfigurationId() {
474 return configurationId;
477 public void setConfigurationId(String configurationId) {
478 this.configurationId = configurationId;
481 public String getConfigurationName() {
482 return configurationName;
485 public void setConfigurationName(String configurationName) {
486 this.configurationName = configurationName;
489 public String getOperationalEnvId() {
490 return operationalEnvId;
493 public void setOperationalEnvId(String operationalEnvId) {
494 this.operationalEnvId = operationalEnvId;
497 public String getOperationalEnvName() {
498 return operationalEnvName;
501 public void setOperationalEnvName(String operationalEnvName) {
502 this.operationalEnvName = operationalEnvName;
505 public String getInstanceGroupId() {
506 return instanceGroupId;
509 public void setInstanceGroupId(String instanceGroupId) {
510 this.instanceGroupId = instanceGroupId;
513 public String getInstanceGroupName() {
514 return instanceGroupName;
517 public void setInstanceGroupName(String instanceGroupName) {
518 this.instanceGroupName = instanceGroupName;
521 public String getRequestUrl() {
522 return this.requestUrl;
525 public void setRequestUrl(String requestUrl) {
526 this.requestUrl = requestUrl;
529 public String getOriginalRequestId() {
530 return this.originalRequestId;
533 public void setOriginalRequestId(String originalRequestId) {
534 this.originalRequestId = originalRequestId;
537 public String getExtSystemErrorSource() {
538 return this.extSystemErrorSource;
541 public void setExtSystemErrorSource(String extSystemErrorSource) {
542 this.extSystemErrorSource = extSystemErrorSource;
545 public String getRollbackExtSystemErrorSource() {
546 return this.rollbackExtSystemErrorSource;
549 public void setRollbackExtSystemErrorSource(String rollbackExtSystemErrorSource) {
550 this.rollbackExtSystemErrorSource = rollbackExtSystemErrorSource;
554 protected void onCreate() {
555 if (requestScope == null)
556 requestScope = UNKNOWN;
557 if (requestAction == null)
558 requestAction = UNKNOWN;
559 this.modifyTime = new Date();
563 protected void onUpdate() {
564 if (requestScope == null)
565 requestScope = UNKNOWN;
566 if (requestAction == null)
567 requestAction = UNKNOWN;
568 this.modifyTime = new Date();
572 public boolean equals(final Object other) {
576 if (!(other instanceof InfraRequests)) {
579 InfraRequests castOther = (InfraRequests) other;
580 return Objects.equals(getRequestId(), castOther.getRequestId());
584 public int hashCode() {
585 return Objects.hash(getRequestId());
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();