From c71863696d729286502f951a64c3d2193c6641e7 Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Mon, 19 Dec 2022 14:43:11 +0000 Subject: Add compositionId into Messages between ACM and Participants Issue-ID: POLICY-4489 Change-Id: I1fb8c04eacee040d5c944c522ca59a2a9a50376b Signed-off-by: FrancescoFioraEst --- .../AutomationCompositionElementDefinition.java | 10 -- .../participant/AutomationCompositionUpdate.java | 4 +- .../dmaap/participant/ParticipantMessage.java | 3 + .../policy/clamp/models/acm/utils/AcmUtils.java | 115 +-------------------- 4 files changed, 6 insertions(+), 126 deletions(-) (limited to 'models/src/main/java/org/onap') diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java index aebee0e2c..cba6a93bd 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementDefinition.java @@ -20,17 +20,12 @@ package org.onap.policy.clamp.models.acm.concepts; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.function.UnaryOperator; import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; -import org.onap.policy.models.base.PfUtils; 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.ToscaProperty; /** * Class to represent an automation composition element definition instance. @@ -46,10 +41,6 @@ public class AutomationCompositionElementDefinition { // 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. - private Map commonPropertiesMap = new LinkedHashMap<>(); - /** * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. * @@ -59,6 +50,5 @@ public class AutomationCompositionElementDefinition { 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/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java index 55fcc7462..6bc79f67e 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.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. @@ -58,7 +58,7 @@ public class AutomationCompositionUpdate extends ParticipantMessage { */ public AutomationCompositionUpdate(AutomationCompositionUpdate source) { super(source); - + this.startPhase = source.startPhase; this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, ParticipantUpdates::new); } } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java index ae6dce515..c1ef4b416 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java @@ -62,6 +62,8 @@ public class ParticipantMessage { */ private UUID automationCompositionId; + private UUID compositionId; + /** * Constructor for instantiating a participant message class. * @@ -81,6 +83,7 @@ public class ParticipantMessage { this.participantType = source.participantType; this.participantId = source.participantId; this.automationCompositionId = source.automationCompositionId; + this.compositionId = source.compositionId; } /** 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 index cdd3e1e54..220a3c132 100644 --- 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 @@ -22,7 +22,6 @@ package org.onap.policy.clamp.models.acm.utils; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -41,11 +40,8 @@ import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.parameters.ValidationStatus; -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.ToscaNodeType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; @@ -120,21 +116,13 @@ public final class AcmUtils { * @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 participantDefinitionUpdates, - Map commonPropertiesMap) { + ToscaNodeTemplate entryValue, List participantDefinitionUpdates) { 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 automationCompositionElementDefinitionList = new ArrayList<>(); @@ -252,105 +240,4 @@ public final class AcmUtils { .collect(Collectors.toList()); // @formatter:on } - - /** - * Get the initial node types with common or instance properties. - * - * @param fullNodeTypes map of all the node types in the specified template - * @param common boolean to indicate whether common or instance properties are required - * @return node types map that only has common properties - */ - private static Map getInitialNodeTypesMap(Map fullNodeTypes, - boolean common) { - - var tempNodeTypesMap = new HashMap(); - - fullNodeTypes.forEach((key, nodeType) -> { - var tempToscaNodeType = new ToscaNodeType(); - tempToscaNodeType.setName(key); - - var resultantPropertyMap = findCommonOrInstancePropsInNodeTypes(nodeType, common); - - if (!resultantPropertyMap.isEmpty()) { - tempToscaNodeType.setProperties(resultantPropertyMap); - tempNodeTypesMap.put(key, tempToscaNodeType); - } - }); - return tempNodeTypesMap; - } - - private static Map findCommonOrInstancePropsInNodeTypes(ToscaNodeType nodeType, - boolean common) { - - var tempCommonPropertyMap = new HashMap(); - var tempInstancePropertyMap = new HashMap(); - - nodeType.getProperties().forEach((propKey, prop) -> { - - if (prop.getMetadata() != null) { - prop.getMetadata().forEach((k, v) -> { - if (k.equals("common") && v.equals("true") && common) { - tempCommonPropertyMap.put(propKey, prop); - } else if (k.equals("common") && v.equals("false") && !common) { - tempInstancePropertyMap.put(propKey, prop); - } - - }); - } else { - tempInstancePropertyMap.put(propKey, prop); - } - }); - - if (tempCommonPropertyMap.isEmpty() && !common) { - return tempInstancePropertyMap; - } else { - return tempCommonPropertyMap; - } - } - - /** - * Get the node types derived from those that have common properties. - * - * @param initialNodeTypes map of all the node types in the specified template - * @param filteredNodeTypes map of all the node types that have common or instance properties - * @return all node types that have common properties including their children - * @throws PfModelException on errors getting node type with common properties - */ - private static Map getFinalNodeTypesMap(Map initialNodeTypes, - Map filteredNodeTypes) { - for (var i = 0; i < initialNodeTypes.size(); i++) { - initialNodeTypes.forEach((key, nodeType) -> { - var tempToscaNodeType = new ToscaNodeType(); - tempToscaNodeType.setName(key); - - if (filteredNodeTypes.get(nodeType.getDerivedFrom()) != null) { - tempToscaNodeType.setName(key); - - var finalProps = new HashMap( - filteredNodeTypes.get(nodeType.getDerivedFrom()).getProperties()); - - tempToscaNodeType.setProperties(finalProps); - } else { - return; - } - filteredNodeTypes.putIfAbsent(key, tempToscaNodeType); - - }); - } - return filteredNodeTypes; - } - - /** - * Get the requested node types with common or instance properties. - * - * @param common boolean indicating common or instance properties - * @param serviceTemplate the ToscaServiceTemplate - * @return the node types with common or instance properties - */ - public static Map getCommonOrInstancePropertiesFromNodeTypes(boolean common, - ToscaServiceTemplate serviceTemplate) { - var tempNodeTypesMap = getInitialNodeTypesMap(serviceTemplate.getNodeTypes(), common); - - return getFinalNodeTypesMap(serviceTemplate.getNodeTypes(), tempNodeTypesMap); - } } -- cgit 1.2.3-korg