From cc5b96bfd33cd7d91fe6994d348e8d6a0ebb54fa Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 29 Mar 2019 10:31:22 +0000 Subject: Restructure for authorative models Use authorative models instead of the JPA stored models as the venacular models in the Policy Framework. The next step is to pass the authorative objects over the provider interface rather than the JPA obejcts. This change will be made in the next review. Minor changes to pdp objects to remove JPA things from them. These object will be the authorative in-memory obejcts on the PDP side and new JPA entity object will be introduced in a future review to persist them. Issue-ID: POLICY-1095 Change-Id: I40e7b713903980cb41bb315417111b67a9b17307 Signed-off-by: liamfallon --- .../org/onap/policy/models/pdp/concepts/Pdp.java | 63 ++++++++++++++++ .../onap/policy/models/pdp/concepts/PdpGroup.java | 20 +++-- .../models/pdp/concepts/PdpInstanceDetails.java | 63 ---------------- .../onap/policy/models/pdp/concepts/PdpStatus.java | 2 +- .../policy/models/pdp/concepts/PdpSubGroup.java | 9 +-- .../onap/policy/models/pdp/concepts/PdpUpdate.java | 2 +- .../policy/models/pdp/enums/PdpHealthStatus.java | 5 ++ .../pdp/persistence/provider/PdpProvider.java | 86 ++++++++++++++++++++++ .../policy/models/pdp/provider/PdpProvider.java | 86 ---------------------- 9 files changed, 168 insertions(+), 168 deletions(-) create mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java delete mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetails.java create mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java delete mode 100644 models-pdp/src/main/java/org/onap/policy/models/pdp/provider/PdpProvider.java (limited to 'models-pdp/src/main') 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 new file mode 100644 index 000000000..1eaa41547 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +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; + +/** + * Class to represent details of a running instance of PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +public class Pdp { + + @NonNull + private String instanceId; + + @NonNull + private PdpState pdpState; + + private PdpHealthStatus healthy; + private String message; + + /** + * Constructs the object, creating a deep copy of the fields from the source. + * + * @param source source from which to copy the fields + */ + public Pdp(Pdp source) { + this.instanceId = source.instanceId; + this.pdpState = source.pdpState; + this.healthy = source.healthy; + this.message = source.message; + } +} 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 4a26b16dd..c69679416 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 @@ -25,13 +25,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import lombok.Getter; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.pdp.enums.PdpState; -import org.onap.policy.models.tosca.simple.concepts.ToscaEntityType; /** * Class to represent a PDPGroup, which groups multiple PDPSubGroup entities together for @@ -39,13 +36,12 @@ import org.onap.policy.models.tosca.simple.concepts.ToscaEntityType; * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ -@Getter -@Setter -@ToString +@Data @NoArgsConstructor -public class PdpGroup extends ToscaEntityType { - private static final long serialVersionUID = 1L; - +public class PdpGroup { + private String name; + private String version; + private String description; private PdpState pdpGroupState; private Map properties; private List pdpSubgroups; @@ -62,7 +58,9 @@ public class PdpGroup extends ToscaEntityType { * @param source source from which to copy fields */ public PdpGroup(PdpGroup source) { - super(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)); this.pdpSubgroups = PfUtils.mapList(source.pdpSubgroups, PdpSubGroup::new); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetails.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetails.java deleted file mode 100644 index 6cf122e19..000000000 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpInstanceDetails.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * Modifications 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.pdp.concepts; - -import lombok.Getter; -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; - -/** - * Class to represent details of a running instance of PDP. - * - * @author Ram Krishna Verma (ram.krishna.verma@est.tech) - */ -@Getter -@Setter -@ToString -@NoArgsConstructor -public class PdpInstanceDetails { - - @NonNull - private String instanceId; - - @NonNull - private PdpState pdpState; - - private PdpHealthStatus healthy; - private String message; - - /** - * Constructs the object, creating a deep copy of the fields from the source. - * - * @param source source from which to copy the fields - */ - public PdpInstanceDetails(PdpInstanceDetails source) { - this.instanceId = source.instanceId; - this.pdpState = source.pdpState; - this.healthy = source.healthy; - this.message = source.message; - } -} 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 814d35732..eb0758e61 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 @@ -28,7 +28,7 @@ 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.simple.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Class to represent the PDP_STATUS message that all the PDP's will send to PAP. 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 0466c6300..b4539ec3e 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 @@ -29,7 +29,7 @@ import lombok.NonNull; import lombok.Setter; import lombok.ToString; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Class to represent a group of all PDP's of the same pdp type running for a particular @@ -41,16 +41,13 @@ import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; @Setter @ToString public class PdpSubGroup { - - // TODO subclass from ToscaEntityType - private String pdpType; private List supportedPolicyTypes; private List policies; private int currentInstanceCount; private int desiredInstanceCount; private Map properties; - private List pdpInstances; + private List pdpInstances; /** * Constructs the object. @@ -71,6 +68,6 @@ public class PdpSubGroup { 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); + this.pdpInstances = PfUtils.mapList(source.pdpInstances, Pdp::new); } } 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 a048cde48..5c99a56f5 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 @@ -27,7 +27,7 @@ import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.onap.policy.models.pdp.enums.PdpMessageType; -import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; /** * Class to represent the PDP_UPDATE message that PAP will send to a PDP. diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java index 7d31c3344..e8bbb2c30 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java @@ -42,4 +42,9 @@ public enum PdpHealthStatus { * PDP is currently under test state and performing tests. */ TEST_IN_PROGRESS, + + /** + * The health status of the PDP is unknown. + */ + UNKNOWN } 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 new file mode 100644 index 000000000..fe0576dfe --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java @@ -0,0 +1,86 @@ +/*- + * ============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.persistence.provider; + +import lombok.NonNull; + +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.dao.PfDao; +import org.onap.policy.models.pdp.concepts.PdpGroups; + +/** + * This class provides the provision of information on PAP concepts in the database to callers. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class PdpProvider { + /** + * Get PDP groups. + * + * @param dao the DAO to use to access the database + * @param pdpGroupFilter a filter for the get + * @return the PDP groups found + * @throws PfModelException on errors getting PDP groups + */ + public PdpGroups getPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter) + throws PfModelException { + return new PdpGroups(); + } + + /** + * Creates PDP groups. + * + * @param dao the DAO to use to access the database + * @param pdpGroups a specification of the PDP groups to create + * @return the PDP groups created + * @throws PfModelException on errors creating PDP groups + */ + public PdpGroups createPdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups) + throws PfModelException { + return new PdpGroups(); + } + + /** + * Updates PDP groups. + * + * @param dao the DAO to use to access the database + * @param pdpGroups a specification of the PDP groups to update + * @return the PDP groups updated + * @throws PfModelException on errors updating PDP groups + */ + public PdpGroups updatePdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups) + throws PfModelException { + return new PdpGroups(); + } + + /** + * Delete PDP groups. + * + * @param dao the DAO to use to access the database + * @param pdpGroupFilter a filter for the get + * @return the PDP groups deleted + * @throws PfModelException on errors deleting PDP groups + */ + public PdpGroups deletePdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter) + throws PfModelException { + return new PdpGroups(); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/provider/PdpProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/provider/PdpProvider.java deleted file mode 100644 index 57feba620..000000000 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/provider/PdpProvider.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============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.provider; - -import lombok.NonNull; - -import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.dao.PfDao; -import org.onap.policy.models.pdp.concepts.PdpGroups; - -/** - * This class provides the provision of information on PAP concepts in the database to callers. - * - * @author Liam Fallon (liam.fallon@est.tech) - */ -public class PdpProvider { - /** - * Get PDP groups. - * - * @param dao the DAO to use to access the database - * @param pdpGroupFilter a filter for the get - * @return the PDP groups found - * @throws PfModelException on errors getting PDP groups - */ - public PdpGroups getPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter) - throws PfModelException { - return new PdpGroups(); - } - - /** - * Creates PDP groups. - * - * @param dao the DAO to use to access the database - * @param pdpGroups a specification of the PDP groups to create - * @return the PDP groups created - * @throws PfModelException on errors creating PDP groups - */ - public PdpGroups createPdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups) - throws PfModelException { - return new PdpGroups(); - } - - /** - * Updates PDP groups. - * - * @param dao the DAO to use to access the database - * @param pdpGroups a specification of the PDP groups to update - * @return the PDP groups updated - * @throws PfModelException on errors updating PDP groups - */ - public PdpGroups updatePdpGroups(@NonNull final PfDao dao, @NonNull final PdpGroups pdpGroups) - throws PfModelException { - return new PdpGroups(); - } - - /** - * Delete PDP groups. - * - * @param dao the DAO to use to access the database - * @param pdpGroupFilter a filter for the get - * @return the PDP groups deleted - * @throws PfModelException on errors deleting PDP groups - */ - public PdpGroups deletePdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter) - throws PfModelException { - return new PdpGroups(); - } -} -- cgit 1.2.3-korg