Skip to content

Commit

Permalink
added configurable node filter
Browse files Browse the repository at this point in the history
  • Loading branch information
firestar committed Aug 17, 2024
1 parent 8949790 commit bd1838a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencyManagement {
}
}
group = 'com.nucleodb'
version = '3.5.0'
version = '3.5.1'

repositories {
mavenCentral()
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/nucleodb/spring/NDBRepositoryFactoryBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.nucleodb.library.database.modifications.Delete;
import com.nucleodb.library.database.modifications.Update;
import com.nucleodb.library.database.tables.connection.Connection;
import com.nucleodb.library.database.tables.connection.NodeFilter;
import com.nucleodb.library.database.tables.table.DataEntry;
import com.nucleodb.library.database.utils.exceptions.IncorrectDataEntryClassException;
import com.nucleodb.library.database.utils.exceptions.MissingDataEntryConstructorsException;
Expand Down Expand Up @@ -39,6 +40,8 @@ public class NDBRepositoryFactoryBean<T extends Repository<S, ID>, S, ID>

private @NonNull String[] scanPackages;
private @NonNull String mqsConfiguration;
private @NonNull String nodeFilterConnection;
private @NonNull String nodeFilterDataEntry;
private @NonNull String readToTime;
private @NonNull NucleoDB.DBType dbType;

Expand All @@ -64,6 +67,9 @@ protected RepositoryFactorySupport createRepositoryFactory() {
try {
MQSConfiguration mqsConfigurationInstance = (MQSConfiguration) Class.forName(mqsConfiguration).getDeclaredConstructor().newInstance();

NodeFilter connectionNodeFilter = (NodeFilter) Class.forName(nodeFilterConnection).getDeclaredConstructor().newInstance();
com.nucleodb.library.database.tables.table.NodeFilter dataEntryNodeFilter = (com.nucleodb.library.database.tables.table.NodeFilter) Class.forName(nodeFilterDataEntry).getDeclaredConstructor().newInstance();

boolean jsonExport = Boolean.valueOf(getenv.getOrDefault("NDB_TOPIC_EXPORT","false"));
boolean storeState = Boolean.valueOf(getenv.getOrDefault("NDB_STORE_STATE","false"));
boolean loadState = Boolean.valueOf(getenv.getOrDefault("NDB_LOAD_STATE","false"));
Expand All @@ -80,6 +86,7 @@ protected RepositoryFactorySupport createRepositoryFactory() {
c.getConnectionConfig().setJsonExport(jsonExport);
c.getConnectionConfig().setSaveChanges(storeState);
c.getConnectionConfig().setLoadSaved(loadState);
c.getConnectionConfig().setNodeFilter(connectionNodeFilter);
c.getConnectionConfig().setConnectionFileName(
Path.of(saveDirectory, "conn_"+c.getConnectionConfig().getLabel()+".dat")
.toAbsolutePath()
Expand All @@ -92,6 +99,7 @@ protected RepositoryFactorySupport createRepositoryFactory() {
c.getDataTableConfig().setJsonExport(jsonExport);
c.getDataTableConfig().setSaveChanges(storeState);
c.getDataTableConfig().setLoadSave(loadState);
c.getDataTableConfig().setNodeFilter(dataEntryNodeFilter);
c.getDataTableConfig().setTableFileName(
Path.of(saveDirectory, "de_"+c.getDataTableConfig().getTable()+".dat")
.toAbsolutePath()
Expand All @@ -111,6 +119,7 @@ protected RepositoryFactorySupport createRepositoryFactory() {
c.getConnectionConfig().setEventListener(connectionEventListener);
c.getConnectionConfig().setJsonExport(jsonExport);
c.getConnectionConfig().setSaveChanges(storeState);
c.getConnectionConfig().setNodeFilter(connectionNodeFilter);
c.getConnectionConfig().setLoadSaved(loadState);
c.getConnectionConfig().setConnectionFileName(
Path.of(saveDirectory, "conn_"+c.getConnectionConfig().getLabel()+".dat")
Expand All @@ -123,6 +132,7 @@ protected RepositoryFactorySupport createRepositoryFactory() {
c.getDataTableConfig().setEventListener(dataTableEventListener);
c.getDataTableConfig().setJsonExport(jsonExport);
c.getDataTableConfig().setSaveChanges(storeState);
c.getDataTableConfig().setNodeFilter(dataEntryNodeFilter);
c.getDataTableConfig().setLoadSave(loadState);
c.getDataTableConfig().setTableFileName(
Path.of(saveDirectory, "de_"+c.getDataTableConfig().getTable()+".dat")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

String mqsConfiguration() default "com.nucleodb.library.mqs.kafka.KafkaConfiguration";

String nodeFilterConnection() default "com.nucleodb.library.database.tables.connection.NodeFilter";
String nodeFilterDataEntry() default "com.nucleodb.library.database.tables.table.NodeFilter";

String readToTime() default "";

String[] scanPackages() default {"com.nucleocore.library.database.tables.connection"};
Expand Down

0 comments on commit bd1838a

Please sign in to comment.