From 676194789a8b880e2416f9d3bf2484a9fc6be1bc Mon Sep 17 00:00:00 2001 From: "a.sreekumar" Date: Tue, 15 Feb 2022 12:16:30 +0000 Subject: Fix issue with GeneratedValue in PfGeneratedIdKey PfGeneratedIdKey class (which is used as a composite key in JpaPolicyAudit and JpaPdpStatistics) uses GeneratedValue in a wrong way and not according to the specification. This review fixes it. PfGeneratedIdKey class is removed, and the generatedId is directly specified in the JpaPolicyAudit and JpaPdpStatistics classes. Note: These classes are only used by PAP, so the related methods for db interaction is removed as PAP directly talks to DB using spring repository layer. Also the only end result this change brings is that the 'generatedId' alone will be used as the primary key instead of 'generatedId, name and version' together. Corresponding changes in DB Migrator: https://gerrit.onap.org/r/c/policy/docker/+/127139 PAP: https://gerrit.onap.org/r/c/policy/pap/+/127130 Change-Id: Ib4ea8b60ffe5c2480746569c0354bf474a6b7006 Issue-ID: POLICY-3897 Signed-off-by: a.sreekumar --- .../models/provider/PolicyModelsProvider.java | 61 +--------------------- .../impl/AbstractPolicyModelsProvider.java | 47 +---------------- .../impl/DatabasePolicyModelsProviderImpl.java | 2 +- 3 files changed, 3 insertions(+), 107 deletions(-) (limited to 'models-provider/src/main/java') diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java index 5cc5fc96b..f0a5382de 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2022 Nordix Foundation. - * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.policy.models.provider; -import java.time.Instant; import java.util.Collection; import java.util.List; import java.util.Map; @@ -30,15 +29,11 @@ import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.pap.concepts.PolicyAudit; -import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpGroupFilter; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus; -import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; -import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityKey; @@ -378,46 +373,6 @@ public interface PolicyModelsProvider extends AutoCloseable { */ public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException; - - /** - * Get filtered PdpStatistics. - * - * @param filterParams filter parameters - * @return the PDP statistics found - * @throws PfModelException on errors getting policies - */ - public List getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException; - - /** - * Creates PDP statistics. - * - * @param pdpStatisticsList a specification of the PDP statistics to create - * @return the PDP statistics created - * @throws PfModelException on errors creating PDP statistics - */ - public List createPdpStatistics(@NonNull List pdpStatisticsList) - throws PfModelException; - - /** - * Updates PDP statistics. - * - * @param pdpStatisticsList a specification of the PDP statistics to update - * @return the PDP statistics updated - * @throws PfModelException on errors updating PDP statistics - */ - public List updatePdpStatistics(@NonNull List pdpStatisticsList) - throws PfModelException; - - /** - * Delete a PDP statistics. - * - * @param name the name of the policy to get, null to get all PDP statistics - * @param timestamp the timestamp of statistics to delete, null to delete all statistics record of given pdp - * @return the PDP statistics deleted - * @throws PfModelException on errors deleting PDP statistics - */ - public List deletePdpStatistics(@NonNull String name, Instant timestamp) throws PfModelException; - /** * Gets all policy deployments. * @@ -453,18 +408,4 @@ public interface PolicyModelsProvider extends AutoCloseable { */ public void cudPolicyStatus(Collection createObjs, Collection updateObjs, Collection deleteObjs); - - /** - * Creates records for audit actions on policies. - * - * @param auditRecords the objects to create - */ - public void createAuditRecords(@NonNull List auditRecords); - - /** - * Collect the audit records. - * @param auditFilter filter for search - * @return list of {@link PolicyAudit} or empty if none or not match with filter - */ - public List getAuditRecords(AuditFilter auditFilter); } diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java index ffb470628..6747d9c49 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation. + * Modifications Copyright (C) 2022 Bell Canada. 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. @@ -20,7 +21,6 @@ package org.onap.policy.models.provider.impl; -import java.time.Instant; import java.util.Collection; import java.util.List; import java.util.Map; @@ -30,18 +30,12 @@ import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.dao.PfDao; -import org.onap.policy.models.pap.concepts.PolicyAudit; -import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider; -import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpGroupFilter; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus; -import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; -import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters; import org.onap.policy.models.pdp.persistence.provider.PdpProvider; -import org.onap.policy.models.pdp.persistence.provider.PdpStatisticsProvider; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion; @@ -279,33 +273,6 @@ public abstract class AbstractPolicyModelsProvider implements PolicyModelsProvid return new PdpProvider().deletePdpGroup(getPfDao(), name); } - @Override - public List getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException { - assertInitialized(); - return new PdpStatisticsProvider().getFilteredPdpStatistics(getPfDao(), filterParams); - } - - @Override - public List createPdpStatistics(@NonNull final List pdpStatisticsList) - throws PfModelException { - assertInitialized(); - return new PdpStatisticsProvider().createPdpStatistics(getPfDao(), pdpStatisticsList); - } - - @Override - public List updatePdpStatistics(@NonNull final List pdpStatisticsList) - throws PfModelException { - assertInitialized(); - return new PdpStatisticsProvider().updatePdpStatistics(getPfDao(), pdpStatisticsList); - } - - @Override - public List deletePdpStatistics(@NonNull final String name, final Instant timestamp) - throws PfModelException { - assertInitialized(); - return new PdpStatisticsProvider().deletePdpStatistics(getPfDao(), name, timestamp); - } - @Override public List getAllPolicyStatus() throws PfModelException { assertInitialized(); @@ -332,18 +299,6 @@ public abstract class AbstractPolicyModelsProvider implements PolicyModelsProvid new PdpProvider().cudPolicyStatus(getPfDao(), createObjs, updateObjs, deleteObjs); } - @Override - public void createAuditRecords(List auditRecords) { - assertInitialized(); - new PolicyAuditProvider().createAuditRecords(getPfDao(), auditRecords); - } - - @Override - public List getAuditRecords(AuditFilter auditFilter) { - assertInitialized(); - return new PolicyAuditProvider().getAuditRecords(getPfDao(), auditFilter); - } - /** * Check if the model provider is initialized. */ diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java index af03fdbcf..ed47ae0a0 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2020, 2022 Bell Canada. 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. -- cgit 1.2.3-korg