[ 1949319 ] ReportEngine doesn't work inside transaction
This commit is contained in:
parent
6cf931088b
commit
9e5979268e
|
@ -60,8 +60,18 @@ public class DataEngine
|
||||||
*/
|
*/
|
||||||
public DataEngine (Language language)
|
public DataEngine (Language language)
|
||||||
{
|
{
|
||||||
|
this(language, null);
|
||||||
|
} // DataEngine
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param language Language of the data (for translation)
|
||||||
|
* @param trxName
|
||||||
|
*/
|
||||||
|
public DataEngine (Language language, String trxName){
|
||||||
if (language != null)
|
if (language != null)
|
||||||
m_language = language;
|
m_language = language;
|
||||||
|
m_trxName = trxName;
|
||||||
} // DataEngine
|
} // DataEngine
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
|
@ -80,6 +90,8 @@ public class DataEngine
|
||||||
private int m_runningTotalLines = -1;
|
private int m_runningTotalLines = -1;
|
||||||
/** Print String */
|
/** Print String */
|
||||||
private String m_runningTotalString = null;
|
private String m_runningTotalString = null;
|
||||||
|
/** TrxName String */
|
||||||
|
private String m_trxName = null;
|
||||||
|
|
||||||
/** Key Indicator in Report */
|
/** Key Indicator in Report */
|
||||||
public static final String KEY = "*";
|
public static final String KEY = "*";
|
||||||
|
@ -110,7 +122,7 @@ public class DataEngine
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, m_trxName);
|
||||||
pstmt.setInt(1, format.getAD_ReportView_ID());
|
pstmt.setInt(1, format.getAD_ReportView_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -213,7 +225,7 @@ public class DataEngine
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, m_trxName);
|
||||||
pstmt.setInt(1, format.get_ID());
|
pstmt.setInt(1, format.get_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
|
||||||
|
@ -715,7 +727,7 @@ public class DataEngine
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(pd.getSQL(), null);
|
pstmt = DB.prepareStatement(pd.getSQL(), m_trxName);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
// Row Loop
|
// Row Loop
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
|
|
@ -96,6 +96,19 @@ public class ReportEngine implements PrintServiceAttributeListener
|
||||||
* @param info print info
|
* @param info print info
|
||||||
*/
|
*/
|
||||||
public ReportEngine (Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info)
|
public ReportEngine (Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info)
|
||||||
|
{
|
||||||
|
this(ctx, pf, query, info, null);
|
||||||
|
} // ReportEngine
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param ctx context
|
||||||
|
* @param pf Print Format
|
||||||
|
* @param query Optional Query
|
||||||
|
* @param info print info
|
||||||
|
* @param trxName
|
||||||
|
*/
|
||||||
|
public ReportEngine (Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info, String trxName)
|
||||||
{
|
{
|
||||||
if (pf == null)
|
if (pf == null)
|
||||||
throw new IllegalArgumentException("ReportEngine - no PrintFormat");
|
throw new IllegalArgumentException("ReportEngine - no PrintFormat");
|
||||||
|
@ -104,7 +117,9 @@ public class ReportEngine implements PrintServiceAttributeListener
|
||||||
//
|
//
|
||||||
m_printFormat = pf;
|
m_printFormat = pf;
|
||||||
m_info = info;
|
m_info = info;
|
||||||
|
m_trxName = trxName;
|
||||||
setQuery(query); // loads Data
|
setQuery(query); // loads Data
|
||||||
|
|
||||||
} // ReportEngine
|
} // ReportEngine
|
||||||
|
|
||||||
/** Static Logger */
|
/** Static Logger */
|
||||||
|
@ -127,6 +142,8 @@ public class ReportEngine implements PrintServiceAttributeListener
|
||||||
private String m_printerName = Ini.getProperty(Ini.P_PRINTER);
|
private String m_printerName = Ini.getProperty(Ini.P_PRINTER);
|
||||||
/** View */
|
/** View */
|
||||||
private View m_view = null;
|
private View m_view = null;
|
||||||
|
/** Transaction Name */
|
||||||
|
private String m_trxName = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set PrintFormat.
|
* Set PrintFormat.
|
||||||
|
@ -182,11 +199,13 @@ public class ReportEngine implements PrintServiceAttributeListener
|
||||||
{
|
{
|
||||||
if (m_query == null)
|
if (m_query == null)
|
||||||
return;
|
return;
|
||||||
DataEngine de = new DataEngine(m_printFormat.getLanguage());
|
|
||||||
|
DataEngine de = new DataEngine(m_printFormat.getLanguage(),m_trxName);
|
||||||
setPrintData(de.getPrintData (m_ctx, m_printFormat, m_query));
|
setPrintData(de.getPrintData (m_ctx, m_printFormat, m_query));
|
||||||
// m_printData.dump();
|
// m_printData.dump();
|
||||||
} // setPrintData
|
} // setPrintData
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get PrintData
|
* Get PrintData
|
||||||
* @return print data
|
* @return print data
|
||||||
|
@ -217,7 +236,7 @@ public class ReportEngine implements PrintServiceAttributeListener
|
||||||
throw new IllegalStateException ("No print format");
|
throw new IllegalStateException ("No print format");
|
||||||
if (m_printData == null)
|
if (m_printData == null)
|
||||||
throw new IllegalStateException ("No print data (Delete Print Format and restart)");
|
throw new IllegalStateException ("No print data (Delete Print Format and restart)");
|
||||||
m_layout = new LayoutEngine (m_printFormat, m_printData, m_query);
|
m_layout = new LayoutEngine (m_printFormat, m_printData, m_query, m_trxName);
|
||||||
} // layout
|
} // layout
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1069,7 +1088,6 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
X_C_PaySelectionCheck.Table_ID, X_C_PaySelectionCheck.Table_ID,
|
X_C_PaySelectionCheck.Table_ID, X_C_PaySelectionCheck.Table_ID,
|
||||||
X_C_DunningRunEntry.Table_ID };
|
X_C_DunningRunEntry.Table_ID };
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Get Document Print Engine for Document Type.
|
* Get Document Print Engine for Document Type.
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -1078,6 +1096,19 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
* @return Report Engine or null
|
* @return Report Engine or null
|
||||||
*/
|
*/
|
||||||
public static ReportEngine get (Properties ctx, int type, int Record_ID)
|
public static ReportEngine get (Properties ctx, int type, int Record_ID)
|
||||||
|
{
|
||||||
|
return get(ctx, type, Record_ID, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Get Document Print Engine for Document Type.
|
||||||
|
* @param ctx context
|
||||||
|
* @param type document type
|
||||||
|
* @param Record_ID id
|
||||||
|
* @param trxName
|
||||||
|
* @return Report Engine or null
|
||||||
|
*/
|
||||||
|
public static ReportEngine get (Properties ctx, int type, int Record_ID, String trxName)
|
||||||
{
|
{
|
||||||
if (Record_ID < 1)
|
if (Record_ID < 1)
|
||||||
{
|
{
|
||||||
|
@ -1177,7 +1208,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
pstmt.setInt(1, Record_ID);
|
pstmt.setInt(1, Record_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next()) // first record only
|
if (rs.next()) // first record only
|
||||||
|
@ -1252,7 +1283,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
info.setPrinterName(format.getPrinterName());
|
info.setPrinterName(format.getPrinterName());
|
||||||
|
|
||||||
// Engine
|
// Engine
|
||||||
ReportEngine re = new ReportEngine(ctx, format, query, info);
|
ReportEngine re = new ReportEngine(ctx, format, query, info, trxName);
|
||||||
return re;
|
return re;
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,19 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
||||||
*/
|
*/
|
||||||
public LayoutEngine (MPrintFormat format, PrintData data, MQuery query)
|
public LayoutEngine (MPrintFormat format, PrintData data, MQuery query)
|
||||||
{
|
{
|
||||||
|
this(format, data, query, null);
|
||||||
|
} // LayoutEngine
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detail Constructor
|
||||||
|
* @param format Print Format
|
||||||
|
* @param data Print Data
|
||||||
|
* @param query query for parameter info
|
||||||
|
* @param trxName
|
||||||
|
*/
|
||||||
|
public LayoutEngine (MPrintFormat format, PrintData data, MQuery query, String trxName)
|
||||||
|
{
|
||||||
|
m_TrxName = trxName;
|
||||||
log.info(format + " - " + data + " - " + query);
|
log.info(format + " - " + data + " - " + query);
|
||||||
// s_FASTDRAW = MClient.get(format.getCtx()).isUseBetaFunctions();
|
// s_FASTDRAW = MClient.get(format.getCtx()).isUseBetaFunctions();
|
||||||
//
|
//
|
||||||
|
@ -85,6 +98,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
||||||
private MPrintFont m_printFont;
|
private MPrintFont m_printFont;
|
||||||
/** Printed Column Count */
|
/** Printed Column Count */
|
||||||
private int m_columnCount = -1;
|
private int m_columnCount = -1;
|
||||||
|
/** Transaction name */
|
||||||
|
private String m_TrxName = null;
|
||||||
|
|
||||||
|
|
||||||
/** Paper - default: standard portrait */
|
/** Paper - default: standard portrait */
|
||||||
|
@ -215,6 +230,15 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
||||||
layout(); // re-calculate
|
layout(); // re-calculate
|
||||||
} // setPrintData
|
} // setPrintData
|
||||||
|
|
||||||
|
public void setPrintData (PrintData data, MQuery query, boolean doLayout, String trxName)
|
||||||
|
{
|
||||||
|
m_data = data;
|
||||||
|
m_query = query;
|
||||||
|
m_TrxName = trxName;
|
||||||
|
if (m_hasLayout && doLayout)
|
||||||
|
layout(); // re-calculate
|
||||||
|
} // setPrintData
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Set Paper
|
* Set Paper
|
||||||
|
@ -1109,7 +1133,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
||||||
format.setTranslationViewQuery(query);
|
format.setTranslationViewQuery(query);
|
||||||
log.fine(query.toString());
|
log.fine(query.toString());
|
||||||
//
|
//
|
||||||
DataEngine de = new DataEngine(format.getLanguage());
|
DataEngine de = new DataEngine(format.getLanguage(),m_TrxName);
|
||||||
PrintData includedData = de.getPrintData(data.getCtx(), format, query);
|
PrintData includedData = de.getPrintData(data.getCtx(), format, query);
|
||||||
if (includedData == null)
|
if (includedData == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue