use of javax.sql.RowSet 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();
}
use of javax.sql.RowSet in project adempiere by adempiere.
the class ReplicationLocal method sendUpdates.
// getKeyColumns
/*************************************************************************/
/**
* Send Updates to Remote (i.e. r/o on remote)
* @throws Exception
*/
private void sendUpdates() throws Exception {
log.info("sendUpdates");
//
String sql = "SELECT rt.AD_Table_ID, rt.ReplicationType, t.TableName, rt.AD_ReplicationTable_ID " + "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=?" + // Reference
" AND rt.ReplicationType='R' " + "ORDER BY t.LoadSeq";
RowSet rowset = getRowSet(sql, new Object[] { new Integer(m_replication.getAD_ReplicationStrategy_ID()) });
try {
while (rowset.next()) sendUpdatesTable(rowset.getInt(1), rowset.getString(3), rowset.getInt(4));
rowset.close();
} catch (SQLException ex) {
log.log(Level.SEVERE, "sendUpdates", ex);
m_replicated = false;
}
}
use of javax.sql.RowSet in project adempiere by adempiere.
the class ReplicationRemote method mergeDataWithCentral.
// setupRemoteAD_Table
/*************************************************************************
/**
* Send new Data from Remote.
* Transcation Data changed
* @return info
* @throws Exception
*/
private String mergeDataWithCentral() throws Exception {
ProcessInfo pi = getProcessInfo();
RemoteMergeDataVO data = (RemoteMergeDataVO) pi.getSerializableObject();
log.info("mergeDataWithCentral Start (" + pi + ") " + data);
// Merge Data from Central
RowSet sourceRS = data.CentralData;
if (sourceRS == null)
log.log(Level.SEVERE, "mergeDataWithCentral - No Data - " + data);
else if (!data.Test.booleanValue()) {
RowSet targetRS = ReplicationLocal.getRowSet(data.Sql, null);
Object result = doIt(ReplicationLocal.START, "sync", new // Merge
Object[] { data.TableName, data.KeyColumns, sourceRS, targetRS, data.Test, Boolean.TRUE });
log.fine("receiveUpdateFromCentral - " + data.TableName + " - " + result);
pi.setSerializableObject(null);
boolean replicated = ReplicationLocal.isReplicated(result);
if (!replicated)
pi.setError(true);
if (result != null)
pi.addLog(0, null, null, result.toString());
if (Boolean.FALSE.equals(result))
throw new Exception("receiveUpdateFromCentral - " + data.TableName + " - " + result);
}
// Local Remote Data
RowSet rowset = ReplicationLocal.getRowSet(data.Sql, null);
// Result
pi.setSerializableObject((Serializable) rowset);
log.info("mergeDataWithCentral End (" + pi + ") " + data);
return "Remote MergeDataWithCentral - " + data.TableName;
}
use of javax.sql.RowSet in project adempiere by adempiere.
the class AReport method getPrintFormats.
/**
* Get the Print Formats for the table.
* Fill the list and the popup menu
* @param AD_Table_ID table
* @param invoker component to display popup (optional)
*/
private void getPrintFormats(int AD_Table_ID, JComponent invoker) {
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
RowSet rowSet = MPrintFormat.getAccessiblePrintFormats(AD_Table_ID, -1, null);
KeyNamePair pp = null;
try {
while (rowSet.next()) {
pp = new KeyNamePair(rowSet.getInt(1), rowSet.getString(2));
if (rowSet.getInt(3) == AD_Client_ID) {
m_list.add(pp);
m_popup.add(pp.toString()).addActionListener(this);
}
}
} catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
// No Format exists - create it
if (m_list.size() == 0) {
if (pp == null)
// calls launch
createNewFormat(AD_Table_ID);
else
// copies that last format. What if there were several?
copyFormat(pp.getKey(), AD_Client_ID);
} else // One Format exists or no invoker - show it
if (m_list.size() == 1 || invoker == null)
launchReport((KeyNamePair) m_list.get(0));
else // Multiple Formats exist - show selection
if (invoker.isShowing())
// below button
m_popup.show(invoker, 0, invoker.getHeight());
}
Aggregations