AbstractConvertContext.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package org.dbsyncer.common.model;
  2. import org.dbsyncer.common.spi.ConnectorMapper;
  3. import org.dbsyncer.common.spi.ConvertContext;
  4. import org.dbsyncer.common.spi.ProxyApplicationContext;
  5. import java.util.List;
  6. import java.util.Map;
  7. /**
  8. * @author AE86
  9. * @version 1.0.0
  10. * @date 2022/6/30 16:00
  11. */
  12. public abstract class AbstractConvertContext implements ConvertContext {
  13. /**
  14. * 是否终止任务
  15. * <p>true:目标源不再接收同步数据,默认值false
  16. */
  17. private boolean terminated;
  18. /**
  19. * Spring上下文
  20. */
  21. protected ProxyApplicationContext context;
  22. /**
  23. * 数据源连接实例
  24. */
  25. protected ConnectorMapper sourceConnectorMapper;
  26. /**
  27. * 目标源连接实例
  28. */
  29. protected ConnectorMapper targetConnectorMapper;
  30. /**
  31. * 数据源表
  32. */
  33. protected String sourceTableName;
  34. /**
  35. * 目标源表
  36. */
  37. protected String targetTableName;
  38. /**
  39. * 同步事件(INSERT/UPDATE/DELETE)
  40. */
  41. protected String event;
  42. /**
  43. * 数据源数据集合
  44. */
  45. protected List<Map> sourceList;
  46. /**
  47. * 目标源源数据集合
  48. */
  49. protected List<Map> targetList;
  50. public void init(ConnectorMapper sourceConnectorMapper, ConnectorMapper targetConnectorMapper, String sourceTableName, String targetTableName, String event,
  51. List<Map> sourceList, List<Map> targetList) {
  52. this.sourceConnectorMapper = sourceConnectorMapper;
  53. this.targetConnectorMapper = targetConnectorMapper;
  54. this.sourceTableName = sourceTableName;
  55. this.targetTableName = targetTableName;
  56. this.event = event;
  57. this.sourceList = sourceList;
  58. this.targetList = targetList;
  59. }
  60. public void setContext(ProxyApplicationContext context) {
  61. this.context = context;
  62. }
  63. @Override
  64. public boolean isTerminated() {
  65. return terminated;
  66. }
  67. @Override
  68. public void setTerminated(boolean terminated) {
  69. this.terminated = terminated;
  70. }
  71. @Override
  72. public ProxyApplicationContext getContext() {
  73. return context;
  74. }
  75. @Override
  76. public ConnectorMapper getSourceConnectorMapper() {
  77. return sourceConnectorMapper;
  78. }
  79. @Override
  80. public ConnectorMapper getTargetConnectorMapper() {
  81. return targetConnectorMapper;
  82. }
  83. @Override
  84. public String getSourceTableName() {
  85. return sourceTableName;
  86. }
  87. @Override
  88. public String getTargetTableName() {
  89. return targetTableName;
  90. }
  91. @Override
  92. public String getEvent() {
  93. return event;
  94. }
  95. @Override
  96. public List<Map> getSourceList() {
  97. return sourceList;
  98. }
  99. public void setSourceList(List<Map> sourceList) {
  100. this.sourceList = sourceList;
  101. }
  102. @Override
  103. public List<Map> getTargetList() {
  104. return targetList;
  105. }
  106. public void setTargetList(List<Map> targetList) {
  107. this.targetList = targetList;
  108. }
  109. }