diff options
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); } } |