IDEMPIERE-308 Performance: Replace use of StringBuffer and String concatenation with StringBuilder

This commit is contained in:
Heng Sin Low 2012-06-20 16:16:11 +08:00
parent 430cc0331b
commit d6bb8020f3
13 changed files with 270 additions and 231 deletions

View File

@ -30,7 +30,7 @@ import org.compiere.util.CLogger;
* @author Mario Calderon / Carlos Ruiz
*/
public final class MCity extends X_C_City
implements Comparator, Serializable
implements Comparator<Object>, Serializable
{
/**
*

View File

@ -41,7 +41,7 @@ import org.compiere.util.Language;
* <li>BF [ 2695078 ] Country is not translated on invoice
*/
public final class MCountry extends X_C_Country
implements Comparator, Serializable, SystemIDs
implements Comparator<Object>, Serializable, SystemIDs
{
/**
*

View File

@ -44,7 +44,7 @@ import org.compiere.util.Util;
* <li>BF [ 3002736 ] MLocation.get cache all MLocations
* https://sourceforge.net/tracker/?func=detail&aid=3002736&group_id=176962&atid=879332
*/
public class MLocation extends X_C_Location implements Comparator
public class MLocation extends X_C_Location implements Comparator<Object>
{
/**
*

View File

@ -97,7 +97,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc
public String getSqlPI (MGoalRestriction[] restrictions,
String MeasureScope, String MeasureDataType, Timestamp reportDate, MRole role)
{
StringBuffer sb = new StringBuffer(getSelectClause())
StringBuilder sb = new StringBuilder(getSelectClause())
.append(" ")
.append(getWhereClause());
// Date Restriction
@ -141,7 +141,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc
public String getSqlBarChart (MGoalRestriction[] restrictions,
String MeasureDisplay, Timestamp startDate, MRole role)
{
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
String dateCol = null;
String groupBy = null;
if (getDateColumn() != null
@ -208,7 +208,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc
{
MQuery query = new MQuery(getAD_Table_ID());
//
StringBuffer sql = new StringBuffer("SELECT ").append(getKeyColumn()).append(" ");
StringBuilder sql = new StringBuilder("SELECT ").append(getKeyColumn()).append(" ");
String from = getSelectClause();
int index = from.indexOf("FROM ");
if (index == -1)
@ -235,7 +235,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc
}
String finalSQL = addRestrictions(sql.toString(), restrictions, role);
// Execute
StringBuffer where = new StringBuffer();
StringBuilder where = new StringBuilder();
PreparedStatement pstmt = null;
try
{
@ -269,7 +269,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc
if (where.length() == 0)
return MQuery.getNoRecordQuery(query.getTableName(), false);
//
StringBuffer whereClause = new StringBuffer (getKeyColumn())
StringBuilder whereClause = new StringBuilder (getKeyColumn())
.append(" IN (").append(where).append(")");
query.addRestriction(whereClause.toString());
query.setRecordCount(1);
@ -307,7 +307,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc
MGoalRestriction[] restrictions, MRole role,
String tableName, String orgColumn, String bpColumn, String pColumn)
{
StringBuffer sb = new StringBuffer(sql);
StringBuilder sb = new StringBuilder(sql);
// Org Restrictions
if (orgColumn != null)
{
@ -459,7 +459,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("MMeasureCalc[");
StringBuilder sb = new StringBuilder ("MMeasureCalc[");
sb.append (get_ID()).append ("-").append (getName()).append ("]");
return sb.toString ();
} // toString

View File

@ -621,7 +621,7 @@ public class MQuery implements Serializable
if (qualified && (m_TableName == null || m_TableName.length() == 0))
qualified = false;
//
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
if (! isActive())
return sb.toString();
@ -661,7 +661,7 @@ public class MQuery implements Serializable
*/
public String getInfo ()
{
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
int currentDepth = 0;
if (m_TableName != null)
sb.append(m_TableName).append(": ");
@ -701,7 +701,7 @@ public class MQuery implements Serializable
*/
public String getWhereClause (int index)
{
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
if (index >= 0 && index < m_list.size())
{
Restriction r = (Restriction)m_list.get(index);
@ -1090,7 +1090,7 @@ class Restriction implements Serializable
if (DirectWhereClause != null)
return DirectWhereClause;
//
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
if (tableName != null && tableName.length() > 0)
{
// Assumes - REPLACE(INITCAP(variable),'s','X') or UPPER(variable)
@ -1184,7 +1184,7 @@ class Restriction implements Serializable
{
if (InfoDisplay_to == null)
return InfoDisplay;
StringBuffer sb = new StringBuffer(InfoDisplay);
StringBuilder sb = new StringBuilder(InfoDisplay);
sb.append(" - ").append(InfoDisplay_to);
return sb.toString();
} // getInfoDisplay

View File

@ -40,7 +40,7 @@ import org.compiere.util.Env;
* @version $Id: MRegion.java,v 1.3 2006/07/30 00:58:36 jjanke Exp $
*/
public final class MRegion extends X_C_Region
implements Comparator, Serializable, SystemIDs
implements Comparator<Object>, Serializable, SystemIDs
{
/**
*

View File

@ -29,7 +29,7 @@ import org.compiere.util.Env;
* @author Jorg Janke
* @version $Id: MRfQResponseLineQty.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/
public class MRfQResponseLineQty extends X_C_RfQResponseLineQty implements Comparator
public class MRfQResponseLineQty extends X_C_RfQResponseLineQty implements Comparator<Object>
{
/**
*

View File

@ -404,7 +404,7 @@ public class MTable extends X_AD_Table
PO po = null;
POInfo info = POInfo.getPOInfo(getCtx(), getAD_Table_ID(), trxName);
if (info == null) return null;
StringBuffer sqlBuffer = info.buildSelect();
StringBuilder sqlBuffer = info.buildSelect();
sqlBuffer.append(" WHERE ").append(whereClause);
String sql = sqlBuffer.toString();
PreparedStatement pstmt = null;

View File

@ -352,7 +352,7 @@ public class Query
throw new DBException("Table "+table+" has 0 or more than 1 key columns");
}
StringBuffer selectClause = new StringBuffer("SELECT ");
StringBuilder selectClause = new StringBuilder("SELECT ");
selectClause.append(keys[0]);
selectClause.append(" FROM ").append(table.getTableName());
String sql = buildSQL(selectClause, true);
@ -437,7 +437,7 @@ public class Query
}
}
StringBuffer sqlSelect = new StringBuffer("SELECT ").append(sqlFunction).append("(")
StringBuilder sqlSelect = new StringBuilder("SELECT ").append(sqlFunction).append("(")
.append(sqlExpression).append(")")
.append(" FROM ").append(table.getTableName());
@ -530,7 +530,7 @@ public class Query
*/
public boolean match() throws DBException
{
String sql = buildSQL(new StringBuffer("SELECT 1 FROM ").append(table.getTableName()), false);
String sql = buildSQL(new StringBuilder("SELECT 1 FROM ").append(table.getTableName()), false);
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
@ -558,7 +558,7 @@ public class Query
public <T extends PO> Iterator<T> iterate() throws DBException
{
String[] keys = table.getKeyColumns();
StringBuffer sqlBuffer = new StringBuffer(" SELECT ");
StringBuilder sqlBuffer = new StringBuilder(" SELECT ");
for (int i = 0; i < keys.length; i++) {
if (i > 0)
sqlBuffer.append(", ");
@ -634,7 +634,7 @@ public class Query
* @param selectClause optional; if null the select clause will be build according to POInfo
* @return final SQL
*/
private final String buildSQL(StringBuffer selectClause, boolean useOrderByClause)
private final String buildSQL(StringBuilder selectClause, boolean useOrderByClause)
{
if (selectClause == null)
{
@ -646,7 +646,7 @@ public class Query
selectClause = info.buildSelect();
}
StringBuffer whereBuffer = new StringBuffer();
StringBuilder whereBuffer = new StringBuilder();
if (!Util.isEmpty(this.whereClause, true))
{
if (whereBuffer.length() > 0)
@ -679,7 +679,7 @@ public class Query
+" AND s.T_Selection_ID="+table.getTableName()+"."+keys[0]+")");
}
StringBuffer sqlBuffer = new StringBuffer(selectClause);
StringBuilder sqlBuffer = new StringBuilder(selectClause);
if (whereBuffer.length() > 0)
{
sqlBuffer.append(" WHERE ").append(whereBuffer);
@ -706,18 +706,21 @@ public class Query
if (this.onlyActiveRecords)
{
DB.setParameter(pstmt, i++, true);
log.finest("Parameter IsActive = Y");
if (log.isLoggable(Level.FINEST))
log.finest("Parameter IsActive = Y");
}
if (this.onlyClient_ID)
{
int AD_Client_ID = Env.getAD_Client_ID(ctx);
DB.setParameter(pstmt, i++, AD_Client_ID);
log.finest("Parameter AD_Client_ID = "+AD_Client_ID);
if (log.isLoggable(Level.FINEST))
log.finest("Parameter AD_Client_ID = "+AD_Client_ID);
}
if (this.onlySelection_ID > 0)
{
DB.setParameter(pstmt, i++, this.onlySelection_ID);
log.finest("Parameter Selection AD_PInstance_ID = "+this.onlySelection_ID);
if (log.isLoggable(Level.FINEST))
log.finest("Parameter Selection AD_PInstance_ID = "+this.onlySelection_ID);
}
return pstmt.executeQuery();
}
@ -734,7 +737,7 @@ public class Query
throw new DBException("Table "+table+" has 0 or more than 1 key columns");
}
StringBuffer selectClause = new StringBuffer("SELECT ");
StringBuilder selectClause = new StringBuilder("SELECT ");
selectClause.append(keys[0]);
selectClause.append(" FROM ").append(table.getTableName());
String sql = buildSQL(selectClause, true);

View File

@ -16,6 +16,7 @@
*****************************************************************************/
package org.compiere.print;
import java.io.Serializable;
import java.sql.Clob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -146,15 +147,15 @@ public class DataEngine
//
if (format.getAD_ReportView_ID() != 0)
{
String sql = "SELECT t.AD_Table_ID, t.TableName, rv.Name, rv.WhereClause "
+ "FROM AD_Table t"
+ " INNER JOIN AD_ReportView rv ON (t.AD_Table_ID=rv.AD_Table_ID) "
+ "WHERE rv.AD_ReportView_ID=?"; // 1
StringBuilder sql = new StringBuilder("SELECT t.AD_Table_ID, t.TableName, rv.Name, rv.WhereClause ")
.append("FROM AD_Table t")
.append(" INNER JOIN AD_ReportView rv ON (t.AD_Table_ID=rv.AD_Table_ID) ")
.append("WHERE rv.AD_ReportView_ID=?"); // 1
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, m_trxName);
pstmt = DB.prepareStatement(sql.toString(), m_trxName);
pstmt.setInt(1, format.getAD_ReportView_ID());
rs = pstmt.executeQuery();
if (rs.next())
@ -169,7 +170,7 @@ public class DataEngine
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
log.log(Level.SEVERE, sql.toString(), e);
return null;
}
finally
@ -214,8 +215,11 @@ public class DataEngine
{
m_startTime = System.currentTimeMillis();
log.info(reportName + " - " + m_language.getAD_Language());
log.fine("TableName=" + tableName + ", Query=" + query);
log.fine("Format=" + format);
if (log.isLoggable(Level.FINE))
{
log.fine("TableName=" + tableName + ", Query=" + query);
log.fine("Format=" + format);
}
ArrayList<PrintDataColumn> columns = new ArrayList<PrintDataColumn>();
m_group = new PrintDataGroup();
@ -224,49 +228,50 @@ public class DataEngine
ArrayList<String> orderColumns = new ArrayList<String>(orderAD_Column_IDs.length);
for (int i = 0; i < orderAD_Column_IDs.length; i++)
{
log.finest("Order AD_Column_ID=" + orderAD_Column_IDs[i]);
if (log.isLoggable(Level.FINEST))
log.finest("Order AD_Column_ID=" + orderAD_Column_IDs[i]);
orderColumns.add(""); // initial value overwritten with fully qualified name
}
// Direct SQL w/o Reference Info
StringBuffer sqlSELECT = new StringBuffer("SELECT ");
StringBuffer sqlFROM = new StringBuffer(" FROM ").append(tableName);
StringBuilder sqlSELECT = new StringBuilder("SELECT ");
StringBuilder sqlFROM = new StringBuilder(" FROM ").append(tableName);
ArrayList<String> groupByColumns = new ArrayList<String>();
//
boolean IsGroupedBy = false;
//
String sql = "SELECT c.AD_Column_ID,c.ColumnName," // 1..2
+ "c.AD_Reference_ID,c.AD_Reference_Value_ID," // 3..4
+ "c.FieldLength,c.IsMandatory,c.IsKey,c.IsParent," // 5..8
+ "COALESCE(rvc.IsGroupFunction,'N'),rvc.FunctionColumn," // 9..10
+ "pfi.IsGroupBy,pfi.IsSummarized,pfi.IsAveraged,pfi.IsCounted, " // 11..14
+ "pfi.IsPrinted,pfi.SortNo,pfi.IsPageBreak, " // 15..17
+ "pfi.IsMinCalc,pfi.IsMaxCalc, " // 18..19
+ "pfi.isRunningTotal,pfi.RunningTotalLines, " // 20..21
+ "pfi.IsVarianceCalc, pfi.IsDeviationCalc, " // 22..23
+ "c.ColumnSQL, COALESCE(pfi.FormatPattern, c.FormatPattern) " // 24, 25
StringBuilder sql = new StringBuilder("SELECT c.AD_Column_ID,c.ColumnName,") // 1..2
.append("c.AD_Reference_ID,c.AD_Reference_Value_ID,") // 3..4
.append("c.FieldLength,c.IsMandatory,c.IsKey,c.IsParent,") // 5..8
.append("COALESCE(rvc.IsGroupFunction,'N'),rvc.FunctionColumn,") // 9..10
.append("pfi.IsGroupBy,pfi.IsSummarized,pfi.IsAveraged,pfi.IsCounted, ") // 11..14
.append("pfi.IsPrinted,pfi.SortNo,pfi.IsPageBreak, ") // 15..17
.append("pfi.IsMinCalc,pfi.IsMaxCalc, ") // 18..19
.append("pfi.isRunningTotal,pfi.RunningTotalLines, ") // 20..21
.append("pfi.IsVarianceCalc, pfi.IsDeviationCalc, ") // 22..23
.append("c.ColumnSQL, COALESCE(pfi.FormatPattern, c.FormatPattern) ") // 24, 25
//BEGIN http://jira.idempiere.com/browse/IDEMPIERE-153
+ " , pfi.isDesc " //26
.append(" , pfi.isDesc ") //26
//END
+ "FROM AD_PrintFormat pf"
+ " INNER JOIN AD_PrintFormatItem pfi ON (pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID)"
+ " INNER JOIN AD_Column c ON (pfi.AD_Column_ID=c.AD_Column_ID)"
+ " LEFT OUTER JOIN AD_ReportView_Col rvc ON (pf.AD_ReportView_ID=rvc.AD_ReportView_ID AND c.AD_Column_ID=rvc.AD_Column_ID) "
+ "WHERE pf.AD_PrintFormat_ID=?" // #1
+ " AND pfi.IsActive='Y' AND (pfi.IsPrinted='Y' OR c.IsKey='Y' OR pfi.SortNo > 0) "
+ " AND pfi.PrintFormatType IN ('"
.append("FROM AD_PrintFormat pf")
.append(" INNER JOIN AD_PrintFormatItem pfi ON (pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID)")
.append(" INNER JOIN AD_Column c ON (pfi.AD_Column_ID=c.AD_Column_ID)")
.append(" LEFT OUTER JOIN AD_ReportView_Col rvc ON (pf.AD_ReportView_ID=rvc.AD_ReportView_ID AND c.AD_Column_ID=rvc.AD_Column_ID) ")
.append("WHERE pf.AD_PrintFormat_ID=?") // #1
.append(" AND pfi.IsActive='Y' AND (pfi.IsPrinted='Y' OR c.IsKey='Y' OR pfi.SortNo > 0) ")
.append(" AND pfi.PrintFormatType IN ('"
+ MPrintFormatItem.PRINTFORMATTYPE_Field
+ "','"
+ MPrintFormatItem.PRINTFORMATTYPE_Image
+ "','"
+ MPrintFormatItem.PRINTFORMATTYPE_PrintFormat
+ "') "
+ "ORDER BY pfi.IsPrinted DESC, pfi.SeqNo"; // Functions are put in first column
+ "') ")
.append("ORDER BY pfi.IsPrinted DESC, pfi.SeqNo"); // Functions are put in first column
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, m_trxName);
pstmt = DB.prepareStatement(sql.toString(), m_trxName);
pstmt.setInt(1, format.get_ID());
rs = pstmt.executeQuery();
@ -556,7 +561,7 @@ public class DataEngine
else if (index == -1)
{
// => Table.Column,
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(tableName).append(".").append(ColumnName);
sqlSELECT.append(sb).append(",");
if (!IsGroupFunction)
@ -565,7 +570,7 @@ public class DataEngine
else
{
// => Function(Table.Column) AS Column -- function has @ where column name goes
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(FunctionColumn.substring(0, index))
.append(tableName).append(".").append(ColumnName)
.append(FunctionColumn.substring(index+1));
@ -621,7 +626,8 @@ public class DataEngine
if (columns.size() == 0)
{
log.log(Level.SEVERE, "No Colums - Delete Report Format " + reportName + " and start again");
log.finest("No Colums - SQL=" + sql + " - ID=" + format.get_ID());
if (log.isLoggable(Level.FINEST))
log.finest("No Colums - SQL=" + sql + " - ID=" + format.get_ID());
return null;
}
@ -636,7 +642,7 @@ public class DataEngine
/**
* Assemble final SQL - delete last SELECT ','
*/
StringBuffer finalSQL = new StringBuffer();
StringBuilder finalSQL = new StringBuilder();
finalSQL.append(sqlSELECT.substring(0, sqlSELECT.length()-1))
.append(sqlFROM);
@ -666,7 +672,7 @@ public class DataEngine
if (role.getAD_Role_ID() == 0 && !Ini.isClient())
; // System Access
else
finalSQL = new StringBuffer (role.addAccessSQL (finalSQL.toString (),
finalSQL = new StringBuilder (role.addAccessSQL (finalSQL.toString (),
tableName, MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO));
}
@ -709,8 +715,11 @@ public class DataEngine
pd.setSQL(finalSQL.toString());
pd.setHasLevelNo(hasLevelNo);
log.finest (finalSQL.toString ());
log.finest ("Group=" + m_group);
if (log.isLoggable(Level.FINEST))
{
log.finest (finalSQL.toString ());
log.finest ("Group=" + m_group);
}
return pd;
} // getPrintDataInfo
@ -751,19 +760,19 @@ public class DataEngine
//
TableReference tr = new TableReference();
//
String SQL = "SELECT t.TableName, ck.ColumnName AS KeyColumn," // 1..2
+ " cd.ColumnName AS DisplayColumn, rt.IsValueDisplayed, cd.IsTranslated "
+ "FROM AD_Ref_Table rt"
+ " INNER JOIN AD_Table t ON (rt.AD_Table_ID = t.AD_Table_ID)"
+ " INNER JOIN AD_Column ck ON (rt.AD_Key = ck.AD_Column_ID)"
+ " INNER JOIN AD_Column cd ON (rt.AD_Display = cd.AD_Column_ID) "
+ "WHERE rt.AD_Reference_ID=?" // 1
+ " AND rt.IsActive = 'Y' AND t.IsActive = 'Y'";
StringBuilder SQL = new StringBuilder("SELECT t.TableName, ck.ColumnName AS KeyColumn,") // 1..2
.append(" cd.ColumnName AS DisplayColumn, rt.IsValueDisplayed, cd.IsTranslated ")
.append("FROM AD_Ref_Table rt")
.append(" INNER JOIN AD_Table t ON (rt.AD_Table_ID = t.AD_Table_ID)")
.append(" INNER JOIN AD_Column ck ON (rt.AD_Key = ck.AD_Column_ID)")
.append(" INNER JOIN AD_Column cd ON (rt.AD_Display = cd.AD_Column_ID) ")
.append("WHERE rt.AD_Reference_ID=?") // 1
.append(" AND rt.IsActive = 'Y' AND t.IsActive = 'Y'");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL.toString(), null);
pstmt.setInt (1, AD_Reference_Value_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -777,7 +786,7 @@ public class DataEngine
}
catch (SQLException ex)
{
log.log(Level.SEVERE, SQL, ex);
log.log(Level.SEVERE, SQL.toString(), ex);
}
finally
{
@ -993,7 +1002,7 @@ public class DataEngine
pde = new PrintDataElement(pdc.getColumnName(), s, pdc.getDisplayType(), pdc.getFormatPattern());
}
else
pde = new PrintDataElement(pdc.getColumnName(), obj, pdc.getDisplayType(), pdc.getFormatPattern());
pde = new PrintDataElement(pdc.getColumnName(), (Serializable)obj, pdc.getDisplayType(), pdc.getFormatPattern());
}
}
} // Value only
@ -1120,12 +1129,14 @@ public class DataEngine
{
if (m_runningTotalLines < 1) // -1 = none
return;
log.fine("(" + m_runningTotalLines + ") - Row=" + rowNo
+ ", mod=" + rowNo % m_runningTotalLines);
if (log.isLoggable(Level.FINE))
log.fine("(" + m_runningTotalLines + ") - Row=" + rowNo
+ ", mod=" + rowNo % m_runningTotalLines);
if (rowNo % m_runningTotalLines != 0)
return;
log.fine("Row=" + rowNo);
if (log.isLoggable(Level.FINE))
log.fine("Row=" + rowNo);
PrintDataColumn pdc = null;
int start = 0;
if (rowNo == 0) // no page break on page 1

View File

@ -431,7 +431,8 @@ PrintEvent on Win32 Printer : \\MAIN\HP LaserJet 5L
PrintServiceAttributeSet - length=1
queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
**/
log.fine("attributeUpdate - " + psae);
if (log.isLoggable(Level.FINE))
log.fine("attributeUpdate - " + psae);
// PrintUtil.dump (psae.getAttributes());
} // attributeUpdate
@ -978,7 +979,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
return false;
}
log.fine(uri.toString());
if (log.isLoggable(Level.FINE))
log.fine(uri.toString());
try
{
@ -1111,20 +1113,20 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
int Client_ID = -1;
// Get AD_Table_ID and TableName
String sql = "SELECT rv.AD_ReportView_ID,rv.WhereClause,"
+ " t.AD_Table_ID,t.TableName, pf.AD_PrintFormat_ID, pf.IsForm, pf.AD_Client_ID "
+ "FROM AD_PInstance pi"
+ " INNER JOIN AD_Process p ON (pi.AD_Process_ID=p.AD_Process_ID)"
+ " INNER JOIN AD_ReportView rv ON (p.AD_ReportView_ID=rv.AD_ReportView_ID)"
+ " INNER JOIN AD_Table t ON (rv.AD_Table_ID=t.AD_Table_ID)"
+ " LEFT OUTER JOIN AD_PrintFormat pf ON (p.AD_ReportView_ID=pf.AD_ReportView_ID AND pf.AD_Client_ID IN (0,?) AND pf.IsActive='Y') "
+ "WHERE pi.AD_PInstance_ID=? " // #2
+ "ORDER BY pf.AD_Client_ID DESC, pf.IsDefault DESC"; // own first
StringBuilder sql = new StringBuilder("SELECT rv.AD_ReportView_ID,rv.WhereClause,")
.append(" t.AD_Table_ID,t.TableName, pf.AD_PrintFormat_ID, pf.IsForm, pf.AD_Client_ID ")
.append("FROM AD_PInstance pi")
.append(" INNER JOIN AD_Process p ON (pi.AD_Process_ID=p.AD_Process_ID)")
.append(" INNER JOIN AD_ReportView rv ON (p.AD_ReportView_ID=rv.AD_ReportView_ID)")
.append(" INNER JOIN AD_Table t ON (rv.AD_Table_ID=t.AD_Table_ID)")
.append(" LEFT OUTER JOIN AD_PrintFormat pf ON (p.AD_ReportView_ID=pf.AD_ReportView_ID AND pf.AD_Client_ID IN (0,?) AND pf.IsActive='Y') ")
.append("WHERE pi.AD_PInstance_ID=? ") // #2
.append("ORDER BY pf.AD_Client_ID DESC, pf.IsDefault DESC"); // own first
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, AD_Client_ID);
pstmt.setInt(2, pi.getAD_PInstance_ID());
rs = pstmt.executeQuery();
@ -1155,15 +1157,15 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
if (AD_ReportView_ID == 0)
{
// Check Print format in Report Directly
sql = "SELECT t.AD_Table_ID,t.TableName, pf.AD_PrintFormat_ID, pf.IsForm "
+ "FROM AD_PInstance pi"
+ " INNER JOIN AD_Process p ON (pi.AD_Process_ID=p.AD_Process_ID)"
+ " INNER JOIN AD_PrintFormat pf ON (p.AD_PrintFormat_ID=pf.AD_PrintFormat_ID)"
+ " INNER JOIN AD_Table t ON (pf.AD_Table_ID=t.AD_Table_ID) "
+ "WHERE pi.AD_PInstance_ID=?";
sql = new StringBuilder("SELECT t.AD_Table_ID,t.TableName, pf.AD_PrintFormat_ID, pf.IsForm ")
.append("FROM AD_PInstance pi")
.append(" INNER JOIN AD_Process p ON (pi.AD_Process_ID=p.AD_Process_ID)")
.append(" INNER JOIN AD_PrintFormat pf ON (p.AD_PrintFormat_ID=pf.AD_PrintFormat_ID)")
.append(" INNER JOIN AD_Table t ON (pf.AD_Table_ID=t.AD_Table_ID) ")
.append("WHERE pi.AD_PInstance_ID=?");
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, pi.getAD_PInstance_ID());
rs = pstmt.executeQuery();
if (rs.next())
@ -1332,115 +1334,115 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
MClient client = MClient.get(ctx);
Language language = client.getLanguage();
// Get Document Info
String sql = null;
StringBuilder sql = null;
if (type == CHECK)
sql = "SELECT bad.Check_PrintFormat_ID," // 1
+ " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo " // 2..5
+ "FROM C_PaySelectionCheck d"
+ " INNER JOIN C_PaySelection ps ON (d.C_PaySelection_ID=ps.C_PaySelection_ID)"
+ " INNER JOIN C_BankAccountDoc bad ON (ps.C_BankAccount_ID=bad.C_BankAccount_ID AND d.PaymentRule=bad.PaymentRule)"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE d.C_PaySelectionCheck_ID=?"; // info from BankAccount
sql = new StringBuilder("SELECT bad.Check_PrintFormat_ID,") // 1
.append(" c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo ") // 2..5
.append("FROM C_PaySelectionCheck d")
.append(" INNER JOIN C_PaySelection ps ON (d.C_PaySelection_ID=ps.C_PaySelection_ID)")
.append(" INNER JOIN C_BankAccountDoc bad ON (ps.C_BankAccount_ID=bad.C_BankAccount_ID AND d.PaymentRule=bad.PaymentRule)")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) ")
.append("WHERE d.C_PaySelectionCheck_ID=?"); // info from BankAccount
else if (type == DUNNING)
sql = "SELECT dl.Dunning_PrintFormat_ID,"
+ " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,dr.DunningDate "
+ "FROM C_DunningRunEntry d"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)"
+ " INNER JOIN C_DunningRun dr ON (d.C_DunningRun_ID=dr.C_DunningRun_ID)"
+ " INNER JOIN C_DunningLevel dl ON (dl.C_DunningLevel_ID=d.C_DunningLevel_ID) "
+ "WHERE d.C_DunningRunEntry_ID=?"; // info from Dunning
sql = new StringBuilder("SELECT dl.Dunning_PrintFormat_ID,")
.append(" c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,dr.DunningDate ")
.append("FROM C_DunningRunEntry d")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)")
.append(" INNER JOIN C_DunningRun dr ON (d.C_DunningRun_ID=dr.C_DunningRun_ID)")
.append(" INNER JOIN C_DunningLevel dl ON (dl.C_DunningLevel_ID=d.C_DunningLevel_ID) ")
.append("WHERE d.C_DunningRunEntry_ID=?"); // info from Dunning
else if (type == REMITTANCE)
sql = "SELECT pf.Remittance_PrintFormat_ID,"
+ " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo "
+ "FROM C_PaySelectionCheck d"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)"
+ " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE d.C_PaySelectionCheck_ID=?" // info from PrintForm
+ " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
sql = new StringBuilder("SELECT pf.Remittance_PrintFormat_ID,")
.append(" c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo ")
.append("FROM C_PaySelectionCheck d")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)")
.append(" INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) ")
.append("WHERE d.C_PaySelectionCheck_ID=?") // info from PrintForm
.append(" AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC");
else if (type == PROJECT)
sql = "SELECT pf.Project_PrintFormat_ID,"
+ " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.Value "
+ "FROM C_Project d"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)"
+ " LEFT OUTER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE d.C_Project_ID=?" // info from PrintForm
+ " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
sql = new StringBuilder("SELECT pf.Project_PrintFormat_ID,")
.append(" c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.Value ")
.append("FROM C_Project d")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)")
.append(" LEFT OUTER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) ")
.append("WHERE d.C_Project_ID=?") // info from PrintForm
.append(" AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC");
else if (type == MANUFACTURING_ORDER)
sql = "SELECT pf.Manuf_Order_PrintFormat_ID,"
+ " c.IsMultiLingualDocument,bp.AD_Language, 0 , d.DocumentNo "
+ "FROM PP_Order d"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " LEFT OUTER JOIN AD_User u ON (u.AD_User_ID=d.Planner_ID)"
+ " LEFT OUTER JOIN C_BPartner bp ON (u.C_BPartner_ID=bp.C_BPartner_ID) "
+ " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)"
+ "WHERE d.PP_Order_ID=?" // info from PrintForm
+ " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
sql = new StringBuilder("SELECT pf.Manuf_Order_PrintFormat_ID,")
.append(" c.IsMultiLingualDocument,bp.AD_Language, 0 , d.DocumentNo ")
.append("FROM PP_Order d")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" LEFT OUTER JOIN AD_User u ON (u.AD_User_ID=d.Planner_ID)")
.append(" LEFT OUTER JOIN C_BPartner bp ON (u.C_BPartner_ID=bp.C_BPartner_ID) ")
.append(" INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)")
.append("WHERE d.PP_Order_ID=?") // info from PrintForm
.append(" AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC");
else if (type == DISTRIBUTION_ORDER)
sql = "SELECT pf.Distrib_Order_PrintFormat_ID,"
+ " c.IsMultiLingualDocument,bp.AD_Language, bp.C_BPartner_ID , d.DocumentNo "
+ "FROM DD_Order d"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)"
+ " LEFT OUTER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE d.DD_Order_ID=?" // info from PrintForm
+ " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
sql = new StringBuilder("SELECT pf.Distrib_Order_PrintFormat_ID,")
.append(" c.IsMultiLingualDocument,bp.AD_Language, bp.C_BPartner_ID , d.DocumentNo ")
.append("FROM DD_Order d")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)")
.append(" LEFT OUTER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) ")
.append("WHERE d.DD_Order_ID=?") // info from PrintForm
.append(" AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC");
else if (type == RFQ)
sql = "SELECT COALESCE(t.AD_PrintFormat_ID, pf.AD_PrintFormat_ID),"
+ " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,rr.Name "
+ "FROM C_RfQResponse rr"
+ " INNER JOIN C_RfQ r ON (rr.C_RfQ_ID=r.C_RfQ_ID)"
+ " INNER JOIN C_RfQ_Topic t ON (r.C_RfQ_Topic_ID=t.C_RfQ_Topic_ID)"
+ " INNER JOIN AD_Client c ON (rr.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN C_BPartner bp ON (rr.C_BPartner_ID=bp.C_BPartner_ID),"
+ " AD_PrintFormat pf "
+ "WHERE pf.AD_Client_ID IN (0,rr.AD_Client_ID)"
+ " AND pf.AD_Table_ID=725 AND pf.IsTableBased='N'" // from RfQ PrintFormat
+ " AND rr.C_RfQResponse_ID=? " // Info from RfQTopic
+ "ORDER BY t.AD_PrintFormat_ID, pf.AD_Client_ID DESC, pf.AD_Org_ID DESC";
sql = new StringBuilder("SELECT COALESCE(t.AD_PrintFormat_ID, pf.AD_PrintFormat_ID),")
.append(" c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,rr.Name ")
.append("FROM C_RfQResponse rr")
.append(" INNER JOIN C_RfQ r ON (rr.C_RfQ_ID=r.C_RfQ_ID)")
.append(" INNER JOIN C_RfQ_Topic t ON (r.C_RfQ_Topic_ID=t.C_RfQ_Topic_ID)")
.append(" INNER JOIN AD_Client c ON (rr.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN C_BPartner bp ON (rr.C_BPartner_ID=bp.C_BPartner_ID),")
.append(" AD_PrintFormat pf ")
.append("WHERE pf.AD_Client_ID IN (0,rr.AD_Client_ID)")
.append(" AND pf.AD_Table_ID=725 AND pf.IsTableBased='N'") // from RfQ PrintFormat
.append(" AND rr.C_RfQResponse_ID=? ") // Info from RfQTopic
.append("ORDER BY t.AD_PrintFormat_ID, pf.AD_Client_ID DESC, pf.AD_Org_ID DESC");
// Fix [2574162] Priority to choose invoice print format not working
else if (type == ORDER || type == INVOICE)
sql = "SELECT pf.Order_PrintFormat_ID,pf.Shipment_PrintFormat_ID," // 1..2
sql = new StringBuilder("SELECT pf.Order_PrintFormat_ID,pf.Shipment_PrintFormat_ID,") // 1..2
// Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org) // see InvoicePrint
+ " COALESCE (bp.Invoice_PrintFormat_ID,dt.AD_PrintFormat_ID,pf.Invoice_PrintFormat_ID)," // 3
+ " pf.Project_PrintFormat_ID, pf.Remittance_PrintFormat_ID," // 4..5
+ " c.IsMultiLingualDocument, bp.AD_Language," // 6..7
+ " COALESCE(dt.DocumentCopies,0)+COALESCE(bp.DocumentCopies,1), " // 8
+ " dt.AD_PrintFormat_ID,bp.C_BPartner_ID,d.DocumentNo " // 9..11
+ "FROM " + DOC_BASETABLES[type] + " d"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)"
+ " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)"
+ " LEFT OUTER JOIN C_DocType dt ON ((d.C_DocType_ID>0 AND d.C_DocType_ID=dt.C_DocType_ID) OR (d.C_DocType_ID=0 AND d.C_DocTypeTarget_ID=dt.C_DocType_ID)) "
+ "WHERE d." + DOC_IDS[type] + "=?" // info from PrintForm
+ " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) "
+ "ORDER BY pf.AD_Org_ID DESC";
.append(" COALESCE (bp.Invoice_PrintFormat_ID,dt.AD_PrintFormat_ID,pf.Invoice_PrintFormat_ID),") // 3
.append(" pf.Project_PrintFormat_ID, pf.Remittance_PrintFormat_ID,") // 4..5
.append(" c.IsMultiLingualDocument, bp.AD_Language,") // 6..7
.append(" COALESCE(dt.DocumentCopies,0)+COALESCE(bp.DocumentCopies,1), ") // 8
.append(" dt.AD_PrintFormat_ID,bp.C_BPartner_ID,d.DocumentNo ") // 9..11
.append("FROM " + DOC_BASETABLES[type] + " d")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)")
.append(" INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)")
.append(" LEFT OUTER JOIN C_DocType dt ON ((d.C_DocType_ID>0 AND d.C_DocType_ID=dt.C_DocType_ID) OR (d.C_DocType_ID=0 AND d.C_DocTypeTarget_ID=dt.C_DocType_ID)) ")
.append("WHERE d." + DOC_IDS[type] + "=?") // info from PrintForm
.append(" AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ")
.append("ORDER BY pf.AD_Org_ID DESC");
else // Get PrintFormat from Org or 0 of document client
sql = "SELECT pf.Order_PrintFormat_ID,pf.Shipment_PrintFormat_ID," // 1..2
sql = new StringBuilder("SELECT pf.Order_PrintFormat_ID,pf.Shipment_PrintFormat_ID,") // 1..2
// Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org) // see InvoicePrint
+ " COALESCE (bp.Invoice_PrintFormat_ID,dt.AD_PrintFormat_ID,pf.Invoice_PrintFormat_ID)," // 3
+ " pf.Project_PrintFormat_ID, pf.Remittance_PrintFormat_ID," // 4..5
+ " c.IsMultiLingualDocument, bp.AD_Language," // 6..7
+ " COALESCE(dt.DocumentCopies,0)+COALESCE(bp.DocumentCopies,1), " // 8
+ " dt.AD_PrintFormat_ID,bp.C_BPartner_ID,d.DocumentNo, " // 9..11
+ " pf.Manuf_Order_PrintFormat_ID, pf.Distrib_Order_PrintFormat_ID " // 12..13
+ "FROM " + DOC_BASETABLES[type] + " d"
+ " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)"
+ " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)"
+ " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)"
+ " LEFT OUTER JOIN C_DocType dt ON (d.C_DocType_ID=dt.C_DocType_ID) "
+ "WHERE d." + DOC_IDS[type] + "=?" // info from PrintForm
+ " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) "
+ "ORDER BY pf.AD_Org_ID DESC";
.append(" COALESCE (bp.Invoice_PrintFormat_ID,dt.AD_PrintFormat_ID,pf.Invoice_PrintFormat_ID),") // 3
.append(" pf.Project_PrintFormat_ID, pf.Remittance_PrintFormat_ID,") // 4..5
.append(" c.IsMultiLingualDocument, bp.AD_Language,") // 6..7
.append(" COALESCE(dt.DocumentCopies,0)+COALESCE(bp.DocumentCopies,1), ") // 8
.append(" dt.AD_PrintFormat_ID,bp.C_BPartner_ID,d.DocumentNo, ") // 9..11
.append(" pf.Manuf_Order_PrintFormat_ID, pf.Distrib_Order_PrintFormat_ID ") // 12..13
.append("FROM " + DOC_BASETABLES[type] + " d")
.append(" INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)")
.append(" INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)")
.append(" INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)")
.append(" LEFT OUTER JOIN C_DocType dt ON (d.C_DocType_ID=dt.C_DocType_ID) ")
.append("WHERE d." + DOC_IDS[type] + "=?") // info from PrintForm
.append(" AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ")
.append("ORDER BY pf.AD_Org_ID DESC");
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
pstmt = DB.prepareStatement(sql.toString(), trxName);
pstmt.setInt(1, Record_ID);
rs = pstmt.executeQuery();
if (rs.next()) // first record only
@ -1530,16 +1532,16 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
what[0] = ORDER;
what[1] = C_Order_ID;
//
String sql = "SELECT dt.DocSubTypeSO "
+ "FROM C_DocType dt, C_Order o "
+ "WHERE o.C_DocType_ID=dt.C_DocType_ID"
+ " AND o.C_Order_ID=?";
StringBuilder sql = new StringBuilder("SELECT dt.DocSubTypeSO ")
.append("FROM C_DocType dt, C_Order o ")
.append("WHERE o.C_DocType_ID=dt.C_DocType_ID")
.append(" AND o.C_Order_ID=?");
String DocSubTypeSO = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_Order_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -1548,11 +1550,11 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
// @Trifon - Order is not completed(C_DoctType_ID=0) then try with C_DocTypeTarget_ID
// [ 2819637 ] Wrong print format on non completed order - https://sourceforge.net/tracker/?func=detail&aid=2819637&group_id=176962&atid=879332
if (DocSubTypeSO == null || "".equals(DocSubTypeSO)) {
sql = "SELECT dt.DocSubTypeSO "
+ "FROM C_DocType dt, C_Order o "
+ "WHERE o.C_DocTypeTarget_ID=dt.C_DocType_ID"
+ " AND o.C_Order_ID=?";
pstmt = DB.prepareStatement(sql, null);
sql = new StringBuilder("SELECT dt.DocSubTypeSO ")
.append("FROM C_DocType dt, C_Order o ")
.append("WHERE o.C_DocTypeTarget_ID=dt.C_DocType_ID")
.append(" AND o.C_Order_ID=?");
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_Order_ID);
rs = pstmt.executeQuery();
if (rs.next()) {
@ -1583,14 +1585,14 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
// Get Record_ID of Invoice/Receipt
if (what[0] == INVOICE)
sql = "SELECT C_Invoice_ID REC FROM C_Invoice WHERE C_Order_ID=?" // 1
+ " ORDER BY C_Invoice_ID DESC";
sql = new StringBuilder("SELECT C_Invoice_ID REC FROM C_Invoice WHERE C_Order_ID=?") // 1
.append(" ORDER BY C_Invoice_ID DESC");
else
sql = "SELECT M_InOut_ID REC FROM M_InOut WHERE C_Order_ID=?" // 1
+ " ORDER BY M_InOut_ID DESC";
sql = new StringBuilder("SELECT M_InOut_ID REC FROM M_InOut WHERE C_Order_ID=?") // 1
.append(" ORDER BY M_InOut_ID DESC");
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_Order_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -1610,7 +1612,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
log.fine("Order => " + what[0] + " ID=" + what[1]);
if (log.isLoggable(Level.FINE))
log.fine("Order => " + what[0] + " ID=" + what[1]);
return what;
} // getDocumentWhat

