Upgrade the H2 database to the latest version 95/132795/1
authorliamfallon <liam.fallon@est.tech>
Sun, 18 Dec 2022 02:26:01 +0000 (02:26 +0000)
committerliamfallon <liam.fallon@est.tech>
Sun, 18 Dec 2022 02:26:12 +0000 (02:26 +0000)
The latest verison of H2 does not allow colums called "user" or indexes
using an underscore in their name.

Issue-ID: POLICY-4488
Change-Id: I1db62768b0c0f85543c2f7d3681243f8386825e7
Signed-off-by: liamfallon <liam.fallon@est.tech>
models-pap/src/main/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAudit.java
models-pap/src/test/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAuditTest.java
models-pap/src/test/resources/META-INF/persistence.xml
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java
models-pdp/src/test/resources/META-INF/persistence.xml

index 35e3856..e2f8972 100644 (file)
@@ -63,7 +63,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
  *
  */
 @Entity
-@Table(name = "JpaPolicyAudit", indexes = {@Index(name = "JpaPolicyAuditIndex_timestamp", columnList = "timeStamp")})
+@Table(name = "JpaPolicyAudit", indexes = {
+    @Index(name = "JpaPolicyAuditIndex_timestamp", columnList = "timeStamp")
+})
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -105,7 +107,7 @@ public class JpaPolicyAudit extends PfConcept implements PfAuthorative<PolicyAud
     private Date timeStamp;
 
     @Column
-    private String user;
+    private String userName;
 
     /**
      * Default constructor.
@@ -137,7 +139,7 @@ public class JpaPolicyAudit extends PfConcept implements PfAuthorative<PolicyAud
         this.pdpType = copyConcept.getPdpType();
         this.action = copyConcept.getAction();
         this.timeStamp = copyConcept.getTimeStamp();
-        this.user = copyConcept.getUser();
+        this.userName = copyConcept.getUserName();
     }
 
     @Override
@@ -163,7 +165,7 @@ public class JpaPolicyAudit extends PfConcept implements PfAuthorative<PolicyAud
                         .append(pdpType, other.pdpType)
                         .append(action, other.action)
                         .append(timeStamp, other.timeStamp)
-                        .append(user, other.user)
+                        .append(userName, other.userName)
                         .toComparison();
         // @formatter:on
     }
@@ -180,7 +182,7 @@ public class JpaPolicyAudit extends PfConcept implements PfAuthorative<PolicyAud
                         .policy(policyIdent)
                         .action(action)
                         .timestamp(timeStamp == null ? null : timeStamp.toInstant())
-                        .user(user)
+                        .user(userName)
                         .build();
         // @formatter:on
     }
@@ -200,11 +202,10 @@ public class JpaPolicyAudit extends PfConcept implements PfAuthorative<PolicyAud
         pdpType = authorativeConcept.getPdpType();
         action = authorativeConcept.getAction();
         timeStamp = authorativeConcept.getTimestamp() == null ? Date.from(Instant.now())
-                : Date.from(authorativeConcept.getTimestamp());
-        user = authorativeConcept.getUser();
+            : Date.from(authorativeConcept.getTimestamp());
+        userName = authorativeConcept.getUser();
     }
 
-
     @Override
     public List<PfKey> getKeys() {
         final List<PfKey> keyList = new ArrayList<>();
@@ -221,7 +222,7 @@ public class JpaPolicyAudit extends PfConcept implements PfAuthorative<PolicyAud
     public void clean() {
         pdpGroup = Assertions.validateStringParameter("pdpGroup", pdpGroup, PfReferenceKey.LOCAL_NAME_REGEXP);
         pdpType = Assertions.validateStringParameter("pdpType", pdpType, PfReferenceKey.LOCAL_NAME_REGEXP);
-        user = Assertions.validateStringParameter("user", user, PfReferenceKey.LOCAL_NAME_REGEXP);
+        userName = Assertions.validateStringParameter("user", userName, PfReferenceKey.LOCAL_NAME_REGEXP);
     }
 
     @Override
index 4f86933..25d7304 100644 (file)
@@ -84,7 +84,7 @@ public class JpaPolicyAuditTest {
         audit.setUser("   user");
         JpaPolicyAudit jpaAudit = new JpaPolicyAudit(audit);
         assertThatNoException().isThrownBy(() -> jpaAudit.clean());
-        assertEquals(USER, jpaAudit.getUser());
+        assertEquals(USER, jpaAudit.getUserName());
     }
 
     @Test
index 58e2dec..fcab08f 100644 (file)
@@ -31,7 +31,7 @@
             <property name="eclipselink.ddl-generation.output-mode" value="database" />
             <property name="eclipselink.logging.level" value="INFO" />
 
-            <property name="eclipselink.logging.level" value="ALL" />
+            <!--property name="eclipselink.logging.level" value="ALL" />
             <property name="eclipselink.logging.level.jpa" value="ALL" />
             <property name="eclipselink.logging.level.ddl" value="ALL" />
             <property name="eclipselink.logging.level.connection" value="ALL" />
@@ -40,7 +40,7 @@
             <property name="eclipselink.logging.level.sequencing" value="ALL" />
             <property name="eclipselink.logging.level.server" value="ALL" />
             <property name="eclipselink.logging.level.query" value="ALL" />
-            <property name="eclipselink.logging.level.properties" value="ALL" />
+            <property name="eclipselink.logging.level.properties" value="ALL" /-->
         </properties>
     </persistence-unit>
 </persistence>
index 536bb76..88fb14a 100644 (file)
@@ -82,7 +82,7 @@ public class JpaPdpPolicyStatus extends PfConcept implements PfAuthorative<PdpPo
     @VerifyKey(versionNotNull = true)
     private PfConceptKey policyType;
 
-    @Column
+    @Column(columnDefinition = "TINYINT DEFAULT 1")
     private boolean deploy;
 
     @Column
index 45e63e4..7eb4e7c 100644 (file)
@@ -59,14 +59,15 @@ 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"})
+@Index(name = "IDXTSIDX1", columnNames = {
+    "timeStamp", "name", "version"
+})
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
 @AllArgsConstructor
@@ -189,21 +190,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 +253,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
index 6538064..7d4e589 100644 (file)
@@ -43,7 +43,7 @@
             <property name="eclipselink.ddl-generation.output-mode" value="database" />
             <property name="eclipselink.logging.level" value="INFO" />
 
-            <property name="eclipselink.logging.level" value="ALL" />
+            <!--property name="eclipselink.logging.level" value="ALL" />
             <property name="eclipselink.logging.level.jpa" value="ALL" />
             <property name="eclipselink.logging.level.ddl" value="ALL" />
             <property name="eclipselink.logging.level.connection" value="ALL" />
@@ -52,7 +52,7 @@
             <property name="eclipselink.logging.level.sequencing" value="ALL" />
             <property name="eclipselink.logging.level.server" value="ALL" />
             <property name="eclipselink.logging.level.query" value="ALL" />
-            <property name="eclipselink.logging.level.properties" value="ALL" />
+            <property name="eclipselink.logging.level.properties" value="ALL" /-->
         </properties>
     </persistence-unit>
 </persistence>