summaryrefslogtreecommitdiffstats
path: root/models-dao/src/main/java
diff options
context:
space:
mode:
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();