From 9a67d321484b935eaf63e55373088fa64b0ffd76 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 12 Jan 2021 11:52:29 -0500 Subject: Add more methods to query deployment status Issue-ID: POLICY-2648 Change-Id: I398fa1332eb5a862dabd97ed409ef6413bb0c202 Signed-off-by: Jim Hahn --- .../pdp/persistence/provider/PdpProvider.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'models-pdp/src/main') 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. @@ -254,6 +255,40 @@ public class PdpProvider { // Not implemented yet } + /** + * 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 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 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. * -- cgit 1.2.3-korg