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.AcTypeState;
30 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
31 import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
32 import org.onap.policy.models.base.PfModelException;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35 import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
36 import org.springframework.stereotype.Component;
38 @ConditionalOnExpression("'${element.handler}'=='AcElementHandlerV1'")
40 public class AutomationCompositionElementHandlerV1 extends AcElementListenerV1 {
42 private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandlerV1.class);
44 private final SimulatorService simulatorService;
46 public AutomationCompositionElementHandlerV1(ParticipantIntermediaryApi intermediaryApi,
47 SimulatorService simulatorService) {
48 super(intermediaryApi);
49 this.simulatorService = simulatorService;
53 public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
54 throws PfModelException {
55 LOGGER.debug("deploy call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
56 simulatorService.deploy(instanceId, element.getId());
60 public void undeploy(UUID instanceId, UUID elementId) throws PfModelException {
61 LOGGER.debug("undeploy call instanceId: {}, elementId: {}", instanceId, elementId);
62 simulatorService.undeploy(instanceId, elementId);
66 public void lock(UUID instanceId, UUID elementId) throws PfModelException {
67 LOGGER.debug("lock call instanceId: {}, elementId: {}", instanceId, elementId);
68 simulatorService.lock(instanceId, elementId);
72 public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
73 LOGGER.debug("unlock call instanceId: {}, elementId: {}", instanceId, elementId);
74 simulatorService.unlock(instanceId, elementId);
78 public void delete(UUID instanceId, UUID elementId) throws PfModelException {
79 LOGGER.debug("delete call instanceId: {}, elementId: {}", instanceId, elementId);
80 simulatorService.delete(instanceId, elementId);
84 public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
85 throws PfModelException {
86 LOGGER.debug("update call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
87 simulatorService.update(instanceId, element.getId());
91 public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
92 throws PfModelException {
93 LOGGER.debug("prime call compositionId: {}, elementDefinitionList: {}", compositionId, elementDefinitionList);
94 simulatorService.prime(compositionId);
98 public void deprime(UUID compositionId) throws PfModelException {
99 LOGGER.debug("deprime call compositionId: {}", compositionId);
100 simulatorService.deprime(compositionId);
104 public void migrate(UUID instanceId, AcElementDeploy element, UUID compositionTargetId,
105 Map<String, Object> properties) throws PfModelException {
106 LOGGER.debug("migrate call instanceId: {}, element: {}, compositionTargetId: {}, properties: {}",
107 instanceId, element, compositionTargetId, properties);
108 simulatorService.migrate(instanceId, element.getId());