diff options
author | Jim Hahn <jrh3@att.com> | 2019-03-22 14:12:03 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-03-25 10:33:34 -0400 |
commit | a8cd3141696d2a2258d90fc234eb6a2618b8731b (patch) | |
tree | be1fa429f936d68b3db9e8b69bed05fd072d52fb /models-pap/src/main/java/org/onap | |
parent | 2a245ef80e39a101015efb164de53f1753fa5d47 (diff) |
Add PolicyIdentOptVersion
Added additional PolicyIdentXxx classes. Added PdpDeployPolicies, which
makes use of it, thus eliminating the need for PdpPolicies, which will be
deleted once the PAP has been modified to use the new code.
Added Validated class to facilitate field validation.
Added utility methods to Validated class.
Use new validator methods in PolicyIdentXxx classes.
Use addError() method in validator class.
Use parameter types instead of "?".
Use static Validator instead of local.
Get "result" from each call to a validateXxx() method.
Derived PolicyIdentOptVersion from PfConceptKey.
Moved PolicyIdent classes to models-pdp.
Added PolicyIdent classes to models-pap.
Also removed copy constructors from classes in models-pap, as those
are plain POJOs that will not be copied. Copy constructors will be
added to new classes that will be added to models-pdp in a separate
review.
Forgot to include the new Ident classes in models-pap.
Change-Id: I923132c464c7802ee3e9225685cde44f36c64620
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pap/src/main/java/org/onap')
9 files changed, 153 insertions, 91 deletions
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java new file mode 100644 index 000000000..1f4339f15 --- /dev/null +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpDeployPolicies.java @@ -0,0 +1,39 @@ +/* + * ============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.pap.concepts; + +import java.util.List; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Request deploy or update a set of policies using the <i>simple</i> PDP Group deployment + * REST API. Only the "name" and "policyVersion" fields of a Policy are used, and only the + * "name" field is actually required. + */ +@Getter +@Setter +@ToString +public class PdpDeployPolicies { + private List<PolicyIdentOptVersion> policies; +} diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java index d5e4191a2..29c4713db 100644 --- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java @@ -21,14 +21,11 @@ package org.onap.policy.models.pap.concepts; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import lombok.Getter; -import lombok.NonNull; import lombok.Setter; import lombok.ToString; -import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.pdp.enums.PdpState; /** @@ -47,25 +44,4 @@ public class PdpGroup { private String description; private Map<String, String> properties; private List<PdpSubGroup> pdpSubgroups; - - /** - * Constructs the object. - */ - public PdpGroup() { - super(); - } - - /** - * Constructs the object, making a deep copy from the source. - * - * @param source source from which to copy fields - */ - public PdpGroup(@NonNull PdpGroup source) { - this.name = source.name; - this.version = source.version; - this.pdpGroupState = source.pdpGroupState; - this.description = source.description; - this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties)); - this.pdpSubgroups = PfUtils.mapList(source.pdpSubgroups, PdpSubGroup::new); - } } diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java index c214c7409..d5846160c 100644 --- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java @@ -22,7 +22,6 @@ package org.onap.policy.models.pap.concepts; import lombok.Getter; -import lombok.NonNull; import lombok.Setter; import lombok.ToString; import org.onap.policy.models.pdp.enums.PdpHealthStatus; @@ -42,23 +41,4 @@ public class PdpInstanceDetails { private PdpState pdpState; private PdpHealthStatus healthy; private String message; - - /** - * Constructs the object. - */ - public PdpInstanceDetails() { - super(); - } - - /** - * Constructs the object, making a deep copy from the source. - * - * @param source source from which to copy fields - */ - public PdpInstanceDetails(@NonNull PdpInstanceDetails source) { - this.instanceId = source.instanceId; - this.pdpState = source.pdpState; - this.healthy = source.healthy; - this.message = source.message; - } } diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpPolicies.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpPolicies.java index e5ae24d0f..3111becca 100644 --- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpPolicies.java +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpPolicies.java @@ -26,6 +26,7 @@ import lombok.Getter; import lombok.Setter; import lombok.ToString; +// TODO delete this once PAP has been modified to use PdpDeployPolicies /** * Request deploy or update a set of policies using the <i>simple</i> PDP Group deployment * REST API. Only the "name" and "policyVersion" fields of a Policy are used, and only the diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java index 43356982e..9989d2516 100644 --- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java @@ -21,15 +21,11 @@ package org.onap.policy.models.pap.concepts; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import lombok.Getter; -import lombok.NonNull; import lombok.Setter; import lombok.ToString; -import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.base.keys.PolicyTypeIdent; /** * Class to represent a group of all PDP's of the same pdp type running for a particular @@ -49,26 +45,4 @@ public class PdpSubGroup { private int desiredInstanceCount; private Map<String, String> properties; private List<PdpInstanceDetails> pdpInstances; - - /** - * Constructs the object. - */ - public PdpSubGroup() { - super(); - } - - /** - * Constructs the object, making a deep copy from the source. - * - * @param source source from which to copy fields - */ - public PdpSubGroup(@NonNull PdpSubGroup source) { - this.pdpType = source.pdpType; - this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, PolicyTypeIdent::new); - this.policies = PfUtils.mapList(source.policies, Policy::new); - this.currentInstanceCount = source.currentInstanceCount; - this.desiredInstanceCount = source.desiredInstanceCount; - this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties)); - this.pdpInstances = PfUtils.mapList(source.pdpInstances, PdpInstanceDetails::new); - } } diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java index b83510e83..541eb2435 100644 --- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java @@ -22,7 +22,6 @@ package org.onap.policy.models.pap.concepts; import lombok.Getter; -import lombok.NonNull; import lombok.Setter; import lombok.ToString; @@ -41,24 +40,4 @@ public class Policy { private String policyType; private String policyTypeVersion; private String policyTypeImpl; - - /** - * Constructs the object. - */ - public Policy() { - super(); - } - - /** - * Constructs the object, making a deep copy from the source. - * - * @param source source from which to copy fields - */ - public Policy(@NonNull Policy source) { - this.name = source.name; - this.policyVersion = source.policyVersion; - this.policyType = source.policyType; - this.policyTypeVersion = source.policyTypeVersion; - this.policyTypeImpl = source.policyTypeImpl; - } } diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyIdent.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyIdent.java new file mode 100644 index 000000000..2eb9df136 --- /dev/null +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyIdent.java @@ -0,0 +1,36 @@ +/* + * ============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.pap.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Identifies a policy. Both the name and version must be non-null. + */ +@Getter +@Setter +@ToString +public class PolicyIdent { + private String name; + private String version; +} diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyIdentOptVersion.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyIdentOptVersion.java new file mode 100644 index 000000000..ecac2a27e --- /dev/null +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyIdentOptVersion.java @@ -0,0 +1,39 @@ +/* + * ============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.pap.concepts; + +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; + +/** + * Policy identifier with an optional version; only the "name" is required. + */ +@Getter +@Setter +@ToString +public class PolicyIdentOptVersion { + @NonNull + private String name; + + private String version; +} diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyTypeIdent.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyTypeIdent.java new file mode 100644 index 000000000..3d466b7f5 --- /dev/null +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PolicyTypeIdent.java @@ -0,0 +1,38 @@ +/* + * ============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.pap.concepts; + +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; + +/** + * Identifies a policy type. Both the name and version must be non-null. + */ +@Getter +@Setter +@ToString +@NonNull +public class PolicyTypeIdent { + private String name; + private String version; +} |