01: package com.xoetrope.service.replication.mssql;
02:
03: import net.xoetrope.optional.data.sql.DataConnection;
04: import net.xoetrope.xui.XProject;
05:
06: public class XMsSqlReplicationEngine extends
07: com.xoetrope.service.XReplicationEngine {
08: /**
09: * Creates a new instance of <code>XMsSqlReplicationEngine</code>
10: * @param project the current project.
11: * @param dataConnection associated DataConnection object.
12: */
13: public XMsSqlReplicationEngine(XProject project,
14: DataConnection dataConnection) {
15: super (project, dataConnection);
16: }
17:
18: protected void tagLocalTable(String tableName) {
19: if (!tableName.startsWith("XSYS")) {
20: String sql = "CREATE TRIGGER " + tableName
21: + "_DeleteTrigger ON " + tableName
22: + " FOR DELETE AS " + " BEGIN "
23: + " SET NOCOUNT ON; "
24: + " INSERT INTO XSYSLOCALDELETIONS SELECT '"
25: + tableName + "',PSEUDOID,GETDATE() FROM deleted;"
26: + " END";
27: dataConnection.doUpdate(sql);
28: }
29:
30: }
31:
32: protected void createTimestampTables() {
33: if (dataConnection
34: .doUpdate("CREATE TABLE XSYSLOCALTIMESTAMPS (tableName VARCHAR(64), lastUpdate DATETIME, maxPseudoID INT)") != Integer.MIN_VALUE) {
35: dataConnection
36: .doUpdate("CREATE TABLE XSYSSERVERTIMESTAMPS (tableName VARCHAR(64), lastUpdate DATETIME, lastDelete DATETIME)");
37: dataConnection
38: .doUpdate("CREATE TABLE XSYSLOCALDELETIONS (tableName VARCHAR(64), pseudoId INT, deleteDate DATETIME)");
39: hasTimeStamps = true;
40: }
41: }
42:
43: }
|