Set all cross references of policy/models
[policy/models.git] / models-pdp / src / main / java / org / onap / policy / models / pdp / persistence / concepts / JpaPdpStatistics.java
index 45e63e4..57a8ec9 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Model
  * ================================================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021,2023 Nordix Foundation.
  * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
@@ -35,6 +35,7 @@ import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.Index;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.Table;
@@ -46,7 +47,6 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NonNull;
 import org.apache.commons.lang3.builder.CompareToBuilder;
-import org.eclipse.persistence.annotations.Index;
 import org.onap.policy.common.parameters.BeanValidationResult;
 import org.onap.policy.common.parameters.ValidationStatus;
 import org.onap.policy.common.parameters.annotations.Pattern;
@@ -59,14 +59,21 @@ import org.onap.policy.models.base.Validated;
 import org.onap.policy.models.pdp.concepts.PdpEngineWorkerStatistics;
 import org.onap.policy.models.pdp.concepts.PdpStatistics;
 
-
 /**
  * Class to represent a PDP statistics in the database.
  *
  */
 @Entity
-@Table(name = "PdpStatistics")
-@Index(name = "IDX_TSIDX1", columnNames = {"timeStamp", "name", "version"})
+@Table(
+    name = "PdpStatistics",
+    indexes = {
+        @Index(
+            name = "IDXTSIDX1",
+            columnList = "timeStamp,name,version",
+            unique = true
+            )
+    }
+)
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
 @AllArgsConstructor
@@ -79,7 +86,7 @@ public class JpaPdpStatistics extends PfConcept implements PfAuthorative<PdpStat
     @GeneratedValue(strategy = GenerationType.TABLE, generator = "statisticsIdGen")
     @TableGenerator(
         name = "statisticsIdGen",
-        table = "sequence",
+        table = "statistics_sequence",
         pkColumnName = "SEQ_NAME",
         valueColumnName = "SEQ_COUNT",
         pkColumnValue = "SEQ_GEN")
@@ -189,21 +196,21 @@ public class JpaPdpStatistics extends PfConcept implements PfAuthorative<PdpStat
 
         final JpaPdpStatistics other = (JpaPdpStatistics) otherConcept;
         return new CompareToBuilder()
-                .append(this.name, other.name)
-                .append(this.version, other.version)
-                .append(this.generatedId, other.generatedId)
-                .append(this.timeStamp, other.timeStamp)
-                .append(this.pdpGroupName, other.pdpGroupName)
-                .append(this.pdpSubGroupName, other.pdpSubGroupName)
-                .append(this.policyDeployCount, other.policyDeployCount)
-                .append(this.policyDeployFailCount, other.policyDeployFailCount)
-                .append(this.policyDeploySuccessCount, other.policyDeploySuccessCount)
-                .append(this.policyUndeployCount, other.policyUndeployCount)
-                .append(this.policyUndeployFailCount, other.policyUndeployFailCount)
-                .append(this.policyUndeploySuccessCount, other.policyUndeploySuccessCount)
-                .append(this.policyExecutedCount, other.policyExecutedCount)
-                .append(this.policyExecutedFailCount, other.policyExecutedFailCount)
-                .append(this.policyExecutedSuccessCount, other.policyExecutedSuccessCount).toComparison();
+            .append(this.name, other.name)
+            .append(this.version, other.version)
+            .append(this.generatedId, other.generatedId)
+            .append(this.timeStamp, other.timeStamp)
+            .append(this.pdpGroupName, other.pdpGroupName)
+            .append(this.pdpSubGroupName, other.pdpSubGroupName)
+            .append(this.policyDeployCount, other.policyDeployCount)
+            .append(this.policyDeployFailCount, other.policyDeployFailCount)
+            .append(this.policyDeploySuccessCount, other.policyDeploySuccessCount)
+            .append(this.policyUndeployCount, other.policyUndeployCount)
+            .append(this.policyUndeployFailCount, other.policyUndeployFailCount)
+            .append(this.policyUndeploySuccessCount, other.policyUndeploySuccessCount)
+            .append(this.policyExecutedCount, other.policyExecutedCount)
+            .append(this.policyExecutedFailCount, other.policyExecutedFailCount)
+            .append(this.policyExecutedSuccessCount, other.policyExecutedSuccessCount).toComparison();
     }
 
     @Override
@@ -252,7 +259,7 @@ public class JpaPdpStatistics extends PfConcept implements PfAuthorative<PdpStat
         this.setPolicyExecutedFailCount(pdpStatistics.getPolicyExecutedFailCount());
         this.setPolicyExecutedSuccessCount(pdpStatistics.getPolicyExecutedSuccessCount());
         this.setEngineStats(
-                PfUtils.mapList(pdpStatistics.getEngineStats(), PdpEngineWorkerStatistics::new, null));
+            PfUtils.mapList(pdpStatistics.getEngineStats(), PdpEngineWorkerStatistics::new, null));
     }
 
     @Override