2 * ============LICENSE_START=======================================================
\r
3 * Copyright (C) 2024 Nordix Foundation.
\r
4 * ================================================================================
\r
5 * Licensed under the Apache License, Version 2.0 (the "License");
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
17 * SPDX-License-Identifier: Apache-2.0
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.onap.policy.clamp.acm.participant.intermediary.api.impl;
\r
23 import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
\r
24 import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
\r
25 import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
\r
26 import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
\r
27 import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
\r
28 import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
\r
29 import org.onap.policy.clamp.models.acm.concepts.DeployState;
\r
30 import org.onap.policy.clamp.models.acm.concepts.LockState;
\r
31 import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
\r
32 import org.onap.policy.models.base.PfModelException;
\r
35 * Wrapper of AutomationCompositionElementListener.
\r
36 * Valid since 8.0.1 release.
\r
38 public abstract class AcElementListenerV3 implements AutomationCompositionElementListener {
\r
39 protected final ParticipantIntermediaryApi intermediaryApi;
\r
41 protected AcElementListenerV3(ParticipantIntermediaryApi intermediaryApi) {
\r
42 this.intermediaryApi = intermediaryApi;
\r
46 public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
\r
47 throws PfModelException {
\r
48 intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
\r
49 instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
\r
53 public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
\r
54 throws PfModelException {
\r
55 intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
\r
56 instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
\r
60 public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
\r
61 throws PfModelException {
\r
62 intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
\r
63 instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
\r
67 public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
\r
68 InstanceElementDto instanceElementUpdated) throws PfModelException {
\r
69 intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
\r
70 instanceElement.elementId(), DeployState.DEPLOYED, null,
\r
71 StateChangeResult.NO_ERROR, "Update not supported");
\r
76 public void prime(CompositionDto composition) throws PfModelException {
\r
77 intermediaryApi.updateCompositionState(composition.compositionId(), AcTypeState.PRIMED,
\r
78 StateChangeResult.NO_ERROR, "Primed");
\r
82 public void deprime(CompositionDto composition) throws PfModelException {
\r
83 intermediaryApi.updateCompositionState(composition.compositionId(), AcTypeState.COMMISSIONED,
\r
84 StateChangeResult.NO_ERROR, "Deprimed");
\r
88 public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
\r
89 InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, int stage)
\r
90 throws PfModelException {
\r
91 intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(),
\r
92 instanceElementMigrate.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
\r
96 public void migratePrecheck(CompositionElementDto compositionElement,
\r
97 CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
\r
98 InstanceElementDto instanceElementMigrate) throws PfModelException {
\r
99 intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(),
\r
100 instanceElementMigrate.elementId(), DeployState.DEPLOYED, null,
\r
101 StateChangeResult.NO_ERROR, "Migration Precheck completed");
\r
105 public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
\r
106 throws PfModelException {
\r
107 intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
\r
108 instanceElement.elementId(), DeployState.DEPLOYED, null,
\r
109 StateChangeResult.NO_ERROR, "Review completed");
\r
113 public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
\r
114 throws PfModelException {
\r
115 intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
\r
116 instanceElement.elementId(), DeployState.UNDEPLOYED, null,
\r
117 StateChangeResult.NO_ERROR, "Prepare completed");
\r