From 8813ba72c340e45f586b71c9ee12382cdecec91f Mon Sep 17 00:00:00 2001 From: "Mnushkin, Dmitry" Date: Wed, 24 Jul 2019 12:44:16 -0400 Subject: set multi-stage flag in listener to log success set multi-stage flag in listener to log success msg added post listener for requests db object Issue-ID: SO-2153 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I4b27cbb69b983bd2f7c0d72c8ebb4d9c43201120 --- .../db/PostCompletionRequestsDbListener.java | 33 +++++++++++ .../listener/db/RequestsDbListenerRunner.java | 65 ++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/PostCompletionRequestsDbListener.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java (limited to 'bpmn/MSOCommonBPMN/src') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/PostCompletionRequestsDbListener.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/PostCompletionRequestsDbListener.java new file mode 100644 index 0000000000..f888e5333a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/PostCompletionRequestsDbListener.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.listener.db; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.db.request.beans.InfraActiveRequests; + +public interface PostCompletionRequestsDbListener { + + public boolean shouldRunFor(BuildingBlockExecution execution); + + public void run(InfraActiveRequests request, BuildingBlockExecution execution); + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java new file mode 100644 index 0000000000..68cda5c22b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.listener.db; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class RequestsDbListenerRunner extends ListenerRunner { + + + private static Logger logger = LoggerFactory.getLogger(FlowManipulatorListenerRunner.class); + + protected List postListeners; + + @PostConstruct + protected void init() { + + postListeners = + new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PostCompletionRequestsDbListener.class)) + .orElse(new HashMap<>()).values()); + + } + + public void post(InfraActiveRequests request, BuildingBlockExecution execution) { + + List filtered = + filterListeners(postListeners, (item -> item.shouldRunFor(execution))); + + logger.info("Running post request db listeners:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(request, execution)); + + } + +} -- cgit 1.2.3-korg