diff options
author | ChuanyuChen <chenchuanyu@huawei.com> | 2023-05-17 11:20:42 +0800 |
---|---|---|
committer | ChuanyuChen <chenchuanyu@huawei.com> | 2023-05-17 11:20:42 +0800 |
commit | b436bc418da80472426e2aeaddd2eadf0f8de17b (patch) | |
tree | 417175c8b3327680931f625092e769f33f1d0ea6 /intentanalysis/src/main | |
parent | 9ecd6e7fb953fa581f7900c11f6b85856073da24 (diff) |
Trigger the Intent Notification Callback
Trigger the Intent Notification Callback
Issue-ID: USECASEUI-794
Signed-off-by: ChuanyuChen <chenchuanyu@huawei.com>
Change-Id: I14656e8d40efdd2a9b937293eb93be8b668c41a8
Diffstat (limited to 'intentanalysis/src/main')
4 files changed, 46 insertions, 6 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java index 04f06ce..3c387a1 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dcae/dmaap/DCAENotificationCallback.java @@ -13,21 +13,40 @@ * 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); } } diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventEntity.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventEntity.java index 3dce969..23fd072 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventEntity.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventEntity.java @@ -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; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java index d465eba..279e71c 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/dmaap/NotificationEventModel.java @@ -15,8 +15,9 @@ */ package org.onap.usecaseui.intentanalysis.adapters.dmaap; -import java.util.Date; +import lombok.Data; +@Data public class NotificationEventModel { private String source; diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java index 44ad9ca..429f952 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/adapters/policy/dmaap/PolicyNotificationCallback.java @@ -16,20 +16,37 @@ 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); } } |