2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2023 Nordix Foundation.
4 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
25 import java.util.UUID;
26 import lombok.RequiredArgsConstructor;
27 import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
28 import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionOutHandler;
29 import org.onap.policy.clamp.acm.participant.intermediary.handler.CacheProvider;
30 import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
31 import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
32 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
33 import org.onap.policy.clamp.models.acm.concepts.DeployState;
34 import org.onap.policy.clamp.models.acm.concepts.LockState;
35 import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
36 import org.onap.policy.models.base.PfUtils;
37 import org.springframework.stereotype.Component;
40 * This class is api implementation used by participant intermediary.
43 @RequiredArgsConstructor
44 public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryApi {
46 // The handler for the automationComposition intermediary
47 private final AutomationCompositionOutHandler automationCompositionHandler;
48 private final CacheProvider cacheProvider;
51 public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState newState,
52 LockState lockState, StateChangeResult stateChangeResult, String message) {
53 automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, newState,
54 lockState, stateChangeResult, message);
58 public void sendAcElementInfo(UUID automationCompositionId, UUID elementId, String useState,
59 String operationalState, Map<String, Object> outProperties) {
60 automationCompositionHandler.sendAcElementInfo(automationCompositionId, elementId, useState, operationalState,
65 public Map<UUID, AutomationComposition> getAutomationCompositions() {
66 return PfUtils.mapMap(cacheProvider.getAutomationCompositions(), AutomationComposition::new);
70 public void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult,
72 automationCompositionHandler.updateCompositionState(compositionId, state, stateChangeResult, message);
76 public AutomationCompositionElement getAutomationCompositionElement(UUID automationCompositionId, UUID elementId) {
77 var automationComposition = cacheProvider.getAutomationCompositions().get(automationCompositionId);
78 if (automationComposition == null) {
81 var element = automationComposition.getElements().get(elementId);
82 return element != null ? new AutomationCompositionElement(element) : null;