The document replication not working
kind regards Victor Perez www.e-evolution.com Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2947615
This commit is contained in:
parent
cdb6040076
commit
6da7726327
|
@ -24,7 +24,7 @@
|
||||||
* - Trifon Trifonov (trifonnt@users.sourceforge.net) *
|
* - Trifon Trifonov (trifonnt@users.sourceforge.net) *
|
||||||
* *
|
* *
|
||||||
* Sponsors: *
|
* Sponsors: *
|
||||||
* - E-evolution (http://www.e-evolution.com) *
|
* - e-Evolution (http://www.e-evolution.com) *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
package org.adempiere.model;
|
package org.adempiere.model;
|
||||||
|
@ -39,6 +39,7 @@ import org.compiere.model.PO;
|
||||||
import org.compiere.model.X_AD_ReplicationDocument;
|
import org.compiere.model.X_AD_ReplicationDocument;
|
||||||
import org.compiere.model.X_AD_ReplicationTable;
|
import org.compiere.model.X_AD_ReplicationTable;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,11 +51,15 @@ import org.compiere.util.CLogger;
|
||||||
* <li> https://sourceforge.net/tracker/?func=detail&aid=2875989&group_id=176962&atid=879332
|
* <li> https://sourceforge.net/tracker/?func=detail&aid=2875989&group_id=176962&atid=879332
|
||||||
* <li>[ 2195090 ] Stabilization of replication
|
* <li>[ 2195090 ] Stabilization of replication
|
||||||
* <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962
|
* <li>https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2936561&group_id=176962
|
||||||
|
* <li> BF2947615 The document recplicacion not working
|
||||||
|
* <li> https://sourceforge.net/tracker/?func=detail&aid=2947615&group_id=176962&atid=879332
|
||||||
*
|
*
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class ExportModelValidator implements ModelValidator
|
public class ExportModelValidator implements ModelValidator
|
||||||
{
|
{
|
||||||
|
/** Context variable which says if replication is enabled */
|
||||||
|
public static final String CTX_IsReplicationEnabled = "#IsReplicationEnabled";
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger(ExportModelValidator.class);
|
private static CLogger log = CLogger.getCLogger(ExportModelValidator.class);
|
||||||
|
@ -129,8 +134,8 @@ public class ExportModelValidator implements ModelValidator
|
||||||
if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType())
|
if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType())
|
||||||
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType()))
|
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType()))
|
||||||
{
|
{
|
||||||
MTable table = MTable.get (client.getCtx(), rplTable.getAD_Table_ID());
|
String tableName = MTable.getTableName(client.getCtx(), rplTable.getAD_Table_ID());
|
||||||
engine.addModelChange(table.getTableName(), this);
|
engine.addModelChange(tableName, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,9 +146,8 @@ public class ExportModelValidator implements ModelValidator
|
||||||
if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType())
|
if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType())
|
||||||
|| X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType()))
|
|| X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType()))
|
||||||
{
|
{
|
||||||
//MDocType docType = MDocType.get(client.getCtx(), rplDocuments[i].getC_DocType_ID());
|
String tableName = MTable.getTableName(client.getCtx(), rplDocument.getAD_Table_ID());
|
||||||
MTable table = MTable.get (client.getCtx(), rplDocument.getAD_Table_ID());
|
engine.addDocValidate(tableName, this);
|
||||||
engine.addDocValidate(table.getTableName(), this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,12 +171,18 @@ public class ExportModelValidator implements ModelValidator
|
||||||
|| type == TYPE_AFTER_NEW
|
|| type == TYPE_AFTER_NEW
|
||||||
|| type == TYPE_BEFORE_DELETE) // After Change or After New
|
|| type == TYPE_BEFORE_DELETE) // After Change or After New
|
||||||
{
|
{
|
||||||
expHelper.exportRecord( po,
|
X_AD_ReplicationTable replicationTable = MReplicationStrategy.getReplicationTable(
|
||||||
|
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID());
|
||||||
|
if (replicationTable != null)
|
||||||
|
{
|
||||||
|
expHelper.exportRecord(
|
||||||
|
po,
|
||||||
MReplicationStrategy.REPLICATION_TABLE,
|
MReplicationStrategy.REPLICATION_TABLE,
|
||||||
MReplicationStrategy.getReplicationTable(po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID()).getReplicationType(),
|
replicationTable.getReplicationType(),
|
||||||
type);
|
type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +198,7 @@ public class ExportModelValidator implements ModelValidator
|
||||||
*/
|
*/
|
||||||
public String docValidate (PO po, int type)
|
public String docValidate (PO po, int type)
|
||||||
{
|
{
|
||||||
log.info("po.get_TableName() = " + po.get_TableName());
|
log.info("Replicate the Document = " + po.get_TableName() + " with Type = " + type);
|
||||||
String result = null;
|
String result = null;
|
||||||
if (expHelper != null) {
|
if (expHelper != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -196,13 +206,30 @@ public class ExportModelValidator implements ModelValidator
|
||||||
|| type == TIMING_AFTER_CLOSE
|
|| type == TIMING_AFTER_CLOSE
|
||||||
|| type == TIMING_AFTER_REVERSECORRECT
|
|| type == TIMING_AFTER_REVERSECORRECT
|
||||||
|| type == TIMING_AFTER_VOID
|
|| type == TIMING_AFTER_VOID
|
||||||
|| type == TIMING_AFTER_PREPARE
|
//|| type == TIMING_AFTER_PREPARE
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
expHelper.exportRecord( po,
|
X_AD_ReplicationDocument replicationDocument = null;
|
||||||
MReplicationStrategy.REPLICATION_DOCUMENT ,
|
int C_DocType_ID = po.get_ValueAsInt("C_DocType_ID");
|
||||||
MReplicationStrategy.getReplicationDocument(po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID()).getReplicationType(),
|
if (C_DocType_ID > 0)
|
||||||
|
{
|
||||||
|
replicationDocument = MReplicationStrategy.getReplicationDocument(
|
||||||
|
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID(), C_DocType_ID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
replicationDocument = MReplicationStrategy.getReplicationDocument(
|
||||||
|
po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (replicationDocument != null) {
|
||||||
|
expHelper.exportRecord(
|
||||||
|
po,
|
||||||
|
MReplicationStrategy.REPLICATION_DOCUMENT,
|
||||||
|
replicationDocument.getReplicationType(),
|
||||||
type);
|
type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -223,6 +250,7 @@ public class ExportModelValidator implements ModelValidator
|
||||||
*/
|
*/
|
||||||
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
|
public String login (int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
|
||||||
{
|
{
|
||||||
|
Env.setContext(Env.getCtx(), CTX_IsReplicationEnabled, true);
|
||||||
m_AD_Org_ID = AD_Org_ID;
|
m_AD_Org_ID = AD_Org_ID;
|
||||||
m_AD_Role_ID = AD_Role_ID;
|
m_AD_Role_ID = AD_Role_ID;
|
||||||
m_AD_User_ID = AD_User_ID;
|
m_AD_User_ID = AD_User_ID;
|
||||||
|
|
|
@ -27,6 +27,8 @@ import org.compiere.util.CLogger;
|
||||||
* @author victor.perez@e-evolution.com, e-Evolution
|
* @author victor.perez@e-evolution.com, e-Evolution
|
||||||
* <li> BF2875989 Deactivate replication records are include to replication
|
* <li> BF2875989 Deactivate replication records are include to replication
|
||||||
* <li> https://sourceforge.net/tracker/?func=detail&aid=2875989&group_id=176962&atid=879332
|
* <li> https://sourceforge.net/tracker/?func=detail&aid=2875989&group_id=176962&atid=879332
|
||||||
|
* <li> BF2947615 The document recplicacion not working
|
||||||
|
* <li> https://sourceforge.net/tracker/?func=detail&aid=2947615&group_id=176962&atid=879332
|
||||||
*/
|
*/
|
||||||
public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +59,7 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
public Collection <X_AD_ReplicationTable> getReplicationTables() {
|
public Collection <X_AD_ReplicationTable> getReplicationTables() {
|
||||||
String whereClause = new StringBuffer(X_AD_ReplicationTable.COLUMNNAME_AD_ReplicationStrategy_ID)+"=?"; // #1
|
String whereClause = new StringBuffer(X_AD_ReplicationTable.COLUMNNAME_AD_ReplicationStrategy_ID)+"=?"; // #1
|
||||||
return new Query(getCtx(), X_AD_ReplicationTable.Table_Name, whereClause, get_TrxName())
|
return new Query(getCtx(), X_AD_ReplicationTable.Table_Name, whereClause, get_TrxName())
|
||||||
|
.setClient_ID()
|
||||||
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
|
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setApplyAccessFilter(false)
|
.setApplyAccessFilter(false)
|
||||||
|
@ -70,6 +73,7 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
public Collection<X_AD_ReplicationDocument> getReplicationDocuments() {
|
public Collection<X_AD_ReplicationDocument> getReplicationDocuments() {
|
||||||
String whereClause = "AD_ReplicationStrategy_ID=?"; // #1
|
String whereClause = "AD_ReplicationStrategy_ID=?"; // #1
|
||||||
return new Query(getCtx(),X_AD_ReplicationDocument.Table_Name,whereClause,get_TrxName())
|
return new Query(getCtx(),X_AD_ReplicationDocument.Table_Name,whereClause,get_TrxName())
|
||||||
|
.setClient_ID()
|
||||||
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
|
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setApplyAccessFilter(false)
|
.setApplyAccessFilter(false)
|
||||||
|
@ -86,6 +90,7 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
{
|
{
|
||||||
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
|
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
|
||||||
return new Query(ctx, X_AD_ReplicationTable.Table_Name, whereClause, null)
|
return new Query(ctx, X_AD_ReplicationTable.Table_Name, whereClause, null)
|
||||||
|
.setClient_ID()
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setApplyAccessFilter(false)
|
.setApplyAccessFilter(false)
|
||||||
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID})
|
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID})
|
||||||
|
@ -102,6 +107,7 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
{
|
{
|
||||||
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
|
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
|
||||||
return new Query(ctx, X_AD_ReplicationDocument.Table_Name, whereClause, null)
|
return new Query(ctx, X_AD_ReplicationDocument.Table_Name, whereClause, null)
|
||||||
|
.setClient_ID()
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setApplyAccessFilter(false)
|
.setApplyAccessFilter(false)
|
||||||
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID})
|
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID})
|
||||||
|
@ -109,4 +115,20 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param AD_Table_ID
|
||||||
|
* @return X_AD_ReplicationDocument Document to replication
|
||||||
|
*/
|
||||||
|
public static X_AD_ReplicationDocument getReplicationDocument(Properties ctx ,int AD_ReplicationStrategy_ID , int AD_Table_ID, int C_DocType_ID)
|
||||||
|
{
|
||||||
|
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=? AND C_DocType_ID=?";
|
||||||
|
return new Query(ctx, X_AD_ReplicationDocument.Table_Name, whereClause, null)
|
||||||
|
.setClient_ID()
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setApplyAccessFilter(false)
|
||||||
|
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID, C_DocType_ID})
|
||||||
|
.first();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue