[ 2354040 ] Implementation Replication Mode, Type, Event
http://sourceforge.net/tracker/index.php?func=detail&aid=2354040&group_id=176962&atid=879335
This commit is contained in:
parent
eaac0e16de
commit
1aa6c93344
|
@ -1,18 +1,30 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Contributor(s): Trifon N. Trifonov *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.util.Collection;
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Trifon N. Trifonov
|
* @author Trifon N. Trifonov
|
||||||
|
* @author victor.perez@e-evolution.com, e-Evolution
|
||||||
*/
|
*/
|
||||||
public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
|
|
||||||
|
@ -21,84 +33,73 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static final int REPLICATION_TABLE =0;
|
||||||
|
public static final int REPLICATION_DOCUMENT =1;
|
||||||
|
|
||||||
|
|
||||||
/** Static Logger */
|
/** Static Logger */
|
||||||
private static CLogger s_log = CLogger.getCLogger (MReplicationStrategy.class);
|
private static CLogger s_log = CLogger.getCLogger (MReplicationStrategy.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param ctx
|
||||||
|
* @param AD_ReplicationStrategy_ID
|
||||||
|
* @param trxName
|
||||||
|
*/
|
||||||
public MReplicationStrategy(Properties ctx, int AD_ReplicationStrategy_ID, String trxName) {
|
public MReplicationStrategy(Properties ctx, int AD_ReplicationStrategy_ID, String trxName) {
|
||||||
super(ctx, AD_ReplicationStrategy_ID, trxName);
|
super(ctx, AD_ReplicationStrategy_ID, trxName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public X_AD_ReplicationTable[] getReplicationTables() {
|
/**
|
||||||
List<X_AD_ReplicationTable> resultList = new ArrayList<X_AD_ReplicationTable>();
|
* @return the collection the X_AD_ReplicationTable
|
||||||
|
*/
|
||||||
StringBuffer sql = new StringBuffer("SELECT * ")
|
public Collection <X_AD_ReplicationTable> getReplicationTables() {
|
||||||
.append(" FROM ").append(X_AD_ReplicationTable.Table_Name)
|
String whereClause = new StringBuffer(X_AD_ReplicationTable.COLUMNNAME_AD_ReplicationStrategy_ID)+"=?"; // #1
|
||||||
.append(" WHERE ").append(X_AD_ReplicationTable.COLUMNNAME_AD_ReplicationStrategy_ID).append("=?") // #1
|
return new Query(getCtx(),X_AD_ReplicationTable.Table_Name,whereClause,get_TrxName())
|
||||||
.append(" AND IsActive = ?") // #2
|
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
|
||||||
// .append(" ORDER BY ").append(orderBy)
|
.setApplyAccessFilter(true)
|
||||||
;
|
.list();
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
X_AD_ReplicationTable rplTable = null;
|
|
||||||
try {
|
|
||||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
|
||||||
pstmt.setInt(1, getAD_ReplicationStrategy_ID());
|
|
||||||
pstmt.setString(2, "Y");
|
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
|
||||||
while ( rs.next() ) {
|
|
||||||
rplTable = new X_AD_ReplicationTable (getCtx(), rs, get_TrxName());
|
|
||||||
resultList.add(rplTable);
|
|
||||||
}
|
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
s_log.log(Level.SEVERE, sql.toString(), e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (pstmt != null) pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
} catch (Exception e) { pstmt = null; }
|
|
||||||
}
|
|
||||||
|
|
||||||
X_AD_ReplicationTable[] result = (X_AD_ReplicationTable[])resultList.toArray( new X_AD_ReplicationTable[0]);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public X_AD_ReplicationDocument[] getReplicationDocuments() {
|
/**
|
||||||
List<X_AD_ReplicationDocument> resultList = new ArrayList<X_AD_ReplicationDocument>();
|
* @return the collection the X_AD_ReplicationDocument
|
||||||
|
*/
|
||||||
StringBuffer sql = new StringBuffer("SELECT * ")
|
public Collection<X_AD_ReplicationDocument> getReplicationDocuments() {
|
||||||
.append(" FROM ").append(X_AD_ReplicationDocument.Table_Name)
|
String whereClause = "AD_ReplicationStrategy_ID=?"; // #1
|
||||||
.append(" WHERE ").append(X_AD_ReplicationDocument.COLUMNNAME_AD_ReplicationStrategy_ID).append("=?") // #1
|
return new Query(getCtx(),X_AD_ReplicationDocument.Table_Name,whereClause,get_TrxName())
|
||||||
.append(" AND IsActive = ?") // #2
|
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
|
||||||
// .append(" ORDER BY ").append(orderBy)
|
.setApplyAccessFilter(true)
|
||||||
;
|
.list();
|
||||||
PreparedStatement pstmt = null;
|
}
|
||||||
X_AD_ReplicationDocument rplDocument = null;
|
|
||||||
try {
|
/**
|
||||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
*
|
||||||
pstmt.setInt(1, getAD_ReplicationStrategy_ID());
|
* @param AD_Table_ID
|
||||||
pstmt.setString(2, "Y");
|
* @return X_AD_ReplicationTable table to replication
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
*/
|
||||||
while ( rs.next() ) {
|
public static X_AD_ReplicationTable getReplicationTable(Properties ctx ,int AD_ReplicationStrategy_ID, int AD_Table_ID)
|
||||||
rplDocument = new X_AD_ReplicationDocument (getCtx(), rs, get_TrxName());
|
{
|
||||||
resultList.add(rplDocument);
|
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
|
||||||
}
|
return new Query(ctx,X_AD_ReplicationTable.Table_Name,whereClause, null)
|
||||||
rs.close ();
|
.setApplyAccessFilter(true)
|
||||||
pstmt.close ();
|
.setParameters(new Object[]{AD_ReplicationStrategy_ID,AD_Table_ID})
|
||||||
pstmt = null;
|
.first();
|
||||||
} catch (SQLException e) {
|
}
|
||||||
s_log.log(Level.SEVERE, sql.toString(), e);
|
|
||||||
} finally {
|
/**
|
||||||
try {
|
*
|
||||||
if (pstmt != null) pstmt.close ();
|
* @param AD_Table_ID
|
||||||
pstmt = null;
|
* @return X_AD_ReplicationDocument Document to replication
|
||||||
} catch (Exception e) { pstmt = null; }
|
*/
|
||||||
}
|
public static X_AD_ReplicationDocument getReplicationDocument(Properties ctx ,int AD_ReplicationStrategy_ID , int AD_Table_ID)
|
||||||
|
{
|
||||||
X_AD_ReplicationDocument[] result = (X_AD_ReplicationDocument[])resultList.toArray( new X_AD_ReplicationDocument[0]);
|
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
|
||||||
return result;
|
new Query(ctx ,X_AD_ReplicationDocument.Table_Name,whereClause, null)
|
||||||
|
.setApplyAccessFilter(true)
|
||||||
|
.setParameters(new Object[]{AD_ReplicationStrategy_ID,AD_Table_ID})
|
||||||
|
.first();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue