Move PAP database provider to spring boot default
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / notification / DeploymentStatus.java
index 087383f..20e5933 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. 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.
@@ -32,13 +33,12 @@ import java.util.function.BiPredicate;
 import java.util.stream.Collectors;
 import lombok.AccessLevel;
 import lombok.Getter;
-import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.pap.concepts.PolicyNotification;
 import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
 import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State;
-import org.onap.policy.models.provider.PolicyModelsProvider;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 import org.onap.policy.pap.main.notification.StatusAction.Action;
+import org.onap.policy.pap.main.service.PolicyStatusService;
 
 /**
  * Collection of Policy Deployment Status records. The sequence of method invocations
@@ -70,16 +70,16 @@ public class DeploymentStatus {
      */
     private DeploymentTracker tracker = new DeploymentTracker();
 
-    private PolicyModelsProvider provider;
+    private PolicyStatusService policyStatusService;
 
 
     /**
      * Constructs the object.
      *
-     * @param provider the provider to use to access the DB
+     * @param policyStatusService the policyStatusService
      */
-    public DeploymentStatus(PolicyModelsProvider provider) {
-        this.provider = provider;
+    public DeploymentStatus(PolicyStatusService policyStatusService) {
+        this.policyStatusService = policyStatusService;
     }
 
     /**
@@ -100,16 +100,15 @@ public class DeploymentStatus {
      * Loads policy deployment status associated with the given PDP group.
      *
      * @param pdpGroup group whose records are to be loaded
-     * @throws PfModelException if an error occurs
      */
-    public void loadByGroup(String pdpGroup) throws PfModelException {
+    public void loadByGroup(String pdpGroup) {
         if (pdpGroupLoaded.contains(pdpGroup)) {
             return;
         }
 
         pdpGroupLoaded.add(pdpGroup);
 
-        for (PdpPolicyStatus status : provider.getGroupPolicyStatus(pdpGroup)) {
+        for (PdpPolicyStatus status : policyStatusService.getGroupPolicyStatus(pdpGroup)) {
             var status2 = new StatusAction(Action.UNCHANGED, status);
             recordMap.put(new StatusKey(status), status2);
             tracker.add(status2);
@@ -153,7 +152,7 @@ public class DeploymentStatus {
             }
         }
 
-        provider.cudPolicyStatus(created, updated, deleted);
+        policyStatusService.cudPolicyStatus(created, updated, deleted);
 
         /*
          * update the records to indicate everything is now unchanged (i.e., matches what