use of org.compiere.model.X_AD_ReplicationDocument in project adempiere by adempiere.
the class ExportModelValidator method loadReplicationStrategy.
public void loadReplicationStrategy(Properties ctx) {
MClient m_client = MClient.get(Env.getCtx(), clientId);
/*replicationStrategyId = MRole.get(m_client.getCtx(), roleId).get_ValueAsInt("AD_ReplicationStrategy_ID");
if(replicationStrategyId <= 0)
{
replicationStrategyId = MOrg.get(m_client.getCtx(), orgId).getAD_ReplicationStrategy_ID();
}
if(replicationStrategyId <= 0)
{
replicationStrategyId = m_client.getAD_ReplicationStrategy_ID();
log.info("client.getAD_ReplicationStrategy_ID() = " + replicationStrategyId);
}
if (replicationStrategyId > 0) {
replicationStrategy = new MReplicationStrategy(m_client.getCtx(), replicationStrategyId, null);
if(!replicationStrategy.isActive())
{
return;
}
exportHelper = new ExportHelper(m_client, replicationStrategy);
}*/
// Add Tables
// We want to be informed when records in Replication tables are created/updated/deleted!
//engine.addModelChange(MBPartner.Table_Name, this);
//engine.addModelChange(MOrder.Table_Name, this);
//engine.addModelChange(MOrderLine.Table_Name, this);
MReplicationStrategy.getByOrgAndRole(ctx, orgId, roleId, null).stream().filter(replicationStrategy -> replicationStrategy != null).forEach(replicationStrategy -> {
for (X_AD_ReplicationTable rplTable : replicationStrategy.getReplicationTables()) {
if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType()) || X_AD_ReplicationTable.REPLICATIONTYPE_Broadcast.equals(rplTable.getReplicationType()) || X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType())) {
String tableName = MTable.getTableName(replicationStrategy.getCtx(), rplTable.getAD_Table_ID());
modelValidationEngine.addModelChange(tableName, this);
}
}
for (X_AD_ReplicationDocument rplDocument : replicationStrategy.getReplicationDocuments()) {
if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType()) || X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType())) {
String tableName = MTable.getTableName(replicationStrategy.getCtx(), rplDocument.getAD_Table_ID());
modelValidationEngine.addDocValidate(tableName, this);
}
}
});
}
use of org.compiere.model.X_AD_ReplicationDocument in project adempiere by adempiere.
the class ExportModelValidator method docValidate.
/**
* Validate Document.
* Called as first step of DocAction.prepareIt
* when you called addDocValidate for the table.
* @param po persistent object
* @param type see TIMING_ constants
* @return error message or null
* @throws Exception
*/
public String docValidate(PO po, int type) {
log.info("Replicate the Document = " + po.get_TableName() + " with Type = " + type);
String result = null;
if (exportHelper != null) {
try {
if (type == TIMING_AFTER_COMPLETE || type == TIMING_AFTER_CLOSE || type == TIMING_AFTER_REVERSECORRECT || type == TIMING_AFTER_VOID || type == TIMING_AFTER_REACTIVATE) //|| type == TIMING_AFTER_PREPARE
{
MReplicationStrategy.getByOrgAndRole(po.getCtx(), orgId, roleId, po.get_TrxName()).stream().forEach(replicationStrategy -> {
X_AD_ReplicationDocument replicationDocument = null;
int C_DocType_ID = po.get_ValueAsInt("C_DocType_ID");
if (C_DocType_ID > 0) {
replicationDocument = MReplicationStrategy.getReplicationDocument(po.getCtx(), replicationStrategy.get_ID(), po.get_Table_ID(), C_DocType_ID);
} else {
replicationDocument = MReplicationStrategy.getReplicationDocument(po.getCtx(), replicationStrategy.get_ID(), po.get_Table_ID());
}
if (replicationDocument != null) {
exportHelper = new ExportHelper(client, replicationStrategy);
try {
exportHelper.exportRecord(po, MReplicationStrategy.REPLICATION_DOCUMENT, replicationDocument.getReplicationType(), type);
} catch (Exception exeption) {
}
}
});
}
} catch (Exception e) {
e.printStackTrace();
result = e.toString();
}
}
return result;
}
Aggregations