aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-01-12 11:52:29 -0500
committerJim Hahn <jrh3@att.com>2021-01-12 12:38:15 -0500
commit9a67d321484b935eaf63e55373088fa64b0ffd76 (patch)
tree334576ddb1d7a736996bd325cf4102fe2215d79c /models-pdp/src/main
parente926efbc4d5dde8ade1a5521f5be1294079df057 (diff)
Add more methods to query deployment status
Issue-ID: POLICY-2648 Change-Id: I398fa1332eb5a862dabd97ed409ef6413bb0c202 Signed-off-by: Jim Hahn <jrh3@att.com>
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