2 * ============LICENSE_START=======================================================
3 * Copyright (C) 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 java.util.List;
25 import java.util.UUID;
26 import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
27 import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
28 import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
29 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
30 import org.onap.policy.models.base.PfModelException;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
34 import org.springframework.stereotype.Component;
36 @ConditionalOnExpression("'${element.handler}'=='AcElementHandlerV1'")
38 public class AutomationCompositionElementHandlerV1 extends AcElementListenerV1 {
40 private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandlerV1.class);
42 private final SimulatorService simulatorService;
44 public AutomationCompositionElementHandlerV1(ParticipantIntermediaryApi intermediaryApi,
45 SimulatorService simulatorService) {
46 super(intermediaryApi);
47 this.simulatorService = simulatorService;
51 public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
52 throws PfModelException {
53 LOGGER.debug("deploy call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
54 simulatorService.deploy(instanceId, element.getId());
58 public void undeploy(UUID instanceId, UUID elementId) throws PfModelException {
59 LOGGER.debug("undeploy call instanceId: {}, elementId: {}", instanceId, elementId);
60 simulatorService.undeploy(instanceId, elementId);
64 public void lock(UUID instanceId, UUID elementId) throws PfModelException {
65 LOGGER.debug("lock call instanceId: {}, elementId: {}", instanceId, elementId);
66 simulatorService.lock(instanceId, elementId);
70 public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
71 LOGGER.debug("unlock call instanceId: {}, elementId: {}", instanceId, elementId);
72 simulatorService.unlock(instanceId, elementId);
76 public void delete(UUID instanceId, UUID elementId) throws PfModelException {
77 LOGGER.debug("delete call instanceId: {}, elementId: {}", instanceId, elementId);
78 simulatorService.delete(instanceId, elementId);
82 public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
83 throws PfModelException {
84 LOGGER.debug("update call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
85 simulatorService.update(instanceId, element.getId());
89 public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
90 throws PfModelException {
91 LOGGER.debug("prime call compositionId: {}, elementDefinitionList: {}", compositionId, elementDefinitionList);
92 simulatorService.prime(compositionId);
96 public void deprime(UUID compositionId) throws PfModelException {
97 LOGGER.debug("deprime call compositionId: {}", compositionId);
98 simulatorService.deprime(compositionId);
102 public void migrate(UUID instanceId, AcElementDeploy element, UUID compositionTargetId,
103 Map<String, Object> properties) throws PfModelException {
104 LOGGER.debug("migrate call instanceId: {}, element: {}, compositionTargetId: {}, properties: {}",
105 instanceId, element, compositionTargetId, properties);
106 simulatorService.migrate(instanceId, element.getId());