View Javadoc

1   package org.jumpmind.symmetric.ext;
2   
3   import org.jumpmind.symmetric.load.IDataLoaderContext;
4   import org.jumpmind.symmetric.load.INodeGroupDataLoaderFilter;
5   
6   abstract public class AbstractTableDataLoaderFilter implements INodeGroupDataLoaderFilter {
7   
8       private boolean autoRegister = true;
9   
10      private String[] nodeGroupIdsToApplyTo;
11  
12      private boolean loadDataInTargetDatabase = true;
13  
14      private String tableName;
15  
16      public boolean filterDelete(IDataLoaderContext context, String[] keyValues) {
17          if (context.getTableName().equals(tableName)) {
18              filterDeleteForTable(context, keyValues);
19          }
20          return loadDataInTargetDatabase;
21      }
22  
23      abstract protected void filterDeleteForTable(IDataLoaderContext context, String[] keyValues);
24  
25      public boolean filterInsert(IDataLoaderContext context, String[] columnValues) {
26          if (context.getTableName().equals(tableName)) {
27              filterInsertForTable(context, columnValues);
28          }
29          return loadDataInTargetDatabase;
30      }
31  
32      abstract protected void filterInsertForTable(IDataLoaderContext context, String[] columnValues);
33  
34      public boolean filterUpdate(IDataLoaderContext context, String[] columnValues, String[] keyValues) {
35          if (context.getTableName().equals(tableName)) {
36              filterUpdateForTable(context, columnValues, keyValues);
37          }
38          return loadDataInTargetDatabase;
39      }
40  
41      abstract protected void filterUpdateForTable(IDataLoaderContext context, String[] columnValues, String[] keyValues);
42  
43      public boolean isAutoRegister() {
44          return this.autoRegister;
45      }
46  
47      public String[] getNodeGroupIdsToApplyTo() {
48          return this.nodeGroupIdsToApplyTo;
49      }
50  
51      public void setAutoRegister(boolean autoRegister) {
52          this.autoRegister = autoRegister;
53      }
54  
55      public void setNodeGroupIdsToApplyTo(String[] nodeGroupIdsToApplyTo) {
56          this.nodeGroupIdsToApplyTo = nodeGroupIdsToApplyTo;
57      }
58  
59      public void setNodeGroupIdToApplyTo(String nodeGroupId) {
60          this.nodeGroupIdsToApplyTo = new String[] { nodeGroupId };
61      }
62  
63      public void setLoadDataInTargetDatabase(boolean loadDataInTargetDatabase) {
64          this.loadDataInTargetDatabase = loadDataInTargetDatabase;
65      }
66  
67      public void setTableName(String tableName) {
68          this.tableName = tableName;
69      }
70  
71  }