aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models-pdp/src/main')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
index ed3551a9e..7d59166e2 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
@@ -46,6 +46,7 @@ import org.onap.policy.models.pdp.persistence.concepts.JpaPdp;
import org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup;
import org.onap.policy.models.pdp.persistence.concepts.JpaPdpPolicyStatus;
import org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
/**
* This class provides the provision of information on PAP concepts in the database to callers.
@@ -255,6 +256,40 @@ public class PdpProvider {
}
/**
+ * Gets all policy deployments.
+ *
+ * @param dao the DAO to use to access the database
+ * @return the deployments found
+ * @throws PfModelException on errors getting PDP groups
+ */
+ public List<PdpPolicyStatus> getAllPolicyStatus(@NonNull final PfDao dao)
+ throws PfModelException {
+
+ return dao.getAll(JpaPdpPolicyStatus.class).stream().map(JpaPdpPolicyStatus::toAuthorative)
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Gets all deployments for a policy.
+ *
+ * @param dao the DAO to use to access the database
+ * @return the deployments found
+ * @throws PfModelException on errors getting PDP groups
+ */
+ public List<PdpPolicyStatus> getAllPolicyStatus(@NonNull final PfDao dao,
+ @NonNull ToscaConceptIdentifierOptVersion policy) throws PfModelException {
+
+ if (policy.getVersion() != null) {
+ return dao.getAll(JpaPdpPolicyStatus.class, new PfConceptKey(policy.getName(), policy.getVersion()))
+ .stream().map(JpaPdpPolicyStatus::toAuthorative).collect(Collectors.toList());
+
+ } else {
+ return dao.getAllVersionsByParent(JpaPdpPolicyStatus.class, policy.getName()).stream()
+ .map(JpaPdpPolicyStatus::toAuthorative).collect(Collectors.toList());
+ }
+ }
+
+ /**
* Gets the policy deployments for a PDP group.
*
* @param dao the DAO to use to access the database