Search in sources :

Example 1 with MReplicationRun

use of org.compiere.model.MReplicationRun in project adempiere by adempiere.

the class ReplicationLocal method setupRemote.

//	connectRemote
/**
	 *	Setup Remote AD_System/AD_Table/AD_Sequence for Remote Management.
	 * 	@throws Exception
	 */
private void setupRemote() throws Exception {
    log.info("setupRemote");
    //
    String sql = "SELECT rt.AD_Table_ID, rt.ReplicationType, t.TableName " + "FROM AD_ReplicationTable rt" + " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID) " + "WHERE rt.IsActive='Y' AND t.IsActive='Y'" + //	#1
    " AND AD_ReplicationStrategy_ID=? " + "ORDER BY t.LoadSeq";
    RowSet rowset = getRowSet(sql, new Object[] { new Integer(m_replication.getAD_ReplicationStrategy_ID()) });
    if (rowset == null)
        throw new Exception("setupRemote - No RowSet Data");
    //	Data Info
    RemoteSetupVO data = new RemoteSetupVO();
    data.Test = m_test;
    //	RowSet
    data.ReplicationTable = rowset;
    data.IDRangeStart = m_replication.getIDRangeStart();
    data.IDRangeEnd = m_replication.getIDRangeEnd();
    data.AD_Client_ID = m_replication.getRemote_Client_ID();
    data.AD_Org_ID = m_replication.getRemote_Org_ID();
    data.Prefix = m_replication.getPrefix();
    data.Suffix = m_replication.getSuffix();
    //	Process Info
    ProcessInfo pi = new ProcessInfo(data.toString(), 0);
    pi.setClassName(REMOTE);
    pi.setSerializableObject(data);
    Object result = doIt(START, "init", new Object[] { m_system });
    if (result == null || !Boolean.TRUE.equals(result))
        throw new Exception("setupRemote - Init Error - " + result);
    //	send it
    pi = m_serverRemote.process(new Properties(), pi);
    ProcessInfoLog[] logs = pi.getLogs();
    Timestamp dateRun = null;
    if (logs != null && logs.length > 0)
        //	User Remote Timestamp!
        dateRun = logs[0].getP_Date();
    //
    log.info("setupRemote - " + pi + " - Remote Timestamp = " + dateRun);
    if (dateRun != null)
        m_replicationStart = dateRun;
    m_replicationRun = new MReplicationRun(getCtx(), m_replication.getAD_Replication_ID(), m_replicationStart, get_TrxName());
    m_replicationRun.saveEx();
}
Also used : RowSet(javax.sql.RowSet) CCachedRowSet(org.compiere.util.CCachedRowSet) MReplicationRun(org.compiere.model.MReplicationRun) Properties(java.util.Properties) Timestamp(java.sql.Timestamp) SQLException(java.sql.SQLException)

Aggregations

SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 Properties (java.util.Properties)1 RowSet (javax.sql.RowSet)1 MReplicationRun (org.compiere.model.MReplicationRun)1 CCachedRowSet (org.compiere.util.CCachedRowSet)1