View File

@ -318,7 +318,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
if (!paperChange)
paperChange = !paper.equals(m_paper);
//
log.fine(paper + " - Header=" + headerHeight + ", Footer=" + footerHeight);
if (log.isLoggable(Level.FINE))
log.fine(paper + " - Header=" + headerHeight + ", Footer=" + footerHeight);
m_paper = paper;
m_headerHeight = headerHeight;
m_footerHeight = footerHeight;
@ -405,8 +406,11 @@ public class LayoutEngine implements Pageable, Printable, Doc
height = m_footerHeight;
m_footer.setBounds (x, y, w, height);
log.fine("Paper=" + m_paper + ",HeaderHeight=" + m_headerHeight + ",FooterHeight=" + m_footerHeight
+ " => Header=" + m_header + ",Contents=" + m_content + ",Footer=" + m_footer);
if (log.isLoggable(Level.FINE))
{
log.fine("Paper=" + m_paper + ",HeaderHeight=" + m_headerHeight + ",FooterHeight=" + m_footerHeight
+ " => Header=" + m_header + ",Contents=" + m_content + ",Footer=" + m_footer);
}
} // calculatePageSize
/**
@ -582,7 +586,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
&& m_position[AREA_CONTENT].getX() == m_content.x
&& m_position[AREA_CONTENT].getY() == m_content.y)
{
log.fine("skipped");
if (log.isLoggable(Level.FINE))
log.fine("skipped");
return m_pageNo;
}
@ -597,7 +602,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
m_position[AREA_CONTENT].setLocation(m_content.x, m_content.y);
m_position[AREA_FOOTER].setLocation(m_footer.x, m_footer.y);
m_maxHeightSinceNewLine = new float[] {0f, 0f, 0f};
log.finer("Page=" + m_pageNo);
if (log.isLoggable(Level.FINE))
log.finer("Page=" + m_pageNo);
return m_pageNo;
} // newPage
@ -620,14 +626,16 @@ public class LayoutEngine implements Pageable, Printable, Doc
if (isYspaceFor(m_maxHeightSinceNewLine[m_area]))
{
m_position[m_area].setLocation(xPos, m_position[m_area].y + m_maxHeightSinceNewLine[m_area]);
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
}
else if (m_area == AREA_CONTENT)
{
log.finest("Not enough Y space "
+ m_lastHeight[m_area] + " - remaining " + getYspace() + " - Area=" + m_area);
newPage(true, false);
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
}
else // footer/header
{
@ -766,7 +774,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
else if (m_area == AREA_FOOTER)
part = m_footer;
m_position[m_area].setLocation(part.x + p.getX(), part.y + p.getY());
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
} // setPosition
/**
@ -795,7 +804,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
protected void setX (float x)
{
m_position[m_area].x = x;
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
} // setX
/**
@ -807,7 +817,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
if (xOffset == 0f)
return;
m_position[m_area].x += xOffset;
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
} // addX
/**
@ -826,7 +837,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
protected void setY (int y)
{
m_position[m_area].y = y;
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
} // setY
/**
@ -840,14 +852,16 @@ public class LayoutEngine implements Pageable, Printable, Doc
if (isYspaceFor(yOffset))
{
m_position[m_area].y += yOffset;
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
}
else if (m_area == AREA_CONTENT)
{
log.finest("Not enough Y space "
+ m_lastHeight[m_area] + " - remaining " + getYspace() + " - Area=" + m_area);
newPage(true, true);
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
if (log.isLoggable(Level.FINEST))
log.finest("Page=" + m_pageNo + " [" + m_area + "] " + m_position[m_area].x + "/" + m_position[m_area].y);
}
else
{
@ -1147,13 +1161,15 @@ public class LayoutEngine implements Pageable, Printable, Doc
{
if (!isXspaceFor(m_lastWidth[m_area]))
{
log.finest("Not enough X space for "
if (log.isLoggable(Level.FINEST))
log.finest("Not enough X space for "
+ m_lastWidth[m_area] + " - remaining " + getXspace() + " - Area=" + m_area);
newLine ();
}
if (m_area == AREA_CONTENT && !isYspaceFor(m_lastHeight[m_area]))
{
log.finest("Not enough Y space "
if (log.isLoggable(Level.FINEST))
log.finest("Not enough Y space "
+ m_lastHeight[m_area] + " - remaining " + getYspace() + " - Area=" + m_area);
newPage (true, true);
}
@ -1235,13 +1251,15 @@ public class LayoutEngine implements Pageable, Printable, Doc
MQuery query = new MQuery (format.getAD_Table_ID());
query.addRestriction(item.getColumnName(), MQuery.EQUAL, new Integer(Record_ID));
format.setTranslationViewQuery(query);
log.fine(query.toString());
if (log.isLoggable(Level.FINE))
log.fine(query.toString());
//
DataEngine de = new DataEngine(format.getLanguage(),m_TrxName);
PrintData includedData = de.getPrintData(data.getCtx(), format, query);
if (includedData == null)
return null;
log.fine(includedData.toString());
if (log.isLoggable(Level.FINE))
log.fine(includedData.toString());
//
element = layoutTable (format, includedData, item.getXSpace());
// handle multi page tables
@ -1263,13 +1281,15 @@ public class LayoutEngine implements Pageable, Printable, Doc
if (!isXspaceFor(m_lastWidth[m_area]))
{
log.finest("Not enough X space for "
if (log.isLoggable(Level.FINEST))
log.finest("Not enough X space for "
+ m_lastWidth[m_area] + " - remaining " + getXspace() + " - Area=" + m_area);
newLine ();
}
if (m_area == AREA_CONTENT && !isYspaceFor(m_lastHeight[m_area]))
{
log.finest("Not enough Y space "
if (log.isLoggable(Level.FINEST))
log.finest("Not enough Y space "
+ m_lastHeight[m_area] + " - remaining " + getYspace() + " - Area=" + m_area);
newPage (true, false);
}
@ -1353,7 +1373,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
// Convert AmtInWords Content to alpha
if (item.getColumnName().equals("AmtInWords"))
{
log.fine("AmtInWords: " + stringContent);
if (log.isLoggable(Level.FINE))
log.fine("AmtInWords: " + stringContent);
stringContent = Msg.getAmtInWords (m_format.getLanguage(), stringContent);
content = stringContent;
}
@ -1647,7 +1668,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
if (printData.isPageBreak())
{
pageBreak.add(new Integer(row));
log.finer("PageBreak row=" + row);
if (log.isLoggable(Level.FINER))
log.finer("PageBreak row=" + row);
}
}
// Summary/Line Levels for Finanial Reports

View File

@ -141,7 +141,7 @@ public class DashboardController implements EventListener<MaximizeEvent> {
String htmlContent = dp.getHTML();
if(htmlContent != null)
{
StringBuffer result = new StringBuffer("<html><head>");
StringBuilder result = new StringBuilder("<html><head>");
URL url = getClass().getClassLoader().getResource("org/compiere/images/PAPanel.css");
InputStreamReader ins;