2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023-2024 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.clamp.acm.participant.sim.main.handler;
23 import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
24 import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
25 import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
26 import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
27 import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2;
28 import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
29 import org.onap.policy.clamp.models.acm.concepts.DeployState;
30 import org.onap.policy.clamp.models.acm.concepts.LockState;
31 import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
32 import org.onap.policy.clamp.models.acm.utils.AcmUtils;
33 import org.onap.policy.models.base.PfModelException;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
37 import org.springframework.stereotype.Component;
40 * This class handles implementation of automationCompositionElement updates.
42 @ConditionalOnExpression("'${element.handler:AcElementHandlerV2}' == 'AcElementHandlerV2'")
44 public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
46 private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandlerV2.class);
48 private final SimulatorService simulatorService;
50 public AutomationCompositionElementHandlerV2(ParticipantIntermediaryApi intermediaryApi,
51 SimulatorService simulatorService) {
52 super(intermediaryApi);
53 this.simulatorService = simulatorService;
57 * Handle a deploy on a automation composition element.
59 * @param compositionElement the information of the Automation Composition Definition Element
60 * @param instanceElement the information of the Automation Composition Instance Element
61 * @throws PfModelException from Policy framework
64 public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
65 throws PfModelException {
66 LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
67 simulatorService.deploy(instanceElement.instanceId(), instanceElement.elementId());
71 * Handle a automation composition element state change.
73 * @param compositionElement the information of the Automation Composition Definition Element
74 * @param instanceElement the information of the Automation Composition Instance Element
75 * @throws PfModelException from Policy framework
78 public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
79 throws PfModelException {
80 LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
81 simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
85 public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
86 throws PfModelException {
87 LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
88 simulatorService.lock(instanceElement.instanceId(), instanceElement.elementId());
92 public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
93 throws PfModelException {
94 LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
95 simulatorService.unlock(instanceElement.instanceId(), instanceElement.elementId());
99 public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
100 throws PfModelException {
101 LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
102 simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
106 public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
107 InstanceElementDto instanceElementUpdated) throws PfModelException {
108 LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
109 compositionElement, instanceElement, instanceElementUpdated);
110 simulatorService.update(instanceElement.instanceId(), instanceElement.elementId());
114 public void prime(CompositionDto composition) throws PfModelException {
115 LOGGER.debug("prime call composition: {}", composition);
116 simulatorService.prime(composition.compositionId());
120 public void deprime(CompositionDto composition) throws PfModelException {
121 LOGGER.debug("deprime call composition: {}", composition);
122 simulatorService.deprime(composition.compositionId());
126 public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
127 InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate)
128 throws PfModelException {
129 LOGGER.debug("migrate call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
130 + " instanceElementMigrate: {}",
131 compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
132 simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId());