- change hardcoded values to be configurable.
Issue-ID: POLICY-5107
Change-Id: I2176cb136c6a5d9cdf6153730e209418dec7bc3c
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Number of records that have been inserted into the DB by this data manager
- * instance, whether or not they were committed.
+ * instance, whether they were committed.
*/
@Getter
private long recordsInserted = 0;
/**
* Number of records that have been updated within the DB by this data manager
- * instance, whether or not they were committed.
+ * instance, whether they were committed.
*/
@Getter
private long recordsUpdated = 0;
props.put("jakarta.persistence.jdbc.url", params.getUrl());
props.put("jakarta.persistence.jdbc.user", params.getUserName());
props.put("jakarta.persistence.jdbc.password", params.getPassword());
- props.put("hibernate.dialect", params.getDbHibernateDialect());
return props;
}
// the following may be overridden by junit tests
protected EntityManagerFactory makeEntityManagerFactory(String opsHistPu, Properties props) {
+ logger.info("Starting persistence unit {}", opsHistPu);
+ logger.info("Properties {}", props);
return Persistence.createEntityManagerFactory(opsHistPu, props);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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 = "MariaDB";
@NotBlank
private String url;
@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.
public ValidationResult validate(String resultName) {
return new BeanValidator().validateTop(resultName, this);
}
-
- /**
- * Return the Hibernate dialect for the database type.
- * @return the dialect
- */
- public Object getDbHibernateDialect() {
- return "org.hibernate.dialect." + dbType + "Dialect";
- }
}
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>org.onap.policy.guard.OperationsHistory</class>
<properties>
- <property name="jakarta.persistence.schema-generation.database.action" value="create"/>
+ <property name="jakarta.persistence.schema-generation.database.action" value="none"/>
<property name="hibernate.show_sql" value="false"/>
</properties>
</persistence-unit>
private static OperationHistoryDataManagerParamsBuilder makeBuilder() {
return OperationHistoryDataManagerParams.builder()
.url("jdbc:h2:mem:" + OperationHistoryDataManagerImplTest.class.getSimpleName())
- .dbType("H2")
.driver("org.h2.Driver")
.userName("sa")
.password("")
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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";
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 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
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);
operation.history.url=${envd:JDBC_URL}operationshistory${envd:JDBC_OPTS}
operation.history.userName=${envd:SQL_USER}
operation.history.password=${envd:SQL_PASSWORD}
+operation.history.driver=${envd:JDBC_DRIVER}
#
# Actor parameters
#
# Note: every operation must have at least one entry, otherwise it will not be
-# configured and started. Thus some of them have a "placeholder" property.
+# configured and started. Thus, some of them have a "placeholder" property.
#
actor.service.XACML.disabled=${envd:GUARD_DISABLED:false}