aa9d90e914a92b3828f1c29f1762f4b6eabf4e84
[policy/clamp.git] /
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.clamp.acm.participant.sim.main.handler;
22
23 import java.util.List;
24 import java.util.Map;
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;
35
36 @ConditionalOnExpression("'${element.handler}'=='AcElementHandlerV1'")
37 @Component
38 public class AutomationCompositionElementHandlerV1 extends AcElementListenerV1 {
39
40     private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandlerV1.class);
41
42     private final SimulatorService simulatorService;
43
44     public AutomationCompositionElementHandlerV1(ParticipantIntermediaryApi intermediaryApi,
45         SimulatorService simulatorService) {
46         super(intermediaryApi);
47         this.simulatorService = simulatorService;
48     }
49
50     @Override
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());
55     }
56
57     @Override
58     public void undeploy(UUID instanceId, UUID elementId) throws PfModelException {
59         LOGGER.debug("undeploy call instanceId: {}, elementId: {}", instanceId, elementId);
60         simulatorService.undeploy(instanceId, elementId);
61     }
62
63     @Override
64     public void lock(UUID instanceId, UUID elementId) throws PfModelException {
65         LOGGER.debug("lock call instanceId: {}, elementId: {}", instanceId, elementId);
66         simulatorService.lock(instanceId, elementId);
67     }
68
69     @Override
70     public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
71         LOGGER.debug("unlock call instanceId: {}, elementId: {}", instanceId, elementId);
72         simulatorService.unlock(instanceId, elementId);
73     }
74
75     @Override
76     public void delete(UUID instanceId, UUID elementId) throws PfModelException {
77         LOGGER.debug("delete call instanceId: {}, elementId: {}", instanceId, elementId);
78         simulatorService.delete(instanceId, elementId);
79     }
80
81     @Override
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());
86     }
87
88     @Override
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);
93     }
94
95     @Override
96     public void deprime(UUID compositionId) throws PfModelException {
97         LOGGER.debug("deprime call compositionId: {}", compositionId);
98         simulatorService.deprime(compositionId);
99     }
100
101     @Override
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());
107     }
108 }