aboutsummaryrefslogtreecommitdiffstats
path: root/models-provider/src/main/java/org/onap
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2022-02-15 12:16:30 +0000
committera.sreekumar <ajith.sreekumar@bell.ca>2022-02-16 11:49:27 +0000
commit676194789a8b880e2416f9d3bf2484a9fc6be1bc (patch)
tree71617241837026c53dec1f76b9c0b3ae7a584dff /models-provider/src/main/java/org/onap
parent45b653fc5a8d641452247eca5c80cf580609e9bf (diff)
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 <ajith.sreekumar@bell.ca>
Diffstat (limited to 'models-provider/src/main/java/org/onap')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java61
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java47
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java2
3 files changed, 3 insertions, 107 deletions
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<PdpStatistics> 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<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> 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<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> 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<PdpStatistics> 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<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
Collection<PdpPolicyStatus> deleteObjs);
-
- /**
- * Creates records for audit actions on policies.
- *
- * @param auditRecords the objects to create
- */
- public void createAuditRecords(@NonNull List<PolicyAudit> 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<PolicyAudit> 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;
@@ -280,33 +274,6 @@ public abstract class AbstractPolicyModelsProvider implements PolicyModelsProvid
}
@Override
- public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().getFilteredPdpStatistics(getPfDao(), filterParams);
- }
-
- @Override
- public List<PdpStatistics> createPdpStatistics(@NonNull final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().createPdpStatistics(getPfDao(), pdpStatisticsList);
- }
-
- @Override
- public List<PdpStatistics> updatePdpStatistics(@NonNull final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().updatePdpStatistics(getPfDao(), pdpStatisticsList);
- }
-
- @Override
- public List<PdpStatistics> deletePdpStatistics(@NonNull final String name, final Instant timestamp)
- throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().deletePdpStatistics(getPfDao(), name, timestamp);
- }
-
- @Override
public List<PdpPolicyStatus> getAllPolicyStatus() throws PfModelException {
assertInitialized();
return new PdpProvider().getAllPolicyStatus(getPfDao());
@@ -332,18 +299,6 @@ public abstract class AbstractPolicyModelsProvider implements PolicyModelsProvid
new PdpProvider().cudPolicyStatus(getPfDao(), createObjs, updateObjs, deleteObjs);
}
- @Override
- public void createAuditRecords(List<PolicyAudit> auditRecords) {
- assertInitialized();
- new PolicyAuditProvider().createAuditRecords(getPfDao(), auditRecords);
- }
-
- @Override
- public List<PolicyAudit> 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.