Move PAP database provider to spring boot default
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / rest / PolicyUndeployerImpl.java
index 1e7c788..004d4ad 100644 (file)
@@ -2,8 +2,9 @@
  * ============LICENSE_START=======================================================
  * ONAP PAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021-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.
@@ -35,21 +36,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
 import org.onap.policy.pap.main.comm.PolicyUndeployer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
 /**
  * Implementation of policy undeployer.
  */
+@Component
 public class PolicyUndeployerImpl extends ProviderBase implements PolicyUndeployer {
     private static final Logger logger = LoggerFactory.getLogger(PolicyUndeployerImpl.class);
 
-
-    /**
-     * Constructs the object.
-     */
-    public PolicyUndeployerImpl() {
-        super();
-    }
-
     @Override
     public void undeploy(String group, String subgroup, Collection<ToscaConceptIdentifier> policies)
                     throws PfModelException {
@@ -81,7 +76,7 @@ public class PolicyUndeployerImpl extends ProviderBase implements PolicyUndeploy
         PdpSubGroup subgroup = optsub.get();
 
         // remove the policies
-        boolean updated = false;
+        var updated = false;
         Set<String> pdps = subgroup.getPdpInstances().stream().map(Pdp::getInstanceId).collect(Collectors.toSet());
 
         for (ToscaConceptIdentifier ident : policyInfo.policies) {
@@ -93,7 +88,7 @@ public class PolicyUndeployerImpl extends ProviderBase implements PolicyUndeploy
                     subgroup.getPdpType(), subgroup.getPolicies().size());
 
             updated = true;
-            data.trackUndeploy(ident, pdps);
+            data.trackUndeploy(ident, pdps, policyInfo.group, policyInfo.subgroup);
         }
 
         // push the updates