summaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models-pdp/src/main')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java45
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java15
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java35
3 files changed, 36 insertions, 59 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java
index 53bf3c1c6..3c1aec258 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java
@@ -1,7 +1,7 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,36 +32,28 @@ import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.models.base.PfKey;
import org.onap.policy.models.base.PfNameVersion;
import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.pdp.enums.PdpState;
/**
- * Class to represent a PDPGroup, which groups multiple PDPSubGroup entities together for
- * a particular domain.
+ * Class to represent a PDPGroup, which groups multiple PDPSubGroup entities together for a particular domain.
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
@Data
@NoArgsConstructor
public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
- /**
- * In the future, we'll eliminate the "version" field. Until then, the version of
- * every group should always be this fixed value.
- */
- public static final String VERSION = "1.0.0";
-
private String name;
- private String version;
private String description;
private PdpState pdpGroupState;
private Map<String, String> properties;
private List<PdpSubGroup> pdpSubgroups;
/*
- * Note: removed "@NotNull" annotation from the constructor argument, because it
- * cannot be covered by a junit test, as the superclass does the check and throws an
- * exception first.
+ * Note: removed "@NotNull" annotation from the constructor argument, because it cannot be covered by a junit test,
+ * as the superclass does the check and throws an exception first.
*/
/**
@@ -71,7 +63,6 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
*/
public PdpGroup(PdpGroup source) {
this.name = source.name;
- this.version = source.version;
this.description = source.description;
this.pdpGroupState = source.pdpGroupState;
this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties));
@@ -84,8 +75,7 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
}
/**
- * Validates that appropriate fields are populated for an incoming call to the PAP
- * REST API.
+ * Validates that appropriate fields are populated for an incoming call to the PAP REST API.
*
* @return the validation result
*/
@@ -93,8 +83,7 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
BeanValidationResult result = new BeanValidationResult("group", this);
/*
- * Don't care about version or state, because we override them. Ok if description
- * is null.
+ * Don't care about version or state, because we override them. Ok if description is null.
*/
result.validateNotNull("name", name);
@@ -118,19 +107,27 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
Set<String> set = new HashSet<>();
for (PdpSubGroup subgrp : pdpSubgroups) {
- if (subgrp == null) {
- continue;
- }
+ String pdpType = (subgrp == null ? null : subgrp.getPdpType());
- String pdpType = subgrp.getPdpType();
if (pdpType == null) {
continue;
}
if (!set.add(pdpType)) {
result.addResult(new ObjectValidationResult("subgroups", pdpType, ValidationStatus.INVALID,
- "duplicate subgroup"));
+ "duplicate subgroup"));
}
}
}
+
+ @Override
+ public String getVersion() {
+ // We need to pass a version for keying in the database
+ return PfKey.NULL_KEY_VERSION;
+ }
+
+ @Override
+ public void setVersion(String version) {
+ // Just ignore any version that is set
+ }
}
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
index 0f86c6890..d67f2d4cb 100644
--- 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
@@ -41,14 +41,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
@Builder
@Data
public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
- public static final String LATEST_VERSION = "LATEST";
-
// Name to find
private String name;
- // Version to find, set to LATEST_VERSION to get the latest version
- private String version;
-
// State to find
private PdpState groupState;
@@ -76,10 +71,8 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
public List<PdpGroup> filter(@NonNull final List<PdpGroup> originalList) {
// @formatter:off
- List<PdpGroup> returnList = originalList.stream()
+ return originalList.stream()
.filter(p -> filterString(p.getName(), name))
- .filter(p -> LATEST_VERSION.equals(version)
- || filterString(p.getVersion(), version))
.filter(p -> groupState == null || ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0)
.filter(p -> filterOnPdpType(p, pdpType))
.filter(p -> filterOnPolicyTypeList(p, policyTypeList, matchPolicyTypesExactly))
@@ -87,12 +80,6 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
.filter(p -> filterOnPdpState(p, pdpState))
.collect(Collectors.toList());
// @formatter:on
-
- if (LATEST_VERSION.equals(version)) {
- returnList = this.latestVersionFilter(returnList);
- }
-
- return returnList;
}
/**
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 bfdeda984..0a0f5f7ef 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
@@ -28,6 +28,7 @@ import javax.ws.rs.core.Response;
import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.base.PfReferenceKey;
@@ -60,14 +61,12 @@ public class PdpProvider {
*
* @param dao the DAO to use to access the database
* @param name the name of the PDP group to get, null to get all PDP groups
- * @param version the version of the policy to get, null to get all versions of a PDP group
* @return the PDP groups found
* @throws PfModelException on errors getting PDP groups
*/
- public List<PdpGroup> getPdpGroups(@NonNull final PfDao dao, final String name, final String version)
- throws PfModelException {
+ public List<PdpGroup> getPdpGroups(@NonNull final PfDao dao, final String name) throws PfModelException {
- return asPdpGroupList(dao.getFiltered(JpaPdpGroup.class, name, version));
+ return asPdpGroupList(dao.getFiltered(JpaPdpGroup.class, name, PfKey.NULL_KEY_VERSION));
}
/**
@@ -115,7 +114,7 @@ public class PdpProvider {
for (PdpGroup pdpGroup : pdpGroups) {
JpaPdpGroup jpaPdpGroup =
- dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), pdpGroup.getVersion()));
+ dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION));
returnPdpGroups.add(jpaPdpGroup.toAuthorative());
}
@@ -152,7 +151,7 @@ public class PdpProvider {
for (PdpGroup pdpGroup : pdpGroups) {
JpaPdpGroup jpaPdpGroup =
- dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), pdpGroup.getVersion()));
+ dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION));
returnPdpGroups.add(jpaPdpGroup.toAuthorative());
}
@@ -164,14 +163,14 @@ public class PdpProvider {
*
* @param dao the DAO to use to access the database
* @param pdpGroupName the name of the PDP group of the PDP subgroup
- * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
* @param pdpSubGroup the PDP subgroup to be updated
* @throws PfModelException on errors updating PDP subgroups
*/
public void updatePdpSubGroup(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
- @NonNull final String pdpGroupVersion, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
+ @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
- final PfReferenceKey subGroupKey = new PfReferenceKey(pdpGroupName, pdpGroupVersion, pdpSubGroup.getPdpType());
+ final PfReferenceKey subGroupKey =
+ new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup.getPdpType());
final JpaPdpSubGroup jpaPdpSubgroup = new JpaPdpSubGroup(subGroupKey);
jpaPdpSubgroup.fromAuthorative(pdpSubGroup);
@@ -190,16 +189,15 @@ public class PdpProvider {
*
* @param dao the DAO to use to access the database
* @param pdpGroupName the name of the PDP group of the PDP subgroup
- * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
* @param pdpSubGroup the PDP subgroup to be updated
* @param pdp the PDP to be updated
* @throws PfModelException on errors updating PDP subgroups
*/
public void updatePdp(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
- @NonNull final String pdpGroupVersion, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) {
+ @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) {
final PfReferenceKey pdpKey =
- new PfReferenceKey(pdpGroupName, pdpGroupVersion, pdpSubGroup, pdp.getInstanceId());
+ new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup, pdp.getInstanceId());
final JpaPdp jpaPdp = new JpaPdp(pdpKey);
jpaPdp.fromAuthorative(pdp);
@@ -218,14 +216,12 @@ public class PdpProvider {
*
* @param dao the DAO to use to access the database
* @param name the name of the policy to get, null to get all PDP groups
- * @param version the version of the policy to get, null to get all versions of a PDP group
* @return the PDP group deleted
* @throws PfModelException on errors deleting PDP groups
*/
- public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name,
- @NonNull final String version) {
+ public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name) {
- PfConceptKey pdpGroupKey = new PfConceptKey(name, version);
+ PfConceptKey pdpGroupKey = new PfConceptKey(name, PfKey.NULL_KEY_VERSION);
JpaPdpGroup jpaDeletePdpGroup = dao.get(JpaPdpGroup.class, pdpGroupKey);
@@ -245,12 +241,10 @@ public class PdpProvider {
*
* @param dao the DAO to use to access the database
* @param name the name of the PDP group to get statistics for, null to get all PDP groups
- * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
* @return the statistics found
* @throws PfModelException on errors getting statistics
*/
- public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final String version)
- throws PfModelException {
+ public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name) throws PfModelException {
return new ArrayList<>();
}
@@ -259,14 +253,13 @@ public class PdpProvider {
*
* @param dao the DAO to use to access the database
* @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
- * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
* @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
* @param pdpInstanceId the instance ID of the PDP to update statistics for
* @param pdpStatistics the statistics to update
* @throws PfModelException on errors updating statistics
*/
public void updatePdpStatistics(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
- @NonNull final String pdpGroupVersion, @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final String pdpType, @NonNull final String pdpInstanceId,
@NonNull final PdpStatistics pdpStatistics) throws PfModelException {
// Not implemented yet
}