Commit baac7ded authored by Luna Riegel's avatar Luna Riegel
Browse files

Feature: Add tempfile-mode flag to db settings

parent 50d7e64f
...@@ -50,10 +50,12 @@ public final class DataBaseSettings { ...@@ -50,10 +50,12 @@ public final class DataBaseSettings {
String inMemoryModeString = props.getProperty("inMemoryMode"); String inMemoryModeString = props.getProperty("inMemoryMode");
String attemptFallbackString = props.getProperty("attemptFallback"); String attemptFallbackString = props.getProperty("attemptFallback");
String debugModeString = props.getProperty("debugMode"); String debugModeString = props.getProperty("debugMode");
String tempModeString = props.getProperty("tempMode");
boolean inMemoryMode = Boolean.parseBoolean(inMemoryModeString); boolean inMemoryMode = Boolean.parseBoolean(inMemoryModeString);
boolean attemptFallback = attemptFallbackString == null || Boolean.parseBoolean(attemptFallbackString); boolean attemptFallback = attemptFallbackString == null || Boolean.parseBoolean(attemptFallbackString);
boolean debugMode = Boolean.parseBoolean(debugModeString); boolean debugMode = Boolean.parseBoolean(debugModeString);
boolean tempMode = Boolean.parseBoolean(tempModeString);
int poolSize; int poolSize;
try { try {
poolSize = Integer.parseInt(poolSizeString); poolSize = Integer.parseInt(poolSizeString);
...@@ -86,7 +88,7 @@ public final class DataBaseSettings { ...@@ -86,7 +88,7 @@ public final class DataBaseSettings {
} }
} }
return new EmbeddedDatabaseConfiguration(name, directory, poolSize, inMemoryMode, attemptFallback, debugMode); return new EmbeddedDatabaseConfiguration(name, directory, poolSize, inMemoryMode, attemptFallback, debugMode, tempMode);
} }
} }
...@@ -14,9 +14,11 @@ import java.io.File; ...@@ -14,9 +14,11 @@ import java.io.File;
* database-file fails. Will be ignored if inMemoryMode is true * database-file fails. Will be ignored if inMemoryMode is true
* @param debugMode If true, CityDoctor will start the embedded database in automatic mixed mode to allow access to the * @param debugMode If true, CityDoctor will start the embedded database in automatic mixed mode to allow access to the
* database during runtime. * database during runtime.
* @param tempFileMode If true, CityDoctor will create the database in the system's temp directory. Will be ignored if
* inMemoryMode is true
*/ */
public record EmbeddedDatabaseConfiguration(String databaseName, String databaseDirectory, int connectionPoolSize, public record EmbeddedDatabaseConfiguration(String databaseName, String databaseDirectory, int connectionPoolSize,
boolean inMemoryMode, boolean attemptFallback, boolean debugMode) { boolean inMemoryMode, boolean attemptFallback, boolean debugMode, boolean tempFileMode) {
private static final String IN_MEMORY_PREFIX= "jdbc:h2:mem"; private static final String IN_MEMORY_PREFIX= "jdbc:h2:mem";
private static final String AUTO_SERVER_PARAMETER = ";AUTO_SERVER=TRUE"; private static final String AUTO_SERVER_PARAMETER = ";AUTO_SERVER=TRUE";
...@@ -25,7 +27,12 @@ public record EmbeddedDatabaseConfiguration(String databaseName, String database ...@@ -25,7 +27,12 @@ public record EmbeddedDatabaseConfiguration(String databaseName, String database
*/ */
EmbeddedDatabaseConfiguration() { EmbeddedDatabaseConfiguration() {
this("cd_db", File.separator + "database"+ File.separator, Runtime.getRuntime().availableProcessors(), this("cd_db", File.separator + "database"+ File.separator, Runtime.getRuntime().availableProcessors(),
false, true, false); false, true, false, false);
}
public static EmbeddedDatabaseConfiguration getTestConfig() {
return new EmbeddedDatabaseConfiguration("cd_db", File.separator + "database"+ File.separator, Runtime.getRuntime().availableProcessors(),
true, true, true, false);
} }
public String getInMemoryH2Url() { public String getInMemoryH2Url() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment