[ 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
97d3b922c5
commit
eaac0e16de
|
@ -65,9 +65,11 @@ public class ExportModelValidator implements ModelValidator
|
||||||
/** User */
|
/** User */
|
||||||
private int m_AD_User_ID = -1;
|
private int m_AD_User_ID = -1;
|
||||||
|
|
||||||
/** Export Helper */
|
/** Replication Strategy **/
|
||||||
ExportHelper expHelper = null;
|
private int m_AD_ReplicationStrategy_ID = -1;
|
||||||
|
|
||||||
|
/** Export Helper */
|
||||||
|
ExportHelper expHelper = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -89,10 +91,12 @@ public class ExportModelValidator implements ModelValidator
|
||||||
log.info(client.toString());
|
log.info(client.toString());
|
||||||
|
|
||||||
MReplicationStrategy rplStrategy = null;
|
MReplicationStrategy rplStrategy = null;
|
||||||
log.info("client.getAD_ReplicationStrategy_ID() = " + client.getAD_ReplicationStrategy_ID());
|
|
||||||
|
|
||||||
if (client.getAD_ReplicationStrategy_ID() > 0) {
|
m_AD_ReplicationStrategy_ID = client.getAD_ReplicationStrategy_ID();
|
||||||
rplStrategy = new MReplicationStrategy(client.getCtx(), client.getAD_ReplicationStrategy_ID(), null);
|
log.info("client.getAD_ReplicationStrategy_ID() = " + m_AD_ReplicationStrategy_ID);
|
||||||
|
|
||||||
|
if (m_AD_ReplicationStrategy_ID > 0) {
|
||||||
|
rplStrategy = new MReplicationStrategy(client.getCtx(), m_AD_ReplicationStrategy_ID, null);
|
||||||
expHelper = new ExportHelper(client, rplStrategy);
|
expHelper = new ExportHelper(client, rplStrategy);
|
||||||
}
|
}
|
||||||
// Add Tables
|
// Add Tables
|
||||||
|
@ -101,16 +105,12 @@ public class ExportModelValidator implements ModelValidator
|
||||||
//engine.addModelChange(MOrder.Table_Name, this);
|
//engine.addModelChange(MOrder.Table_Name, this);
|
||||||
//engine.addModelChange(MOrderLine.Table_Name, this);
|
//engine.addModelChange(MOrderLine.Table_Name, this);
|
||||||
if (rplStrategy != null) {
|
if (rplStrategy != null) {
|
||||||
X_AD_ReplicationTable[] rplTables = rplStrategy.getReplicationTables();
|
|
||||||
for (int i = 0; i < rplTables.length; i++) {
|
for (X_AD_ReplicationTable rplTable : rplStrategy.getReplicationTables()) {
|
||||||
String rplType = rplTables[i].getReplicationType();
|
if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplTable.getReplicationType())
|
||||||
|
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplTable.getReplicationType()))
|
||||||
if (X_AD_ReplicationTable.REPLICATIONTYPE_Merge.equals(rplType)
|
|
||||||
|| X_AD_ReplicationTable.REPLICATIONTYPE_Reference.equals(rplType)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
MTable table = MTable.get (client.getCtx(), rplTables[i].getAD_Table_ID());
|
MTable table = MTable.get (client.getCtx(), rplTable.getAD_Table_ID());
|
||||||
|
|
||||||
engine.addModelChange(table.getTableName(), this);
|
engine.addModelChange(table.getTableName(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,17 +118,12 @@ public class ExportModelValidator implements ModelValidator
|
||||||
// Add Documents
|
// Add Documents
|
||||||
// We want to be informed when Replication documents are created/updated/deleted!
|
// We want to be informed when Replication documents are created/updated/deleted!
|
||||||
if (rplStrategy != null) {
|
if (rplStrategy != null) {
|
||||||
X_AD_ReplicationDocument[] rplDocuments = rplStrategy.getReplicationDocuments();
|
for (X_AD_ReplicationDocument rplDocument : rplStrategy.getReplicationDocuments()) {
|
||||||
for (int i = 0; i < rplDocuments.length; i++) {
|
if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplDocument.getReplicationType())
|
||||||
String rplType = rplDocuments[i].getReplicationType();
|
|| X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplDocument.getReplicationType()))
|
||||||
|
|
||||||
if (X_AD_ReplicationDocument.REPLICATIONTYPE_Merge.equals(rplType)
|
|
||||||
|| X_AD_ReplicationDocument.REPLICATIONTYPE_Reference.equals(rplType)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
//MDocType docType = MDocType.get(client.getCtx(), rplDocuments[i].getC_DocType_ID());
|
//MDocType docType = MDocType.get(client.getCtx(), rplDocuments[i].getC_DocType_ID());
|
||||||
MTable table = MTable.get (client.getCtx(), rplDocuments[i].getAD_Table_ID());
|
MTable table = MTable.get (client.getCtx(), rplDocument.getAD_Table_ID());
|
||||||
|
|
||||||
engine.addDocValidate(table.getTableName(), this);
|
engine.addDocValidate(table.getTableName(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,16 +141,18 @@ public class ExportModelValidator implements ModelValidator
|
||||||
*/
|
*/
|
||||||
public String modelChange (PO po, int type) throws Exception
|
public String modelChange (PO po, int type) throws Exception
|
||||||
{
|
{
|
||||||
|
String Mode = "Table";
|
||||||
log.info("po.get_TableName() = " + po.get_TableName());
|
log.info("po.get_TableName() = " + po.get_TableName());
|
||||||
if (expHelper != null) {
|
if (expHelper != null) {
|
||||||
|
if ( type == TYPE_AFTER_CHANGE
|
||||||
if ( type == TYPE_AFTER_CHANGE || type == TYPE_AFTER_NEW ) // After Change or After New
|
|| type == TYPE_AFTER_NEW
|
||||||
|
|| type == TYPE_BEFORE_DELETE) // After Change or After New
|
||||||
{
|
{
|
||||||
expHelper.exportRecord(po, false);
|
expHelper.exportRecord( po,
|
||||||
} else if ( type == TYPE_BEFORE_DELETE ) // Before delete
|
MReplicationStrategy.REPLICATION_TABLE,
|
||||||
{
|
MReplicationStrategy.getReplicationDocument(po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID()).getReplicationType(),
|
||||||
expHelper.exportRecord(po, true);
|
type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -176,13 +173,19 @@ public class ExportModelValidator implements ModelValidator
|
||||||
String result = null;
|
String result = null;
|
||||||
if (expHelper != null) {
|
if (expHelper != null) {
|
||||||
try {
|
try {
|
||||||
if ( type == TIMING_AFTER_COMPLETE
|
if ( type == TIMING_AFTER_COMPLETE
|
||||||
|| 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_VOID
|
||||||
|
|| type == TIMING_AFTER_PREPARE
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
expHelper.exportRecord(po, false);
|
expHelper.exportRecord( po,
|
||||||
|
MReplicationStrategy.REPLICATION_DOCUMENT ,
|
||||||
|
MReplicationStrategy.getReplicationDocument(po.getCtx(), m_AD_ReplicationStrategy_ID, po.get_Table_ID()).getReplicationType(),
|
||||||
|
type);
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -107,12 +107,12 @@ public class ExportHelper {
|
||||||
m_dateFormat = DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(ctx)));
|
m_dateFormat = DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(ctx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process - Generate Export Format
|
* Process - Generate Export Format
|
||||||
* @return info
|
* @return info
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public String exportRecord (PO po, boolean isDeleted) throws Exception
|
public String exportRecord (PO po, Integer ReplicationMode , String ReplicationType, Integer ReplicationEvent) throws Exception
|
||||||
{
|
{
|
||||||
MClient client = MClient.get (po.getCtx(), m_AD_Client_ID);
|
MClient client = MClient.get (po.getCtx(), m_AD_Client_ID);
|
||||||
log.info("Client = " + client.toString());
|
log.info("Client = " + client.toString());
|
||||||
|
@ -178,9 +178,9 @@ public class ExportHelper {
|
||||||
}
|
}
|
||||||
rootElement.setAttribute("AD_Client_Value", client.getValue());
|
rootElement.setAttribute("AD_Client_Value", client.getValue());
|
||||||
rootElement.setAttribute("Version", exportFormat.getVersion());
|
rootElement.setAttribute("Version", exportFormat.getVersion());
|
||||||
if (isDeleted) {
|
rootElement.setAttribute("ReplicationMode", ReplicationMode.toString());
|
||||||
rootElement.setAttribute("deleted", "Y");
|
rootElement.setAttribute("ReplicationType", ReplicationType);
|
||||||
}
|
rootElement.setAttribute("ReplicationEvent", ReplicationEvent.toString());
|
||||||
outDocument.appendChild(rootElement);
|
outDocument.appendChild(rootElement);
|
||||||
generateExportFormat(rootElement, exportFormat, rs, po, po.get_ID(), variableMap);
|
generateExportFormat(rootElement, exportFormat, rs, po, po.get_ID(), variableMap);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ public class ExportHelper {
|
||||||
* @return Document
|
* @return Document
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Document exportRecord (MEXPFormat exportFormat, String where, boolean isDeleted) throws Exception
|
public Document exportRecord (MEXPFormat exportFormat, String where , Integer ReplicationMode , String ReplicationType, Integer ReplicationEvent) throws Exception
|
||||||
{
|
{
|
||||||
MClient client = MClient.get (exportFormat.getCtx(), m_AD_Client_ID);
|
MClient client = MClient.get (exportFormat.getCtx(), m_AD_Client_ID);
|
||||||
MTable table = MTable.get(exportFormat.getCtx(), exportFormat.getAD_Table_ID());
|
MTable table = MTable.get(exportFormat.getCtx(), exportFormat.getAD_Table_ID());
|
||||||
|
@ -278,9 +278,9 @@ public class ExportHelper {
|
||||||
}
|
}
|
||||||
rootElement.setAttribute("AD_Client_Value", client.getValue());
|
rootElement.setAttribute("AD_Client_Value", client.getValue());
|
||||||
rootElement.setAttribute("Version", exportFormat.getVersion());
|
rootElement.setAttribute("Version", exportFormat.getVersion());
|
||||||
if (isDeleted) {
|
rootElement.setAttribute("ReplicationMode", ReplicationMode.toString());
|
||||||
rootElement.setAttribute("deleted", "true");
|
rootElement.setAttribute("ReplicationType", ReplicationType);
|
||||||
}
|
rootElement.setAttribute("ReplicationEvent", ReplicationEvent.toString());
|
||||||
outDocument.appendChild(rootElement);
|
outDocument.appendChild(rootElement);
|
||||||
generateExportFormat(rootElement, exportFormat, rs, po, po.get_ID(), variableMap);
|
generateExportFormat(rootElement, exportFormat, rs, po, po.get_ID(), variableMap);
|
||||||
}
|
}
|
||||||
|
@ -346,8 +346,10 @@ public class ExportHelper {
|
||||||
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
||||||
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
||||||
} else {
|
} else {
|
||||||
valueString = m_dateFormat.format (Timestamp.valueOf (valueString));
|
//valueString = m_dateFormat.format (Timestamp.valueOf (valueString));
|
||||||
newElement.setAttribute("DateFormat", m_dateTimeFormat.toPattern()); // Add "DateForamt attribute
|
//newElement.setAttribute("DateFormat", m_dateTimeFormat.toPattern()); // Add "DateForamt attribute
|
||||||
|
//Standard Japanese Format (default) works better (yyyy-mm-dd)
|
||||||
|
newElement.setAttribute("DateFormat", valueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -359,8 +361,10 @@ public class ExportHelper {
|
||||||
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
||||||
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
||||||
} else {
|
} else {
|
||||||
valueString = m_dateTimeFormat.format (Timestamp.valueOf (valueString));
|
//valueString = m_dateTimeFormat.format (Timestamp.valueOf (valueString));
|
||||||
newElement.setAttribute("DateFormat", m_dateTimeFormat.toPattern()); // Add "DateForamt attribute
|
//newElement.setAttribute("DateFormat", m_dateTimeFormat.toPattern()); // Add "DateForamt attribute
|
||||||
|
//Standard Japanese Format (default) works better (yyyy-mm-dd hh:mm:ss m.mm)
|
||||||
|
newElement.setAttribute("DateFormat", valueString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,9 @@ import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
//import org.adempiere.server.rpl.XMLHelper;
|
//import org.adempiere.server.rpl.XMLHelper;
|
||||||
import org.compiere.Adempiere;
|
import org.compiere.Adempiere;
|
||||||
|
import org.compiere.model.MReplicationStrategy;
|
||||||
|
import org.compiere.model.ModelValidator;
|
||||||
|
import org.compiere.model.X_AD_ReplicationTable;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
|
@ -118,7 +121,7 @@ public class ModelExporter extends SvrProcess {
|
||||||
ExportHelper expHelper = new ExportHelper(getCtx(),p_AD_Client_ID);
|
ExportHelper expHelper = new ExportHelper(getCtx(),p_AD_Client_ID);
|
||||||
MEXPFormat exportFormat = new MEXPFormat (getCtx(), p_EXP_Format_ID, get_TrxName() );
|
MEXPFormat exportFormat = new MEXPFormat (getCtx(), p_EXP_Format_ID, get_TrxName() );
|
||||||
File file = new File(p_FileName);
|
File file = new File(p_FileName);
|
||||||
Document doc = expHelper.exportRecord(exportFormat,"", false);
|
Document doc = expHelper.exportRecord(exportFormat,"", MReplicationStrategy.REPLICATION_TABLE, X_AD_ReplicationTable.REPLICATIONTYPE_Merge,ModelValidator.TYPE_AFTER_CHANGE);
|
||||||
// Save the document to the disk file
|
// Save the document to the disk file
|
||||||
TransformerFactory tranFactory = TransformerFactory.newInstance();
|
TransformerFactory tranFactory = TransformerFactory.newInstance();
|
||||||
|
|
||||||
|
|
|
@ -156,12 +156,12 @@ public class TopicExportProcessor implements IExportProcessor {
|
||||||
connection = connectionFactory.createConnection();
|
connection = connectionFactory.createConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
// connection.setClientID( clientID ); Commented by Victor as he had issue!
|
connection.setClientID( clientID );// Commented by Victor as he had issue!
|
||||||
connection.start();
|
connection.start();
|
||||||
|
|
||||||
// Create a Session
|
// Create a Session
|
||||||
session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); //TODO - Trifon could be EXP_ProcessorParameter
|
session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); //TODO - Trifon could be EXP_ProcessorParameter
|
||||||
|
|
||||||
// Create the destination (Topic or Queue)
|
// Create the destination (Topic or Queue)
|
||||||
Destination destination = session.createTopic(topicName);
|
Destination destination = session.createTopic(topicName);
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public class TopicExportProcessor implements IExportProcessor {
|
||||||
// Tell the producer to send the message
|
// Tell the producer to send the message
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
producer.send(message);
|
producer.send(destination, message);
|
||||||
session.commit();
|
session.commit();
|
||||||
log.info("JMS Message sent!");
|
log.info("JMS Message sent!");
|
||||||
}catch(JMSException ex)
|
}catch(JMSException ex)
|
||||||
|
@ -198,12 +198,13 @@ public class TopicExportProcessor implements IExportProcessor {
|
||||||
} finally {
|
} finally {
|
||||||
// Clean up
|
// Clean up
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
try { session.close(); } catch (JMSException ex) { /* ignored */ }
|
try { session.close(); } catch (JMSException ex) {}
|
||||||
}
|
}
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
try { connection.close(); } catch (JMSException ex) { /* ignored */ }
|
try { connection.close(); } catch (JMSException ex) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,14 @@ import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
import org.eevolution.model.MEXPFormat;
|
import org.eevolution.model.MEXPFormat;
|
||||||
import org.eevolution.model.MEXPFormatLine;
|
import org.eevolution.model.MEXPFormatLine;
|
||||||
|
import org.compiere.model.MReplicationStrategy;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
|
import org.compiere.model.ModelValidator;
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
import org.compiere.model.X_AD_Client;
|
import org.compiere.model.X_AD_Client;
|
||||||
|
import org.compiere.model.X_AD_ReplicationDocument;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.DocumentEngine;
|
||||||
import org.eevolution.model.X_EXP_FormatLine;
|
import org.eevolution.model.X_EXP_FormatLine;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
@ -58,7 +63,6 @@ import org.compiere.util.Msg;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Trifon N. Trifonov
|
* @author Trifon N. Trifonov
|
||||||
* @author Antonio Cañaveral, e-Evolution
|
* @author Antonio Cañaveral, e-Evolution
|
||||||
|
@ -124,8 +128,13 @@ public class ImportHelper {
|
||||||
if (version == null || "".equals(version)) {
|
if (version == null || "".equals(version)) {
|
||||||
throw new Exception(Msg.getMsg(ctx, "XMLVersionAttributeMandatory"));
|
throw new Exception(Msg.getMsg(ctx, "XMLVersionAttributeMandatory"));
|
||||||
}
|
}
|
||||||
boolean isDelete=false;
|
///Getting Attributes.
|
||||||
isDelete=rootElement.getAttribute("deleted").equals("Y");
|
|
||||||
|
;
|
||||||
|
|
||||||
|
int ReplicationMode = new Integer(rootElement.getAttribute("ReplicationMode"));
|
||||||
|
String ReplicationType = rootElement.getAttribute("ReplicationType");
|
||||||
|
int ReplicationEvent = new Integer(rootElement.getAttribute("ReplicationEvent"));
|
||||||
|
|
||||||
MClient client = null;
|
MClient client = null;
|
||||||
client = getAD_ClientByValue(ctx, AD_Client_Value, trxName);
|
client = getAD_ClientByValue(ctx, AD_Client_Value, trxName);
|
||||||
|
@ -157,16 +166,28 @@ public class ImportHelper {
|
||||||
log.info("expFormat = " + expFormat.toString());
|
log.info("expFormat = " + expFormat.toString());
|
||||||
|
|
||||||
PO po = importElement(ctx, result, rootElement, expFormat, trxName);
|
PO po = importElement(ctx, result, rootElement, expFormat, trxName);
|
||||||
|
|
||||||
// Here must invoke other method else we get cycle...
|
// Here must invoke other method else we get cycle...
|
||||||
boolean resultSave=false;
|
boolean resultSave=false;
|
||||||
if(isDelete)
|
if(ReplicationEvent == ModelValidator.TYPE_BEFORE_DELETE ||
|
||||||
|
ReplicationEvent == ModelValidator.TYPE_BEFORE_DELETE_REPLICATION ||
|
||||||
|
ReplicationEvent == ModelValidator.TYPE_DELETE)
|
||||||
resultSave=po.delete(true);
|
resultSave=po.delete(true);
|
||||||
else
|
else
|
||||||
resultSave = po.saveReplica(true);
|
resultSave = po.saveReplica(true);
|
||||||
|
|
||||||
result.append("ResultSave=").append(resultSave).append("; ");
|
result.append("ResultSave=").append(resultSave).append("; ");
|
||||||
if (resultSave) {
|
/*if (resultSave)
|
||||||
|
{
|
||||||
|
if(ReplicationMode == MReplicationStrategy.REPLICATION_DOCUMENT &&
|
||||||
|
ReplicationType == X_AD_ReplicationDocument.REPLICATIONTYPE_Merge)
|
||||||
|
{
|
||||||
|
String status = po.get_ValueAsString("DocStatus");
|
||||||
|
String action = po.get_ValueAsString("DocAction");
|
||||||
|
DocAction m_document;
|
||||||
|
m_document=(DocAction) po;
|
||||||
|
DocumentEngine engine = new DocumentEngine (m_document, status);
|
||||||
|
engine.processIt (action);
|
||||||
|
}
|
||||||
// Success in save
|
// Success in save
|
||||||
} else {
|
} else {
|
||||||
// Failed in save
|
// Failed in save
|
||||||
|
@ -251,11 +272,17 @@ public class ImportHelper {
|
||||||
//referencedNode = (Element)nodeList.item(0);
|
//referencedNode = (Element)nodeList.item(0);
|
||||||
|
|
||||||
log.info("referencedNode = " + referencedNode);
|
log.info("referencedNode = " + referencedNode);
|
||||||
|
if(referencedNode!=null)
|
||||||
refRecord_ID = getID(ctx, referencedExpFormat, referencedNode, formatLines[i].getValue(), trxName);
|
{
|
||||||
log.info("refRecord_ID = " + refRecord_ID);
|
refRecord_ID = getID(ctx, referencedExpFormat, referencedNode, formatLines[i].getValue(), trxName);
|
||||||
|
log.info("refRecord_ID = " + refRecord_ID);
|
||||||
value = new Integer(refRecord_ID);
|
value = new Integer(refRecord_ID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.info("NULL VALUE FOR " + xPath.toString());
|
||||||
|
value=null;
|
||||||
|
}
|
||||||
log.info("value=[" + value + "]");
|
log.info("value=[" + value + "]");
|
||||||
} else if (MEXPFormatLine.TYPE_EmbeddedEXPFormat.equals(formatLines[i].getType())) {
|
} else if (MEXPFormatLine.TYPE_EmbeddedEXPFormat.equals(formatLines[i].getType())) {
|
||||||
boolean resSave = false;
|
boolean resSave = false;
|
||||||
|
@ -363,10 +390,14 @@ public class ImportHelper {
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int intValue = Integer.parseInt(value.toString());
|
if(!value.toString().isEmpty())
|
||||||
value = new Integer( intValue );
|
{
|
||||||
|
int intValue = Integer.parseInt(value.toString());
|
||||||
|
value = new Integer( intValue );
|
||||||
|
}else
|
||||||
|
value=null;
|
||||||
log.info("Abut to set int value of column ["+column.getColumnName()+"]=["+value+"]");
|
log.info("Abut to set int value of column ["+column.getColumnName()+"]=["+value+"]");
|
||||||
po.set_ValueOfColumn(formatLines[i].getAD_Column_ID(), intValue);
|
po.set_ValueOfColumn(formatLines[i].getAD_Column_ID(), value);
|
||||||
log.info("Set int value of column ["+column.getColumnName()+"]=["+value+"]");
|
log.info("Set int value of column ["+column.getColumnName()+"]=["+value+"]");
|
||||||
} else if (column.getAD_Reference_ID() == DisplayType.Amount
|
} else if (column.getAD_Reference_ID() == DisplayType.Amount
|
||||||
|| column.getAD_Reference_ID() == DisplayType.Number
|
|| column.getAD_Reference_ID() == DisplayType.Number
|
||||||
|
@ -375,8 +406,12 @@ public class ImportHelper {
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
double doubleValue = Double.parseDouble(value.toString());
|
if(!value.toString().isEmpty())
|
||||||
value = new BigDecimal(doubleValue);
|
{
|
||||||
|
double doubleValue = Double.parseDouble(value.toString());
|
||||||
|
value = new BigDecimal(doubleValue);
|
||||||
|
}else
|
||||||
|
value=null;
|
||||||
//value = new Double( doubleValue );
|
//value = new Double( doubleValue );
|
||||||
log.info("About to set BigDecimal value of column ["+column.getColumnName()+"]=["+value+"]");
|
log.info("About to set BigDecimal value of column ["+column.getColumnName()+"]=["+value+"]");
|
||||||
po.set_ValueOfColumn(formatLines[i].getAD_Column_ID(), value);
|
po.set_ValueOfColumn(formatLines[i].getAD_Column_ID(), value);
|
||||||
|
@ -390,7 +425,10 @@ public class ImportHelper {
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
log.info("About to set value of column ["+column.getColumnName()+"]=["+value+"]");
|
log.info("About to set value of column ["+column.getColumnName()+"]=["+value+"]");
|
||||||
po.set_ValueOfColumn(formatLines[i].getAD_Column_ID(), clazz.cast(value));
|
if(clazz == Boolean.class)
|
||||||
|
po.set_ValueOfColumn(formatLines[i].getAD_Column_ID(), value);
|
||||||
|
else
|
||||||
|
po.set_ValueOfColumn(formatLines[i].getAD_Column_ID(), clazz.cast(value));
|
||||||
log.info("Set value of column ["+column.getColumnName()+"]=["+value+"]");
|
log.info("Set value of column ["+column.getColumnName()+"]=["+value+"]");
|
||||||
} catch (ClassCastException ex) {
|
} catch (ClassCastException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -486,6 +524,14 @@ public class ImportHelper {
|
||||||
log.info("--- iterate unique column with index = ["+i+"]");
|
log.info("--- iterate unique column with index = ["+i+"]");
|
||||||
MColumn column = MColumn.get(ctx, uniqueFormatLines[i].getAD_Column_ID());
|
MColumn column = MColumn.get(ctx, uniqueFormatLines[i].getAD_Column_ID());
|
||||||
log.info("column = ["+column+"]");
|
log.info("column = ["+column+"]");
|
||||||
|
String valuecol=column.getColumnName();
|
||||||
|
if(column.getAD_Reference_ID() == DisplayType.Amount
|
||||||
|
|| column.getAD_Reference_ID() == DisplayType.Number
|
||||||
|
|| column.getAD_Reference_ID() == DisplayType.CostPrice
|
||||||
|
|| column.getAD_Reference_ID() == DisplayType.Quantity)
|
||||||
|
{
|
||||||
|
valuecol="Round("+valuecol+",2)";
|
||||||
|
}
|
||||||
|
|
||||||
if (MEXPFormatLine.TYPE_XMLElement.equals(uniqueFormatLines[i].getType())) {
|
if (MEXPFormatLine.TYPE_XMLElement.equals(uniqueFormatLines[i].getType())) {
|
||||||
// XML Element
|
// XML Element
|
||||||
|
@ -529,9 +575,9 @@ public class ImportHelper {
|
||||||
throw new Exception(Msg.getMsg(ctx, "EXPFormatLineNonValidType"));
|
throw new Exception(Msg.getMsg(ctx, "EXPFormatLineNonValidType"));
|
||||||
}
|
}
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
sql.append(" ").append(column.getColumnName()).append(" = ? ");
|
sql.append(" ").append(valuecol).append(" = ? ");
|
||||||
} else {
|
} else {
|
||||||
sql.append(" AND ").append(column.getColumnName()).append(" = ? ");
|
sql.append(" AND ").append(valuecol).append(" = ? ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -544,13 +590,25 @@ public class ImportHelper {
|
||||||
MColumn col = MColumn.get(ctx, uniqueFormatLines[i].getAD_Column_ID());
|
MColumn col = MColumn.get(ctx, uniqueFormatLines[i].getAD_Column_ID());
|
||||||
|
|
||||||
if (col.getAD_Reference_ID() == DisplayType.DateTime
|
if (col.getAD_Reference_ID() == DisplayType.DateTime
|
||||||
|| col.getAD_Reference_ID() == DisplayType.Date
|
|| col.getAD_Reference_ID() == DisplayType.Date)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Timestamp value = (Timestamp)handleDateTime(values[i], col , uniqueFormatLines[i]);
|
Timestamp value = (Timestamp)handleDateTime(values[i], col , uniqueFormatLines[i]);
|
||||||
pstmt.setTimestamp(i+1, value);
|
pstmt.setTimestamp(i+1, value);
|
||||||
}
|
}
|
||||||
|
else if(col.getAD_Reference_ID() == DisplayType.String)
|
||||||
|
{
|
||||||
|
String value = (String)values[i];
|
||||||
|
pstmt.setString(i+1, value);
|
||||||
|
}
|
||||||
|
else if(col.getAD_Reference_ID() == DisplayType.Amount
|
||||||
|
|| col.getAD_Reference_ID() == DisplayType.Number
|
||||||
|
|| col.getAD_Reference_ID() == DisplayType.CostPrice
|
||||||
|
|| col.getAD_Reference_ID() == DisplayType.Quantity)
|
||||||
|
{
|
||||||
|
BigDecimal value = new BigDecimal((String)values[i]);
|
||||||
|
pstmt.setBigDecimal(i+1, value.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pstmt.setObject(i+1, values[i]);
|
pstmt.setObject(i+1, values[i]);
|
||||||
|
@ -590,10 +648,11 @@ public class ImportHelper {
|
||||||
result = new Timestamp(m_customDateFormat.parse(valueString).getTime());
|
result = new Timestamp(m_customDateFormat.parse(valueString).getTime());
|
||||||
log.info("Custom Date Format; Parsed value = " + result.toString());
|
log.info("Custom Date Format; Parsed value = " + result.toString());
|
||||||
} else {
|
} else {
|
||||||
result = new Timestamp(m_dateFormat.parse(valueString).getTime());
|
//result = new Timestamp(m_dateFormat.parse(valueString).getTime());
|
||||||
log.info("Custom Date Format; Parsed value = " + result.toString());
|
//log.info("Custom Date Format; Parsed value = " + result.toString());
|
||||||
}
|
//NOW Using Standard Japanese Format yyyy-mm-dd hh:mi:ss.mil so don't care about formats....
|
||||||
|
result = Timestamp.valueOf(valueString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (column.getAD_Reference_ID() == DisplayType.DateTime) {
|
} else if (column.getAD_Reference_ID() == DisplayType.DateTime) {
|
||||||
if (valueString != null) {
|
if (valueString != null) {
|
||||||
|
@ -602,12 +661,15 @@ public class ImportHelper {
|
||||||
result = new Timestamp(m_customDateFormat.parse(valueString).getTime());
|
result = new Timestamp(m_customDateFormat.parse(valueString).getTime());
|
||||||
log.info("Custom Date Format; Parsed value = " + result.toString());
|
log.info("Custom Date Format; Parsed value = " + result.toString());
|
||||||
} else {
|
} else {
|
||||||
result = new Timestamp(m_dateTimeFormat.parse(valueString).getTime());
|
//result = new Timestamp(m_dateTimeFormat.parse(valueString).getTime());
|
||||||
log.info("Custom Date Format; Parsed value = " + result.toString());
|
//log.info("Custom Date Format; Parsed value = " + result.toString());
|
||||||
|
//NOW Using Standard Japanese Format yyyy-mm-dd hh:mi:ss.mil so don't care about formats....
|
||||||
|
result = Timestamp.valueOf(valueString);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class TopicListener implements MessageListener {
|
||||||
{
|
{
|
||||||
if(conn.getClientID().equals(clientID))
|
if(conn.getClientID().equals(clientID))
|
||||||
{
|
{
|
||||||
log.config("Connection with clientID '" + clientID
|
log.warning("Connection with clientID '" + clientID
|
||||||
+ "' already exists");
|
+ "' already exists");
|
||||||
return;
|
return;
|
||||||
}else
|
}else
|
||||||
|
|
Loading…
Reference in New Issue