aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-04 15:54:23 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-04 15:54:23 +0000
commit325646aaa6c064fefe2a8a33a86db4b1f15f8983 (patch)
treefca5f6fa496906bb677d0eaee92bc9508306da98 /models-pdp/src/main
parenta2ec30735da8be9228c4360489660f17030dcb07 (diff)
parentfc297c8a98df155971e2fa485c7724a61b70c69c (diff)
Merge "Add filter obejcts for concepts"
Diffstat (limited to 'models-pdp/src/main')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java30
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java1
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java46
3 files changed, 46 insertions, 31 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
new file mode 100644
index 000000000..f06a34dbb
--- /dev/null
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.pdp.concepts;
+
+/**
+ * Filter class for searches for {@link PdpGroup} instances.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class PdpGroupFilter {
+
+}
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
index 7020b4596..2a9343902 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
@@ -60,7 +60,6 @@ import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifier;
import org.onap.policy.models.pdp.concepts.ToscaPolicyTypeIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Class to represent a PDP subgroup in the database.
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 20553d788..a1eb97dd0 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
@@ -21,15 +21,12 @@
package org.onap.policy.models.pdp.persistence.provider;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
-import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
@@ -38,12 +35,12 @@ import org.onap.policy.models.base.PfValidationResult;
import org.onap.policy.models.dao.PfDao;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
+import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
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.JpaPdpSubGroup;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,7 +67,7 @@ public class PdpProvider {
public List<PdpGroup> getPdpGroups(@NonNull final PfDao dao, final String name, final String version)
throws PfModelException {
- List<JpaPdpGroup> foundPdpGroups = dao.getFiltered(JpaPdpGroup.class, new PfConceptKey(name, version));
+ List<JpaPdpGroup> foundPdpGroups = dao.getFiltered(JpaPdpGroup.class, name, version);
if (foundPdpGroups != null) {
return asPdpGroupList(foundPdpGroups);
@@ -90,29 +87,31 @@ public class PdpProvider {
* @throws PfModelException on errors getting policies
*/
public List<PdpGroup> getLatestPdpGroups(@NonNull final PfDao dao, final String name) throws PfModelException {
- List<JpaPdpGroup> returnList = new ArrayList<>();
+ List<JpaPdpGroup> jpaPdpGroupList = new ArrayList<>();
if (name == null) {
- returnList.add(dao.getLatestVersion(JpaPdpGroup.class, name));
- }
- else {
- returnList.addAll(dao.getLatestVersions(JpaPdpGroup.class));
+ jpaPdpGroupList.addAll(dao.getAll(JpaPdpGroup.class));
+ } else {
+ jpaPdpGroupList.addAll(dao.getAllVersions(JpaPdpGroup.class, name));
}
- return asPdpGroupList(returnList);
+ return asPdpGroupList(jpaPdpGroupList);
}
/**
- * Get a filtered list of PDP groups, returns only active PDP groups.
+ * Get filtered PDP groups.
*
* @param dao the DAO to use to access the database
- * @param pdpType The PDP type filter for the returned PDP groups, null to get policy types across PDP subgroups
- * @param supportedPolicyTypes a list of policy type name/version pairs that the PDP groups must support.
+ * @param filter the filter for the PDP groups to get
* @return the PDP groups found
+ * @throws PfModelException on errors getting policies
*/
- public List<PdpGroup> getFilteredPdpGroups(@NonNull final PfDao dao, final String pdpType,
- @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
- return new ArrayList<>();
+ public List<PdpGroup> getFilteredPdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroupFilter filter)
+ throws PfModelException {
+
+ List<JpaPdpGroup> jpaPdpGroupList = dao.getAll(JpaPdpGroup.class);
+
+ return asPdpGroupList(jpaPdpGroupList);
}
/**
@@ -308,19 +307,6 @@ public class PdpProvider {
}
/**
- * Get deployed policies.
- *
- * @param dao the DAO to use to access the database
- * @param name the name of the policy to get deployed policies for, null to get all deployed policies
- * @return the policies deployed as a map of policy lists keyed by PDP group name and version
- * @throws PfModelException on errors getting policies
- */
- public Map<Pair<String, String>, List<ToscaPolicy>> getDeployedPolicyList(@NonNull final PfDao dao,
- final String name) throws PfModelException {
- return new LinkedHashMap<>();
- }
-
- /**
* Convert JPA PDP group list to an authorative PDP group list.
*
* @param foundPdpGroups the list to convert