aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2019-04-08 16:54:06 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-08 16:54:06 +0000
commita32b49c3ec54e5f3bf23634a5fb538909905f8e6 (patch)
tree1a865fd043ccbda577cf5b9c4ac1649ba6b4aba5 /models-pdp/src/main
parent59e8be2fdc958156eaac43a0e78627fa187af3e4 (diff)
parent9ce39af891ccf063d46e18ecf5a2a47eb1408930 (diff)
Merge "Add bug fixes and tests for filters"
Diffstat (limited to 'models-pdp/src/main')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java6
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java9
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java8
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java4
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java23
5 files changed, 27 insertions, 23 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java
index 1eaa41547..034374c29 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java
@@ -21,10 +21,9 @@
package org.onap.policy.models.pdp.concepts;
-import lombok.Getter;
+import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
-import lombok.Setter;
import lombok.ToString;
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -34,10 +33,9 @@ import org.onap.policy.models.pdp.enums.PdpState;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@Getter
-@Setter
@ToString
@NoArgsConstructor
+@Data
public class Pdp {
@NonNull
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 5965b728d..3c07a9d0f 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
@@ -46,7 +46,7 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
// Regular expression
private String name;
- // Regular Expression, set to LATEST_VERRSION to get the latest version
+ // Regular Expression, set to to get the latest version
private String version;
private PdpState groupState;
@@ -67,9 +67,10 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
// @formatter:off
List<PdpGroup> returnList = originalList.stream()
- .filter(p -> filterOnRegexp(p.getName(), name))
- .filter(p -> version.equals(LATEST_VERSION) || filterOnRegexp(p.getVersion(), version))
- .filter(p -> ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0)
+ .filter(p -> filterString(p.getName(), name))
+ .filter(p -> (version != null && 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 -> filterOnPolicyType(p, policyType))
.filter(p -> filterOnPolicy(p, policy))
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
index 4e5843678..405408946 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
@@ -25,10 +25,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import lombok.Getter;
+import lombok.Data;
import lombok.NonNull;
-import lombok.Setter;
-import lombok.ToString;
import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
@@ -39,9 +37,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@Getter
-@Setter
-@ToString
+@Data
public class PdpSubGroup {
private String pdpType;
private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes;
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java
index 71f27c48b..d0fc216c2 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java
@@ -29,11 +29,13 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
@@ -87,7 +89,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> {
private Map<String, String> properties;
// @formatter:off
- @OneToMany
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@CollectionTable(joinColumns = {
@JoinColumn(name = "pdpGroupParentKeyName", referencedColumnName = "parentKeyName"),
@JoinColumn(name = "pdpGroupParentKeyVersion", referencedColumnName = "parentKeyVersion"),
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 d51cfc67e..20e43f0b5 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
@@ -28,19 +28,23 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import javax.persistence.CollectionTable;
+
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
+
import org.onap.policy.common.utils.validation.Assertions;
import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.models.base.PfAuthorative;
@@ -89,13 +93,16 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
@ElementCollection
private Map<String, String> properties;
- // @formatter:ofF
- @OneToMany
- @CollectionTable(
- joinColumns = { @JoinColumn(name = "pdpSubGroupParentKeyName", referencedColumnName = "parentKeyName"),
- @JoinColumn(name = "pdpSubGroupParentKeyVersion", referencedColumnName = "parentKeyVersion"),
- @JoinColumn(name = "pdpSubGroupParentLocalName", referencedColumnName = "parentLocalName"),
- @JoinColumn(name = "pdpSubGroupLocalName", referencedColumnName = "localName") })
+ // @formatter:off
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
+ @JoinTable (
+ joinColumns = {
+ @JoinColumn(name = "pdpParentKeyName", referencedColumnName = "parentKeyName"),
+ @JoinColumn(name = "pdpParentKeyVersion", referencedColumnName = "parentKeyVersion"),
+ @JoinColumn(name = "pdpParentLocalName", referencedColumnName = "parentLocalName"),
+ @JoinColumn(name = "pdpLocalName", referencedColumnName = "localName")
+ }
+ )
// formatter:on
private List<JpaPdp> pdpInstances;