Trigger the Intent Notification Callback 74/134574/1
authorChuanyuChen <chenchuanyu@huawei.com>
Wed, 17 May 2023 03:20:42 +0000 (11:20 +0800)
committerChuanyuChen <chenchuanyu@huawei.com>
Wed, 17 May 2023 03:20:42 +0000 (11:20 +0800)
Trigger the Intent Notification Callback

Issue-ID: USECASEUI-794

Signed-off-by: ChuanyuChen <chenchuanyu@huawei.com>
Change-Id: I14656e8d40efdd2a9b937293eb93be8b668c41a8

intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventEntity.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java
intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java

index 04f06ce..3c387a1 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.onap.usecaseui.intentanalysis.adapters.dcae.dmaap;
 
 import com.google.gson.Gson;
+import java.util.ArrayList;
+import java.util.List;
 import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationCallback;
 import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationEventModel;
-import org.onap.usecaseui.intentanalysis.adapters.policy.dmaap.PolicyNotificationCallback;
+import org.onap.usecaseui.intentanalysis.bean.enums.FulfillmentStatus;
+import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentOperation;
+import org.onap.usecaseui.intentanalysis.service.ComponentNotificationService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 
 public class DCAENotificationCallback implements NotificationCallback {
     private static final Logger logger = LoggerFactory.getLogger(DCAENotificationCallback.class);
+
+    @Autowired
+    ComponentNotificationService componentNotificationService;
+
     @Override
     public void activateCallBack(String msg) {
         logger.info("Received event from DCAE: \n" + msg);
         NotificationEventModel event = (new Gson()).fromJson(msg, NotificationEventModel.class);
-        //Todo analyze the event and Report to the Intent Flow;
+        FulfillmentOperation info = new FulfillmentOperation();
+        info.setOperation(event.getEntity().getOperation());
+        info.setFulfillmentStatus(FulfillmentStatus.NOT_FULFILLED);
+        List<String> instances = new ArrayList<>();
+        instances.add(event.getEntity().getId());
+        info.setObjectInstances(instances);
+        info.setNotFulfilledState(NotFulfilledState.FULFILMENTFAILED);
+        info.setNotFulfilledReason(event.getEntity().getReason());
+        componentNotificationService.callBack(info);
     }
 }
index 3dce969..23fd072 100644 (file)
@@ -15,6 +15,9 @@
  */
 package org.onap.usecaseui.intentanalysis.adapters.dmaap;
 
+import lombok.Data;
+
+@Data
 public class NotificationEventEntity {
     //The entity id , currently in CLL User Case, it is CLL id
     private String id;
index 44ad9ca..429f952 100644 (file)
 package org.onap.usecaseui.intentanalysis.adapters.policy.dmaap;
 
 import com.google.gson.Gson;
+import java.util.ArrayList;
+import java.util.List;
 import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationCallback;
 import org.onap.usecaseui.intentanalysis.adapters.dmaap.NotificationEventModel;
-import org.onap.usecaseui.intentanalysis.adapters.policy.impl.PolicyServiceImpl;
+import org.onap.usecaseui.intentanalysis.bean.enums.FulfillmentStatus;
+import org.onap.usecaseui.intentanalysis.bean.enums.NotFulfilledState;
+import org.onap.usecaseui.intentanalysis.bean.models.FulfillmentOperation;
+import org.onap.usecaseui.intentanalysis.service.ComponentNotificationService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 
 public class PolicyNotificationCallback implements NotificationCallback {
 
     private static final Logger logger = LoggerFactory.getLogger(PolicyNotificationCallback.class);
+
+    @Autowired
+    ComponentNotificationService componentNotificationService;
+
     @Override
     public void activateCallBack(String msg) {
         logger.info("Received event from Policy: \n" + msg);
         NotificationEventModel event = (new Gson()).fromJson(msg, NotificationEventModel.class);
-
-        //Todo analyze the event and Report to the Intent Flow;
+        FulfillmentOperation info = new FulfillmentOperation();
+        info.setOperation(event.getEntity().getOperation());
+        info.setFulfillmentStatus(FulfillmentStatus.NOT_FULFILLED);
+        List<String> instances = new ArrayList<>();
+        instances.add(event.getEntity().getId());
+        info.setObjectInstances(instances);
+        info.setNotFulfilledState(NotFulfilledState.FULFILMENTFAILED);
+        info.setNotFulfilledReason(event.getEntity().getReason());
+        componentNotificationService.callBack(info);
     }
 }