summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-01-04 13:36:34 +0000
committerliamfallon <liam.fallon@est.tech>2021-01-04 16:11:39 +0000
commit20379d580cd91dfb5d7d945dc46a627445c87aa6 (patch)
treefef024b432eb251dc25e9526bf7119917b0078fd /main
parent24220a823f9b5516a3bed1c1e8cf51f36ea75efe (diff)
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: I9ba3deae8eb4a8e51df5a40cdb8be8d9d23c5990 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java21
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java9
2 files changed, 14 insertions, 16 deletions
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java
index 03f46b9e..cb20c04c 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/provider/CommonModelProvider.java
@@ -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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,8 +41,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;
/**
* Super class for providers that use a model provider.
@@ -131,8 +130,8 @@ public class CommonModelProvider implements AutoCloseable {
*/
private List<PdpGroup> getPolicyTypeFilteredPdpGroups(PfConceptKey policyType) throws PfModelException {
- List<ToscaPolicyTypeIdentifier> policyTypes = new ArrayList<>();
- policyTypes.add(new ToscaPolicyTypeIdentifier(policyType.getName(), policyType.getVersion()));
+ List<ToscaConceptIdentifier> policyTypes = new ArrayList<>();
+ policyTypes.add(new ToscaConceptIdentifier(policyType.getName(), policyType.getVersion()));
PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder().policyTypeList(policyTypes).groupState(PdpState.ACTIVE)
.pdpState(PdpState.ACTIVE).build();
return modelsProvider.getFilteredPdpGroups(pdpGroupFilter);
@@ -158,7 +157,7 @@ public class CommonModelProvider implements AutoCloseable {
Map<Pair<String, String>, T> deployedPolicyMap = new HashMap<>();
for (PdpGroup pdpGroup : pdpGroups) {
- List<ToscaPolicyIdentifier> policyIdentifiers = extractPolicyIdentifiers(policyId, pdpGroup, policyType);
+ List<ToscaConceptIdentifier> policyIdentifiers = extractPolicyIdentifiers(policyId, pdpGroup, policyType);
T deployedPolicies = getDeployedPolicies(policyIdentifiers, policyType, getter, consumer, data);
deployedPolicyMap.put(Pair.of(pdpGroup.getName(), pdpGroup.getVersion()), deployedPolicies);
}
@@ -176,12 +175,12 @@ public class CommonModelProvider implements AutoCloseable {
*
* @throws PfModelException the PfModel parsing exception
*/
- private List<ToscaPolicyIdentifier> extractPolicyIdentifiers(String policyId, PdpGroup pdpGroup,
+ private List<ToscaConceptIdentifier> extractPolicyIdentifiers(String policyId, PdpGroup pdpGroup,
PfConceptKey policyType) throws PfModelException {
- List<ToscaPolicyIdentifier> policyIdentifiers = new ArrayList<>();
+ List<ToscaConceptIdentifier> policyIdentifiers = new ArrayList<>();
for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) {
- for (ToscaPolicyIdentifier policyIdentifier : pdpSubGroup.getPolicies()) {
+ for (ToscaConceptIdentifier policyIdentifier : pdpSubGroup.getPolicies()) {
if (policyId.equalsIgnoreCase(policyIdentifier.getName())) {
policyIdentifiers.add(policyIdentifier);
}
@@ -207,10 +206,10 @@ public class CommonModelProvider implements AutoCloseable {
*
* @throws PfModelException the PfModel parsing exception
*/
- private <T, R> T getDeployedPolicies(List<ToscaPolicyIdentifier> policyIdentifiers, PfConceptKey policyType,
+ private <T, R> T getDeployedPolicies(List<ToscaConceptIdentifier> policyIdentifiers, PfConceptKey policyType,
BiFunctionWithEx<String, String, R> getter, BiConsumer<T, R> consumer, T data) throws PfModelException {
- for (ToscaPolicyIdentifier policyIdentifier : policyIdentifiers) {
+ for (ToscaConceptIdentifier policyIdentifier : policyIdentifiers) {
R result = getter.apply(policyIdentifier.getName(),
getTrimedVersionForLegacyType(policyIdentifier.getVersion(), policyType));
consumer.accept(data, result);
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
index e71cfc54..e0f3375f 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -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());