summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-09 13:01:55 -0500
committerJim Hahn <jrh3@att.com>2021-02-09 13:07:22 -0500
commit7081b69b3f60ea7cbbfad0d4f421dbdd55674731 (patch)
tree7dbff4642c8552cd21ffb6291f4997025bd6d2c1 /controlloop/common/eventmanager
parent6d5c367c38a83608f5c0639692e7f7eba772a88f (diff)
Upgrade dependencies
Added target-database property. Also moved the db-driver value out of persistence.xml and into properties. Issue-ID: POLICY-3005 Change-Id: I2c9e53c099e400c32d11632f8732e770a7abba9f Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java4
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java10
-rw-r--r--controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml3
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java14
4 files changed, 26 insertions, 5 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java
index f2feef666..52a869597 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -321,9 +321,11 @@ public class OperationHistoryDataManagerImpl implements OperationHistoryDataMana
*/
private Properties toProperties(OperationHistoryDataManagerParams params) {
Properties props = new Properties();
+ props.put(PersistenceUnitProperties.JDBC_DRIVER, params.getDriver());
props.put(PersistenceUnitProperties.JDBC_URL, params.getUrl());
props.put(PersistenceUnitProperties.JDBC_USER, params.getUserName());
props.put(PersistenceUnitProperties.JDBC_PASSWORD, params.getPassword());
+ props.put(PersistenceUnitProperties.TARGET_DATABASE, params.getDbType());
props.put(PersistenceUnitProperties.CLASSLOADER, getClass().getClassLoader());
return props;
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java
index fc919d845..c93ac8b58 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParams.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -40,6 +40,8 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@AllArgsConstructor
public class OperationHistoryDataManagerParams {
public static final String DEFAULT_PU = "OperationsHistoryPU";
+ public static final String DEFAULT_DRIVER = "org.mariadb.jdbc.Driver";
+ public static final String DEFAULT_TYPE = "MySQL";
@NotBlank
private String url;
@@ -52,6 +54,12 @@ public class OperationHistoryDataManagerParams {
@Builder.Default
private String persistenceUnit = DEFAULT_PU;
+ @Builder.Default
+ private String driver = DEFAULT_DRIVER;
+
+ @Builder.Default
+ private String dbType = DEFAULT_TYPE;
+
/**
* Maximum number of records that can be waiting to be inserted into the DB. When the
* limit is reached, the oldest records are discarded.
diff --git a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
index c3c633674..f5d313adc 100644
--- a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
+++ b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml
@@ -3,7 +3,7 @@
============LICENSE_START=======================================================
drools-applications
================================================================================
- Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2018-2021 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.
@@ -30,7 +30,6 @@
<properties>
<property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
- <property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" />
<property name="eclipselink.logging.level" value="WARNING" />
</properties>
</persistence-unit>
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java
index aeeac4796..97f306528 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/ophistory/OperationHistoryDataManagerParamsTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -37,6 +37,8 @@ public class OperationHistoryDataManagerParamsTest {
private static final int MAX_QUEUE_LENGTH = 20;
private static final String MY_PASS = "my-pass";
private static final String MY_PU = "my-pu";
+ private static final String MY_DRIVER = "my-driver";
+ private static final String MY_DB_TYPE = "my-db-type";
private static final String MY_URL = "my-url";
private static final String MY_USER = "my-user";
@@ -53,11 +55,19 @@ public class OperationHistoryDataManagerParamsTest {
assertEquals(MAX_QUEUE_LENGTH, params.getMaxQueueLength());
assertEquals(MY_PASS, params.getPassword());
assertEquals(OperationHistoryDataManagerParams.DEFAULT_PU, params.getPersistenceUnit());
+ assertEquals(OperationHistoryDataManagerParams.DEFAULT_DRIVER, params.getDriver());
+ assertEquals(OperationHistoryDataManagerParams.DEFAULT_TYPE, params.getDbType());
assertEquals(MY_URL, params.getUrl());
assertEquals(MY_USER, params.getUserName());
// use specified PU
assertEquals(MY_PU, makeBuilder().persistenceUnit(MY_PU).build().getPersistenceUnit());
+
+ // use specified driver
+ assertEquals(MY_DRIVER, makeBuilder().driver(MY_DRIVER).build().getDriver());
+
+ // use specified DB type
+ assertEquals(MY_DB_TYPE, makeBuilder().dbType(MY_DB_TYPE).build().getDbType());
}
@Test
@@ -68,6 +78,8 @@ public class OperationHistoryDataManagerParamsTest {
testValidateField("userName", "null", params2 -> params2.setUserName(null));
testValidateField("password", "null", params2 -> params2.setPassword(null));
testValidateField("persistenceUnit", "null", params2 -> params2.setPersistenceUnit(null));
+ testValidateField("driver", "null", params2 -> params2.setDriver(null));
+ testValidateField("dbType", "null", params2 -> params2.setDbType(null));
// check edge cases
params.setBatchSize(0);