summaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-04-04 11:20:42 -0400
committerJim Hahn <jrh3@att.com>2019-04-04 22:43:05 -0400
commitb0bb6076e2298c7a016a00adcaefb7ed75eac641 (patch)
treec312e7604febf139a562b26679d819418db5864f /models-pdp/src/main
parent2f925fb69dfc65bf25870fe89c004a009a73e476 (diff)
Updates to models from scrum on 4/4
Moved ToscaPolicyIdentXxx classes from models-pdp to models-tosca, and added methods to retrieve them from a ToscaPolicy. Removed version and instance fields from PdpStatus. Chose to leave "description" field in the PAP/PDP messages. The PDPs can ignore them or leave them null. In a PdpUpdate message, the description will be the description associated with the PdpGroup. In a PdpStatus message, the PDP could choose to provide a description of the PDP, itself (or the type of PDP). Added comments to that effect. Moved name, group, and subgroup fields into PdpMessage. Fixed typos in comments. Updated licenses. Change "long" to "Long" in PdpUpdate. Use lombok @ToString instead of override. Fixed merge conflict. Change-Id: Icd928f9a7630b838ad4b0b5556e899dc21b7872b Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src/main')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java2
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java34
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java10
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java16
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java2
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java16
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java50
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java58
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java50
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java7
10 files changed, 56 insertions, 189 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
index f7a47ccd7..b49bedefe 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
@@ -29,6 +29,8 @@ import lombok.NonNull;
import org.onap.policy.models.base.PfObjectFiler;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Filter class for searches for {@link PdpGroup} instances.
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java
index 6160027ed..a48724e34 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java
@@ -29,7 +29,8 @@ import lombok.ToString;
import org.onap.policy.models.pdp.enums.PdpMessageType;
/**
- * Class to represent the base class for various messages that will ve exchanged between PAP and PDP.
+ * Class to represent the base class for various messages that will be exchanged between
+ * PAP and PDP.
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
@@ -50,6 +51,24 @@ public class PdpMessage {
private long timestampMs = System.currentTimeMillis();
/**
+ * PDP name, or {@code null} for state-change broadcast messages.
+ */
+ private String name;
+
+ /**
+ * Group associated with the PDP. For state-change messages, this may be {@code null},
+ * if the {@link #name} is provided.
+ */
+ private String pdpGroup;
+
+ /**
+ * Group associated with the PDP. For state-change messages, this may be {@code null},
+ * if the {@link #name} is provided.
+ */
+ private String pdpSubgroup;
+
+
+ /**
* Constructor for instantiating PdpMessage class with message name.
*
* @param messageName the message name
@@ -57,4 +76,17 @@ public class PdpMessage {
public PdpMessage(final PdpMessageType messageName) {
this.messageName = messageName;
}
+
+ /**
+ * Constructs the object, making a deep copy. Does <i>not</i> copy the request id or
+ * the time stamp.
+ *
+ * @param source source from which to copy
+ */
+ public PdpMessage(final PdpMessage source) {
+ this.messageName = source.messageName;
+ this.name = source.name;
+ this.pdpGroup = source.pdpGroup;
+ this.pdpSubgroup = source.pdpSubgroup;
+ }
}
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java
index d8f938bbc..fe953cb65 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java
@@ -35,13 +35,10 @@ import org.onap.policy.models.pdp.enums.PdpState;
*/
@Getter
@Setter
-@ToString
+@ToString(callSuper = true)
public class PdpStateChange extends PdpMessage {
- private String name;
private PdpState state;
- private String pdpGroup;
- private String pdpSubgroup;
/**
* Constructor for instantiating PdpStateChange class with message name.
@@ -57,11 +54,8 @@ public class PdpStateChange extends PdpMessage {
* @param source source from which to copy
*/
public PdpStateChange(PdpStateChange source) {
- super(PdpMessageType.PDP_STATE_CHANGE);
+ super(source);
- this.name = source.name;
this.state = source.state;
- this.pdpGroup = source.pdpGroup;
- this.pdpSubgroup = source.pdpSubgroup;
}
}
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java
index d0fef4503..5858b6acd 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java
@@ -22,14 +22,14 @@
package org.onap.policy.models.pdp.concepts;
import java.util.List;
-
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpMessageType;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Class to represent the PDP_STATUS message that all the PDP's will send to PAP.
@@ -38,20 +38,20 @@ import org.onap.policy.models.pdp.enums.PdpState;
*/
@Getter
@Setter
-@ToString
+@ToString(callSuper = true)
public class PdpStatus extends PdpMessage {
- private String name;
- private String version;
private String pdpType;
private PdpState state;
private PdpHealthStatus healthy;
+
+ /**
+ * Description of the PDP or the PDP type. May be left {@code null}.
+ */
private String description;
- private String pdpGroup;
- private String pdpSubgroup;
+
private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes;
private List<ToscaPolicyIdentifier> policies;
- private String instance;
private String deploymentInstanceInfo;
private String properties;
private PdpStatistics statistics;
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 b4f469388..4e5843678 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
@@ -31,6 +31,8 @@ import lombok.Setter;
import lombok.ToString;
import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Class to represent a group of all PDP's of the same pdp type running for a particular domain.
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
index 200515cc4..a28bd7640 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
@@ -36,14 +36,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
*/
@Getter
@Setter
-@ToString
+@ToString(callSuper = true)
public class PdpUpdate extends PdpMessage {
- private String name;
+ /**
+ * Description of the PDP group.
+ */
private String description;
- private String pdpGroup;
- private String pdpSubgroup;
- private long pdpHeartbeatIntervalMs;
+
+ private Long pdpHeartbeatIntervalMs;
private List<ToscaPolicy> policies;
/**
@@ -60,12 +61,9 @@ public class PdpUpdate extends PdpMessage {
* @param source source from which to copy
*/
public PdpUpdate(PdpUpdate source) {
- super(PdpMessageType.PDP_UPDATE);
+ super(source);
- this.name = source.name;
this.description = source.description;
- this.pdpGroup = source.pdpGroup;
- this.pdpSubgroup = source.pdpSubgroup;
this.pdpHeartbeatIntervalMs = source.pdpHeartbeatIntervalMs;
this.policies = (source.policies == null ? null
: source.policies.stream().map(ToscaPolicy::new).collect(Collectors.toList()));
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java
deleted file mode 100644
index 245806c71..000000000
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifier.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Models
- * ================================================================================
- * Copyright (C) 2019 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.
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.pdp.concepts;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.NonNull;
-
-/**
- * Identifies a policy. Both the name and version must be non-null.
- */
-@Data
-@NoArgsConstructor
-public class ToscaPolicyIdentifier {
-
- @NonNull
- private String name;
-
- @NonNull
- private String version;
-
-
- public ToscaPolicyIdentifier(@NonNull String name, @NonNull String version) {
- this.name = name;
- this.version = version;
- }
-
- public ToscaPolicyIdentifier(ToscaPolicyIdentifier source) {
- this.name = source.name;
- this.version = source.version;
- }
-}
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java
deleted file mode 100644
index bd6b26ede..000000000
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyIdentifierOptVersion.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Models
- * ================================================================================
- * Copyright (C) 2019 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.
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.pdp.concepts;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.NonNull;
-
-/**
- * Policy identifier with an optional version; only the "name" is required.
- */
-@Data
-@NoArgsConstructor
-public class ToscaPolicyIdentifierOptVersion {
-
- @NonNull
- private String name;
-
- private String version;
-
-
- public ToscaPolicyIdentifierOptVersion(@NonNull String name, String version) {
- this.name = name;
- this.version = version;
- }
-
- public ToscaPolicyIdentifierOptVersion(ToscaPolicyIdentifierOptVersion source) {
- this.name = source.name;
- this.version = source.version;
- }
-
- /**
- * Determines if the version is null/missing.
- *
- * @return {@code true} if the version is null/missing, {@code false}
- */
- public boolean isNullVersion() {
- return (version == null);
- }
-}
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java
deleted file mode 100644
index cf989f3ae..000000000
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/ToscaPolicyTypeIdentifier.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Models
- * ================================================================================
- * Copyright (C) 2019 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.
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.pdp.concepts;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.NonNull;
-
-/**
- * Identifies a policy type. Both the name and version must be non-null.
- */
-@Data
-@NoArgsConstructor
-public class ToscaPolicyTypeIdentifier {
-
- @NonNull
- private String name;
-
- @NonNull
- private String version;
-
-
- public ToscaPolicyTypeIdentifier(@NonNull String name, @NonNull String version) {
- this.name = name;
- this.version = version;
- }
-
- public ToscaPolicyTypeIdentifier(ToscaPolicyTypeIdentifier source) {
- this.name = source.name;
- this.version = source.version;
- }
-}
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 2a9343902..1937cbfbb 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,7 +28,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
@@ -39,11 +38,9 @@ import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
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;
@@ -58,8 +55,8 @@ import org.onap.policy.models.base.PfValidationResult;
import org.onap.policy.models.base.PfValidationResult.ValidationResult;
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.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
* Class to represent a PDP subgroup in the database.