Merge "BB workflow with post instantiation is not working"
[so.git] / adapters / etsi-sol003-adapter / etsi-sol003-lcm / etsi-sol003-lcm-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     private boolean vnfDeleted;
32
33     public VnfmOperation(final String vnfmId, final String operationId, final boolean waitForNotificationForSuccess) {
34         this.vnfmId = vnfmId;
35         this.operationId = operationId;
36         this.notificationStatus = waitForNotificationForSuccess ? NotificationStatus.NOTIFICATION_PROCESSING_PENDING
37                 : NotificationStatus.NOTIFICATION_PROCESSING_NOT_REQUIRED;
38     }
39
40     /**
41      * Get the ID of the operation on the VNFM.
42      *
43      * @return the ID of the operation on the VNFM
44      */
45     public String getOperationId() {
46         return operationId;
47     }
48
49     /**
50      * Get the ID of the VNFM the operation is carried out by.
51      *
52      * @return the ID of the VNFM
53      */
54     public String getVnfmId() {
55         return vnfmId;
56     }
57
58     /**
59      * Set the required notification has been processed for the operation.
60      *
61      * @param notificationProcessingWasSuccessful <code>true</code> if the notification processing was successful,
62      *        <code>false<code> otherwise
63      */
64     public void setNotificationProcessed(final boolean notificationProcessingWasSuccessful) {
65         this.notificationStatus =
66                 notificationProcessingWasSuccessful ? NotificationStatus.NOTIFICATION_PROCEESING_SUCCESSFUL
67                         : NotificationStatus.NOTIFICATION_PROCESSING_FAILED;
68     }
69
70     /**
71      * Get the notification status for the operation.
72      *
73      * @return the notification status
74      */
75     public NotificationStatus getNotificationStatus() {
76         return notificationStatus;
77     }
78
79     /**
80      * Set the VNF has been deleted from the VNFM.
81      */
82     public void setVnfDeleted() {
83         this.vnfDeleted = true;
84     }
85
86     /**
87      * Check if the VNF has been deleted from the VNFM
88      *
89      * @return <code>true</code> of the VNF has been deleted from the VNFM, <code>false</code> otherwise
90      */
91     public boolean isVnfDeleted() {
92         return vnfDeleted;
93     }
94
95
96     public enum NotificationStatus {
97         /**
98          * No notification handling is required to determine the status of the operation
99          */
100         NOTIFICATION_PROCESSING_NOT_REQUIRED,
101         /**
102          * A notification must be processed before the notification can be considered to be completed
103          */
104         NOTIFICATION_PROCESSING_PENDING,
105         /**
106          * A notification has been successfully handled for the operation
107          */
108         NOTIFICATION_PROCEESING_SUCCESSFUL,
109         /**
110          * An error occurred processing a notification for the operation
111          */
112         NOTIFICATION_PROCESSING_FAILED;
113     }
114
115     @Override
116     public String toString() {
117         return "VnfmOperation [vnfmId=" + vnfmId + ", operationId=" + operationId + ", notificationStatus="
118                 + notificationStatus + "]";
119     }
120
121
122 }