summaryrefslogtreecommitdiffstats
path: root/models-dao/src/main/java
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-dao/src/main/java
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-dao/src/main/java')
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java11
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java22
2 files changed, 32 insertions, 1 deletions
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
index 062ec4662..6c862bb64 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -230,6 +231,16 @@ public interface PfDao {
<T extends PfConcept> List<T> getAllVersions(Class<T> someClass, final String name);
/**
+ * Get all the objects in the database of a given type.
+ *
+ * @param <T> the type of the objects to get, a subclass of {@link PfConcept}
+ * @param someClass the class of the objects to get, a subclass of {@link PfConcept}
+ * @param parentKeyName the name of the concepts for which to get all versions
+ * @return the objects or null if no objects were retrieved
+ */
+ <T extends PfConcept> List<T> getAllVersionsByParent(Class<T> someClass, final String parentKeyName);
+
+ /**
* Get a concept from the database with the given concept key.
*
* @param <T> the type of the object to get, a subclass of {@link PfConcept}
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
index ad9ef1215..b7dda8dbb 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. 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.
@@ -91,6 +91,9 @@ public class DefaultPfDao implements PfDao {
private static final String SELECT_ALL_FOR_PARENT =
SELECT_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER;
+ private static final String SELECT_ALL_VERSIONS_FOR_PARENT =
+ SELECT_FROM_TABLE + WHERE + PARENT_NAME_FILTER;
+
private static final String SELECT_ALL_VERSIONS = SELECT_FROM_TABLE + WHERE + NAME_FILTER;
private static final String SELECT_BY_CONCEPT_KEY =
@@ -470,6 +473,23 @@ public class DefaultPfDao implements PfDao {
}
@Override
+ public <T extends PfConcept> List<T> getAllVersionsByParent(final Class<T> someClass, final String parentKeyName) {
+ if (someClass == null || parentKeyName == null) {
+ return Collections.emptyList();
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ // @formatter:off
+ return mg.createQuery(setQueryTable(SELECT_ALL_VERSIONS_FOR_PARENT, someClass), someClass)
+ .setParameter(PARENT_NAME, parentKeyName)
+ .getResultList();
+ // @formatter:on
+ } finally {
+ mg.close();
+ }
+ }
+
+ @Override
public <T extends PfConcept> List<T> getAllVersions(final Class<T> someClass, final String conceptName) {
if (someClass == null || conceptName == null) {
return Collections.emptyList();