Changed identifiers to concept identifiers 67/116567/1
authorliamfallon <liam.fallon@est.tech>
Mon, 4 Jan 2021 13:36:34 +0000 (13:36 +0000)
committerliamfallon <liam.fallon@est.tech>
Mon, 4 Jan 2021 16:11:39 +0000 (16:11 +0000)
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: I9ba3deae8eb4a8e51df5a40cdb8be8d9d23c5990
Signed-off-by: liamfallon <liam.fallon@est.tech>
main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java
main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java

index 03f46b9..cb20c04 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy API\r
  * ================================================================================\r
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.\r
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.\r
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -41,8 +41,7 @@ import org.onap.policy.models.pdp.enums.PdpState;
 import org.onap.policy.models.provider.PolicyModelsProvider;\r
 import org.onap.policy.models.provider.PolicyModelsProviderFactory;\r
 import org.onap.policy.models.provider.PolicyModelsProviderParameters;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;\r
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;\r
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;\r
 \r
 /**\r
  * Super class for providers that use a model provider.\r
@@ -131,8 +130,8 @@ public class CommonModelProvider implements AutoCloseable {
      */\r
     private List<PdpGroup> getPolicyTypeFilteredPdpGroups(PfConceptKey policyType) throws PfModelException {\r
 \r
-        List<ToscaPolicyTypeIdentifier> policyTypes = new ArrayList<>();\r
-        policyTypes.add(new ToscaPolicyTypeIdentifier(policyType.getName(), policyType.getVersion()));\r
+        List<ToscaConceptIdentifier> policyTypes = new ArrayList<>();\r
+        policyTypes.add(new ToscaConceptIdentifier(policyType.getName(), policyType.getVersion()));\r
         PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder().policyTypeList(policyTypes).groupState(PdpState.ACTIVE)\r
                 .pdpState(PdpState.ACTIVE).build();\r
         return modelsProvider.getFilteredPdpGroups(pdpGroupFilter);\r
@@ -158,7 +157,7 @@ public class CommonModelProvider implements AutoCloseable {
 \r
         Map<Pair<String, String>, T> deployedPolicyMap = new HashMap<>();\r
         for (PdpGroup pdpGroup : pdpGroups) {\r
-            List<ToscaPolicyIdentifier> policyIdentifiers = extractPolicyIdentifiers(policyId, pdpGroup, policyType);\r
+            List<ToscaConceptIdentifier> policyIdentifiers = extractPolicyIdentifiers(policyId, pdpGroup, policyType);\r
             T deployedPolicies = getDeployedPolicies(policyIdentifiers, policyType, getter, consumer, data);\r
             deployedPolicyMap.put(Pair.of(pdpGroup.getName(), pdpGroup.getVersion()), deployedPolicies);\r
         }\r
@@ -176,12 +175,12 @@ public class CommonModelProvider implements AutoCloseable {
      *\r
      * @throws PfModelException the PfModel parsing exception\r
      */\r
-    private List<ToscaPolicyIdentifier> extractPolicyIdentifiers(String policyId, PdpGroup pdpGroup,\r
+    private List<ToscaConceptIdentifier> extractPolicyIdentifiers(String policyId, PdpGroup pdpGroup,\r
             PfConceptKey policyType) throws PfModelException {\r
 \r
-        List<ToscaPolicyIdentifier> policyIdentifiers = new ArrayList<>();\r
+        List<ToscaConceptIdentifier> policyIdentifiers = new ArrayList<>();\r
         for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) {\r
-            for (ToscaPolicyIdentifier policyIdentifier : pdpSubGroup.getPolicies()) {\r
+            for (ToscaConceptIdentifier policyIdentifier : pdpSubGroup.getPolicies()) {\r
                 if (policyId.equalsIgnoreCase(policyIdentifier.getName())) {\r
                     policyIdentifiers.add(policyIdentifier);\r
                 }\r
@@ -207,10 +206,10 @@ public class CommonModelProvider implements AutoCloseable {
      *\r
      * @throws PfModelException the PfModel parsing exception\r
      */\r
-    private <T, R> T getDeployedPolicies(List<ToscaPolicyIdentifier> policyIdentifiers, PfConceptKey policyType,\r
+    private <T, R> T getDeployedPolicies(List<ToscaConceptIdentifier> policyIdentifiers, PfConceptKey policyType,\r
             BiFunctionWithEx<String, String, R> getter, BiConsumer<T, R> consumer, T data) throws PfModelException {\r
 \r
-        for (ToscaPolicyIdentifier policyIdentifier : policyIdentifiers) {\r
+        for (ToscaConceptIdentifier policyIdentifier : policyIdentifiers) {\r
             R result = getter.apply(policyIdentifier.getName(),\r
                     getTrimedVersionForLegacyType(policyIdentifier.getVersion(), policyType));\r
             consumer.accept(data, result);\r
index e71cfc5..e0f3375 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy API
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
  * Modifications Copyright (C) 2020 Bell Canada.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,8 +54,7 @@ import org.onap.policy.models.pdp.enums.PdpState;
 import org.onap.policy.models.provider.PolicyModelsProvider;
 import org.onap.policy.models.provider.PolicyModelsProviderFactory;
 import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 /**
@@ -180,7 +179,7 @@ public class TestPolicyProvider {
             pdpSubGroup.setPdpType("type");
             pdpSubGroup.setDesiredInstanceCount(123);
             pdpSubGroup.setSupportedPolicyTypes(new ArrayList<>());
-            pdpSubGroup.getSupportedPolicyTypes().add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion));
+            pdpSubGroup.getSupportedPolicyTypes().add(new ToscaConceptIdentifier(policyTypeId, policyTypeVersion));
             pdpGroup.getPdpSubgroups().add(pdpSubGroup);
 
             Pdp pdp = new Pdp();
@@ -215,7 +214,7 @@ public class TestPolicyProvider {
 
             // Update pdpSubGroup
             pdpSubGroup.setPolicies(new ArrayList<>());
-            pdpSubGroup.getPolicies().add(new ToscaPolicyIdentifier(policyId, policyVersion));
+            pdpSubGroup.getPolicies().add(new ToscaConceptIdentifier(policyId, policyVersion));
             assertEquals(1,
                     databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getPolicies().size());