7ce08df52f2f2c0a837b7b0201a61a184fe8f2a0
[so.git] / adapters / mso-vnfm-adapter / mso-vnfm-etsi-adapter / src / main / java / org / onap / so / adapters / vnfmadapter / jobmanagement / VnfmOperation.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.adapters.vnfmadapter.jobmanagement;
22
23 /**
24  * Represents an operation on a VNFM.
25  */
26 public class VnfmOperation {
27
28     private final String vnfmId;
29     private final String operationId;
30     private NotificationStatus notificationStatus;
31
32     public VnfmOperation(final String vnfmId, final String operationId, final boolean waitForNotificationForSuccess) {
33         this.vnfmId = vnfmId;
34         this.operationId = operationId;
35         this.notificationStatus = waitForNotificationForSuccess ? NotificationStatus.NOTIFICATION_PROCESSING_PENDING
36                 : NotificationStatus.NOTIFICATION_PROCESSING_NOT_REQUIRED;
37     }
38
39     /**
40      * Get the ID of the operation on the VNFM.
41      *
42      * @return the ID of the operation on the VNFM
43      */
44     public String getOperationId() {
45         return operationId;
46     }
47
48     /**
49      * Get the ID of the VNFM the operation is carried out by.
50      *
51      * @return the ID of the VNFM
52      */
53     public String getVnfmId() {
54         return vnfmId;
55     }
56
57     /**
58      * Set the required notification has been processed for the operation.
59      *
60      * @param notificationProcessingWasSuccessful <code>true</code> if the notification processing was successful,
61      *        <code>false<code> otherwise
62      */
63     public void setNotificationProcessed(final boolean notificationProcessingWasSuccessful) {
64         this.notificationStatus =
65                 notificationProcessingWasSuccessful ? NotificationStatus.NOTIFICATION_PROCEESING_SUCCESSFUL
66                         : NotificationStatus.NOTIFICATION_PROCESSING_FAILED;
67     }
68
69     /**
70      * Get the notification status for the operation.
71      *
72      * @return the notification status
73      */
74     public NotificationStatus getNotificationStatus() {
75         return notificationStatus;
76     }
77
78     public enum NotificationStatus {
79         /**
80          * No notification handling is required to determine the status of the operation
81          */
82         NOTIFICATION_PROCESSING_NOT_REQUIRED,
83         /**
84          * A notification must be processed before the notification can be considered to be completed
85          */
86         NOTIFICATION_PROCESSING_PENDING,
87         /**
88          * A notification has been successfully handled for the operation
89          */
90         NOTIFICATION_PROCEESING_SUCCESSFUL,
91         /**
92          * An error occurred processing a notification for the operation
93          */
94         NOTIFICATION_PROCESSING_FAILED;
95     }
96
97     @Override
98     public String toString() {
99         return "VnfmOperation [vnfmId=" + vnfmId + ", operationId=" + operationId + ", notificationStatus="
100                 + notificationStatus + "]";
101     }
102
103
104 }