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