Skip to content

Commit

Permalink
chore(merge): release-10.2.0 into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bonita-ci committed Sep 18, 2024
2 parents dfc5e1f + ff37067 commit 8afb211
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class BonitaEngine {
private BasicDataSource notManagedBizDataSource;
private javax.transaction.UserTransaction userTransaction;
private javax.transaction.TransactionManager arjunaTransactionManager;
public static final String BONITA_BDM_DB_VENDOR = "sysprop.bonita.bdm.db.vendor";
public static final String BONITA_DB_VENDOR = "sysprop.bonita.db.vendor";
public static final String BONITA_BDM_DB_VENDOR = PlatformSetup.BONITA_BDM_DB_VENDOR_PROPERTY;
public static final String BONITA_DB_VENDOR = PlatformSetup.BONITA_DB_VENDOR_PROPERTY;

public void initializeEnvironment() throws Exception {
if (!initialized) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.bonitasoft.engine.search.SearchOptionsBuilder;
import org.bonitasoft.engine.search.SearchResult;
import org.bonitasoft.engine.session.PlatformSession;
import org.bonitasoft.platform.setup.PlatformSetup;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -734,7 +735,7 @@ public void searchUserSortedById() throws BonitaException {
@Test
public void should_search_user_case_insensitively() throws BonitaException {
Assume.assumeTrue("Search is case sensitive on our docker oracle",
!System.getProperty("sysprop.bonita.bdm.db.vendor").equals("oracle"));
!PlatformSetup.getPropertyBonitaBdmDbVendor().equals("oracle"));
List<User> users = asList(
getIdentityAPI().createUser("Jean_Michel", "bpm", "Jean Michel", "Jarre"),
getIdentityAPI().createUser("michel.mimi", "bpm", "Michel", "Mimi"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.bonitasoft.engine.operation.OperatorType;
import org.bonitasoft.engine.service.ServiceAccessor;
import org.bonitasoft.engine.service.ServiceAccessorSingleton;
import org.bonitasoft.platform.setup.PlatformSetup;
import org.junit.*;
import org.junit.rules.TemporaryFolder;

Expand Down Expand Up @@ -485,7 +486,7 @@ private BusinessObjectModel buildCustomBOM() {

@Test
public void deploy_a_BDR_and_verify_sequence_behaviour_by_DBVendor() throws Exception {
String dbVendor = System.getProperty("sysprop.bonita.bdm.db.vendor");
String dbVendor = PlatformSetup.getPropertyBonitaBdmDbVendor();
Assume.assumeTrue("We don't test sequence behaviour on h2", !dbVendor.equals("h2"));
switch (dbVendor) {
case "postgres":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.bonitasoft.engine.test.ClientEventUtil;
import org.bonitasoft.engine.test.TestEngineImpl;
import org.bonitasoft.engine.util.APITypeManager;
import org.bonitasoft.platform.database.DatabaseVendor;
import org.bonitasoft.platform.setup.PlatformSetup;
import org.bonitasoft.platform.setup.PlatformSetupAccessor;
import org.slf4j.Logger;
Expand Down Expand Up @@ -118,9 +119,10 @@ protected PlatformSetup getPlatformSetup() throws NamingException {

protected void prepareEnvironment() throws Exception {
LOGGER.info("========= PREPARE ENVIRONMENT =======");
String dbVendor = setSystemPropertyIfNotSet("sysprop.bonita.db.vendor", "h2");
String dbVendor = setSystemPropertyIfNotSet(PlatformSetup.BONITA_DB_VENDOR_PROPERTY,
DatabaseVendor.H2.getValue());
//is h2 and not started outside
if (Objects.equals("h2", dbVendor)) {
if (DatabaseVendor.H2.equalsValue(dbVendor)) {
setSystemPropertyIfNotSet(DATABASE_DIR, "build/database");
}
engine.initializeEnvironment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.List;

import org.bonitasoft.platform.configuration.model.FullBonitaConfiguration;
import org.bonitasoft.platform.database.DatabaseVendor;
import org.bonitasoft.platform.setup.PlatformSetup;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.support.lob.TemporaryLobCreator;

Expand All @@ -30,15 +32,12 @@ public class BonitaAllConfigurationPreparedStatementSetter
public static final String INSERT_CONFIGURATION = "INSERT into configuration(tenant_id, content_type, resource_name, resource_content) values (?,?,?,?)";
private final List<FullBonitaConfiguration> bonitaConfigurations;

String dbVendor;
private final String dbVendor;

public BonitaAllConfigurationPreparedStatementSetter(List<FullBonitaConfiguration> bonitaConfigurations,
String dbVendor) {
this.bonitaConfigurations = bonitaConfigurations;
this.dbVendor = dbVendor;
if (this.dbVendor == null) {
this.dbVendor = System.getProperty("sysprop.bonita.db.vendor");
}
this.dbVendor = dbVendor == null ? PlatformSetup.getPropertyBonitaDbVendor() : dbVendor;
}

@Override
Expand All @@ -47,14 +46,11 @@ public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setLong(COLUMN_INDEX_TENANT_ID, bonitaConfiguration.getTenantId());
ps.setString(COLUMN_INDEX_TYPE, bonitaConfiguration.getConfigurationType());
ps.setString(COLUMN_INDEX_RESOURCE_NAME, bonitaConfiguration.getResourceName());
switch (dbVendor) {
case "h2":
case "postgres":
switch (DatabaseVendor.parseValue(dbVendor)) {
case H2, POSTGRES:
ps.setBytes(COLUMN_INDEX_RESOURCE_CONTENT, bonitaConfiguration.getResourceContent());
break;
case "oracle":
case "mysql":
case "sqlserver":
case ORACLE, MYSQL, SQLSERVER:
TemporaryLobCreator temporaryLobCreator = new TemporaryLobCreator();
temporaryLobCreator.setBlobAsBytes(ps, COLUMN_INDEX_RESOURCE_CONTENT,
bonitaConfiguration.getResourceContent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import org.bonitasoft.platform.configuration.model.BonitaConfiguration;
import org.bonitasoft.platform.configuration.type.ConfigurationType;
import org.bonitasoft.platform.database.DatabaseVendor;
import org.bonitasoft.platform.setup.PlatformSetup;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.support.lob.TemporaryLobCreator;

Expand All @@ -30,17 +32,14 @@ public class BonitaConfigurationPreparedStatementSetter implements BatchPrepared
public static final String INSERT_CONFIGURATION = "INSERT into configuration(tenant_id, content_type, resource_name, resource_content) values (?,?,?,?)";
private final List<BonitaConfiguration> bonitaConfigurations;

private String dbVendor;
private ConfigurationType type;
private long tenantId;
private final String dbVendor;
private final ConfigurationType type;
private final long tenantId;

public BonitaConfigurationPreparedStatementSetter(List<BonitaConfiguration> bonitaConfigurations, String dbVendor,
ConfigurationType type, long tenantId) {
this.bonitaConfigurations = bonitaConfigurations;
this.dbVendor = dbVendor;
if (this.dbVendor == null) {
this.dbVendor = System.getProperty("sysprop.bonita.db.vendor");
}
this.dbVendor = dbVendor == null ? PlatformSetup.getPropertyBonitaDbVendor() : dbVendor;
this.type = type;
this.tenantId = tenantId;
}
Expand All @@ -51,16 +50,12 @@ public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setLong(COLUMN_INDEX_TENANT_ID, tenantId);
ps.setString(COLUMN_INDEX_TYPE, type.toString());
ps.setString(COLUMN_INDEX_RESOURCE_NAME, bonitaConfiguration.getResourceName());
switch (dbVendor) {
case "h2":
case "postgres":
switch (DatabaseVendor.parseValue(dbVendor)) {
case H2, POSTGRES:
ps.setBytes(COLUMN_INDEX_RESOURCE_CONTENT, bonitaConfiguration.getResourceContent());
break;
case "oracle":
case "mysql":
case "sqlserver":
TemporaryLobCreator temporaryLobCreator = new TemporaryLobCreator();
temporaryLobCreator.setBlobAsBytes(ps, COLUMN_INDEX_RESOURCE_CONTENT,
case ORACLE, MYSQL, SQLSERVER:
new TemporaryLobCreator().setBlobAsBytes(ps, COLUMN_INDEX_RESOURCE_CONTENT,
bonitaConfiguration.getResourceContent());
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.bonitasoft.platform.configuration.model.BonitaConfiguration;
import org.bonitasoft.platform.configuration.type.ConfigurationType;
import org.bonitasoft.platform.database.DatabaseVendor;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.support.lob.TemporaryLobCreator;

Expand All @@ -30,8 +31,8 @@ public class BonitaConfigurationTenantUpdater implements BatchPreparedStatementS
public static final String UPDATE_ALL_TENANTS_CONFIGURATION = "UPDATE configuration SET resource_content=? WHERE content_type=? AND resource_name=?";

private final List<BonitaConfiguration> bonitaConfigurations;
private String dbVendor;
private ConfigurationType type;
private final String dbVendor;
private final ConfigurationType type;

public BonitaConfigurationTenantUpdater(List<BonitaConfiguration> bonitaConfigurations, String dbVendor,
ConfigurationType type) {
Expand All @@ -45,14 +46,11 @@ public void setValues(PreparedStatement ps, int i) throws SQLException {
final BonitaConfiguration bonitaConfiguration = bonitaConfigurations.get(i);
ps.setString(2, type.toString());
ps.setString(3, bonitaConfiguration.getResourceName());
switch (dbVendor) {
case "h2":
case "postgres":
switch (DatabaseVendor.parseValue(dbVendor)) {
case H2, POSTGRES:
ps.setBytes(1, bonitaConfiguration.getResourceContent());
break;
case "oracle":
case "mysql":
case "sqlserver":
case ORACLE, MYSQL, SQLSERVER:
new TemporaryLobCreator().setBlobAsBytes(ps, 1, bonitaConfiguration.getResourceContent());
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (C) 2024 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301, USA.
**/
package org.bonitasoft.platform.database;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum DatabaseVendor {

H2("h2"), //
MYSQL("mysql"), //
ORACLE("oracle"), //
POSTGRES("postgres"), //
SQLSERVER("sqlserver");

private final String value;

public static DatabaseVendor parseValue(String databaseVendorValue) {
for (DatabaseVendor databaseVendor : DatabaseVendor.values()) {
if (databaseVendor.value.equalsIgnoreCase(databaseVendorValue)) {
return databaseVendor;
}
}
throw new IllegalArgumentException("Unknown database vendor: " + databaseVendorValue);
}

public boolean equalsValue(String anotherValue) {
return value.equals(anotherValue);
}
}
Loading

0 comments on commit 8afb211

Please sign in to comment.