diff options
author | liamfallon <liam.fallon@est.tech> | 2022-01-25 19:55:43 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2022-02-18 15:54:40 +0000 |
commit | 43098043c4ef31d9d5dead66568d7d9482a6b165 (patch) | |
tree | 6f6ea4812ff93d65e7c64e12a3ec6ab4462a64e2 /models/src/main/java/org/onap | |
parent | f401b5099bcb64f3e21de608d0207dd69d8043cd (diff) |
Rename TOSCA Control Loop to ACM
This commit renames the TOSCA Control Loop functionality in CLAMP to
Automation Composition Management.
This review is a direct renaming review and, as everything is renamed
together it is large.
Issue-ID: POLICY-3939
Change-Id: I28f0a6dd889bf3570a4c1365ae9e71fc58db6d6c
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models/src/main/java/org/onap')
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java | 63 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java | 279 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java | 104 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatistics.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsList.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java) | 6 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java) | 51 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java) | 16 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementAck.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java) | 26 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java) | 18 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionOrderedState.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java) | 25 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java | 67 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionStatistics.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopStatistics.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java) | 12 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java) | 11 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java) | 23 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatistics.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsList.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java) | 10 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java) | 40 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java) | 16 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java) | 6 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java) | 29 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java) | 24 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java) | 24 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java) | 6 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregister.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAck.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java) | 12 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java | 104 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAck.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantResponseStatus.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java) | 25 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReq.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/GenericNameVersion.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/GenericNameVersion.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/TypedSimpleResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/commissioning/CommissioningResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java) | 6 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionOrderStateResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopOrderStateResponse.java) | 14 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimed.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimedResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java) | 10 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstancePropertiesResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java) | 12 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationOrderStateResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationOrderStateResponse.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java) | 6 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatistics.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java) | 74 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java) | 115 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java) | 52 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatistics.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java) | 12 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProvider.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java) | 84 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java | 287 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProvider.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java) | 10 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProvider.java) | 12 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AcElementStatisticsRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ClElementStatisticsRepository.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java) | 8 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepository.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImpl.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantStatisticsRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantStatisticsRepository.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplateRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaServiceTemplateRepository.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java) | 2 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/rest/RestUtils.java (renamed from models/src/main/java/org/onap/policy/clamp/controlloop/models/rest/RestUtils.java) | 4 | ||||
-rw-r--r-- | models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java | 152 |
72 files changed, 1085 insertions, 904 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java deleted file mode 100644 index ff0d553af..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopState.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; - -public enum ControlLoopState { - /** - * The control loop or control loop element is not initialised on participants, it does not exist on participants. - */ - UNINITIALISED, - /** - * The control loop or control loop element is changing from unitialised to passive, it is being initialised onto - * participants. - */ - UNINITIALISED2PASSIVE, - /** - * The control loop or control loop element is initialised on the participants but is passive, that is, it is not - * handling control loop messages yet. - */ - PASSIVE, - /** - * The control loop or control loop element is changing from passive to running, the participants are preparing to - * execute control loops. - */ - PASSIVE2RUNNING, - /** The control loop or control loop element is running and is executing control loops. */ - RUNNING, - /** - * The control loop or control loop element is completing execution of current control loops but will not start - * running any more control loops and will become passive. - */ - RUNNING2PASSIVE, - /** - * The control loop or control loop element is changing from passive to unitialised, the control loop is being - * removed from participants. - */ - PASSIVE2UNINITIALISED; - - public boolean equalsControlLoopOrderedState(final ControlLoopOrderedState controlLoopOrderedState) { - return this.name().equals(controlLoopOrderedState.name()); - } - - public ControlLoopOrderedState asOrderedState() { - return ControlLoopOrderedState.valueOf(this.name()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java deleted file mode 100644 index a1b1045eb..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java +++ /dev/null @@ -1,279 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import javax.persistence.EntityNotFoundException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import lombok.AllArgsConstructor; -import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ControlLoopRepository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplateRepository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaNodeTemplatesRepository; -import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; -import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * This class provides information on control loop concepts in the database to callers. - */ -@Service -@Transactional -@AllArgsConstructor -public class ControlLoopProvider { - - private final ControlLoopRepository controlLoopRepository; - private final ToscaNodeTemplateRepository toscaNodeTemplateRepository; - private final ToscaNodeTemplatesRepository toscaNodeTemplatesRepository; - - /** - * Get Control Loop. - * - * @param controlLoopId the ID of the control loop to get - * @return the control loop found - * @throws PfModelException on errors getting the control loop - */ - @Transactional(readOnly = true) - public ControlLoop getControlLoop(final ToscaConceptIdentifier controlLoopId) throws PfModelException { - try { - return controlLoopRepository.getById(controlLoopId.asConceptKey()).toAuthorative(); - } catch (EntityNotFoundException e) { - throw new PfModelException(Status.NOT_FOUND, "ControlLoop not found", e); - } - } - - /** - * Find Control Loop by controlLoopId. - * - * @param name the name of the control loop to get, null to get all control loops - * @param version the version of the control loop to get, null to get all control loops - * @return the control loop found - * @throws PfModelException on errors getting the control loop - */ - @Transactional(readOnly = true) - public Optional<ControlLoop> findControlLoop(@NonNull final String name, @NonNull final String version) - throws PfModelException { - return findControlLoop(new PfConceptKey(name, version)); - } - - /** - * Find Control Loop by controlLoopId. - * - * @param controlLoopId the ID of the control loop to get - * @return the control loop found - * @throws PfModelException on errors getting the control loop - */ - @Transactional(readOnly = true) - public Optional<ControlLoop> findControlLoop(final ToscaConceptIdentifier controlLoopId) throws PfModelException { - return findControlLoop(controlLoopId.asConceptKey()); - } - - private Optional<ControlLoop> findControlLoop(@NonNull final PfConceptKey key) throws PfModelException { - try { - return controlLoopRepository.findById(key).map(JpaControlLoop::toAuthorative); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Not valid parameter", e); - } - } - - /** - * Save Control Loop. - * - * @param controlLoop the control loop to update - * @return the updated control loop - * @throws PfModelException on errors updating the control loop - */ - public ControlLoop saveControlLoop(final ControlLoop controlLoop) throws PfModelException { - try { - var result = controlLoopRepository - .save(ProviderUtils.getJpaAndValidate(controlLoop, JpaControlLoop::new, "control loop")); - - // Return the saved participant - return result.toAuthorative(); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save controlLoop", e); - } - } - - /** - * Get All Control Loops. - * - * @return all control loops found - * @throws PfModelException on errors getting control loops - */ - @Transactional(readOnly = true) - public List<ControlLoop> getControlLoops() throws PfModelException { - - return ProviderUtils.asEntityList(controlLoopRepository.findAll()); - } - - /** - * Get Control Loops. - * - * @param name the name of the control loop to get, null to get all control loops - * @param version the version of the control loop to get, null to get all control loops - * @return the control loops found - * @throws PfModelException on errors getting control loops - */ - @Transactional(readOnly = true) - public List<ControlLoop> getControlLoops(final String name, final String version) throws PfModelException { - - return ProviderUtils.asEntityList(controlLoopRepository.getFiltered(JpaControlLoop.class, name, version)); - } - - /** - * Saves control loops. - * - * @param controlLoops a specification of the control loops to create - * @return the control loops created - * @throws PfModelException on errors creating control loops - */ - public List<ControlLoop> saveControlLoops(@NonNull final List<ControlLoop> controlLoops) throws PfModelException { - try { - var result = controlLoopRepository - .saveAll(ProviderUtils.getJpaAndValidateList(controlLoops, JpaControlLoop::new, "control loops")); - - // Return the saved participant - return ProviderUtils.asEntityList(result); - } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save ControlLoops", e); - } - } - - /** - * Saves Instance Properties to the database. - * - * @param serviceTemplate the service template - * @return a Map of tosca node templates - */ - public Map<String, ToscaNodeTemplate> saveInstanceProperties(ToscaServiceTemplate serviceTemplate) { - Map<String, ToscaNodeTemplate> savedNodeTemplates = new HashMap<>(); - - var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); - jpaToscaNodeTemplates.fromAuthorative(List.of(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates())); - - toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); - serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach(savedNodeTemplates::put); - - return savedNodeTemplates; - } - - /** - * Delete a control loop. - * - * @param name the name of the control loop to delete - * @param version the version of the control loop to delete - * @return the control loop deleted - * @throws PfModelException on errors deleting the control loop - */ - public ControlLoop deleteControlLoop(@NonNull final String name, @NonNull final String version) - throws PfModelException { - - var controlLoopKey = new PfConceptKey(name, version); - var jpaDeleteControlLoop = controlLoopRepository.findById(controlLoopKey); - - if (jpaDeleteControlLoop.isEmpty()) { - String errorMessage = - "delete of control loop \"" + controlLoopKey.getId() + "\" failed, control loop does not exist"; - throw new PfModelException(Response.Status.BAD_REQUEST, errorMessage); - } - - controlLoopRepository.deleteById(controlLoopKey); - - return jpaDeleteControlLoop.get().toAuthorative(); - } - - /** - * Deletes Instance Properties on the database. - * - * @param filteredToscaNodeTemplateMap filtered node templates map to delete - * @param filteredToscaNodeTemplateList filtered node template list to delete - */ - public void deleteInstanceProperties(Map<String, ToscaNodeTemplate> filteredToscaNodeTemplateMap, - List<ToscaNodeTemplate> filteredToscaNodeTemplateList) { - - var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); - jpaToscaNodeTemplates.fromAuthorative(List.of(filteredToscaNodeTemplateMap)); - - toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); - - filteredToscaNodeTemplateList.forEach(template -> { - var jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template); - - toscaNodeTemplateRepository.delete(jpaToscaNodeTemplate); - }); - } - - /** - * Get All Node Templates. - * - * @return the list of node templates found - * @throws PfModelException on errors getting node templates - */ - @Transactional(readOnly = true) - public List<ToscaNodeTemplate> getAllNodeTemplates() { - return ProviderUtils.asEntityList(toscaNodeTemplateRepository.findAll()); - } - - /** - * Get Node Templates. - * - * @param name the name of the node template to get, null to get all node templates - * @param version the version of the node template to get, null to get all node templates - * @return the node templates found - * @throws PfModelException on errors getting node templates - */ - @Transactional(readOnly = true) - public List<ToscaNodeTemplate> getNodeTemplates(final String name, final String version) { - return ProviderUtils - .asEntityList(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version)); - } - - /** - * Get filtered node templates. - * - * @param filter the filter for the node templates to get - * @return the node templates found - * @throws PfModelException on errors getting node templates - */ - @Transactional(readOnly = true) - public List<ToscaNodeTemplate> getFilteredNodeTemplates( - @NonNull final ToscaTypedEntityFilter<ToscaNodeTemplate> filter) { - - return filter.filter(ProviderUtils.asEntityList(toscaNodeTemplateRepository - .getFiltered(JpaToscaNodeTemplate.class, filter.getName(), filter.getVersion()))); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java deleted file mode 100644 index 62b8d20b0..000000000 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; - -/** - * Class to hold the possible values for the type of participant messages. - */ -public enum ParticipantMessageType { - - /** - * Used by participants to report status to the control loop runtime. - */ - PARTICIPANT_STATUS, - - /** - * Used by the controlloop runtime to change the state of participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_STATE_CHANGE operation. - */ - PARTICIPANT_STATE_CHANGE, - - /** - * Used by controlloop runtime to update the controlloops running on participants, triggers a - * PARTICIPANT_STATUS message with the result of the CONTROL_LOOP_UPDATE operation. - */ - CONTROL_LOOP_UPDATE, - - /** - * Used by controlloop runtime to change the state of controlloops in participants, triggers a - * PARTICIPANT_STATUS message with result of CONTROL_LOOP_STATE_CHANGE operation. - */ - CONTROL_LOOP_STATE_CHANGE, - - /** - * Used by the control loop runtime to order a health check on participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_HEALTH_CHECK operation. - */ - PARTICIPANT_HEALTH_CHECK, - - /** - * Used by participant to register itself with control loop runtime. - */ - PARTICIPANT_REGISTER, - - /** - * Used by control loop runtime to respond to participant registration. - */ - PARTICIPANT_REGISTER_ACK, - - /** - * Used by participant to deregister itself with control loop runtime. - */ - PARTICIPANT_DEREGISTER, - - /** - * Used by control loop runtime to respond to participant deregistration. - */ - PARTICIPANT_DEREGISTER_ACK, - - /** - * Used by control loop runtime to send ToscaServiceTemplate to participant. - */ - PARTICIPANT_UPDATE, - - /** - * Used by participant to acknowledge the receipt of Participant_Update message - * from control loop runtime. - */ - PARTICIPANT_UPDATE_ACK, - - /** - * Used by participant to acknowledge the receipt of ControlLoop_Update message - * from control loop runtime. - */ - CONTROLLOOP_UPDATE_ACK, - - /** - * Used by participant to acknowledge the receipt of ControlLoop_StateChange message - * from control loop runtime. - */ - CONTROLLOOP_STATECHANGE_ACK, - - /** - * Used by control loop runtime to request for ParticipantStatus message immediately. - */ - PARTICIPANT_STATUS_REQ -} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatistics.java index 4ef9bdcd9..d1b1e31e8 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatistics.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatistics.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.io.Serializable; import java.time.Instant; @@ -32,7 +32,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @NoArgsConstructor @Data @ToString -public class ClElementStatistics implements Serializable { +public class AcElementStatistics implements Serializable { private static final long serialVersionUID = 3284285693112271055L; @@ -46,8 +46,8 @@ public class ClElementStatistics implements Serializable { private Instant timeStamp; @NonNull - private ControlLoopState controlLoopState; + private AutomationCompositionState state; - private long clElementUptime; + private long acElementUptime; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsList.java index 166f1e48f..3b8feb5f6 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ClElementStatisticsList.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementStatisticsList.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.List; import lombok.Getter; @@ -28,6 +28,6 @@ import lombok.ToString; @Getter @Setter @ToString -public class ClElementStatisticsList { - private List<ClElementStatistics> clElementStatistics; +public class AcElementStatisticsList { + private List<AcElementStatistics> acElementStatistics; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java index cf22b7228..f6134782b 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.List; import java.util.Map; @@ -35,22 +35,22 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; /** - * Class to represent a control loop instance. + * Class to represent an automation composition instance. */ @NoArgsConstructor @Data @EqualsAndHashCode(callSuper = true) -public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> { +public class AutomationComposition extends ToscaEntity implements Comparable<AutomationComposition> { @NonNull private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); @NonNull - private ControlLoopState state = ControlLoopState.UNINITIALISED; + private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED; @NonNull - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; + private AutomationCompositionOrderedState orderedState = AutomationCompositionOrderedState.UNINITIALISED; - private Map<UUID, ControlLoopElement> elements; + private Map<UUID, AutomationCompositionElement> elements; @NonNull private Boolean primed = false; @@ -68,28 +68,28 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> /** * Copy contructor, does a deep copy. * - * @param otherControlLoop the other element to copy from + * @param otherAutomationComposition the other element to copy from */ - public ControlLoop(final ControlLoop otherControlLoop) { - super(otherControlLoop); - this.definition = new ToscaConceptIdentifier(otherControlLoop.definition); - this.state = otherControlLoop.state; - this.orderedState = otherControlLoop.orderedState; - this.elements = PfUtils.mapMap(otherControlLoop.elements, ControlLoopElement::new); - this.primed = otherControlLoop.primed; + public AutomationComposition(final AutomationComposition otherAutomationComposition) { + super(otherAutomationComposition); + this.definition = new ToscaConceptIdentifier(otherAutomationComposition.definition); + this.state = otherAutomationComposition.state; + this.orderedState = otherAutomationComposition.orderedState; + this.elements = PfUtils.mapMap(otherAutomationComposition.elements, AutomationCompositionElement::new); + this.primed = otherAutomationComposition.primed; } @Override - public int compareTo(final ControlLoop other) { + public int compareTo(final AutomationComposition other) { return compareNameVersion(this, other); } /** - * Set the ordered state on the control loop and on all its control loop elements. + * Set the ordered state on the automation composition and on all its automation composition elements. * - * @param orderedState the state we want the control loop to transition to + * @param orderedState the state we want the automation composition to transition to */ - public void setCascadedOrderedState(final ControlLoopOrderedState orderedState) { + public void setCascadedOrderedState(final AutomationCompositionOrderedState orderedState) { this.orderedState = orderedState; if (MapUtils.isEmpty(elements)) { @@ -100,17 +100,18 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> } /** - * Get a list of control loop element statistics. + * Get a list of automation composition element statistics. * - * @param controlLoop the control loop - * @return List of ClElementStatistics + * @param automationComposition the automation composition + * @return List of AcElementStatistics */ - public List<ClElementStatistics> getControlLoopElementStatisticsList(final ControlLoop controlLoop) { - if (MapUtils.isEmpty(controlLoop.elements)) { + public List<AcElementStatistics> getAutomationCompositionElementStatisticsList( + final AutomationComposition automationComposition) { + if (MapUtils.isEmpty(automationComposition.elements)) { return List.of(); } - return controlLoop.elements.values().stream().map(ControlLoopElement::getClElementStatistics) - .collect(Collectors.toList()); + return automationComposition.elements.values().stream() + .map(AutomationCompositionElement::getAcElementStatistics).collect(Collectors.toList()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java index c7d85e4b6..046b77f76 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.LinkedHashMap; import java.util.Map; @@ -35,12 +35,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** - * Class to represent a control loop instance. + * Class to represent a automation composition instance. */ @NoArgsConstructor @Data @ToString -public class ControlLoopElement { +public class AutomationCompositionElement { @NonNull private UUID id = UUID.randomUUID(); @@ -54,16 +54,16 @@ public class ControlLoopElement { private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); @NonNull - private ControlLoopState state = ControlLoopState.UNINITIALISED; + private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED; @NonNull - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; + private AutomationCompositionOrderedState orderedState = AutomationCompositionOrderedState.UNINITIALISED; private ToscaServiceTemplate toscaServiceTemplateFragment; private String description; - private ClElementStatistics clElementStatistics; + private AcElementStatistics acElementStatistics; // A map indexed by the property name. Each map entry is the serialized value of the property, // which can be deserialized into an instance of the type of the property. @@ -74,7 +74,7 @@ public class ControlLoopElement { * * @param otherElement the other element to copy from */ - public ControlLoopElement(final ControlLoopElement otherElement) { + public AutomationCompositionElement(final AutomationCompositionElement otherElement) { this.id = otherElement.id; this.definition = new ToscaConceptIdentifier(otherElement.definition); this.participantType = new ToscaConceptIdentifier(otherElement.participantType); @@ -83,7 +83,7 @@ public class ControlLoopElement { this.orderedState = otherElement.orderedState; this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment; this.description = otherElement.description; - this.clElementStatistics = otherElement.clElementStatistics; + this.acElementStatistics = otherElement.acElementStatistics; this.propertiesMap = PfUtils.mapMap(otherElement.propertiesMap, UnaryOperator.identity()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java index 61b90c9e9..b100f28c0 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementAck.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import lombok.AllArgsConstructor; import lombok.Getter; @@ -29,10 +29,10 @@ import lombok.ToString; @Setter @AllArgsConstructor @ToString -public class ControlLoopElementAck { +public class AutomationCompositionElementAck { - // State of the controlLoopElement - private ControlLoopState state; + // State of the AutomationCompositionElement + private AutomationCompositionState state; // Result: Success/Fail. private Boolean result; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java index ae50b40ce..aebee0e2c 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.LinkedHashMap; import java.util.Map; @@ -33,18 +33,18 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; /** - * Class to represent a control loop element definition instance. + * Class to represent an automation composition element definition instance. */ @Getter @NoArgsConstructor @Data @ToString -public class ControlLoopElementDefinition { +public class AutomationCompositionElementDefinition { - private ToscaConceptIdentifier clElementDefinitionId; + private ToscaConceptIdentifier acElementDefinitionId; - // The definition of the Control Loop Element in TOSCA - private ToscaNodeTemplate controlLoopElementToscaNodeTemplate; + // The definition of the Automation Composition Element in TOSCA + private ToscaNodeTemplate automationCompositionElementToscaNodeTemplate; // A map indexed by the property name. Each map entry is the serialized value of the property, // which can be deserialized into an instance of the type of the property. @@ -53,12 +53,12 @@ public class ControlLoopElementDefinition { /** * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. * - * @param clElementDefinition the controlloop element definition to copy from + * @param acElementDefinition the automation composition element definition to copy from */ - public ControlLoopElementDefinition(final ControlLoopElementDefinition clElementDefinition) { - this.clElementDefinitionId = clElementDefinition.clElementDefinitionId; - this.controlLoopElementToscaNodeTemplate = - new ToscaNodeTemplate(clElementDefinition.controlLoopElementToscaNodeTemplate); - this.commonPropertiesMap = PfUtils.mapMap(clElementDefinition.commonPropertiesMap, UnaryOperator.identity()); + public AutomationCompositionElementDefinition(final AutomationCompositionElementDefinition acElementDefinition) { + this.acElementDefinitionId = acElementDefinition.acElementDefinitionId; + this.automationCompositionElementToscaNodeTemplate = + new ToscaNodeTemplate(acElementDefinition.automationCompositionElementToscaNodeTemplate); + this.commonPropertiesMap = PfUtils.mapMap(acElementDefinition.commonPropertiesMap, UnaryOperator.identity()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java index 0c33606db..dba8f553c 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopInfo.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import lombok.Data; import lombok.NoArgsConstructor; @@ -26,27 +26,27 @@ import lombok.ToString; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** - * Class to represent a control loop info instance. + * Class to represent a automation composition info instance. */ @NoArgsConstructor @Data @ToString -public class ControlLoopInfo { +public class AutomationCompositionInfo { - private ToscaConceptIdentifier controlLoopId; + private ToscaConceptIdentifier automationCompositionId; - private ControlLoopState state = ControlLoopState.UNINITIALISED; + private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED; - private ControlLoopStatistics controlLoopStatistics; + private AutomationCompositionStatistics automationCompositionStatistics; /** * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. * * @param otherElement the other element to copy from */ - public ControlLoopInfo(final ControlLoopInfo otherElement) { - this.controlLoopId = otherElement.controlLoopId; + public AutomationCompositionInfo(final AutomationCompositionInfo otherElement) { + this.automationCompositionId = otherElement.automationCompositionId; this.state = otherElement.state; - this.controlLoopStatistics = otherElement.controlLoopStatistics; + this.automationCompositionStatistics = otherElement.automationCompositionStatistics; } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionOrderedState.java index 91f90275e..3be5ffa2f 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopOrderedState.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionOrderedState.java @@ -18,27 +18,30 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; -public enum ControlLoopOrderedState { +public enum AutomationCompositionOrderedState { /** - * The control loop or control loop element should become uninitialised on participants, it should not exist on - * participants. + * The automation composition or automation composition element should become uninitialised on participants, it + * should not exist on participants. */ UNINITIALISED, /** - * The control loop or control loop element should initialised on the participants and be passive, that is, it is - * not handling control loop messages yet. + * The automation composition or automation composition element should initialised on the participants and be + * passive, that is, it is not handling automation composition messages yet. */ PASSIVE, - /** The control loop or control loop element should running and is executing control loops. */ + /** + * The automation composition or automation composition element should running and is executing automation + * compositions. + */ RUNNING; - public boolean equalsControlLoopState(final ControlLoopState controlLoopState) { - return this.name().equals(controlLoopState.name()); + public boolean equalsAutomationCompositionState(final AutomationCompositionState automationCompositionState) { + return this.name().equals(automationCompositionState.name()); } - public ControlLoopState asState() { - return ControlLoopState.valueOf(this.name()); + public AutomationCompositionState asState() { + return AutomationCompositionState.valueOf(this.name()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java new file mode 100644 index 000000000..aa6fcfd1d --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionState.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +public enum AutomationCompositionState { + /** + * The automation composition or automation composition element is not initialised on participants, it does not + * exist on participants. + */ + UNINITIALISED, + /** + * The automation composition or automation composition element is changing from unitialised to passive, it is being + * initialised onto participants. + */ + UNINITIALISED2PASSIVE, + /** + * The automation composition or automation composition element is initialised on the participants but is passive, + * that is, it is not handling automation composition messages yet. + */ + PASSIVE, + /** + * The automation composition or automation composition element is changing from passive to running, the + * participants are preparing to execute automation compositions. + */ + PASSIVE2RUNNING, + /** + * The automation composition or automation composition element is running and is executing automation compositions. + */ + RUNNING, + /** + * The automation composition or automation composition element is completing execution of current automation + * compositions but will not start running any more automation compositions and will become passive. + */ + RUNNING2PASSIVE, + /** + * The automation composition or automation composition element is changing from passive to unitialised, the + * automation composition is being removed from participants. + */ + PASSIVE2UNINITIALISED; + + public boolean equalsAutomationCompositionOrderedState( + final AutomationCompositionOrderedState automationCompositionOrderedState) { + return this.name().equals(automationCompositionOrderedState.name()); + } + + public AutomationCompositionOrderedState asOrderedState() { + return AutomationCompositionOrderedState.valueOf(this.name()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionStatistics.java index 685947b13..8f73328ad 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopStatistics.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionStatistics.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.time.Instant; import lombok.Data; @@ -30,16 +30,16 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @NoArgsConstructor @Data @ToString -public class ControlLoopStatistics { +public class AutomationCompositionStatistics { @NonNull - private ToscaConceptIdentifier controlLoopId; + private ToscaConceptIdentifier automationCompositionId; @NonNull private Instant timeStamp; @NonNull - private ClElementStatisticsList clElementStatisticsList; + private AcElementStatisticsList acElementStatisticsList; private long eventCount; private long lastExecutionTime; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java index 4ab406f3b..1802f814c 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoops.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.ArrayList; import java.util.List; @@ -34,15 +34,15 @@ import org.onap.policy.models.base.PfUtils; @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode -public class ControlLoops { - private List<ControlLoop> controlLoopList = new ArrayList<>(); +public class AutomationCompositions { + private List<AutomationComposition> automationCompositionList = new ArrayList<>(); /** * Copy constructor, does a deep copy. * - * @param otherControlLoops the other element to copy from + * @param otherAutomationCompositions the other element to copy from */ - public ControlLoops(final ControlLoops otherControlLoops) { - this.controlLoopList = PfUtils.mapList(controlLoopList, ControlLoop::new); + public AutomationCompositions(final AutomationCompositions otherAutomationCompositions) { + this.automationCompositionList = PfUtils.mapList(automationCompositionList, AutomationComposition::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java index 198cf1a16..1a8fbc409 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/Participant.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java index 336b309ce..949a7c47d 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDefinition.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.ArrayList; import java.util.List; @@ -42,8 +42,8 @@ public class ParticipantDefinition { private ToscaConceptIdentifier participantType; - // List of ControlLoopElementDefinition values for a particular participant - private List<ControlLoopElementDefinition> controlLoopElementDefinitionList = new ArrayList<>(); + // List of AutomationCompositionElementDefinition values for a particular participant + private List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList = new ArrayList<>(); /** * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. @@ -53,7 +53,8 @@ public class ParticipantDefinition { public ParticipantDefinition(final ParticipantDefinition participantDefinition) { this.participantId = participantDefinition.participantId; this.participantType = participantDefinition.participantType; - this.controlLoopElementDefinitionList = PfUtils.mapList( - participantDefinition.controlLoopElementDefinitionList, ControlLoopElementDefinition::new); + this.automationCompositionElementDefinitionList = + PfUtils.mapList(participantDefinition.automationCompositionElementDefinitionList, + AutomationCompositionElementDefinition::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java index e7c5fecda..f8cc0a852 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantHealthStatus.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantHealthStatus.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; /** * Class to hold the possible values for health status of Participant. diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java index 1af32660d..4ab42c697 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantState.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantState.java @@ -18,44 +18,43 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; /** * Class to hold the possible values for mode of participant. */ public enum ParticipantState { - /** - * Control Loop execution is unknown. + * Participant state is unknown. */ UNKNOWN, /** - * Control Loop execution is always rejected. + * Participant is passive, automation composition element execution is always rejected. */ PASSIVE, /** - * Control Loop execution execution proceeds, but changes to domain state or context are not carried out. The - * participant returns an indication that it is running in SAFE mode together with the action it would have - * performed if it was operating in ACTIVE mode. + * Automation composition element execution execution proceeds, but changes to domain state or context are not + * carried out. The participant returns an indication that it is running in SAFE mode together with the action it + * would have performed if it was operating in ACTIVE mode. */ SAFE, /** - * Control Loop execution execution proceeds and changes to domain and state are carried out in a test environment. - * The participant returns an indication that it is running in TEST mode together with the action it has performed - * on the test environment. + * Automation composition element execution execution proceeds and changes to domain and state are carried out in a + * test environment. The participant returns an indication that it is running in TEST mode together with the action + * it has performed on the test environment. */ TEST, /** - * Control Loop execution execution is executed in the live environment by the participant. + * Automation composition element execution is executed in the live environment by the participant. */ ACTIVE, /** - * Control Loop execution execution is terminated and not available. + * Automation composition element execution has been terminated. */ TERMINATED } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatistics.java index 3a7b21fa1..4d3b96db7 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatistics.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatistics.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.io.Serializable; import java.time.Instant; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsList.java index a69f96f85..4abdf4a63 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantStatisticsList.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantStatisticsList.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.List; import lombok.Getter; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java index ea851b8c5..1872a6144 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUpdates.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.ArrayList; import java.util.List; @@ -40,8 +40,8 @@ public class ParticipantUpdates { private ToscaConceptIdentifier participantId; - // List of ControlLoopElement values for a particular participant - private List<ControlLoopElement> controlLoopElementList = new ArrayList<>(); + // List of AutomationCompositionElement values for a particular participant + private List<AutomationCompositionElement> automationCompositionElementList = new ArrayList<>(); /** * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. @@ -50,7 +50,7 @@ public class ParticipantUpdates { */ public ParticipantUpdates(final ParticipantUpdates participantUpdates) { this.participantId = participantUpdates.participantId; - this.controlLoopElementList = PfUtils.mapList( - participantUpdates.controlLoopElementList, ControlLoopElement::new); + this.automationCompositionElementList = PfUtils.mapList( + participantUpdates.automationCompositionElementList, AutomationCompositionElement::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java index c05311892..9d26ce406 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.concepts; +package org.onap.policy.clamp.models.acm.concepts; import java.util.Map; import javax.ws.rs.core.Response; @@ -36,7 +36,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; public final class ParticipantUtils { private static final Coder CODER = new StandardCoder(); - private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement"; + private static final String AUTOMATION_COMPOSITION_ELEMENT = + "org.onap.policy.clamp.acm.AutomationCompositionElement"; /** * Finds participantType from a map of properties. @@ -57,27 +58,30 @@ public final class ParticipantUtils { } /** - * Get the First StartPhase - * it depend of the state of the Control Loop - * and also from the all startPhase defined into the ToscaServiceTemplate. - * @param controlLoop the ControlLoop + * Get the First StartPhase. + * + * <p>This depends on the state of the automation composition and also on all start phases defined in the + * ToscaServiceTemplate. + * + * @param automationComposition the automation composition * @param toscaServiceTemplate the ToscaServiceTemplate * @return the First StartPhase */ - public static int getFirstStartPhase(ControlLoop controlLoop, ToscaServiceTemplate toscaServiceTemplate) { + public static int getFirstStartPhase( + AutomationComposition automationComposition, ToscaServiceTemplate toscaServiceTemplate) { var minStartPhase = 1000; var maxStartPhase = 0; - for (var element : controlLoop.getElements().values()) { + for (var element : automationComposition.getElements().values()) { ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates() - .get(element.getDefinition().getName()); + .get(element.getDefinition().getName()); int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()); minStartPhase = Math.min(minStartPhase, startPhase); maxStartPhase = Math.max(maxStartPhase, startPhase); } - return ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState()) - || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? minStartPhase - : maxStartPhase; + return AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState()) + || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState()) ? minStartPhase + : maxStartPhase; } /** @@ -95,22 +99,22 @@ public final class ParticipantUtils { } /** - * Checks If NodeTemplate Is ControlLoopElement. + * Checks if a NodeTemplate is an AutomationCompositionElement. * * @param nodeTemplate the ToscaNodeTemplate * @param toscaServiceTemplate the ToscaServiceTemplate - * @return true if NodeTemplate Is ControlLoopElement + * @return true if the NodeTemplate is an AutomationCompositionElement */ - public static boolean checkIfNodeTemplateIsControlLoopElement(ToscaNodeTemplate nodeTemplate, - ToscaServiceTemplate toscaServiceTemplate) { - if (nodeTemplate.getType().contains(CONTROL_LOOP_ELEMENT)) { + public static boolean checkIfNodeTemplateIsAutomationCompositionElement(ToscaNodeTemplate nodeTemplate, + ToscaServiceTemplate toscaServiceTemplate) { + if (nodeTemplate.getType().contains(AUTOMATION_COMPOSITION_ELEMENT)) { return true; } else { var nodeType = toscaServiceTemplate.getNodeTypes().get(nodeTemplate.getType()); if (nodeType != null) { var derivedFrom = nodeType.getDerivedFrom(); if (derivedFrom != null) { - return derivedFrom.contains(CONTROL_LOOP_ELEMENT); + return derivedFrom.contains(AUTOMATION_COMPOSITION_ELEMENT); } } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java index c6bbd81d6..4b898633a 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopNotification.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification; +package org.onap.policy.clamp.models.acm.messages.dmaap.notification; import com.google.gson.annotations.SerializedName; import java.util.ArrayList; @@ -29,23 +29,23 @@ import org.apache.commons.collections4.CollectionUtils; @Data @NoArgsConstructor @AllArgsConstructor -public class ControlLoopNotification { +public class AutomationCompositionNotification { /** - * Status of control loops that are being added to participants. + * Status of automation compositions that are being added to participants. */ - @SerializedName("deployed-control-loops") - private List<ControlLoopStatus> added = new ArrayList<>(); + @SerializedName("deployed-automation-compositions") + private List<AutomationCompositionStatus> added = new ArrayList<>(); /** * Status of policies that are being deleted from PDPs. */ - @SerializedName("undeployed-control-loops") - private List<ControlLoopStatus> deleted = new ArrayList<>(); + @SerializedName("undeployed-automation-compositions") + private List<AutomationCompositionStatus> deleted = new ArrayList<>(); /** - * Determines if the notification is empty (i.e., has no added or delete control loop + * Determines if the notification is empty (i.e., has no added or delete automation composition * notifications). * * @return {@code true} if the notification is empty, {@code false} otherwise diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java index 033843e75..f65c6217b 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/notification/ControlLoopStatus.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.notification; +package org.onap.policy.clamp.models.acm.messages.dmaap.notification; import com.google.gson.annotations.SerializedName; import java.util.UUID; @@ -28,8 +28,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @Data @NoArgsConstructor @AllArgsConstructor -public class ControlLoopStatus { - @SerializedName("control-loop-id") +public class AutomationCompositionStatus { + @SerializedName("automation-composition-id") private UUID id; private ToscaConceptIdentifier definition; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java index cdbfea4e2..c0a21d61a 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import java.util.LinkedHashMap; import java.util.Map; @@ -27,32 +27,32 @@ import java.util.function.UnaryOperator; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementAck; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck; import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** - * Class to represent the CONTROLLOOP_ACK message that a participant sends - * to control loop runtime as an acknowledgement to either ControlLoopUpdate - * or ControlLoopStateChange message. + * Class to represent the AUTOMATION_COMPOSITION_ACK message that a participant sends + * to automation composition runtime as an acknowledgement to either AUTOMATION_COMPOSITION_UPDATE + * or AUTOMATION_COMPOSITION_STATE_CHANGE message. */ @Getter @Setter @ToString(callSuper = true) -public class ControlLoopAck extends ParticipantAckMessage { +public class AutomationCompositionAck extends ParticipantAckMessage { - private ToscaConceptIdentifier controlLoopId; + private ToscaConceptIdentifier automationCompositionId; private Integer startPhase; - // A map with ControlLoopElementID as its key, and a pair of result and message as value per - // ControlLoopElement. - private Map<UUID, ControlLoopElementAck> controlLoopResultMap = new LinkedHashMap<>(); + // A map with AutomationCompositionElementID as its key, and a pair of result and message as value per + // AutomationCompositionElement. + private Map<UUID, AutomationCompositionElementAck> automationCompositionResultMap = new LinkedHashMap<>(); /** * Constructor for instantiating ParticipantRegisterAck class with message name. * */ - public ControlLoopAck(final ParticipantMessageType messageType) { + public AutomationCompositionAck(final ParticipantMessageType messageType) { super(messageType); } @@ -61,9 +61,10 @@ public class ControlLoopAck extends ParticipantAckMessage { * * @param source source from which to copy */ - public ControlLoopAck(final ControlLoopAck source) { + public AutomationCompositionAck(final AutomationCompositionAck source) { super(source); - this.controlLoopId = source.controlLoopId; - this.controlLoopResultMap = PfUtils.mapMap(source.controlLoopResultMap, UnaryOperator.identity()); + this.automationCompositionId = source.automationCompositionId; + this.automationCompositionResultMap = + PfUtils.mapMap(source.automationCompositionResultMap, UnaryOperator.identity()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java index e3b7049e1..f8daa36a9 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java @@ -18,32 +18,32 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; /** - * Class to represent the CONTROL_LOOP_STATE_CHANGE message that the control loop runtime will send to - * participants to change the state of a control loop they are running. + * Class to represent the AUTOMATION_COMPOSITION_STATE_CHANGE message that the automation composition runtime will send + * to participants to change the state of an automation composition they are running. */ @Getter @Setter @ToString(callSuper = true) -public class ControlLoopStateChange extends ParticipantMessage { - private ControlLoopOrderedState orderedState; - private ControlLoopState currentState; +public class AutomationCompositionStateChange extends ParticipantMessage { + private AutomationCompositionOrderedState orderedState; + private AutomationCompositionState currentState; private Integer startPhase; /** - * Constructor for instantiating ControlLoopStateChange class with message name. + * Constructor for instantiating class with message name. * */ - public ControlLoopStateChange() { - super(ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); + public AutomationCompositionStateChange() { + super(ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); } /** @@ -51,7 +51,7 @@ public class ControlLoopStateChange extends ParticipantMessage { * * @param source source from which to copy */ - public ControlLoopStateChange(ControlLoopStateChange source) { + public AutomationCompositionStateChange(AutomationCompositionStateChange source) { super(source); this.orderedState = source.orderedState; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java index f8a47c7c9..55fcc7462 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java @@ -18,36 +18,37 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; import org.onap.policy.models.base.PfUtils; /** - * Class to represent the CONTROL_LOOP_UPDATE message that the control loop runtime sends to a participant. - * When a participant receives this message, it creates the control loop elements contained in the message and sets them - * to state PASSIVE. subsequent CONTROL_LOOP_STATE_CHANGE messages are used to activate the control loops. + * Class to represent the AUTOMATION_COMPOSITION_UPDATE message that the automation composition runtime sends to a + * participant. When a participant receives this message, it creates the automation composition elements contained in + * the message and sets them to state PASSIVE. subsequent AUTOMATION_COMPOSITION_STATE_CHANGE messages are used to + * activate the automation compositions. */ @Getter @Setter @ToString(callSuper = true) -public class ControlLoopUpdate extends ParticipantMessage { +public class AutomationCompositionUpdate extends ParticipantMessage { // A list of ParticipantUpdates instances which carries details of an updated participant. private List<ParticipantUpdates> participantUpdatesList = new ArrayList<>(); private Integer startPhase = 0; /** - * Constructor for instantiating ControlLoopUpdate class with message name. + * Constructor for instantiating class with message name. * */ - public ControlLoopUpdate() { - super(ParticipantMessageType.CONTROL_LOOP_UPDATE); + public AutomationCompositionUpdate() { + super(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); } /** @@ -55,10 +56,9 @@ public class ControlLoopUpdate extends ParticipantMessage { * * @param source source from which to copy */ - public ControlLoopUpdate(ControlLoopUpdate source) { + public AutomationCompositionUpdate(AutomationCompositionUpdate source) { super(source); - this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, - ParticipantUpdates::new); + this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, ParticipantUpdates::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java index 8a1be69bd..8b33d3172 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import java.util.UUID; import lombok.Getter; import lombok.NonNull; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** @@ -104,7 +104,7 @@ public class ParticipantAckMessage { return false; } - // Broadcast message to all control loop elements on this participant + // Broadcast message to all automation composition elements on this participant if (this.participantId == null) { return true; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregister.java index 7705e3d0c..2e7ed8c52 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregister.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** - * Class to represent the PARTICIPANT_DEREGISTER message that all the participants send to control loop runtime. + * Class to represent the PARTICIPANT_DEREGISTER message that all the participants send to the ACM runtime. */ @Getter @Setter diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAck.java index 69406beb7..afa987d65 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterAck.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** - * Class to represent the PARTICIPANT_DEREGISTER_ACK message that control loop runtime sends to the participant. + * Class to represent the PARTICIPANT_DEREGISTER_ACK message that the ACM runtime sends to the participant. */ @Getter @Setter diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java index f98a88c3b..c358376b2 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessage.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import java.time.Instant; import java.util.UUID; @@ -30,7 +30,7 @@ import lombok.ToString; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** - * Class to represent the base class for various messages that will be exchanged between the control loop runtime and + * Class to represent the base class for various messages that will be exchanged between the ACM runtime and * participants. */ @Getter @@ -58,9 +58,9 @@ public class ParticipantMessage { private ToscaConceptIdentifier participantId; /** - * Control loop ID, or {@code null} for messages to participants. + * Automation Composition ID, or {@code null} for messages to participants. */ - private ToscaConceptIdentifier controlLoopId; + private ToscaConceptIdentifier automationCompositionId; /** * Constructor for instantiating a participant message class. @@ -80,7 +80,7 @@ public class ParticipantMessage { this.messageType = source.messageType; this.participantType = source.participantType; this.participantId = source.participantId; - this.controlLoopId = source.controlLoopId; + this.automationCompositionId = source.automationCompositionId; } /** @@ -101,7 +101,7 @@ public class ParticipantMessage { return false; } - // Broadcast message to all control loop elements on this participant + // Broadcast message to all automation composition elements on this participant if (this.participantId == null) { return true; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java new file mode 100644 index 000000000..4f6bcdbf3 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +/** + * Class to hold the possible values for the type of participant messages. + */ +public enum ParticipantMessageType { + + /** + * Used by participants to report status to the automation composition runtime. + */ + PARTICIPANT_STATUS, + + /** + * Used by the acm runtime to change the state of participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_STATE_CHANGE operation. + */ + PARTICIPANT_STATE_CHANGE, + + /** + * Used by acm runtime to update the automation compositions running on participants, triggers a + * PARTICIPANT_STATUS message with the result of the AUTOMATION_COMPOSITION_UPDATE operation. + */ + AUTOMATION_COMPOSITION_UPDATE, + + /** + * Used by acm runtime to change the state of automation compositions in participants, triggers a + * PARTICIPANT_STATUS message with result of AUTOMATION_COMPOSITION_STATE_CHANGE operation. + */ + AUTOMATION_COMPOSITION_STATE_CHANGE, + + /** + * Used by the automation composition runtime to order a health check on participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_HEALTH_CHECK operation. + */ + PARTICIPANT_HEALTH_CHECK, + + /** + * Used by participant to register itself with automation composition runtime. + */ + PARTICIPANT_REGISTER, + + /** + * Used by automation composition runtime to respond to participant registration. + */ + PARTICIPANT_REGISTER_ACK, + + /** + * Used by participant to deregister itself with automation composition runtime. + */ + PARTICIPANT_DEREGISTER, + + /** + * Used by automation composition runtime to respond to participant deregistration. + */ + PARTICIPANT_DEREGISTER_ACK, + + /** + * Used by automation composition runtime to send ToscaServiceTemplate to participant. + */ + PARTICIPANT_UPDATE, + + /** + * Used by participant to acknowledge the receipt of PARTICIPANT_UPDATE message + * from automation composition runtime. + */ + PARTICIPANT_UPDATE_ACK, + + /** + * Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_UPDATE message + * from automation composition runtime. + */ + AUTOMATION_COMPOSITION_UPDATE_ACK, + + /** + * Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_STATE_CHANGE message + * from automation composition runtime. + */ + AUTOMATION_COMPOSITION_STATECHANGE_ACK, + + /** + * Used by automation composition runtime to request for PARTICIPANT_STATUS message immediately. + */ + PARTICIPANT_STATUS_REQ +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java index af0149189..7b315dbe0 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** - * Class to represent the PARTICIPANT_REGISTER message that all the participants send to control loop runtime. + * Class to represent the PARTICIPANT_REGISTER message that all the participants send to the ACM runtime. */ @Getter @Setter diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAck.java index 28d51be93..60858be4c 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterAck.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** - * Class to represent the PARTICIPANT_REGISTER_ACK message that control loop runtime sends to registered participant. + * Class to represent the PARTICIPANT_REGISTER_ACK message that the ACM runtime sends to a registered participant. */ @Getter @Setter diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantResponseStatus.java index f014529b3..cb0307742 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantResponseStatus.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantResponseStatus.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; /** * Class to hold the possible values for participant response status. diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java index 8600b4b5b..32b95e11b 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatus.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java @@ -18,22 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; import org.onap.policy.models.base.PfUtils; /** - * Class to represent the PARTICIPANT_STATUS message that all the participants send to the control loop runtime. + * Class to represent the PARTICIPANT_STATUS message that all the participants send to the ACM runtime. */ @Getter @Setter @@ -49,8 +49,8 @@ public class ParticipantStatus extends ParticipantMessage { // A list of ParticipantDefinition updates, returned in response to ParticipantStatusReq only private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>(); - // List of ControlLoopInfo types with ControlLoopId, its state and statistics - private List<ControlLoopInfo> controlLoopInfoList = new ArrayList<>(); + // List of AutomationCompositionInfo types with AutomationCompositionId, its state and statistics + private List<AutomationCompositionInfo> automationCompositionInfoList = new ArrayList<>(); /** * Constructor for instantiating ParticipantStatus class with message name. @@ -71,8 +71,9 @@ public class ParticipantStatus extends ParticipantMessage { this.state = source.state; this.healthStatus = source.healthStatus; this.participantStatistics = (source.participantStatistics == null ? null : new ParticipantStatistics()); - this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates, - ParticipantDefinition::new); - this.controlLoopInfoList = PfUtils.mapList(source.controlLoopInfoList, ControlLoopInfo::new); + this.participantDefinitionUpdates = + PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new); + this.automationCompositionInfoList = + PfUtils.mapList(source.automationCompositionInfoList, AutomationCompositionInfo::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReq.java index 9242cea02..82260ee67 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReq.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** - * Class to represent the PARTICIPANT_STATUS_REQ message that controlloop runtime + * Class to represent the PARTICIPANT_STATUS_REQ message that the ACM runtime * sends to participants for an immediate ParticipantStatus from participants. */ @Getter diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java index 72db7d97e..36842a8cf 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdate.java @@ -19,19 +19,19 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; import org.onap.policy.models.base.PfUtils; /** - * Class to represent the PARTICIPANT_UPDATE message that the control loop runtime sends to a participant. - * ControlLoop Runtime sends Control Loop Element Definitions and Common Parameter Values to Participants. + * Class to represent the PARTICIPANT_UPDATE message that the ACM runtime sends to a participant. + * the ACM Runtime sends automation composition element Definitions and Common Parameter Values to Participants. */ @Getter @Setter diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java index d38fa4bb2..2c3a68e22 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateAck.java @@ -20,14 +20,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; import lombok.Getter; import lombok.Setter; import lombok.ToString; /** - * Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to controlloop runtime. + * Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to the ACM runtime. */ @Getter @Setter diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/GenericNameVersion.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/GenericNameVersion.java index a48af9223..3e39e970d 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/GenericNameVersion.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/GenericNameVersion.java @@ -17,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest; +package org.onap.policy.clamp.models.acm.messages.rest; import lombok.Data; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java index 2bd09c632..1668652b7 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/SimpleResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest; +package org.onap.policy.clamp.models.acm.messages.rest; import lombok.Getter; import lombok.Setter; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/TypedSimpleResponse.java index 199ac8ee1..871eb3bc2 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/TypedSimpleResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/TypedSimpleResponse.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest; +package org.onap.policy.clamp.models.acm.messages.rest; import lombok.Getter; import lombok.Setter; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/commissioning/CommissioningResponse.java index 6363db8d2..42ce79843 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/commissioning/CommissioningResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/commissioning/CommissioningResponse.java @@ -18,13 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.commissioning; +package org.onap.policy.clamp.models.acm.messages.rest.commissioning; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** @@ -34,5 +34,5 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @Setter @ToString(callSuper = true) public class CommissioningResponse extends SimpleResponse { - private List<ToscaConceptIdentifier> affectedControlLoopDefinitions; + private List<ToscaConceptIdentifier> affectedAutomationCompositionDefinitions; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopOrderStateResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionOrderStateResponse.java index dcc63a538..a87433d4c 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopOrderStateResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionOrderStateResponse.java @@ -17,16 +17,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.rest.GenericNameVersion; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.messages.rest.GenericNameVersion; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; /** @@ -35,9 +35,9 @@ import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; @Getter @Setter @ToString(callSuper = true) -public class ControlLoopOrderStateResponse extends SimpleResponse { +public class AutomationCompositionOrderStateResponse extends SimpleResponse { - private ControlLoopOrderedState orderedState = ControlLoopOrderedState.UNINITIALISED; + private AutomationCompositionOrderedState orderedState = AutomationCompositionOrderedState.UNINITIALISED; - private List<GenericNameVersion> controlLoopIdentifierList = new ArrayList<>(); + private List<GenericNameVersion> automationCompositionIdentifierList = new ArrayList<>(); } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimed.java index d6e670060..34556653b 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimed.java @@ -17,12 +17,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; import lombok.Data; @Data -public class ControlLoopPrimed { +public class AutomationCompositionPrimed { private String name; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimedResponse.java index 4d2dfaf01..fa3e8fad7 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AutomationCompositionPrimedResponse.java @@ -17,23 +17,23 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; /** - * Response to provide all primed controlLoops. + * Response to provide all primed automation compositions. */ @Getter @Setter @ToString(callSuper = true) -public class ControlLoopPrimedResponse extends SimpleResponse { +public class AutomationCompositionPrimedResponse extends SimpleResponse { - private List<ControlLoopPrimed> primedControlLoopsList = new ArrayList<>(); + private List<AutomationCompositionPrimed> primedAutomationCompositionsList = new ArrayList<>(); } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstancePropertiesResponse.java index d8974d6e3..0341d5dae 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstancePropertiesResponse.java @@ -17,14 +17,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; import java.util.ArrayList; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java index 71b7ab92c..a3fb70e15 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationCommand.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java @@ -18,18 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; import java.util.List; import lombok.Data; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @Data public class InstantiationCommand { - // The state to which the control loops are to be set - private ControlLoopOrderedState orderedState; + // The state to which the automation compositions are to be set + private AutomationCompositionOrderedState orderedState; - // The list of control loops on which the command is to be issued - private List<ToscaConceptIdentifier> controlLoopIdentifierList; + // The list of automation compositions on which the command is to be issued + private List<ToscaConceptIdentifier> automationCompositionIdentifierList; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationOrderStateResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationOrderStateResponse.java index 1ddce7840..e6bdaee9d 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationOrderStateResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationOrderStateResponse.java @@ -19,13 +19,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; /** * Response to instantiation OrderState. @@ -35,5 +35,5 @@ import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; @ToString(callSuper = true) public class InstantiationOrderStateResponse extends SimpleResponse { - private ControlLoopOrderedState orderedState; + private AutomationCompositionOrderedState orderedState; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java index d932f29ac..e7c346498 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstantiationResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java @@ -18,13 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation; +package org.onap.policy.clamp.models.acm.messages.rest.instantiation; import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** @@ -34,5 +34,5 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @Setter @ToString(callSuper = true) public class InstantiationResponse extends SimpleResponse { - private List<ToscaConceptIdentifier> affectedControlLoops; + private List<ToscaConceptIdentifier> affectedAutomationCompositions; } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatistics.java index 956f1db02..4a046052e 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAcElementStatistics.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; +package org.onap.policy.clamp.models.acm.persistence.concepts; import java.io.Serializable; import java.util.List; @@ -37,8 +37,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import org.apache.commons.lang3.builder.CompareToBuilder; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConcept; @@ -49,17 +49,17 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** - * Class to represent a controlloop element statistics in the database. + * Class to represent automation composition element statistics in the database. * * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) */ @Entity -@Table(name = "ClElementStatistics") +@Table(name = "AcElementStatistics") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @AllArgsConstructor @EqualsAndHashCode(callSuper = false) -public class JpaClElementStatistics extends PfConcept implements PfAuthorative<ClElementStatistics>, Serializable { +public class JpaAcElementStatistics extends PfConcept implements PfAuthorative<AcElementStatistics>, Serializable { private static final long serialVersionUID = 621426717868738629L; @@ -79,36 +79,36 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative<C @Column @NotNull - private ControlLoopState state; + private AutomationCompositionState state; @Column - private long clElementUptime; + private long acElementUptime; /** - * The Default Constructor creates a {@link JpaClElementStatistics} object with a null key. + * The Default Constructor creates a {@link JpaAcElementStatistics} object with a null key. */ - public JpaClElementStatistics() { + public JpaAcElementStatistics() { this(new PfReferenceTimestampKey()); } /** - * The Key Constructor creates a {@link JpaClElementStatistics} object with the given Reference Timestamp key. + * The Key Constructor creates a {@link JpaAcElementStatistics} object with the given Reference Timestamp key. * * @param key the key */ - public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key) { - this(key, new PfConceptKey(), ControlLoopState.PASSIVE, 0L); + public JpaAcElementStatistics(@NonNull final PfReferenceTimestampKey key) { + this(key, new PfConceptKey(), AutomationCompositionState.PASSIVE, 0L); } /** - * The Key Constructor creates a {@link JpaClElementStatistics} object with all mandatory fields. + * The Key Constructor creates a {@link JpaAcElementStatistics} object with all mandatory fields. * * @param key the key - * @param participantId the TOSCA definition of the control loop element + * @param participantId the TOSCA definition of the automation composition element */ - public JpaClElementStatistics(@NonNull final PfReferenceTimestampKey key, + public JpaAcElementStatistics(@NonNull final PfReferenceTimestampKey key, @NonNull final PfConceptKey participantId) { this.key = key; this.participantId = participantId; @@ -119,12 +119,12 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative<C * * @param copyConcept the concept to copy from */ - public JpaClElementStatistics(@NonNull final JpaClElementStatistics copyConcept) { + public JpaAcElementStatistics(@NonNull final JpaAcElementStatistics copyConcept) { super(copyConcept); this.key = new PfReferenceTimestampKey(copyConcept.key); this.participantId = new PfConceptKey(copyConcept.participantId); this.state = copyConcept.state; - this.clElementUptime = copyConcept.clElementUptime; + this.acElementUptime = copyConcept.acElementUptime; } @@ -133,36 +133,36 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative<C * * @param authorativeConcept the authorative concept to copy from */ - public JpaClElementStatistics(@NonNull final ClElementStatistics authorativeConcept) { + public JpaAcElementStatistics(@NonNull final AcElementStatistics authorativeConcept) { this.fromAuthorative(authorativeConcept); } @Override - public ClElementStatistics toAuthorative() { - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName())); - clElementStatistics.setTimeStamp(key.getInstant()); - clElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); - clElementStatistics.setControlLoopState(state); - clElementStatistics.setClElementUptime(clElementUptime); - - return clElementStatistics; + public AcElementStatistics toAuthorative() { + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName())); + acElementStatistics.setTimeStamp(key.getInstant()); + acElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId)); + acElementStatistics.setState(state); + acElementStatistics.setAcElementUptime(acElementUptime); + + return acElementStatistics; } @Override - public void fromAuthorative(@NonNull ClElementStatistics clElementStatistics) { + public void fromAuthorative(@NonNull AcElementStatistics acElementStatistics) { // @formatter:off if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfReferenceTimestampKey(clElementStatistics.getParticipantId().getName(), - clElementStatistics.getParticipantId().getVersion(), clElementStatistics.getId().toString(), - clElementStatistics.getTimeStamp())); + this.setKey(new PfReferenceTimestampKey(acElementStatistics.getParticipantId().getName(), + acElementStatistics.getParticipantId().getVersion(), acElementStatistics.getId().toString(), + acElementStatistics.getTimeStamp())); } // @formatter:on - this.setParticipantId(clElementStatistics.getParticipantId().asConceptKey()); - this.setState(clElementStatistics.getControlLoopState()); - this.setClElementUptime(clElementStatistics.getClElementUptime()); + this.setParticipantId(acElementStatistics.getParticipantId().asConceptKey()); + this.setState(acElementStatistics.getState()); + this.setAcElementUptime(acElementStatistics.getAcElementUptime()); } @Override @@ -189,8 +189,8 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative<C return getClass().getName().compareTo(otherConcept.getClass().getName()); } - final JpaClElementStatistics other = (JpaClElementStatistics) otherConcept; + final JpaAcElementStatistics other = (JpaAcElementStatistics) otherConcept; return new CompareToBuilder().append(this.key, other.key).append(this.state, other.state) - .append(this.clElementUptime, other.clElementUptime).toComparison(); + .append(this.acElementUptime, other.acElementUptime).toComparison(); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java index adc300607..e5c44d0a2 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; +package org.onap.policy.clamp.models.acm.persistence.concepts; import java.util.LinkedHashMap; import java.util.List; @@ -39,10 +39,10 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; import org.onap.policy.models.base.PfAuthorative; @@ -55,16 +55,16 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** - * Class to represent a control loop in the database. + * Class to represent a automation composition in the database. * * @author Liam Fallon (liam.fallon@est.tech) */ @Entity -@Table(name = "ControlLoop") +@Table(name = "AutomationComposition") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @EqualsAndHashCode(callSuper = false) -public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLoop> { +public class JpaAutomationComposition extends PfConcept implements PfAuthorative<AutomationComposition> { private static final long serialVersionUID = -4725410933242154805L; @EmbeddedId @@ -82,11 +82,11 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo @Column @NotNull - private ControlLoopState state; + private AutomationCompositionState state; @Column @NotNull - private ControlLoopOrderedState orderedState; + private AutomationCompositionOrderedState orderedState; @Column private String description; @@ -96,34 +96,36 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @NotNull - private Map<@NotNull UUID, @NotNull @Valid JpaControlLoopElement> elements; + private Map<@NotNull UUID, @NotNull @Valid JpaAutomationCompositionElement> elements; + // @formatter:on /** - * The Default Constructor creates a {@link JpaControlLoop} object with a null key. + * The Default Constructor creates a {@link JpaAutomationComposition} object with a null key. */ - public JpaControlLoop() { + public JpaAutomationComposition() { this(new PfConceptKey()); } /** - * The Key Constructor creates a {@link JpaControlLoop} object with the given concept key. + * The Key Constructor creates a {@link JpaAutomationComposition} object with the given concept key. * * @param key the key */ - public JpaControlLoop(@NonNull final PfConceptKey key) { - this(key, new PfConceptKey(), ControlLoopState.UNINITIALISED, new LinkedHashMap<>()); + public JpaAutomationComposition(@NonNull final PfConceptKey key) { + this(key, new PfConceptKey(), AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>()); } /** - * The Key Constructor creates a {@link JpaControlLoop} object with all mandatory fields. + * The Key Constructor creates a {@link JpaAutomationComposition} object with all mandatory fields. * * @param key the key - * @param definition the TOSCA definition of the control loop - * @param state the state of the control loop - * @param elements the elements of the control looop in participants + * @param definition the TOSCA definition of the automation composition + * @param state the state of the automation composition + * @param elements the elements of the automation composition in participants */ - public JpaControlLoop(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, - @NonNull final ControlLoopState state, @NonNull final Map<UUID, JpaControlLoopElement> elements) { + public JpaAutomationComposition(@NonNull final PfConceptKey key, @NonNull final PfConceptKey definition, + @NonNull final AutomationCompositionState state, + @NonNull final Map<UUID, JpaAutomationCompositionElement> elements) { this.key = key; this.definition = definition; this.state = state; @@ -135,14 +137,15 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo * * @param copyConcept the concept to copy from */ - public JpaControlLoop(@NonNull final JpaControlLoop copyConcept) { + public JpaAutomationComposition(@NonNull final JpaAutomationComposition copyConcept) { super(copyConcept); this.key = new PfConceptKey(copyConcept.key); this.definition = new PfConceptKey(copyConcept.definition); this.state = copyConcept.state; this.orderedState = copyConcept.orderedState; this.description = copyConcept.description; - this.elements = PfUtils.mapMap(copyConcept.elements, JpaControlLoopElement::new, new LinkedHashMap<>(0)); + this.elements = + PfUtils.mapMap(copyConcept.elements, JpaAutomationCompositionElement::new, new LinkedHashMap<>(0)); this.primed = copyConcept.primed; } @@ -151,44 +154,46 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo * * @param authorativeConcept the authorative concept to copy from */ - public JpaControlLoop(@NonNull final ControlLoop authorativeConcept) { + public JpaAutomationComposition(@NonNull final AutomationComposition authorativeConcept) { this.fromAuthorative(authorativeConcept); } @Override - public ControlLoop toAuthorative() { - var controlLoop = new ControlLoop(); - - controlLoop.setName(getKey().getName()); - controlLoop.setVersion(getKey().getVersion()); - controlLoop.setDefinition(new ToscaConceptIdentifier(definition)); - controlLoop.setState(state); - controlLoop.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); - controlLoop.setDescription(description); - controlLoop.setElements(PfUtils.mapMap(elements, JpaControlLoopElement::toAuthorative, new LinkedHashMap<>(0))); - controlLoop.setPrimed(primed); - - return controlLoop; + public AutomationComposition toAuthorative() { + var automationComposition = new AutomationComposition(); + + automationComposition.setName(getKey().getName()); + automationComposition.setVersion(getKey().getVersion()); + automationComposition.setDefinition(new ToscaConceptIdentifier(definition)); + automationComposition.setState(state); + automationComposition.setOrderedState(orderedState != null ? orderedState : state.asOrderedState()); + automationComposition.setDescription(description); + automationComposition.setElements( + PfUtils.mapMap(elements, JpaAutomationCompositionElement::toAuthorative, new LinkedHashMap<>(0))); + automationComposition.setPrimed(primed); + + return automationComposition; } @Override - public void fromAuthorative(@NonNull final ControlLoop controlLoop) { + public void fromAuthorative(@NonNull final AutomationComposition automationComposition) { if (this.key == null || this.getKey().isNullKey()) { - this.setKey(new PfConceptKey(controlLoop.getName(), controlLoop.getVersion())); + this.setKey(new PfConceptKey(automationComposition.getName(), automationComposition.getVersion())); } - this.definition = controlLoop.getDefinition().asConceptKey(); - this.state = controlLoop.getState(); - this.orderedState = controlLoop.getOrderedState(); - this.description = controlLoop.getDescription(); - this.primed = controlLoop.getPrimed(); - - this.elements = new LinkedHashMap<>(controlLoop.getElements().size()); - for (Entry<UUID, ControlLoopElement> elementEntry : controlLoop.getElements().entrySet()) { - var jpaControlLoopElement = new JpaControlLoopElement(); - jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString())); - jpaControlLoopElement.fromAuthorative(elementEntry.getValue()); - this.elements.put(elementEntry.getKey(), jpaControlLoopElement); + this.definition = automationComposition.getDefinition().asConceptKey(); + this.state = automationComposition.getState(); + this.orderedState = automationComposition.getOrderedState(); + this.description = automationComposition.getDescription(); + this.primed = automationComposition.getPrimed(); + + this.elements = new LinkedHashMap<>(automationComposition.getElements().size()); + for (Entry<UUID, AutomationCompositionElement> elementEntry : automationComposition.getElements().entrySet()) { + var jpaAutomationCompositionElement = new JpaAutomationCompositionElement(); + jpaAutomationCompositionElement + .setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString())); + jpaAutomationCompositionElement.fromAuthorative(elementEntry.getValue()); + this.elements.put(elementEntry.getKey(), jpaAutomationCompositionElement); } } @@ -198,7 +203,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo keyList.add(definition); - for (JpaControlLoopElement element : elements.values()) { + for (JpaAutomationCompositionElement element : elements.values()) { keyList.addAll(element.getKeys()); } @@ -211,7 +216,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo definition.clean(); description = (description == null ? null : description.trim()); - for (JpaControlLoopElement element : elements.values()) { + for (JpaAutomationCompositionElement element : elements.values()) { element.clean(); } } @@ -228,7 +233,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo return this.getClass().getName().compareTo(otherConcept.getClass().getName()); } - final JpaControlLoop other = (JpaControlLoop) otherConcept; + final JpaAutomationComposition other = (JpaAutomationComposition) otherConcept; int result = key.compareTo(other.key); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java index 22773e064..08d8ee06b 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; +package org.onap.policy.clamp.models.acm.persistence.concepts; import java.util.List; import java.util.UUID; @@ -35,9 +35,9 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConcept; @@ -48,16 +48,16 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** - * Class to represent a participant control loop element in the database. + * Class to represent a participant automation composition element in the database. * * @author Liam Fallon (liam.fallon@est.tech) */ @Entity -@Table(name = "ControlLoopElement") +@Table(name = "AutomationCompositionElement") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @EqualsAndHashCode(callSuper = false) -public class JpaControlLoopElement extends PfConcept implements PfAuthorative<ControlLoopElement> { +public class JpaAutomationCompositionElement extends PfConcept implements PfAuthorative<AutomationCompositionElement> { private static final long serialVersionUID = -1791732273187890213L; @EmbeddedId @@ -86,41 +86,41 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co @Column @NotNull - private ControlLoopState state; + private AutomationCompositionState state; @Column @NotNull - private ControlLoopOrderedState orderedState; + private AutomationCompositionOrderedState orderedState; @Column private String description; /** - * The Default Constructor creates a {@link JpaControlLoopElement} object with a null key. + * The Default Constructor creates a {@link JpaAutomationCompositionElement} object with a null key. */ - public JpaControlLoopElement() { + public JpaAutomationCompositionElement() { this(new PfReferenceKey()); } /** - * The Key Constructor creates a {@link JpaControlLoopElement} object with the given concept key. + * The Key Constructor creates a {@link JpaAutomationCompositionElement} object with the given concept key. * * @param key the key */ - public JpaControlLoopElement(@NonNull final PfReferenceKey key) { - this(key, new PfConceptKey(), new PfConceptKey(), ControlLoopState.UNINITIALISED); + public JpaAutomationCompositionElement(@NonNull final PfReferenceKey key) { + this(key, new PfConceptKey(), new PfConceptKey(), AutomationCompositionState.UNINITIALISED); } /** - * The Key Constructor creates a {@link JpaControlLoopElement} object with all mandatory fields. + * The Key Constructor creates a {@link JpaAutomationCompositionElement} object with all mandatory fields. * * @param key the key - * @param definition the TOSCA definition of the control loop element - * @param participantType the TOSCA definition of the participant running the control loop element - * @param state the state of the control loop + * @param definition the TOSCA definition of the automation composition element + * @param participantType the TOSCA definition of the participant running the automation composition element + * @param state the state of the automation composition */ - public JpaControlLoopElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition, - @NonNull final PfConceptKey participantType, @NonNull final ControlLoopState state) { + public JpaAutomationCompositionElement(@NonNull final PfReferenceKey key, @NonNull final PfConceptKey definition, + @NonNull final PfConceptKey participantType, @NonNull final AutomationCompositionState state) { this.key = key; this.definition = definition; this.participantType = participantType; @@ -132,7 +132,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co * * @param copyConcept the concept to copy from */ - public JpaControlLoopElement(@NonNull final JpaControlLoopElement copyConcept) { + public JpaAutomationCompositionElement(@NonNull final JpaAutomationCompositionElement copyConcept) { super(copyConcept); this.key = new PfReferenceKey(copyConcept.key); this.definition = new PfConceptKey(copyConcept.definition); @@ -148,13 +148,13 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co * * @param authorativeConcept the authorative concept to copy from */ - public JpaControlLoopElement(@NonNull final ControlLoopElement authorativeConcept) { + public JpaAutomationCompositionElement(@NonNull final AutomationCompositionElement authorativeConcept) { this.fromAuthorative(authorativeConcept); } @Override - public ControlLoopElement toAuthorative() { - var element = new ControlLoopElement(); + public AutomationCompositionElement toAuthorative() { + var element = new AutomationCompositionElement(); element.setId(UUID.fromString(getKey().getLocalName())); element.setDefinition(new ToscaConceptIdentifier(definition)); @@ -168,7 +168,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co } @Override - public void fromAuthorative(@NonNull final ControlLoopElement element) { + public void fromAuthorative(@NonNull final AutomationCompositionElement element) { if (this.key == null || this.getKey().isNullKey()) { this.setKey(new PfReferenceKey()); getKey().setLocalName(element.getId().toString()); @@ -217,7 +217,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co return this.getClass().getName().compareTo(otherConcept.getClass().getName()); } - final JpaControlLoopElement other = (JpaControlLoopElement) otherConcept; + final JpaAutomationCompositionElement other = (JpaAutomationCompositionElement) otherConcept; int result = key.compareTo(other.key); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java index c8c26a8de..143499c0d 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; +package org.onap.policy.clamp.models.acm.persistence.concepts; import java.io.Serializable; import java.util.List; @@ -33,9 +33,9 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConcept; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatistics.java index 2e5188abe..a076433bb 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantStatistics.java @@ -21,7 +21,7 @@ */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts; +package org.onap.policy.clamp.models.acm.persistence.concepts; import java.io.Serializable; import java.util.List; @@ -37,9 +37,9 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import org.apache.commons.lang3.builder.CompareToBuilder; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.models.acm.concepts.ParticipantState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConcept; @@ -50,7 +50,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** - * Class to represent a control loop statistics in the database. + * Class to represent a participant statistics in the database. * * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) */ @@ -124,7 +124,7 @@ public class JpaParticipantStatistics extends PfConcept implements PfAuthorative * The Key Constructor creates a {@link JpaParticipantStatistics} object with all mandatory fields. * * @param key the key - * @param participantId the TOSCA definition of the control loop participant + * @param participantId the TOSCA definition of the participant */ public JpaParticipantStatistics(@NonNull final PfTimestampKey key, @NonNull final PfConceptKey participantId) { this.key = key; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProvider.java index 3a7fa9c87..59ddcc2ea 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcElementStatisticsProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; +package org.onap.policy.clamp.models.acm.persistence.provider; import java.time.Instant; import java.util.List; @@ -27,9 +27,9 @@ import java.util.stream.Collectors; import javax.ws.rs.core.Response.Status; import lombok.AllArgsConstructor; import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ClElementStatisticsRepository; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAcElementStatistics; +import org.onap.policy.clamp.models.acm.persistence.repository.AcElementStatisticsRepository; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfReferenceTimestampKey; import org.onap.policy.models.dao.PfFilterParameters; @@ -37,87 +37,89 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /** - * This class provides the provision of information on control loop element statistics in the database to callers. + * This class provides the provision of information on automation composition element statistics in the database to + * callers. * * @author Ramesh Murugan Iyer (ramesh.murugan.iyer@est.tech) */ @Service @Transactional @AllArgsConstructor -public class ClElementStatisticsProvider { +public class AcElementStatisticsProvider { - private ClElementStatisticsRepository clElementStatisticsRepository; + private AcElementStatisticsRepository acElementStatisticsRepository; /** - * Creates control loop element statistics. + * Creates automation composition element statistics. * - * @param clElementStatisticsList a specification of the CL element statistics to create - * @return the clElement statistics created + * @param acElementStatisticsList a specification of the statistics to create + * @return the Element statistics created * @throws PfModelException on initiation errors */ - public List<ClElementStatistics> createClElementStatistics( - @NonNull final List<ClElementStatistics> clElementStatisticsList) throws PfModelException { + public List<AcElementStatistics> createAcElementStatistics( + @NonNull final List<AcElementStatistics> acElementStatisticsList) throws PfModelException { try { - var jpaClElementStatisticsList = ProviderUtils.getJpaAndValidateList(clElementStatisticsList, - JpaClElementStatistics::new, "control loop element statistics"); + var jpaAcElementStatisticsList = ProviderUtils.getJpaAndValidateList(acElementStatisticsList, + JpaAcElementStatistics::new, "automation composition element statistics"); - var jpaClElementStatisticsSaved = clElementStatisticsRepository.saveAll(jpaClElementStatisticsList); + var jpaAcElementStatisticsSaved = acElementStatisticsRepository.saveAll(jpaAcElementStatisticsList); - // Return the saved control loop element statistics - return asClElementStatisticsList(jpaClElementStatisticsSaved); + // Return the saved automation composition element statistics + return asAcElementStatisticsList(jpaAcElementStatisticsSaved); } catch (IllegalArgumentException e) { - throw new PfModelException(Status.BAD_REQUEST, "Error in save control loop element statistics", e); + throw new PfModelException(Status.BAD_REQUEST, "Error in save automation composition element statistics", + e); } } /** - * Convert JPA clElement statistics list to clElement statistics list. + * Convert JPA acElement statistics list to acElement statistics list. * - * @param jpaClElementStatistics the list to convert - * @return the clElement statistics list + * @param jpaAcElementStatistics the list to convert + * @return the acElement statistics list */ - private List<ClElementStatistics> asClElementStatisticsList(List<JpaClElementStatistics> jpaClElementStatistics) { - return jpaClElementStatistics.stream().map(JpaClElementStatistics::toAuthorative).collect(Collectors.toList()); + private List<AcElementStatistics> asAcElementStatisticsList(List<JpaAcElementStatistics> jpaAcElementStatistics) { + return jpaAcElementStatistics.stream().map(JpaAcElementStatistics::toAuthorative).collect(Collectors.toList()); } /** - * Get clElement statistics. + * Get acElement statistics. * * @param name the name of the participant * @param version version of the participant - * @param id of the control loop element + * @param id of the automation composition element * @param timestamp timestamp of the statistics - * @return the clElement statistics found + * @return the acElement statistics found */ @Transactional(readOnly = true) - public List<ClElementStatistics> getClElementStatistics(final String name, final String version, final String id, - final Instant timestamp) { + public List<AcElementStatistics> getAcElementStatistics(final String name, final String version, final String id, + final Instant timestamp) { if (name != null && version != null && timestamp != null && id != null) { - return asClElementStatisticsList(clElementStatisticsRepository - .findAllById(List.of(new PfReferenceTimestampKey(name, version, id, timestamp)))); + return asAcElementStatisticsList(acElementStatisticsRepository + .findAllById(List.of(new PfReferenceTimestampKey(name, version, id, timestamp)))); } else if (name != null) { - return getFilteredClElementStatistics(name, version, null, null, null, "DESC", 0); + return getFilteredAcElementStatistics(name, version, null, null, null, "DESC", 0); } - return asClElementStatisticsList(clElementStatisticsRepository.findAll()); + return asAcElementStatisticsList(acElementStatisticsRepository.findAll()); } /** - * Get filtered clElement statistics. + * Get filtered acElement statistics. * - * @param name the clElement name for the statistics to get - * @param version the clElement version for the statistics to get + * @param name the acElement name for the statistics to get + * @param version the acElement version for the statistics to get * @param startTimeStamp startTimeStamp to filter statistics * @param endTimeStamp endTimeStamp to filter statistics * @param sortOrder sortOrder to query database * @param getRecordNum Total query count from database * @param filterMap the filters to apply to the get operation - * @return the clElement statistics found + * @return the acElement statistics found */ @Transactional(readOnly = true) - public List<ClElementStatistics> getFilteredClElementStatistics(final String name, final String version, - final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap, - final String sortOrder, final int getRecordNum) { + public List<AcElementStatistics> getFilteredAcElementStatistics(final String name, final String version, + final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap, final String sortOrder, + final int getRecordNum) { // @formatter:off PfFilterParameters filterParams = PfFilterParameters @@ -131,7 +133,7 @@ public class ClElementStatisticsProvider { .recordNum(getRecordNum) .build(); // @formatter:on - return asClElementStatisticsList( - clElementStatisticsRepository.getFiltered(JpaClElementStatistics.class, filterParams)); + return asAcElementStatisticsList( + acElementStatisticsRepository.getFiltered(JpaAcElementStatistics.class, filterParams)); } } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java new file mode 100644 index 000000000..760613026 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java @@ -0,0 +1,287 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.persistence.provider; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import javax.persistence.EntityNotFoundException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import lombok.AllArgsConstructor; +import lombok.NonNull; +import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; +import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplateRepository; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplatesRepository; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; +import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + * This class provides information on automation composition concepts in the database to callers. + */ +@Service +@Transactional +@AllArgsConstructor +public class AutomationCompositionProvider { + + private final AutomationCompositionRepository automationCompositionRepository; + private final ToscaNodeTemplateRepository toscaNodeTemplateRepository; + private final ToscaNodeTemplatesRepository toscaNodeTemplatesRepository; + + /** + * Get automation composition. + * + * @param automationCompositionId the ID of the automation composition to get + * @return the automation composition found + * @throws PfModelException on errors getting the automation composition + */ + @Transactional(readOnly = true) + public AutomationComposition getAutomationComposition(final ToscaConceptIdentifier automationCompositionId) + throws PfModelException { + try { + return automationCompositionRepository.getById(automationCompositionId.asConceptKey()).toAuthorative(); + } catch (EntityNotFoundException e) { + throw new PfModelException(Status.NOT_FOUND, "AutomationComposition not found", e); + } + } + + /** + * Find automation composition by automationCompositionId. + * + * @param name the name of the automation composition to get, null to get all automation compositions + * @param version the version of the automation composition to get, null to get all automation compositions + * @return the automation composition found + * @throws PfModelException on errors getting the automation composition + */ + @Transactional(readOnly = true) + public Optional<AutomationComposition> findAutomationComposition(@NonNull final String name, + @NonNull final String version) throws PfModelException { + return findAutomationComposition(new PfConceptKey(name, version)); + } + + /** + * Find automation composition by automationCompositionId. + * + * @param automationCompositionId the ID of the automation composition to get + * @return the automation composition found + * @throws PfModelException on errors getting the automation composition + */ + @Transactional(readOnly = true) + public Optional<AutomationComposition> findAutomationComposition( + final ToscaConceptIdentifier automationCompositionId) throws PfModelException { + return findAutomationComposition(automationCompositionId.asConceptKey()); + } + + private Optional<AutomationComposition> findAutomationComposition(@NonNull final PfConceptKey key) + throws PfModelException { + try { + return automationCompositionRepository.findById(key).map(JpaAutomationComposition::toAuthorative); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Not valid parameter", e); + } + } + + /** + * Save automation composition. + * + * @param automationComposition the automation composition to update + * @return the updated automation composition + * @throws PfModelException on errors updating the automation composition + */ + public AutomationComposition saveAutomationComposition(final AutomationComposition automationComposition) + throws PfModelException { + try { + var result = automationCompositionRepository.save(ProviderUtils.getJpaAndValidate(automationComposition, + JpaAutomationComposition::new, "automation composition")); + + // Return the saved participant + return result.toAuthorative(); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save automationComposition", e); + } + } + + /** + * Get all automation compositions. + * + * @return all automation compositions found + * @throws PfModelException on errors getting automation compositions + */ + @Transactional(readOnly = true) + public List<AutomationComposition> getAutomationCompositions() throws PfModelException { + + return ProviderUtils.asEntityList(automationCompositionRepository.findAll()); + } + + /** + * Get automation compositions. + * + * @param name the name of the automation composition to get, null to get all automation compositions + * @param version the version of the automation composition to get, null to get all automation compositions + * @return the automation compositions found + * @throws PfModelException on errors getting automation compositions + */ + @Transactional(readOnly = true) + public List<AutomationComposition> getAutomationCompositions(final String name, final String version) + throws PfModelException { + + return ProviderUtils + .asEntityList(automationCompositionRepository.getFiltered(JpaAutomationComposition.class, name, version)); + } + + /** + * Saves automation compositions. + * + * @param automationCompositions a specification of the automation compositions to create + * @return the automation compositions created + * @throws PfModelException on errors creating automation compositions + */ + public List<AutomationComposition> saveAutomationCompositions( + @NonNull final List<AutomationComposition> automationCompositions) throws PfModelException { + try { + var result = + automationCompositionRepository.saveAll(ProviderUtils.getJpaAndValidateList(automationCompositions, + JpaAutomationComposition::new, "automation compositions")); + + // Return the saved participant + return ProviderUtils.asEntityList(result); + } catch (IllegalArgumentException e) { + throw new PfModelException(Status.BAD_REQUEST, "Error in save AutomationCompositions", e); + } + } + + /** + * Saves Instance Properties to the database. + * + * @param serviceTemplate the service template + * @return a Map of tosca node templates + */ + public Map<String, ToscaNodeTemplate> saveInstanceProperties(ToscaServiceTemplate serviceTemplate) { + Map<String, ToscaNodeTemplate> savedNodeTemplates = new HashMap<>(); + + var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); + jpaToscaNodeTemplates.fromAuthorative(List.of(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates())); + + toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); + serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach(savedNodeTemplates::put); + + return savedNodeTemplates; + } + + /** + * Delete a automation composition. + * + * @param name the name of the automation composition to delete + * @param version the version of the automation composition to delete + * @return the automation composition deleted + * @throws PfModelException on errors deleting the automation composition + */ + public AutomationComposition deleteAutomationComposition(@NonNull final String name, @NonNull final String version) + throws PfModelException { + + var automationCompositionKey = new PfConceptKey(name, version); + var jpaDeleteAutomationComposition = automationCompositionRepository.findById(automationCompositionKey); + + if (jpaDeleteAutomationComposition.isEmpty()) { + String errorMessage = "delete of automation composition \"" + automationCompositionKey.getId() + + "\" failed, automation composition does not exist"; + throw new PfModelException(Response.Status.BAD_REQUEST, errorMessage); + } + + automationCompositionRepository.deleteById(automationCompositionKey); + + return jpaDeleteAutomationComposition.get().toAuthorative(); + } + + /** + * Deletes Instance Properties on the database. + * + * @param filteredToscaNodeTemplateMap filtered node templates map to delete + * @param filteredToscaNodeTemplateList filtered node template list to delete + */ + public void deleteInstanceProperties(Map<String, ToscaNodeTemplate> filteredToscaNodeTemplateMap, + List<ToscaNodeTemplate> filteredToscaNodeTemplateList) { + + var jpaToscaNodeTemplates = new JpaToscaNodeTemplates(); + jpaToscaNodeTemplates.fromAuthorative(List.of(filteredToscaNodeTemplateMap)); + + toscaNodeTemplatesRepository.save(jpaToscaNodeTemplates); + + filteredToscaNodeTemplateList.forEach(template -> { + var jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template); + + toscaNodeTemplateRepository.delete(jpaToscaNodeTemplate); + }); + } + + /** + * Get All Node Templates. + * + * @return the list of node templates found + * @throws PfModelException on errors getting node templates + */ + @Transactional(readOnly = true) + public List<ToscaNodeTemplate> getAllNodeTemplates() { + return ProviderUtils.asEntityList(toscaNodeTemplateRepository.findAll()); + } + + /** + * Get Node Templates. + * + * @param name the name of the node template to get, null to get all node templates + * @param version the version of the node template to get, null to get all node templates + * @return the node templates found + * @throws PfModelException on errors getting node templates + */ + @Transactional(readOnly = true) + public List<ToscaNodeTemplate> getNodeTemplates(final String name, final String version) { + return ProviderUtils + .asEntityList(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version)); + } + + /** + * Get filtered node templates. + * + * @param filter the filter for the node templates to get + * @return the node templates found + * @throws PfModelException on errors getting node templates + */ + @Transactional(readOnly = true) + public List<ToscaNodeTemplate> getFilteredNodeTemplates( + @NonNull final ToscaTypedEntityFilter<ToscaNodeTemplate> filter) { + + return filter.filter(ProviderUtils.asEntityList(toscaNodeTemplateRepository + .getFiltered(JpaToscaNodeTemplate.class, filter.getName(), filter.getVersion()))); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java index 0c001c11c..1f9e07f8e 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProvider.java @@ -18,16 +18,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; +package org.onap.policy.clamp.models.acm.persistence.provider; import java.util.List; import java.util.Optional; import javax.ws.rs.core.Response.Status; import lombok.AllArgsConstructor; import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantRepository; +import org.onap.policy.clamp.models.acm.concepts.Participant; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant; +import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantRepository; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProvider.java index bb4f3a5dd..a5a0ce176 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantStatisticsProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; +package org.onap.policy.clamp.models.acm.persistence.provider; import java.time.Instant; import java.util.List; @@ -27,9 +27,9 @@ import java.util.stream.Collectors; import javax.ws.rs.core.Response.Status; import lombok.AllArgsConstructor; import lombok.NonNull; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ParticipantStatisticsRepository; +import org.onap.policy.clamp.models.acm.concepts.ParticipantStatistics; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics; +import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantStatisticsRepository; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfTimestampKey; import org.onap.policy.models.dao.PfFilterParameters; @@ -103,7 +103,7 @@ public class ParticipantStatisticsProvider { /** * Creates Participant statistics. * - * @param participantStatisticsList a specification of the CL statistics to create + * @param participantStatisticsList a specification of the statistics to create * @return the participant statistics created * @throws PfModelException on errors creating participant statistics */ diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java index 3b0400b4f..9510e5919 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ProviderUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; +package org.onap.policy.clamp.models.acm.persistence.provider; import java.util.ArrayList; import java.util.List; @@ -80,7 +80,7 @@ public final class ProviderUtils { } /** - * Convert JPA control loop list to an authorative control loop list. + * Convert JPA automation composition list to an authorative automation composition list. * * @param <T> the type of TOSCA entity * @param <J> the type of JPA TOSCA entity diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java index 8ff0dd102..0de5f480a 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider; +package org.onap.policy.clamp.models.acm.persistence.provider; import java.util.HashMap; import java.util.List; @@ -26,7 +26,7 @@ import java.util.Map; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import lombok.RequiredArgsConstructor; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository.ToscaServiceTemplateRepository; +import org.onap.policy.clamp.models.acm.persistence.repository.ToscaServiceTemplateRepository; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; @@ -83,19 +83,19 @@ public class ServiceTemplateProvider { } /** - * Get the requested control loop definitions. + * Get the requested automation composition definitions. * * @param name the name of the definition to get, null for all definitions * @param version the version of the definition to get, null for all definitions - * @return the control loop definitions - * @throws PfModelException on errors getting control loop definitions + * @return the automation composition definitions + * @throws PfModelException on errors getting automation composition definitions */ @Transactional(readOnly = true) public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException { var serviceTemplateKey = new PfConceptKey(name, version); var jpaServiceTemplates = serviceTemplateRepository.findById(serviceTemplateKey); if (jpaServiceTemplates.isEmpty()) { - throw new PfModelException(Status.NOT_FOUND, "Control Loop definitions not found"); + throw new PfModelException(Status.NOT_FOUND, "Automation composition definitions not found"); } return jpaServiceTemplates.get().toAuthorative(); } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ClElementStatisticsRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AcElementStatisticsRepository.java index 1e07a4fe6..13001114f 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ClElementStatisticsRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AcElementStatisticsRepository.java @@ -18,15 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAcElementStatistics; import org.onap.policy.models.base.PfReferenceTimestampKey; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface ClElementStatisticsRepository - extends JpaRepository<JpaClElementStatistics, PfReferenceTimestampKey>, FilterRepository { +public interface AcElementStatisticsRepository + extends JpaRepository<JpaAcElementStatistics, PfReferenceTimestampKey>, FilterRepository { } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java index 1a5fd5a56..8eeb77e0d 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ControlLoopRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; import org.onap.policy.models.base.PfConceptKey; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface ControlLoopRepository extends JpaRepository<JpaControlLoop, PfConceptKey>, FilterRepository { - +public interface AutomationCompositionRepository + extends JpaRepository<JpaAutomationComposition, PfConceptKey>, FilterRepository { } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java index ce1f3d8c3..cdedc5eb5 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepository.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; import java.util.List; import org.onap.policy.models.base.PfConcept; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImpl.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java index 0dc8fc373..d7e81d4da 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/FilterRepositoryImpl.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/FilterRepositoryImpl.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; import java.util.List; import javax.persistence.EntityManager; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java index 671d23bbe..2279a75cc 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantRepository.java @@ -18,9 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant; import org.onap.policy.models.base.PfConceptKey; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantStatisticsRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantStatisticsRepository.java index 6fecd6143..9cba62a70 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ParticipantStatisticsRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ParticipantStatisticsRepository.java @@ -18,9 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; -import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics; +import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantStatistics; import org.onap.policy.models.base.PfTimestampKey; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplateRepository.java index a8f830fed..20d0f0f7e 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplateRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplateRepository.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java index 7bd7d1013..f0ab40bf7 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaNodeTemplatesRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaNodeTemplatesRepository.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaServiceTemplateRepository.java index a5d5fe766..b9190d0a7 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/repository/ToscaServiceTemplateRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/ToscaServiceTemplateRepository.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.controlloop.persistence.repository; +package org.onap.policy.clamp.models.acm.persistence.repository; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/rest/RestUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/rest/RestUtils.java index 6c12c2de7..ac19d2a27 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/rest/RestUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/rest/RestUtils.java @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.models.rest; +package org.onap.policy.clamp.models.acm.rest; import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; +import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse; import org.onap.policy.models.errors.concepts.ErrorResponseInfo; import org.springframework.http.ResponseEntity; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java new file mode 100644 index 000000000..394579aa6 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.utils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; +import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; + +/** + * Utility functions used in acm-runtime and participants. + * + */ +public class AcmUtils { + + private AcmUtils() { + throw new IllegalStateException("Utility class"); + } + + /** + * Prepare participant updates map. + * + * @param acElement automation composition element + * @param participantUpdates list of participantUpdates + */ + public static void prepareParticipantUpdate(AutomationCompositionElement acElement, + List<ParticipantUpdates> participantUpdates) { + if (participantUpdates.isEmpty()) { + participantUpdates.add(getAutomationCompositionElementList(acElement)); + return; + } + + var participantExists = false; + for (ParticipantUpdates participantUpdate : participantUpdates) { + if (participantUpdate.getParticipantId().equals(acElement.getParticipantId())) { + participantUpdate.setAutomationCompositionElementList(List.of(acElement)); + participantExists = true; + } + } + if (!participantExists) { + participantUpdates.add(getAutomationCompositionElementList(acElement)); + } + } + + private static ParticipantUpdates getAutomationCompositionElementList(AutomationCompositionElement acElement) { + var participantUpdate = new ParticipantUpdates(); + participantUpdate.setParticipantId(acElement.getParticipantId()); + participantUpdate.setAutomationCompositionElementList(List.of(acElement)); + return participantUpdate; + } + + /** + * Set the Policy information in the service template for the automation composition element. + * + * @param acElement automation composition element + * @param toscaServiceTemplate ToscaServiceTemplate + */ + public static void setServiceTemplatePolicyInfo(AutomationCompositionElement acElement, + ToscaServiceTemplate toscaServiceTemplate) { + // Pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment + if (toscaServiceTemplate.getPolicyTypes() == null + && toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() == null) { + return; + } + ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate(); + toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes()); + ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate(); + toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()); + toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate); + toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes()); + acElement.setToscaServiceTemplateFragment(toscaServiceTemplateFragment); + } + + /** + * Prepare ParticipantDefinitionUpdate to set in the message. + * + * @param acParticipantType participant type + * @param entryKey key for the entry + * @param entryValue value relates to toscaNodeTemplate + * @param participantDefinitionUpdates list of participantDefinitionUpdates + * @param commonPropertiesMap common properties map + */ + public static void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier acParticipantType, String entryKey, + ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates, + Map<String, ToscaNodeType> commonPropertiesMap) { + + var acDefinition = new AutomationCompositionElementDefinition(); + acDefinition.setAcElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion())); + acDefinition.setAutomationCompositionElementToscaNodeTemplate(entryValue); + if (commonPropertiesMap != null) { + ToscaNodeType nodeType = commonPropertiesMap.get(entryValue.getType()); + if (nodeType != null) { + acDefinition.setCommonPropertiesMap(nodeType.getProperties()); + } + } + + List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList = new ArrayList<>(); + + if (participantDefinitionUpdates.isEmpty()) { + participantDefinitionUpdates.add( + getParticipantDefinition(acDefinition, acParticipantType, automationCompositionElementDefinitionList)); + } else { + var participantExists = false; + for (ParticipantDefinition participantDefinitionUpdate : participantDefinitionUpdates) { + if (participantDefinitionUpdate.getParticipantType().equals(acParticipantType)) { + participantDefinitionUpdate.getAutomationCompositionElementDefinitionList().add(acDefinition); + participantExists = true; + } + } + if (!participantExists) { + participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantType, + automationCompositionElementDefinitionList)); + } + } + } + + private static ParticipantDefinition getParticipantDefinition(AutomationCompositionElementDefinition acDefinition, + ToscaConceptIdentifier acParticipantType, + List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList) { + var participantDefinition = new ParticipantDefinition(); + participantDefinition.setParticipantType(acParticipantType); + automationCompositionElementDefinitionList.add(acDefinition); + participantDefinition.setAutomationCompositionElementDefinitionList(automationCompositionElementDefinitionList); + return participantDefinition; + } +} |