From f9455834e7e014fed6e941184ab80eb9fe91d89f Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 4 Jan 2021 13:55:46 +0000 Subject: Changed identifiers to concept identifiers The policy models tosca classes ToscaPolicyIdentifier and ToscaPolicyIdentifierOptVersion can be used to identify any TOSCA concept, not just TOSCA policies so they are renamed to ToscaConceptIdentifier and ToscaCinceptIdentifierOptVersion respectively. The class ToscaPolicyTypeIdentifier is redundant and is replaced by ToscaConceptIdentifier. Issue-ID: POLICY-2900 Change-Id: I5df89d023949cdf0f649951dbbd81a0b30f44ef6 Signed-off-by: liamfallon --- .../apex/service/engine/main/ApexActivator.java | 20 ++++++++++---------- .../policy/apex/service/engine/main/ApexMain.java | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'services/services-engine/src/main') diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java index 4d3349b83..cadcc7ee8 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -50,7 +50,7 @@ import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParame import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; import org.onap.policy.common.parameters.ParameterService; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -69,10 +69,10 @@ public class ApexActivator { // The parameters of the Apex activator when running with multiple policies @Getter @Setter - private Map apexParametersMap; + private Map apexParametersMap; @Getter - Map policyModelsMap; + Map policyModelsMap; // Event unmarshalers are used to receive events asynchronously into Apex private final Map unmarshallerMap = new LinkedHashMap<>(); @@ -95,7 +95,7 @@ public class ApexActivator { * * @param parametersMap the apex parameters map for the Apex service */ - public ApexActivator(Map parametersMap) { + public ApexActivator(Map parametersMap) { apexParametersMap = parametersMap; } @@ -128,7 +128,7 @@ public class ApexActivator { policyModelsMap = new LinkedHashMap<>(); Map inputParametersMap = new LinkedHashMap<>(); Map outputParametersMap = new LinkedHashMap<>(); - Set> apexParamsEntrySet = new LinkedHashSet<>( + Set> apexParamsEntrySet = new LinkedHashSet<>( apexParametersMap.entrySet()); apexParamsEntrySet.stream().forEach(apexParamsEntry -> { ApexParameters apexParams = apexParamsEntry.getValue(); @@ -175,12 +175,12 @@ public class ApexActivator { startUnmarshallers(inputParametersMap); } - private AxPolicyModel aggregatePolicyModels(Map policyModelsMap) { + private AxPolicyModel aggregatePolicyModels(Map policyModelsMap) { // Doing a deep copy so that original values in policyModelsMap is retained // after reduction operation - Set> policyModelsEntries = policyModelsMap.entrySet().stream() + Set> policyModelsEntries = policyModelsMap.entrySet().stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), entry.getValue())).collect(Collectors.toSet()); - Optional> finalPolicyModelEntry = policyModelsEntries.stream() + Optional> finalPolicyModelEntry = policyModelsEntries.stream() .reduce((entry1, entry2) -> { try { entry1.setValue( @@ -303,7 +303,7 @@ public class ApexActivator { * @param apexParamsMap the apex parameters map for the Apex service * @throws ApexException on errors */ - public void updateModel(Map apexParamsMap) throws ApexException { + public void updateModel(Map apexParamsMap) throws ApexException { try { ApexParameters apexParameters = apexParamsMap.values().iterator().next(); setUpModelMarshallerAndUnmarshaller(apexParameters); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java index 459cdff24..5707c95ad 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modification Copyright (C) 2019-2020 Nordix Foundation. + * Modification Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,7 +43,7 @@ import org.onap.policy.apex.service.parameters.ApexParameterHandler; import org.onap.policy.apex.service.parameters.ApexParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.common.parameters.ParameterService; -import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -62,7 +62,7 @@ public class ApexMain { // The parameters read in from JSON for each policy @Getter - private Map apexParametersMap; + private Map apexParametersMap; //engineParameters are aggregated in case of multiple policies private EngineParameters aggregatedEngineParameters; @@ -83,7 +83,7 @@ public class ApexMain { apexParametersMap = new LinkedHashMap<>(); aggregatedEngineParameters = new EngineParameters(); try { - apexParametersMap.put(new ToscaPolicyIdentifier(), populateApexParameters(args)); + apexParametersMap.put(new ToscaConceptIdentifier(), populateApexParameters(args)); } catch (ApexException e) { LOGGER.error(APEX_SERVICE_FAILED_MSG, e); return; @@ -112,10 +112,10 @@ public class ApexMain { * @param policyArgumentsMap the map with command line arguments as value and policy-id as key * @throws ApexException on errors */ - public ApexMain(Map policyArgumentsMap) throws ApexException { + public ApexMain(Map policyArgumentsMap) throws ApexException { apexParametersMap = new LinkedHashMap<>(); aggregatedEngineParameters = new EngineParameters(); - for (Entry policyArgsEntry: policyArgumentsMap.entrySet()) { + for (Entry policyArgsEntry: policyArgumentsMap.entrySet()) { try { apexParametersMap.put(policyArgsEntry.getKey(), populateApexParameters(policyArgsEntry.getValue())); } catch (ApexException e) { @@ -157,14 +157,14 @@ public class ApexMain { * @param policyArgsMap the map with command line arguments as value and policy-id as key * @throws ApexException on errors */ - public void updateModel(Map policyArgsMap) throws ApexException { + public void updateModel(Map policyArgsMap) throws ApexException { // flag that determines if any policy received in PDP_UPDATE is already deployed in the engine boolean isAnyPolicyDeployed = policyArgsMap.keySet().stream().anyMatch(apexParametersMap::containsKey); apexParametersMap.clear(); aggregatedEngineParameters = new EngineParameters(); AxContextAlbums albums = ModelService.getModel(AxContextAlbums.class); Map albumsMap = new TreeMap<>(); - for (Entry policyArgsEntry : policyArgsMap.entrySet()) { + for (Entry policyArgsEntry : policyArgsMap.entrySet()) { findAlbumsToHold(albumsMap, policyArgsEntry.getKey()); try { apexParametersMap.put(policyArgsEntry.getKey(), populateApexParameters(policyArgsEntry.getValue())); @@ -207,8 +207,8 @@ public class ApexMain { * @param albumsMap the albums which should be kept during model update * @param policyId the policy id of current policy */ - private void findAlbumsToHold(Map albumsMap, ToscaPolicyIdentifier policyId) { - for (Entry policyModelsEntry : activator.getPolicyModelsMap() + private void findAlbumsToHold(Map albumsMap, ToscaConceptIdentifier policyId) { + for (Entry policyModelsEntry : activator.getPolicyModelsMap() .entrySet()) { // If a policy with the same major version is received in PDP_UPDATE, // context for that policy has to be retained. For this, take such policies' albums -- cgit 1.2.3-korg