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.models.base.PfModelException;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
32 import org.springframework.stereotype.Component;
35 * This class handles implementation of automationCompositionElement updates.
37 @ConditionalOnExpression("'${element.handler:AcElementHandlerV2}' == 'AcElementHandlerV2'")
39 public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
41 private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandlerV2.class);
43 private final SimulatorService simulatorService;
45 public AutomationCompositionElementHandlerV2(ParticipantIntermediaryApi intermediaryApi,
46 SimulatorService simulatorService) {
47 super(intermediaryApi);
48 this.simulatorService = simulatorService;
52 * Handle a deploy on a automation composition element.
54 * @param compositionElement the information of the Automation Composition Definition Element
55 * @param instanceElement the information of the Automation Composition Instance Element
56 * @throws PfModelException from Policy framework
59 public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
60 throws PfModelException {
61 LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
62 simulatorService.deploy(instanceElement.instanceId(), instanceElement.elementId());
66 * Handle a automation composition element state change.
68 * @param compositionElement the information of the Automation Composition Definition Element
69 * @param instanceElement the information of the Automation Composition Instance Element
70 * @throws PfModelException from Policy framework
73 public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
74 throws PfModelException {
75 LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
76 simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
80 public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
81 throws PfModelException {
82 LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
83 simulatorService.lock(instanceElement.instanceId(), instanceElement.elementId());
87 public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
88 throws PfModelException {
89 LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
90 simulatorService.unlock(instanceElement.instanceId(), instanceElement.elementId());
94 public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
95 throws PfModelException {
96 LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
97 simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
101 public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
102 InstanceElementDto instanceElementUpdated) throws PfModelException {
103 LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
104 compositionElement, instanceElement, instanceElementUpdated);
105 simulatorService.update(instanceElement.instanceId(), instanceElement.elementId());
109 public void prime(CompositionDto composition) throws PfModelException {
110 LOGGER.debug("prime call composition: {}", composition);
111 simulatorService.prime(composition.compositionId());
115 public void deprime(CompositionDto composition) throws PfModelException {
116 LOGGER.debug("deprime call composition: {}", composition);
117 simulatorService.deprime(composition.compositionId());
121 public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
122 InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate)
123 throws PfModelException {
124 LOGGER.debug("migrate call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
125 + " instanceElementMigrate: {}",
126 compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
127 simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId());